// check for been here cookie
function getCookieVal(cookieName) {
	thisCookie = document.cookie.split("; ")
    	for (i=0; i<thisCookie.length; i++) {
        	if (cookieName == thisCookie[i].split("=")[0]) {
        		return thisCookie[i].split("=")[1];
        	}
    	}
	return null; //default value
}
if(getCookieVal("ptobeenhere") != "yes"){
	document.cookie = "ptobeenhere=yes;path=/;domain=.go.com";
	document.location = "http://playhouse.go.com/index.html";
}
// arrays for catching flash events recorded before the page (and hbx object) loads
clickArray = new Array();
viewArray = new Array();
// methods called from flash
function hbxReportPageView(my_mlc,my_pn)
{
//alert("pageview\n" + "my_pn: " + my_pn + "\n" + "my_mlc: " + my_mlc)
	try{
		hitbox.Set_hbPageView(my_mlc, my_pn);
	}catch(e){
		viewArray.push([my_mlc, my_pn]);
	}	
}

function hbxReportClick(lpos,lid)
{
//alert("click\n" + "lid: " + lid + "\n" + "lpos: " + lpos);
	try{
		hitbox.Set_hbLink(lid, lpos);
	}catch(e){
		clickArray.push([lpos, lid]);
	}
}
function hbxReportClickAndNavToPage(lpos,lid,url,win)
{
	//alert("click(and nav)\n" + "lid: " + lid + "\n" + "lpos: " + lpos + "\n" + url)
	try{
		hitbox.Set_hbLink(lid, lpos);
		if(win == "new"){
			popwin = window.open(url);
			popwin.focus();
		}else{
			window.location = url;
		}
	}catch(e){
		if(win == "new"){
			popwin = window.open(url);
			popwin.focus();
		}else{
			window.location = url;
		}
		//clickArray.push([lpos, lid]);
	}
}

function hbxReportEarlyEntries(){
	if(viewArray.length > 0){
		//hitbox.Set_hbPageView(viewArray[0][0], viewArray[0][1]);
		//alert("view\n" + "my_pn: " + viewArray[0][0] + "\n" + "my_mlc: " + viewArray[0][1])
		viewArray.splice(0, 1);
	}else if(clickArray.length > 0){
		//hitbox.Set_hbSet('lid',clickArray[0][1]);
		//hitbox.Set_hbSet('lpos',clickArray[0][0]);
		//hitbox.Set_hbSend();
		//alert("click\n" + "lpos: " + clickArray[0][0] + "\n" + "lid: " + clickArray[0][1])
		clickArray.splice(0, 1);
	}else{
		clearInterval(hbxEarlyReportCycle);
	}
}
// method called when page loads to catch any events recorded before the hbx object loaded
function chkload()
{
	//populate arrays for testing the preload events, uncomment the alerts in hbxReportEarlyEntries
	/*
	viewArray.push(["homeView","/marketing/pathA/"])
	viewArray.push(["homeView","/marketing/pathB/"])
	clickArray.push(["homeClick1","/marketing/pathA/"])
	clickArray.push(["homeClick2","/marketing/pathB/"])
	*/
	if(viewArray.length > 0 || clickArray.length > 0){
		hbxEarlyReportCycle = setInterval('hbxReportEarlyEntries()', 3000);
	}
}
