﻿//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;
//loading popup with jQuery magic!
function loadPopup_left_1(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.4"
		});
		$("#backgroundPopup").fadeIn("fast");
		$("#left_1_content").fadeIn("fast");
		popupStatus = 1;
	}
}
//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#left_1_content").fadeOut("fast");
		popupStatus = 0;
	}
}
//centering popup
function centerPopup_left_1(){
	//request data for centering
	//var windowWidth = document.documentElement.clientWidth;
	var windowWidth = document.body.clientWidth;
	//var windowHeight = document.documentElement.clientHeight;
	var windowHeight = document.body.clientHeight;
	var popupHeight = $("#left_1_content").height();
	var popupWidth = $("#left_1_content").width();
	//centering
	$("#left_1_content").css({
		"position": "absolute",
		"top": 30,//(windowHeight/2-popupHeight/2)-150,
		"left": (windowWidth/2) - 480
	});
	//only need force for IE6	
	$("#backgroundPopup").css({
		"height": windowHeight
		//"height": 800
	});	
}
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#button").click(function(){
		//centering with css
		centerPopup_left_1();
		//load popup
		loadPopup_left_1();
	});				
	//CLOSING POPUP
	//Click the x event!
	$("#left_1_contentClose").click(function(){
		disablePopup();
	});
	$("#left_2_contentClose").click(function(){
		disablePopup2();
	});
	$("#right_1_contentClose").click(function(){
		disablePopup3();
	});
	$("#right_2_contentClose").click(function(){
		disablePopup4();
	});	
	$("#right_3_contentClose").click(function(){
		disablePopup5();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});
});

function popItUp_left_1()
{
	centerPopup_left_1();
	loadPopup_left_1();	
}

/////////Second button//////
function popItUp_left_2()
{
	centerPopup_left_2();
	loadPopup_left_2();	
}

function loadPopup_left_2(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.4"
		});
		$("#backgroundPopup").fadeIn("fast");
		$("#left_2_content").fadeIn("fast");
		popupStatus = 1;
	}
}
function centerPopup_left_2(){
	//request data for centering
	//var windowWidth = document.documentElement.clientWidth;
	var windowWidth = document.body.clientWidth;
	//var windowHeight = document.documentElement.clientHeight;
	var windowHeight = document.body.clientHeight;
	var popupHeight = $("#left_2_content").height();
	var popupWidth = $("#left_2_content").width();
	//centering
	$("#left_2_content").css({
		"position": "absolute",
		"top": 50,
		"left": (windowWidth/2) - 350
	});
	//only need force for IE6	
	$("#backgroundPopup").css({
		"height": windowHeight
		//"height": 800
	});	
}
function disablePopup2(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#left_2_content").fadeOut("fast");
		popupStatus = 0;
	}
}

////Right button 1////
function popItUp_right_1()
{
	centerPopup_right_1();
	loadPopup_right_1();	
}

function loadPopup_right_1(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.4"
		});
		$("#backgroundPopup").fadeIn("fast");
		$("#right_1_content").fadeIn("fast");
		popupStatus = 1;
	}
}
function centerPopup_right_1(){
	//request data for centering
	//var windowWidth = document.documentElement.clientWidth;
	var windowWidth = document.body.clientWidth;
	//var windowHeight = document.documentElement.clientHeight;
	var windowHeight = document.body.clientHeight;
	var popupHeight = $("#right_1_content").height();
	var popupWidth = $("#right_1_content").width();
	//centering
	$("#right_1_content").css({
		"position": "absolute",
		"top": 10,
		"left": (windowWidth/2)+50
	});
	//only need force for IE6	
	$("#backgroundPopup").css({
		"height": windowHeight
	});	
}
function disablePopup3(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#right_1_content").fadeOut("fast");
		popupStatus = 0;
	}
}

////Right button 2////
function popItUp_right_2()
{
	centerPopup_right_2();
	loadPopup_right_2();	
}

function loadPopup_right_2(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.4"
		});
		$("#backgroundPopup").fadeIn("fast");
		$("#right_2_content").fadeIn("fast");
		popupStatus = 1;
	}
}
function centerPopup_right_2(){
	var windowWidth = document.body.clientWidth;
	var windowHeight = document.body.clientHeight;
	var popupHeight = $("#right_2_content").height();
	var popupWidth = $("#right_2_content").width();
	//centering
	$("#right_2_content").css({
		"position": "absolute",
		"top": 180,
		"left": (windowWidth/2)+80
	});
	//only need force for IE6	
	$("#backgroundPopup").css({
		"height": windowHeight
	});	
}
function disablePopup4(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#right_2_content").fadeOut("fast");
		popupStatus = 0;
	}
}

////Right button 3////
function popItUp_right_3()
{
	centerPopup_right_3();
	loadPopup_right_3();	
}

function loadPopup_right_3(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.4"
		});
		$("#backgroundPopup").fadeIn("fast");
		$("#right_3_content").fadeIn("fast");
		popupStatus = 1;
	}
}
function centerPopup_right_3(){
	var windowWidth = document.body.clientWidth;
	var windowHeight = document.body.clientHeight;
	var popupHeight = $("#right_3_content").height();
	var popupWidth = $("#right_3_content").width();
	//centering
	$("#right_3_content").css({
		"position": "absolute",
		"top": 80,
		"left": 180
	});
	//only need force for IE6	
	$("#backgroundPopup").css({
		"height": windowHeight
	});	
}
function disablePopup5(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("fast");
		$("#right_3_content").fadeOut("fast");
		popupStatus = 0;
	}
}