/***************************/
//@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;

//loading popup with jQuery magic!
function loadPopup(){


	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#blanket").css({
			"opacity": "0.7"
			
	
		});
		
		
        size()
		$("#blanket").fadeIn("slow");
		$("#popUpDiv").fadeIn("slow");
		popupStatus = 1;
	
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#blanket").fadeOut("slow");
		$("#popupDiv").fadeOut("slow");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
document.getElementById('blanket').style.height= 1280 + 'px';
	//request data for centering
if(screen.width==1280)
{

//document.getElementById('popUpDiv').style.display='block';
document.getElementById('wrapper').style.width= 1000 + 'px';
document.getElementById('popUpDiv').style.left=245 +'px';
}
if(screen.width==800)
{


document.getElementById('popUpDiv').style.left= 30 + 'px';
document.getElementById('popUpDiv').style.width= 500 + 'px';
document.getElementById('popUpDiv').style.right= 45 + 'px';
document.getElementById('popUpDiv').style.top= 205 + 'px';
document.getElementById('popUpDiv').style.bottom= 10 + 'px';


	
//document.getElementById('popUpDiv').style.display='block';

}


if(screen.width==1024)
{

document.getElementById('popUpDiv').style.left= 120 + 'px';
document.getElementById('popUpDiv').style.width= 800 + 'px';
document.getElementById('popUpDiv').style.right= 45 + 'px';
document.getElementById('popUpDiv').style.top= 205 + 'px';
document.getElementById('popUpDiv').style.bottom= 10 + 'px';

//document.getElementById('popUpDiv').style.display='block';

}

if(screen.width==1152)
{

document.getElementById('popUpDiv').style.left= 120 + 'px';
document.getElementById('popUpDiv').style.width= 800 + 'px';
document.getElementById('popUpDiv').style.right= 45 + 'px';
document.getElementById('popUpDiv').style.top= 205 + 'px';
document.getElementById('popUpDiv').style.bottom= 10 + 'px';

//document.getElementById('popUpDiv').style.display='block';

}
	
}

function size()
{
	$("#blanket").width(1280)
	$("#blanket").height(1800)
	
	
	if(screen.width==1280)
	{
		$("#popUpDiv").width(800)
		$("#popupDiv").height(700)
	
		$("#popUpDiv").css({
			"left": "230",
			"top": "180"
			
	
		});
		
	}
	
	if(screen.width==800)
{
	
		$("#popUpDiv").width(500)
	
		$("#popUpDiv").css({
			"left": "30",
			"right": "45",
			"top":"205",
			"bottom":"10"
			
	
		});

}

	if(screen.width==1024)
{
	
		$("#popUpDiv").width(800)
	
		$("#popUpDiv").css({
			"left": "120",
			"right": "45",
			"top":"205",
			"bottom":"10"
			
	
		});

}
if(screen.width==1152)
{
	
		$("#popUpDiv").width(800)
	
		$("#popUpDiv").css({
			"left": "170",
			"right": "100",
			"top":"205",
			"bottom":"10"
			
	
		});

}






	
}

//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupDivClose").click(function(){
		disablePopup();
	});
	//Click out event!
	$("#blanket").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});
