jQuery.noConflict();

jQuery(document).ready(function() {
	//if (readCookie('popup') != 1) {
		centrePopup();
		
		//displays popup
		jQuery("#popup").fadeIn("slow");
		jQuery("#backgroundPopup").css({  
			"opacity": "0.5"  
		});  
		jQuery("#backgroundPopup").fadeIn("slow"); 
		
		//create cookie
		createCookie('popup', 1, 1);
		
		jQuery("#backgroundPopup, .close").click(function() {
			jQuery("#backgroundPopup").fadeOut("slow");
			jQuery("#popup").fadeOut("slow");
		});	
	//}
});


//centering popup
function centrePopup(){
//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = jQuery("#popup").height();
	var popupWidth = jQuery("#popup").width();
	//centering
	jQuery("#popup").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	
	jQuery("#backgroundPopup").css({
		"height": windowHeight
	});

}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

