var actifAbout =true;
var actifGallery=true;
var actifEvents=true;
var actifContact=true;

function showForm(){
	$("#map").hide();
	$("#contactInfo").hide();
	$("#contactForm").show();
	$("#contactInfoBtn").show();
}

function showInfo(){
	$("#map").show();
	$("#contactInfo").show();
	$("#contactForm").hide();
	$("#contactInfoBtn").hide();
}

$(document).ready(function(){
				
	$(".vidlink").click(function() {
		$(".imgDesc").fadeOut();
   	});
				
	$("#backgroundImage").load(function(){
		$(this).removeAttr("width")
			   .removeAttr("height")
			   .css({ width: "", height: "" });
	
		pic_real_width = this.width;
		pic_real_height = this.height;
		
		$('#loader').removeClass('loading');
		
		ratioImage = Math.round((pic_real_width/pic_real_height)*100)/100;
		ratioWindow = Math.round(($(window).width()/$(window).height())*100)/100;
		
		if (ratioWindow >= ratioImage){
			$("#backgroundImage").width( $(window).width() );
			$("#backgroundImage").height( ($("#backgroundImage").width/ratioImage) );
		}else{
			$("#backgroundImage").height( $(window).height() );
			$("#backgroundImage").width( $(window).height()*ratioImage );
		}
		
	});
	
	/*$(window).resize(function(){
		ratioWindow = Math.round(($(window).width()/$(window).height())*100)/100;
		if (ratioWindow >= ratioImage){
			$("#backgroundImage").width( $(window).width() );
			$("#backgroundImage").height( ($(window).width()/ratioImage) );
		}else{
			$("#backgroundImage").height( $(window).height() );
			$("#backgroundImage").width( $(window).height()*ratioImage );
		}
	});*/
	
	/*
	$("#about").hover(
	  
	  function () {
		if(actifAbout==true){
			actifAbout=false;
			slideDown('about');
		}
	  }, 
	  function () {
		slideUp('about');
	  }
	);
	
	$("#gallery").hover(
	  function () {
		if(actifGallery==true){
			actifGallery=false;
			slideDown('gallery');
		}
	  }, 
	  function () {
		slideUp('gallery');
	  }
	);
	
	$("#events").hover(
	  function () {
		  if(actifEvents==true){
			actifEvents=false;
			slideDown('events');
		  }
	  }, 
	  function () {
		slideUp('events');
	  }
	);
	
	$("#contact").hover(
	  function () {
		  if(actifContact==true){
			actifContact=false;
			slideDown('contact');
		  }
	  }, 
	  function () {
		slideUp('contact');
	  }
	);
	*/

}); //END OF DOCUMENT READY

//-----------------------------------------------------------	
function loadImage(srcImage,idImage){
	$("#backgroundImage").attr( "src", "upload/images/"+srcImage );

	
	$('.imgDesc').fadeOut('slow');
	$('#'+idImage+'Desc').fadeIn();
	
	$("#backgroundImage").load(function(){
		$(this).removeAttr("width")
			   .removeAttr("height")
			   .css({ width: "", height: "" });
	
		pic_real_width = this.width;
		pic_real_height = this.height;
		
		$('#loader').removeClass('loading');
		
		ratioImage = Math.round((pic_real_width/pic_real_height)*100)/100;
		ratioWindow = Math.round(($(window).width()/$(window).height())*100)/100;
		
		if (ratioWindow >= ratioImage){
			$("#backgroundImage").width( $(window).width() );
			$("#backgroundImage").height( ($("#backgroundImage").width/ratioImage) );
		}else{
			$("#backgroundImage").height( $(window).height() );
			$("#backgroundImage").width( $(window).height()*ratioImage );
		}
		
	});
	
	/*$(window).resize(function(){
		
		
		var img = new Image();
		img.src = '/images/'+srcImage;
		
		pic_real_width = img.width;
		pic_real_height = img.height;
							  
		ratioImage = Math.round((pic_real_width/pic_real_height)*100)/100;
		ratioWindow = Math.round(($(window).width()/$(window).height())*100)/100;
		alert(ratioWindow);
		if (ratioWindow >= ratioImage){
			$('#backgroundImage').width( $(window).width() );
			$('#backgroundImage').height( ($(window).width()/ratioImage) );
		}else{
			$('#backgroundImage').height( $(window).height() );
			$('#backgroundImage').width( $(window).height()*ratioImage );
		}
		
	});
	*/
	//$('#topMenu').fadeOut('slow', function(){
										   
//$('#logo').fadeOut('slow', function(){
												
			/*$('#twitter').fadeOut('slow', function(){
												   
				$('#newsletter').fadeOut('slow', function(){
														  
					$('#ongletSideBar').fadeIn('slow', function(){
					
						$('#content').animate( { left:"-515px" }, 700 );
						$('#plus').fadeIn('slow');
						
					});
					
				});		
				
			});*/
			
//});			
		
	//});
	
} //END OF LOAD IMAGE

function showMenus(){
	
	$('#ongletSideBar').fadeOut('slow', function(){
		$('#newsletter').fadeIn('slow', function(){
			$('#twitter').fadeIn('slow', function(){
				$('#facebook').fadeIn('slow', function(){
					$('#topMenu').fadeIn('slow')
				});								   
			});
		});							   
	});
}

function showContent(){
	$('#plus').fadeOut('slow', function(){
		$('#content').animate( { left:"30px" }, 700 );								
	});
	
}

function slideDown(id){
	$('#'+id).animate( { marginLeft:"0px" }, 700,function(){
		actifAbout =true;
 		actifGallery=true;
 		actifEvents=true;
 		actifContact=true;												 
	});	
	
}

function slideUp(id){
	$('#'+id).animate( { marginLeft:"15px" }, 700 );	
}




