//
// TGPsitecentral warning pages
// Lets put this at the top of the body
//
// *** WARNING *** This page is one giant hack. I don't even want to put my name in there, this is how hacky it is.
// Contact: eric@nerd.com

var viewportwidth;
var viewportheight;
var compliant = '';
 
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 clicker(url) {
	createCookie('warned', '1', 360);
	return(true);
}

function page_size() {
    
 if (typeof window.innerWidth != 'undefined')
 {
      compliant = 'a';
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
 {
       compliant = 'b';
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 else
 {
      compliant = 'c';
      viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
      viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
 
}

function JSFX_FloatTopDiv()
{
    // Get viewport size
    page_size();
    
    // calculate the center of the page
    sx = (viewportwidth/2) - (350/2);
    sy = (viewportheight/2) - (300/2);
    
	var startX = sx,
	startY = sy;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	function ml(id)
	{
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x;this.style.top=y;};
		el.x = startX;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		el.y -= startY;
		}
		return el;
	}
	window.stayTopLeft=function()
	{
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : document.body.scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 10);
	}
	ftlObj = ml("warn_light");
	stayTopLeft();
}

// return true if this is a network site
function is_network() {
	
	// check if we have #nowarn flag in the URL
	if (window.location.href.match(/#nowarn/)) {
		return(true)
	}

	if (document.referrer && document.referrer.length > 0) {
		var ref = document.referrer;
		var a = new Array;
		a[0] = /sublime/;
		a[1] = /madt/;
		a[2] = /cowlist/;
		a[3] = /teeniefiles/;
		a[4] = /purextc/;
		a[5] = /88by88/;
		a[6] = /bigtits/;
		a[7] = /madteenies/;
		a[8] = /treasurethumbs/;
		a[9] = /youporn/;
		a[10] = /fling/;
		a[11] = /tube/;

		// If from search engines always show the screen
		if (ref.match(/google|yahoo|msn|ask\.com|aol|live|altvista|yandex|baidu|netscape|alltheweb|lycos|mamma/i)) {
			return(false);
		}

		// compare the referrer
		var i;
		for (i = 0; i < a.length; i++) {
			if (ref.match(a[i])) {
				return(true);
			}
		}

		return(true)
	}
	
	return(false)
}

// Do we have the cookie?
if (!readCookie('warned') && !is_network()) {
	// Write in the style
	document.write('<style>');
	document.write('.black_overlay{ display: none; margin: 0; padding: 0; position: absolute; top: 0%; left: 0%; width: 100%; height: 40000px; background-color: #000; z-index:10001; } .white_content { display: none; position: absolute; top: 25%; left: 25%; width: 350px; height: 300px; padding: 0px; z-index:10002; background-color: #FFF; }');
	document.write('</style>');

	// Write our divs here
	document.write('<div id="warn_light" class="white_content" style="display: none; text-align: center;">');
	document.write('<img src="http://md.tgpsitecentral.com/lightbox/18+.gif" /><br/>');
	document.write('<div style="width: 50%; text-align: center; float: left;"><a href="' + enter_url + '" onClick="clicker(\'' + enter_url + '\');"><img src="http://md.tgpsitecentral.com/lightbox/ENTER.jpg" border="0" /></a></div>');
	document.write('<div style="width: 50%; text-align: center; float: left;"><a href="' + exit_url + '"><img src="http://md.tgpsitecentral.com/lightbox/NOT18.jpg" border="0" /></a></div>');
	document.write('<div style="clear: both;"></div>');
	document.write('</div>');
    
    // Check compliant width
    page_size();
    var dwidth = 100;
    if (compliant == 'c') {
        dwidth = 105;
    }

	document.write('<div id="warn_fade" class="black_overlay" style="display: none;"><div style="width: '+dwidth+'%; -moz-opacity: 0.90; opacity:.90; filter: alpha(opacity=90);"></div></div>');

	// open it if we do not have the cookie
	document.getElementById('warn_light').style.display='block';
	document.getElementById('warn_fade').style.display='block'

    var verticalpos = 'fromtop';
    JSFX_FloatTopDiv();
    
} else {
	// Do nothing
	createCookie('warned', '1', 360);
}

