function ShowHide(id)
{

if (id != '')
 {
  var itm = null;
  if (document.getElementById) { itm = document.getElementById(id); }
  else if (document.all) { itm = document.all[id]; }
  else if (document.layers) { itm = document.layers[id]; }
  
   if (!itm) { /* do nothing */ }
  else if (itm.style)
  {
   if (itm.style.display == "none") { itm.style.display = "";

    

    }
   else { itm.style.display = "none";
  }
  }
  else { itm.visibility = "show";

       }
 }
 
  // id.style.display="visible";
}

function isValidEmail(email) {
    
	re = /^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i;

	return re.test(email);
}
        
        
function makeCheck(address) {
            
        	if (isValidEmail(address)) {
        		return true;
        	} else {
        		return false;
        	}
       return false;
}

function openNews(chapter){
	open('chapter.php?chapter='+chapter,'_blank','location=0,scrollbars=yes,toolbar=no,directories=no,menubar=no,status=no,resizable=yes,width=620,height=500');
}





function  getPageScroll() {
			var xScroll, yScroll;
			if (self.pageYOffset) {
				yScroll = self.pageYOffset;
				xScroll = self.pageXOffset;
			} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
				yScroll = document.documentElement.scrollTop;
				xScroll = document.documentElement.scrollLeft;
			} else if (document.body) {// all other Explorers
				yScroll = document.body.scrollTop;
				xScroll = document.body.scrollLeft;	
			}
			arrayPageScroll = new Array(xScroll,yScroll);
			return arrayPageScroll;
};

function getPageSize() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = $(document).height();//windowHeight;
			} else {
				pageHeight = $(document).height();//yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
};



$('.alb_img').click(function(){
							   $('#fotoalbum').css({'height':'1px', 'width':'1px'})
//										$('#fotoalbum').show();
										
										$.ajax({
																   type: "POST",
																   url: "./inc/_fgallery.php",
																   data: "uin="+$(this).attr('rel'),
																   cached:false,
																   success: function(msg){
																		$('#fotoalbum').html('');
																		$('#fotoalbum').append(msg);
																	
																				$(function() {
																					// Slider in main menu window and photogallery							
																					//LightBox
																					$('#fotoalbum a').lightBox();
																					$('#fotoalbum a').eq(0).click();
																				});
																   		}
														});
							   
							   
						   });


function close_all_window() {
		//main window, menu in second cell
	    $('#info_text').hide('fast');
		$('#photo_in_section').hide('fast');
		$('#info_window').hide('slow');
		// text for main window												  
		$('#info_text').text(" ");
 		$('#view').html("");	
//		$('#info_text').css({'height':'210px', 'padding-right':'50px', 'width':'760px'});
														 
 		// window "o kompanii"												  
		$('#info_ctext').hide('fast');
 		$('#info_company').hide('slow');
		$('#info_ctext').text(" ");	

		//News window										  
		$('#info_ntext').hide('fast');
		$('#info_news').hide('slow');
		$('#info_ntext').text(" ");
		
		// Feedback window
		$('#feedback_text').hide('fast');
		$('#feedback_form').hide('slow');
		$('#fb_message').val('');	
		$('#fb_email').val('');
	    $('#fb_name').val('');
		$('#fb_message').css('border-color', '#FFF');	
		$('#fb_email').css('border-color', '#FFF');	
		$('#fb_name').css('border-color', '#FFF');
		$('#fb_error').text('');
		
}

	hs.graphicsDir = './images/zoom/';
    hs.outlineType = 'outer-glow';

$(document).ready(function() {
						   
					
					var top_ugol=parseInt($('#yellow_line').css('top'))+200;
						$('#third_ugol').css({'top':550});
						
	// Object generate position or other hacks ;)

						   var yel_pos=$('#party_photo').height()+35;
						   $('#yellow_party').css({'top':yel_pos});
						   
						   var about_pos=$('#yellow_line').height()
						   $('#about_company').css({'top':about_pos});
						   
						   var about_nav_pos=$('#about_company').height();
						   $('#company_nav').css({'top':about_nav_pos});
						   
						   var feed_pos=$('#party_photo').height()-55;
						   $('#feedback_icon').css({'top':feed_pos});
						   $('#sitemap_icon').css({'top':feed_pos});
						   
 						   $('#feedback_icon').show();
						   $('#sitemap_icon').show();
						  
							// open feedback form
						   $('#feedback_icon').click(function()
							{
									close_all_window();
									// get page size and scroll size   
									var arrayPageSizes = getPageSize();
									var arrayPageScroll = getPageScroll();

									$('#feedback_form').css({
										top: arrayPageScroll[1] + (arrayPageSizes[3] / 10)}).show('slow');			 
									   //$('#feedback_form').show('slow');
									   $('#feedback_text').show('fast');

						   });
						   
						   
						   $('#close_zakaz').click(function() {
											$('#zakaz_form').hide('slow');				
															
															});
						   
						  // open sitemap window
						   $('#sitemap_icon').click(function()
							{
									close_all_window();
									// get page size and scroll size   
									var arrayPageSizes = getPageSize();
									var arrayPageScroll = getPageScroll();

									$('#info_company').css({
										top: arrayPageScroll[1] + (arrayPageSizes[3] / 10)}).show('slow');			 
									   $('#info_ctext').show('fast');
									   
						   			$.ajax({
										type: "POST",
										url: "./inc/_map.php",
										success: function(msg){
										//lert(msg);
										$('#info_ctext').append(msg);
										
																
						$('.scnav_link').click(function() {
								close_all_window();
									
									// get page size and scroll size   
									var arrayPageSizes = getPageSize();
									var arrayPageScroll = getPageScroll();

									$('#info_company').css({
										top: arrayPageScroll[1] + (arrayPageSizes[3] / 10)}).show('slow');
									
									
									 $.ajax({
													type: "POST",
													url: "./inc/_second_page.php",
													data: "uin="+$(this).attr("rel"),
													success: function(msg){
													$('#info_ctext').append(msg);
													$('#recomend_view a').lightBox();
											   }
										});
									$('#info_ctext').show('fast');
						
						});
										
										$('.snav_link').click(function() {
													close_all_window();

													// get page size and scroll size   
													var arrayPageSizes = getPageSize();
													var arrayPageScroll = getPageScroll();

														$('#info_window').css({
															top:	arrayPageScroll[1] + (arrayPageSizes[3] / 10)}).show('slow');
														
														$('#info_text').show('fast');
														
														$.ajax({
																   type: "POST",
																   url: "./inc/_second_page.php",
																   data: "uin="+$(this).attr("rel"),

																   success: function(msg){
																		$('#info_text').append(msg);
																   }
														});
														

														
														$.ajax({
																   type: "POST",
																   url: "./inc/_gallery.php",
																   data: "uin="+$(this).attr("rel"),
																   success: function(msg){
																		$('#view').append(msg);
																				
																				$(function() {
																					// Slider in main menu window and photogallery							
//																					$('#view a').lightBox();
																					$("#image_list").imageScroller({
																							next:"right",
																							prev:"left",
																							frame:"view",
																							width:100,
																							child:"a",
																							auto:false
																							
																					});
																					//LightBox
																					$('#view a').lightBox();
																					//$("#jquery-overlay").height($(document).height());
																				});
																   		}
														});
													
														
														
						     

															  
										}); 
						
									}
						   			});
									
										
						   });
						   
						   $('#schem_but').click(function() {
									close_all_window();
									
									// get page size and scroll size   
									var arrayPageSizes = getPageSize();
									var arrayPageScroll = getPageScroll();

									$('#info_company').css({
										top: arrayPageScroll[1] + (arrayPageSizes[3] / 10)}).show('slow');
									
									
									 $.ajax({
													type: "POST",
													url: "./inc/_second_page.php",
													data: "uin="+$(this).attr("rel"),
													success: function(msg){
													$('#info_ctext').append(msg);
											   }
										});
									$('#info_ctext').show('fast');	  
														  });
						   
						   // send mail from feedback form
						   $('#ok').click(function() {
												 
												 $('#fb_error').text('');
												   if (makeCheck($('#fb_email').val())==false || $('#fb_name').val()=='' || $('#fb_message').val()=='') {
													   
														   if ($('#fb_name').val()=='') {
																   $('#fb_name').css('border-color', '#F00');
														   } else {
																   $('#fb_name').css('border-color', '#FFF');
														   }
														   
														   if (makeCheck($('#fb_email').val())==false) {
																   $('#fb_email').css('border-color', '#F00');
														   } else {
																   $('#fb_email').css('border-color', '#FFF');
														   }
														   
														   if ($('#fb_message').val()=='') {
																   $('#fb_message').css('border-color', '#F00');
														   } else {
																   $('#fb_message').css('border-color', '#FFF');
														   }
														   
													$('#fb_error').append($('#fb_err').val());   
													   
													} else {
														
													 $('#fb_message').css('border-color', '#FFF');	
													 $('#fb_email').css('border-color', '#FFF');	
													 $('#fb_name').css('border-color', '#FFF');
													 
													
													 $.ajax({
																   type: "POST",
																   url: "./inc/_feedback.php",
																   data: "email="+$('#fb_email').val()+"&name="+$('#fb_name').val()+"&message="+$('#fb_message').val(),
																   success: function(msg){
																		alert(msg);
																		close_all_window();
																   }
																   });
													 
													}
												   
												   });
						   
						   
						   // Window close button
						   $('.close_but').click(function() {
								close_all_window();
						  });
						   
						  
						   
						   // Main menu window
						   $('.nav_link').click(function() {
													close_all_window();

													// get page size and scroll size   
													var arrayPageSizes = getPageSize();
													var arrayPageScroll = getPageScroll();

														$('#info_window').css({
															top:	arrayPageScroll[1] + (arrayPageSizes[3] / 10)}).show('slow');
														
														if ($(this).attr("rel")=='1213258099') { 
												        	$('#photo_in_section').hide('fast');
															$('#info_text').css('height', '390px');
															$('#info_text').css({'height':'390px', 'padding-right':'20px', 'width':'795px'});
															$('#info_text').show('fast');
															//alert('0');
														} else if($(this).attr("rel")=='1215579472' || $(this).attr("rel")=='1213258161') {
															$('#photo_in_section').hide('fast');
															$('#info_text').css({'height':'390px', 'padding-right':'20px', 'width':'795px'});
															$('#info_text').show('fast');
															$('.close_but').css('right', '25px');
															//alert('1');
														}  else if($(this).attr("rel")=='1216708555') {
															//$('#photo_in_section').show('fast');
															//$('#info_text').css({'height':'390px', 'padding-right':'35px', 'width':'775px'});
															//$('#info_text').show('fast');
															//$('.close_but').css('right', '30px');
															$('#info_text').css('height', '270px');
															$('#info_text').css({'height':'210px', 'padding-right':'50px', 'width':'760px'});
															$('.close_but').css('right', '40px')
															$('#info_text').show('fast');
															$('#photo_in_section').show('fast');	

//alert('2');
														} else {
															//alert('3');
															$('#info_text').css('height', '270px');
															$('#info_text').css({'height':'210px', 'padding-right':'50px', 'width':'760px'});
															$('.close_but').css('right', '40px')
															$('#info_text').show('fast');
															$('#photo_in_section').show('fast');	
														}
												        
														
														//height: 400px; padding-right: 20px; width: 795px;
														$.ajax({
																   type: "POST",
																   url: "./inc/_second_page.php",
																   data: "uin="+$(this).attr("rel"),
																   success: function(msg){
																		$('#info_text').append(msg);
																		
																		
																		
																		$('.fotoarc').click(function() {
																		close_all_window();
							
																				// get page size and scroll size   
																				var arrayPageSizes = getPageSize();
																				var arrayPageScroll = getPageScroll();
							
																				$('#info_window').css({
																						top:arrayPageScroll[1] + (arrayPageSizes[3] / 10)}).show('slow');			
																				
														if ($(this).attr("rel")=='1213258099') { 
												        	$('#photo_in_section').hide('fast');
															$('#info_text').css('height', '390px');
															$('#info_text').show('fast');
															//alert('1');
														} else if($(this).attr("rel")=='1215579472') {
															$('#photo_in_section').hide('fast');
															$('#info_text').css({'height':'390px', 'padding-right':'20px', 'width':'795px'});
															$('#info_text').show('fast');
															$('.close_but').css('right', '25px');
															//alert('2');
														} else {
															//alert('3');
															$('#info_text').css('height', '270px');
															$('#info_text').css({'height':'210px', 'padding-right':'50px', 'width':'760px'});
															$('.close_but').css('right', '40px')
															$('#info_text').show('fast');
															$('#photo_in_section').show('fast');	
														}
														
																				$.ajax({
																							   type: "POST",
																							   url: "./inc/_second_page.php",
																							   data: "uin="+$(this).attr("rel"),
																							   success: function(msg){
																									$('#info_text').append(msg);
																							   }
																					});
																				});
																   }
														});
														
														$.ajax({
																   type: "POST",
																   url: "./inc/_gallery.php",
																   data: "uin="+$(this).attr("rel"),
																   cache: false,
																   success: function(msg){
																		$('#view').html(msg);
																				
																				$(function() {
																				// Slider in main menu window and photogallery							
																				$("#image_list").imageScroller({
																						next:"right",
																						prev:"left",
																						frame:"view",
																						width:100,
																						child:"a",
																						auto:false
																				});
																				//LightBox
																				$('#view a').lightBox();
																				//$("#jquery-overlay").height($(document).height());
																				msg="";
								});
																   				}
														});
														
														

						   });
						   
						   
						  
						  // About company window
						  $('.cnav_link').click(function() {
									close_all_window();
									
									// get page size and scroll size   
									var arrayPageSizes = getPageSize();
									var arrayPageScroll = getPageScroll();

									$('#info_company').css({
										top: arrayPageScroll[1] + (arrayPageSizes[3] / 10)}).show('slow');
									
									
									 $.ajax({
													type: "POST",
													url: "./inc/_second_page.php",
													data: "uin="+$(this).attr("rel"),
													success: function(msg){
													$('#info_ctext').append(msg);
													$('#recomend_view a').lightBox();
											   }
										});
									$('#info_ctext').show('fast');
						   });
						  
						  
						  
						   // News window
						   $('.nnav_link').click(function() {
									close_all_window();
									// get page size and scroll size   
									var arrayPageSizes = getPageSize();
									var arrayPageScroll = getPageScroll();

									$('#info_news').css({
										top: arrayPageScroll[1] + (arrayPageSizes[3] / 10)}).show('slow');
									
										 $.ajax({
													type: "POST",
													url: "./inc/_second_page.php",
													data: "uin="+$(this).attr("rel"),
													success: function(msg){
													$('#info_ntext').append(msg);
																   }
														});
									$('#info_ntext').show('fast');
						   });
						   
						   
						   $('#send_zak_but').click(function() {
											var request_string='yourname='+$('#yourname').attr('value')+'&date='+$('#date').attr('value')+'&guests_num='+$('#guests_num').attr('value')+'&place='+$('#place').attr('value')+'&language='+$('#language').attr('value')+'&music='+$('#music').attr('value')+'&artists='+$('#artists').attr('value')+'&video='+$('#video').attr('value')+'&ukrashenie='+$('#ukrashenie').attr('value')+'&cars='+$('#cars').attr('value')+'&relax='+$('#relax').attr('value')+'&poligrafy='+$('#poligrafy').attr('value')+'&personal='+$('#personal').attr('value')+'&money='+$('#money').attr('value')+'&cantact_info='+$('#contact_info').attr('value');
											$.ajax({
													type: "POST",
													url: "./inc/send_zakaz.php",
													data: request_string,
													success: function(msg){
													alert(msg);
													$('#zakaz_form').hide('normal');
													$('#yourname').attr('value', ' ');
													$('#date').attr('value', ' ');
													$('#guests_num').attr('value', ' ');
													$('#money').attr('value', ' ');
													$('#contact_info').attr('value', ' ');
													}
													
													
														});
											
															 
															 });

						   // Open order form
						   $('#zakaz_open').click(function() {
													
									 $('#zakaz_form').show('slow');
									 var zakaz_height = $('#zakaz_form').height();
									 var layHeight=($(document).height()-zakaz_height)+20;

									 
									/* $('#first_coll').height(layHeight);
									 $('#second_coll').height($(document).height());
			 						 $('#third_coll').height($(document).height());
						 			 $('#fourth_coll').height($(document).height());	
									 
									*/				   
							});
						   
						   $('#first_coll').height($(document).height());
						$('#second_coll').height($(document).height());
						$('#third_coll').height($(document).height());
						$('#fourth_coll').height($(document).height());	

$('.alb_img').click(function(){
							   $('#fotoalbum').css({'height':'1px', 'width':'1px'})
//										$('#fotoalbum').show();
										
										$.ajax({
																   type: "POST",
																   url: "./inc/_fgallery.php",
																   data: "uin="+$(this).attr('rel'),
																   cached:false,
																   success: function(msg){
																		$('#fotoalbum').html('');
																		$('#fotoalbum').append(msg);
																	
																				$(function() {
																					$('#fotoalbum a').lightBox();
																					$('#fotoalbum a').eq(0).click();
																				});
																   		}
														});
							   
							   
						   });
														

	 // PNG FIX in IE 5.5 and 6.0
	 $(document).pngFix({ blankgif:'images/pix.gif' });
	 

						

});

