// JavaScript Document
// This function is used by those people who have upgraded and wish to obtain more tracking information

var __ptw_host = (("https:" == document.location.protocol) ? "https://www." : "http://www.");

	if (_pop_sid > 0)
	{
		// check if here before?
		 var iU = 0; // increment unique?		
		 var isNewSession = 0; // is this a new session?
		 
		 var w=80;
		 var h=52;
		 
		 var T = typeof _pop_skin=="string" ? _pop_skin : "";
		 var A = typeof _pop_sauth=="string" ? _pop_sauth : "";
		 var S = typeof _pop_sid=="string" ? _pop_sid : "";
		 var G = typeof _pop_goal=="string" ? _pop_goal : "";
		 var M = typeof _pop_msg=="string" ? _pop_msg : "";
		
		 var b = 1;
		 
		 var cN = '__ptw_' + S;
		 var cS = '__ptw_session_' + S;
		 var cV = readCookie( cN ) ;
		 var cSV = readCookie( cS ) ; // session cookie
		
		 if (cV == null)
		 {
			iU = 1;
			createCookie(cN,S,30);
		 }
		 if (cSV == null)
		 {
			isNewSession = 1;
			createCookie(cS,S,0);
		 } 
		 
		 if ( T=="small" )
		 {
			  w=50;
			  h=50
			  b = 3;
		 }
		 else if ( T=="medium" )
		 {
			   b = 2;
			  w=100;
			  h=100;
		 }
		 else if ( T=="large" )
		 {
			   b = 1;
			  w=160;
			  h=160;
		 }
		 else if ( T=="invis" )
		 {
			   b = 4;
			  w=0;
			  h=0;
		 }
		 else if ( T=="button1" )
		 {
			   b = 5;
			  w=85;
			  h=85;
		 }
		 else if ( T=="button2" )
		 {
			   b = 6;
			  w=85;
			  h=70;
		 }
		 else if ( T=="button3" )
		 {
			   b = 7;
			  w=85;
			  h=32;
		 }
		 else if ( T=="orange1" )
		 {
			   b = 8;
			  w=85;
			  h=85;
		 }
		 else if ( T=="orange2" )
		 {
			   b = 9;
			  w=85;
			  h=70;
		 }
		 else if ( T=="orange3" )
		 {
			   b = 10;
			  w=85;
			  h=32;
		 }
		
		// see if we need authorization
		if (_pop_sauth == null)
		{
			var _pop_sauth = 0; // default to 0	
		}
	
//		alert(__ptw_host + "populatetheweb.com/pop.php?b="+b + "&n=" + iU + "&s="+ S +"&t=" + T + "&a=" + A );
//			document.write("<iframe marginwidth=0 marginheight=0 height=" + h + " width=" + w + " src='" + __ptw_host + "populatetheweb.com/pop.php?b="+b + "&n=" + iU + "&s="+ S +"&t=" + T + "&a=" + A + "&g=" + G + "&m=" + M + "' frameborder='0' scrolling='no'></iframe>");
		if (_pop_show_only_uniques == undefined)
		{
			var _pop_show_only_uniques = false;	
		}
		if (_pop_show_only_sessions == undefined)
		{
			var _pop_show_only_sessions = false;	
		}
		// are we only monitoring uniques visits per month?
		if ( (_pop_show_only_uniques == true && iU == 1) || (_pop_show_only_uniques == false))
		{
			// are we only monitoring sessions?
			if ( (_pop_show_only_sessions == true && isNewSession == 1) || (_pop_show_only_sessions == false))
			{
				if (window.ptw_pop_loaded != true)
				{
					
					window.ptw_pop_loaded = true;
					document.write("<iframe marginwidth=0 marginheight=0 height=" + h + " width=" + w + " src='" + __ptw_host + "populatetheweb.com/pop.php?b="+b + "&n=" + iU + "&s="+ S +"&t=" + T + "&a=" + A + "&g=" + G + "&m=" + M + "' frameborder='0' scrolling='no'></iframe>");	
				}
			}
		}
	}


function createCookie(name,value,days) {
	var expires = "";
	if (days > 0) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	else
	{
		 // do 30 minutes
		 var date = new Date();
		 date.setTime(date.getTime()+(30*60*1000));
		 expires = "; expires="+date.toGMTString();		
	}
	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);
}