/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!					
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

function browserCheck()
{
	var browserChecking = false;
	jQuery.each(jQuery.browser, function(i, val) {
		if(i=="mozilla" && jQuery.browser.version.substr(0,3)=="1.9") {
			browserChecking = true;
		}
	});
	if (browserChecking) {
		return true;
	} else {
		loadNotFF();	
		return false;
	}
}

//loading popup with jQuery magic!
function loadPopup9(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup9").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup9").fadeIn("slow");
		$("#popupContact9").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup9(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup9").fadeOut("slow");
		$("#popupContact9").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup9(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;

	try {
	var scrollTop = $(window).scrollTop();
	}
	catch(e)
	{
	var scrollTop = 0;
	}

	var popupHeight = $("#popupContact9").height();
	var popupWidth = $("#popupContact9").width();
	//centering
	$("#popupContact9").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2+scrollTop,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup9").css({
		"height": windowHeight
	});
	
}

function loadNotFF()
{
	centerPopup9();
	loadPopup9();
}

//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose9").click(function(){
		disablePopup9();
	});
	//Click out event!
	$("#backgroundPopup9").click(function(){
		disablePopup9();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup9();
		}
	});

});
