/***************************/
//@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;

//Number(document.getElementById('wrapper').offsetLeft)+15

var popupStatus = 0;
var popupStatus2 = 0;
var popupStatus3 = 0;
var popupStatus4 = 0;
var popupStatus5 = 0;

//----------------first Popup start --------------------
//loading popup with jQuery magic!
function loadPopup(){
    centerPopup();
	//loads popup only if it is disabled
	if(popupStatus==0){
//		$("#backgroundPopup").css({
//			"opacity": "0.7"
//		});
//		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupStatus = 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;
	}
}

//centering popup
function centerPopup(){
	//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({
		"position": "absolute",
		"top": "340px", //windowHeight/2-popupHeight/2,
		"left": Number(document.getElementById('wrapper').offsetLeft)+15 //windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	
//	$("#backgroundPopup").css({
//		"height": windowHeight
//	});
	
}
//----------------first Popup end-----------------------------


//-------------------- Refer ur frd popup  strat-------------------
//loading popup with jQuery magic!
function loadPopup2(){
    //centering with css
		centerPopup2();
	if(popupStatus2==0){
//		$("#backgroundPopup").css({
//			"opacity": "0.7"
//		});
//		$("#backgroundPopup").fadeIn("slow");
		$("#reg_popup2").fadeIn("slow");
		popupStatus2 = 1;
		disablePopup();
	}
}

//disabling popup with jQuery magic!
function disablePopup2(){
	//disables popup only if it is enabled
	if(popupStatus2==1){
		//$("#backgroundPopup").fadeOut("slow");
		$("#reg_popup2").fadeOut("slow");
		popupStatus2 = 0;
	}
}

function centerPopup2(){
	//request data for centering
	var windowWidth2 = document.documentElement.clientWidth;
	var windowHeight2 = document.documentElement.clientHeight;
	var popupHeight2 = $("#reg_popup2").height();
	var popupWidth2 = $("#reg_popup2").width();
	//centering
	$("#reg_popup2").css({
		"position": "absolute",
		"top": "340px",//windowHeight2/2-popupHeight2/2,
		"left": Number(document.getElementById('wrapper').offsetLeft)+15//windowWidth2/2-popupWidth2/2
	});
	//only need force for IE6
	
//	$("#backgroundPopup").css({
//		"height": windowHeight
//	});
}
//-------------------- Refer ur frd popup end-----------------------

//-------------------- Registration  strat-------------------
//loading popup with jQuery magic!
function loadPopup3(){
		//centering with css
		centerPopup3();
	if(popupStatus3==0){
//		$("#backgroundPopup").css({
//			"opacity": "0.7"
//		});
//		$("#backgroundPopup").fadeIn("slow");
		$("#reg_popup").fadeIn("slow");
		popupStatus3 = 1;
		disablePopup2();
//////		window.alert( $('#select3').val() );
	}
}

//disabling popup with jQuery magic!
function disablePopup3(){
	//disables popup only if it is enabled
	if(popupStatus3==1){
		//$("#backgroundPopup").fadeOut("slow");
		$("#reg_popup").fadeOut("slow");
		popupStatus3 = 0;
	}
}

function centerPopup3(){
	//request data for centering
	var windowWidth3 = document.documentElement.clientWidth;
	var windowHeight3 = document.documentElement.clientHeight;
	var popupHeight3 = $("#reg_popup").height();
	var popupWidth3 = $("#reg_popup").width();
	//centering
	$("#reg_popup").css({
		"position": "absolute",
		"top": "340px", //windowHeight3/2-popupHeight3/2,
		"left": Number(document.getElementById('wrapper').offsetLeft)+15//windowWidth3/2-popupWidth3/2
	});
	//only need force for IE6
	
//	$("#backgroundPopup").css({
//		"height": windowHeight
//	});
}
//-------------------- Registration  end-----------------------

//-------------------- Thank U popup strat-------------------
//loading popup with jQuery magic!
function loadPopup4(){
		//centering with css
		centerPopup4();
	if(popupStatus4==0){
//		$("#backgroundPopup").css({
//			"opacity": "0.7"
//		});
//		$("#backgroundPopup").fadeIn("slow");
		$("#thanku_popup").fadeIn("slow");
		popupStatus4 = 1;
		disablePopup3();
		disablePopup5();
	}
}

//disabling popup with jQuery magic!
function disablePopup4(){
	//disables popup only if it is enabled
	if(popupStatus4==1){
		//$("#backgroundPopup").fadeOut("slow");
		$("#thanku_popup").fadeOut("slow");
		popupStatus4 = 0;
	}
}

function centerPopup4(){
	//request data for centering
	var windowWidth4 = document.documentElement.clientWidth;
	var windowHeight4 = document.documentElement.clientHeight;
	var popupHeight4 = $("#thanku_popup").height();
	var popupWidth4 = $("#thanku_popup").width();
	//centering
	$("#thanku_popup").css({
		"position": "absolute",
		"top": "340px", //windowHeight4/2-popupHeight4/2,
		"left": Number(document.getElementById('wrapper').offsetLeft)+15//windowWidth4/2-popupWidth4/2
	});
	//only need force for IE6
	
//	$("#backgroundPopup").css({
//		"height": windowHeight
//	});
}
//-------------------- Thank U popup end-----------------------

//-------------------- Registration: country popup strat-------------------
//loading popup with jQuery magic!
function loadPopup5(){
	//centering with css
		centerPopup5();
	if(popupStatus5==0){
//		$("#backgroundPopup").css({
//			"opacity": "0.7"
//		});
//		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact2").fadeIn("slow");
		popupStatus5 = 1;
		disablePopup();
		disablePopup3();
		
	}
}

//disabling popup with jQuery magic!
function disablePopup5(){
	//disables popup only if it is enabled
	if(popupStatus5==1){
		//$("#backgroundPopup").fadeOut("slow");
		$("#popupContact2").fadeOut("slow");
		popupStatus5 = 0;
	}
}

function centerPopup5(){
	//request data for centering
	var windowWidth5 = document.documentElement.clientWidth;
	var windowHeight5 = document.documentElement.clientHeight;
	var popupHeight5 = $("#popupContact2").height();
	var popupWidth5 = $("#popupContact2").width();
	//centering
	$("#popupContact2").css({
		"position": "absolute",
		"top": "340px", //windowHeight5/2-popupHeight5/2,
		"left": Number(document.getElementById('wrapper').offsetLeft)+15//windowWidth5/2-popupWidth5/2
	});
	//only need force for IE6
	
//	$("#backgroundPopup").css({
//		"height": windowHeight
//	});
}
//-------------------- Registration: country popup end-----------------------


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	//LOADING POPUP
	//Click the button event!
	$("#button").click(function(){
		//load popup
		loadPopup();
	});
					
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose").click(function(){
		disablePopup();
	});
//	//Click out event!
//	$("#backgroundPopup").click(function(){
//		disablePopup();
//	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
	
	//----- Refer ur frd popup------
	
	//LOADING POPUP
	//Click the go button event!
	$("#gobtn").click(function(){
		//load popup
		loadPopup2();
	});
	//CLOSING POPUP
	//Click the x event!
	$("#Reg_popupClose2").click(function(){
		disablePopup2();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus2==1){
			disablePopup2();
		}
	});
	//----------------------
	
	//----- Registration popup------
	
	//LOADING POPUP
	//Click the go button event!
	
/*	$("#go2register").click(function(){
		//load popup
		loadPopup3();
	});*/
	
	//CLOSING POPUP
	//Click the x event!
	$("#Reg_popupClose").click(function(){
		disablePopup3();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus3==1){
			disablePopup3();
		}
	});
	//----------------------

    //-----call Registration: country popup------
	
	//LOADING POPUP
	//Click the go button event!
	$("#registered").click(function(){
		//load popup
		loadPopup5();
	});
	//CLOSING POPUP
	//Click the x event!
	$("#thanku").click(function(){
		disablePopup5();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus5==1){
			disablePopup5();
		}
	});
	//----------------------
	
	//----- Registration: country popup------
	
	//LOADING POPUP
	//Click the go button event!
	$("#addmorefrd").click(function(){
		//load popup
		if($("#loginId").val() == "")
		{
			$("#loginErr").show();
		}
		else
		{
			$("#loginErr").hide();
			loadPopup5();
		}
	});
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose2").click(function(){
		disablePopup5();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus5==1){
			disablePopup5();
		}
	});
	//----------------------
	
	//-----call Thanku popup------
	
	//LOADING POPUP
	//Click the go button event!
	$("#submitthanku").click(function(){

		//load popup
		//loadPopup4();
	});
	//CLOSING POPUP
	//Click the x event!
	$("#thanku").click(function(){
		disablePopup4();
	});
	$("#thanku_popupClose").click(function(){
		disablePopup4();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus4==1){
			disablePopup4();
		}
	});
	//----------------------

});