//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;
var popupHelp = 0;
var menuStatus = 0;

//loading popup with jQuery magic!
function loadPopup(name){
	centerPopup(name);
	var id = name;
	
//loads popup only if it is disabled
if(id == '#popupContact'){
	if(popupStatus==0){
		$("#backgroundPopup").css({
		"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$(name).fadeIn("slow");
		popupStatus = 1;
	}
} 
if (id == '#popupHelp')
{
	if(popupHelp==0){
		$("#backgroundPopup").css({
		"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$(id).fadeIn("slow");
		popupHelp = 1;
	}
}
}
//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
	if(popupHelp==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupHelp").fadeOut("slow");
		popupHelp = 0;
	}
		
}
//centering popup
function centerPopup(name){
//request data for centering
	var id = name;
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $(id).height();
var popupWidth = $(id).width();
//centering
$(id).css({
"position": "absolute",
"top": windowHeight/2-popupHeight/2,
"left": windowWidth/2-popupWidth/2
});
//only need force for IE6

$("#backgroundPopup").css({
"height": windowHeight
});

}

function slideMenu(element)
{
	if(menuStatus==0) {
		var getPosition = $('#about').position();
	 	var getAddition = $('#about').width();
	 	
	 	getPosition['left'] = getPosition['left'] + getAddition - 5;
	 	$('#aboutMenu').css(getPosition);
	 	$('#aboutMenu').show("slide", null, 500);
	 	menuStatus=1;
	 	$('.pointer').fadeIn("fast");
	}
}

function timeoutStart(element) {
	var timeoutId = setTimeout(function(){
		if(menuStatus!=0) {
		$(element).hide("slide", null, 500); 
		menuStatus=0; 
		$('.pointer').fadeOut("fast");
		}}, 650);
	$(element).data('timeoutId', timeoutId);
}

