// JavaScript Document

function mainmenu()
	{
	$("#mainNav ul li.menu-expand ul").css({display: "none"}); // Opera Fix
	$("#mainNav ul li.menu-expand").hover(function(){
			$(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(100);
			},function(){
			$(this).find('ul:first').css({visibility: "hidden"}).slideUp(150);
			});
	}

/* 
function langaugemenu()
	{
	$("div.additionalLangauges").css({display: "none"}); // Opera Fix
	$(".langaugeSelector").hover(function(){
			$().find('div.additionalLangauges').css({visibility: "visible",display: "none"}).fadeIn(100);
			},function(){
			$().find('div.additionalLangauges').fadeOut(100);
			});
	}
*/

var backgroundStatus = 0;  
var popupContactStatus = 0;
var popupFlickrStatus = 0;

//loading popup with jQuery magic!  
function fadeBackgroundIn(){  
	//loads popup only if it is disabled
	if(backgroundStatus==0){  
		 //Get the screen height and width  
		 var maskHeight = $(document).height();  
		 var maskWidth = $(window).width();    
		 //Set height and width to mask to fill up the whole screen  
		 $("#backgroundPopup").css({  
		 "width":maskWidth,
		 "height":maskHeight,
		 "opacity": "0.7"
		});  
		$("#backgroundPopup").fadeIn("fast");  
		backgroundStatus = 1;  
	}  
}  

//disabling popup with jQuery magic!
function fadeBackgroundOut(){
	//disables popup only if it is enabled
	if(backgroundStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#popupContact").fadeOut("fast");
		backgroundStatus = 0;
	}
}

//Google maps popup
function popupContactIn(){  
	//loads popup only if it is disabled  
	if(popupContactStatus==0){  
		//request data for centering
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $("#popupContact").height();
		var popupWidth = $("#popupContact").width();
		//centering
		$("#popupContact").css({
			"bottom": windowHeight/2-popupHeight/2,
			"left": windowWidth/2-popupWidth/2
		});
		//only need force for IE6
		$("#popupContact").fadeIn("fast");  
			popupContactStatus = 1;  
	}  
	googleMap();
}  
function popupContactOut(){
	//disables popup only if it is enabled
	if(popupContactStatus==1){
		$("#popupContact").fadeOut("fast");
		popupContactStatus = 0;
	}
}

//Flickr popup
function popupFlickrIn(){  
	//loads popup only if it is disabled  
	if(popupFlickrStatus==0){  
		//request data for centering
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $("#popupFlickr").height();
		var popupWidth = $("#popupFlickr").width();
		//centering
		$("#popupFlickr").css({
			"bottom": windowHeight/2-popupHeight/2,
			"left": windowWidth/2-popupWidth/2
		});
		//only need force for IE6
		$("#popupFlickr").fadeIn("fast");  
			popupFlickrStatus = 1;  
	}  
}  

//disabling popup with jQuery magic!
function popupFlickrOut(){
	//disables popup only if it is enabled
	if(popupFlickrStatus==1){
		$("#popupFlickr").fadeOut("fast");
		popupFlickrStatus = 0;
	}
}

 $(document).ready(function(){
	 mainmenu();
	
	
	
	// langaugemenu();
	//LOADING POPUP
	
	//Click the button event!
	$("a.googleMapPopup").click(function(){
	//centering with css
	popupContactIn();
	fadeBackgroundIn();
	});
	$("a.close").click(function(){  
		if(popupContactStatus==1){
			popupContactOut();
			}
		if(popupFlickrStatus==1){
			popupFlickrOut();
			}
		fadeBackgroundOut();
	});
	$("#backgroundPopup").click(function(){  
		if(popupContactStatus==1){
			popupContactOut();
			}
		if(popupFlickrStatus==1){
			popupFlickrOut();
			}
		fadeBackgroundOut();
	});
	
	$(document).keypress(function(e){  
		if(e.keyCode==27 && backgroundStatus==1){  
		if(popupContactStatus==1){
			popupContactOut();
			}
		if(popupFlickrStatus==1){
			popupFlickrOut();
			}
		fadeBackgroundOut();  
		}
	});
	
	//Click the flickR link event!
	$("a.flickrPopup").click(function(){
	//centering with css
	popupFlickrIn();
	fadeBackgroundIn();
		$("#backgroundPopup").css({
			"height": windowHeight
		});
		
	
	});
	
	$(".project-content").hover(
		function () {
			$(this).toggleClass("hover");
			$(this).find("img").animate({"top": '-11px'}, {duration: 100, easing: 'easeOutQuad' });
			$(this).find(".copy").delay(200).animate({"margin-top": '50px'}, {duration: 200, easing: 'easeOutQuad' });
			$(this).find("img").animate({opacity: 0.5}, {duration: 200});
		}, 
		function () {
			$(this).toggleClass("hover");
			$(this).find(".copy").stop().animate({"margin-top": '155px'}, {duration: 100, easing: 'easeOutQuad' });
			$(this).find("img").stop().delay(100).animate({opacity: 1.0}, {duration: 200});
			$(this).find("img").stop().animate({"top": '0px'}, {duration: 50, easing: 'easeOutQuad' });
			
			
		}
	);
	
	
});  
 
