﻿/*[Information]===============================================	

	DeeEmm Adultcheck Popup MOD
	Created on 23/03/2010 02:47 
	by DeeEmm AKA Mick Percy deeemm@deeemm.com
	
	DeeEmm Web Technologies 
	PO Box 2105
	Hilton Plaza
	SA 5033
	Australia
	
	http://www.deeemm.com
	
	See included README file for more information

=====================================[http://www.deeemm.com]*/

var popupStatus = 0;

function loadPopup(){
	if(popupStatus==0){
		$("#DM_Popup_BG").css({
			"opacity": "0.7"
		});
		$("#DM_Popup_BG").fadeIn("slow");
		$("#DM_Popup").fadeIn("slow");
		popupStatus = 1;
	}
}

function disablePopup(){
	if(popupStatus==1){
		$("#DM_Popup_BG").fadeOut("slow");
		$("#DM_Popup").fadeOut("slow");
		popupStatus = 0;
	}
}

function centerPopup(){
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#DM_Popup").height();
	var popupWidth = $("#DM_Popup").width();
	$("#DM_Popup").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	
	$("#DM_Popup_BG").css({
		"height": windowHeight
	});
	
}

function adultcheck(){
	var adultcheckcookie = readCookie('check-accept')
	if (!adultcheckcookie) {
		centerPopup();
		loadPopup();
	}
}

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;
}


$(document).ready(function(){

	$("#DM_PopupClose").click(function(){
		disablePopup();
		document.cookie = "check-accept=true";
	});

});