/***************************/
//@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 popup1
//0 means disabled; 1 means enabled;
var popup1Status1 = 0;
//loading popup1 with jQuery magic!
function loadpopup11(){
	//alert(0);
	//loads popup1 only if it is disabled
	if(popup1Status1==0){
		$("#backgroundpopup1").show();
		$("#popup").show();
		popup1Status1 = 1;
	}
		
}


//disabling popup1 with jQuery magic!
function disablepopup11(){
	//disables popup1 only if it is enabled
	
	$("#popup").html('')
	if(popup1Status1==1){
		$("#backgroundpopup1").hide();
		$("#popup").hide();

		popup1Status1 = 0;
	}

}




//centering popup1
function centerpopup11(name,w,h,yid){

	//request data for centering
	
	var bHeight=document.documentElement.scrollHeight;
	var winH,winW;  
	if(window.innerHeight && window.scrollMaxY) {    // Mozilla 
	winH = window.innerHeight + window.scrollMaxY;
	winW = window.innerWidth + window.scrollMaxX;
	ifrtop=document.frames["topnavindex"].document         //document.getElementById(id).contentDocument || document.frames[id].document;
	
	} 
	else if(document.body.scrollHeight > document.body.offsetHeight){
	 //all but IE Mac
	winH = document.body.scrollHeight;
	winW = document.body.scrollWidth;
	} 
	else if(document.body) { // IE Mac
	winH = document.body.offsetHeight;
	winW = document.body.offsetWidth;
	} 




	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	if(winH<windowHeight&&windowHeight>668){
		winH=windowHeight;
	}
	
	var popup1Height = h;
	var popup1Width = w;
	//centering
    
	if(windowHeight<668){
		
		
	$("#popup").css({
		"position": "absolute",
		"top": 560/2-popup1Height/2,
		"left": 978/2-popup1Width/2
	});
	
	$("#backgroundpopup1").css({
		"height":winH,
		"width":winW,
		"zIndex":"990"
	});
	
	
	}else{

	$("#popup").css({
		"position": "absolute",
		//"top": windowHeight/2-popup1Height/2,
		"top": 560/2-popup1Height/2,
		"left": 978/2-popup1Width/2
	});
	
	$("#backgroundpopup1").css({
		"height":winH,
		"width":winW,
		"zIndex":"990"
	});
	
	
	
	
	}
	//only need force for IE6
	
	
}


//CONTROLLING EVENTS IN jQuery

function popup1(name,w,h,yid){
	
	   //notIe = -[1,];  
	
	if(name=='loginout'){
	   $("#popup").html('<iframe scrolling="no" width="0" height="0" src="regist/loginout.php" frameborder="0" id="login" allowtransparency="true"></iframe>');
		//if(notIe){ 
		//}else{  
		//document.frames('login').location.reload(true)
		//}
	}
	
	centerpopup11(name,w,h,yid);
	loadpopup11();
	$("#backgroundpopup1").click(function(){
		disablepopup11();
	});
	
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popup1Status1==1){
			disablepopup11();
		}
	});

}
