
var onfield=true;
var cookie1="TV0384201";
var cookie2="TV038420M";
var everyN=9;
var Ceiling=7;




function ww_pop_survey(popuphtml)
{
var o,d,cd;
var mc,uc;

mc=document.cookie;
mc=readcookie(cookie1);

uc=document.cookie;
uc=readcookie(cookie2);


//alert ('cookie 1 ' + mc + '\n' + 'cookie 2 ' + uc);


if (is_off_hours()==false && onfield==true && uc!='never')
{
	if (mc=='false')
	{
        	var rnd=Math.round(Math.random() * everyN)
	        //window.status='First time, ' + rnd;
	        if (rnd<Ceiling) {popup_greet(popuphtml)}
	}
	else
	{
        	//window.status=mc;
	        if (mc=='later') 
		{
			if (uc=='false') popup_greet(popuphtml)
		}
	}
	//alert ('FALSE' + is_off_hours());
}
else
{
	//alert ('TRUE' + is_off_hours());
}
return true;
}



function popup_greet(popuphtml)
{
	winStats='toolbar=no,location=no,directories=no,menubar=no,';
	winStats+='scrollbars=no,resizable=yes,status=no';
	if (navigator.appName.indexOf("Microsoft")>=0) 
		{
			winStats+=',left=' + 0 + ',top=' + 0
		}
		else
		{
			winStats+=',screenX=' + 0 + ',screenY=' + 0
		}
	winStats+=',width=' + 400 + ',height=' + 425;
        adWindow=window.open(popuphtml,"fixed",winStats);
	adWindow.focus();
        return true;
}

function readcookie(name)
{
if(document.cookie=='')
        return 'false';
else
	return unescape(getcookie(name));
}

function getcookie(name)
{
var fc, lc;
var bc=document.cookie;
fc=bc.indexOf(name);
if(fc !=-1)
	{
	fc+=name.length+1;
	lc=bc.indexOf(';',fc);
	if(lc==-1) lc=bc.length;
	return bc.substring(fc,lc);
	}
	else
	{
        return 'false';
	}
}










function resetcookie(cookiename)
{
var o,d,cd;
var mc;
mc=document.cookie;



mc=readcookie(cookiename);

if(mc!='false')
{

	d=new Date("August 22, 1999");
	cd=d.toGMTString();
        o=cookiename + "=" + mc + ";path=/;expires=" + cd;
	document.cookie=o;
}

mc=readcookie(cookiename);


//window.status='Cookie ' + cookiename + ' reset!';
}




function is_off_hours() {
	var thedate = new Date()
	
	//	alert('GMT: ' + thedate.toGMTString());
	//	alert('ToString: ' + thedate.toString());

	//	alert('TZ diff: ' + thedate.getTimezoneOffset());
	
    //	alert('Hours: ' + thedate.getHours());
	
	var hours=thedate.getHours() + thedate.getTimezoneOffset()/60;

	var wday=thedate.getDay();
	//	days are 0 to 6 where 0 is sunday, 6 is saturday
        //      for this survey, we control popup, so always return false
        return false;
	
	if((hours == 12 || hours == 13)  && wday == 5 ){
		// alert('Please try again in 1 hour');
		return true;
	}else{
		// alert(hours + ' ' + wday);
		return false;
	}
}





