// JavaScript Document
var timeout = 0;
var timeoutlimit = 120; // 120 = 10 mins
var chatrefreshspeed = 5000;
var timeoutin = 30;
var playedDingDong = 0;
var loginTimer = 0;
function doFocus(val, val2, theID)
{
	//alert(val);
	if (val == val2)
		{
		document.getElementById(theID).value = "";
		}
}
function doBlur(val, val2, theID)
{
	//alert(val);
	if (val == "")
		{
		document.getElementById(theID).value = val2;
		}
}
var tx
var tx2
function timedCountGetOnline(theID)
{
getOnlineNow(scriptname);
tx=setTimeout("timedCountGetOnline()",60000);
}
function timedChatRequests()
{
checkForChat();
if (loginTimer == 0)
	{
	getNewSignIns();
	}
loginTimer++;
if (loginTimer == 5)
	{
	loginTimer = 0;
	}
timeout++;
if (timeout>timeoutlimit)
	{
	if (timeoutin <= 0)
		{
		document.getElementById("timeoutDivHolder").style.display = "none";
		chatrefreshspeed = 5000;
		document.location = "http://www.playzone18.com/logout.asp";
		}
	chatrefreshspeed = 1000;
	document.getElementById("timeoutDivHolder").style.display = "block";
	document.getElementById("timeoutDiv").innerHTML = timeoutin;
	timeoutin--;
	}
tx2=setTimeout("timedChatRequests()",chatrefreshspeed);
}

function resetTimeout()
	{
	timeout = 0;
	chatrefreshspeed = 5000;
	timeoutin = 30;
	document.getElementById("timeoutDivHolder").style.display = "none";
	}
	
function popRespondChat(wh, id)
{
	var objDiv = document.getElementById("ChatRequestDiv");
	objDiv.style.display = "none";
	window.open("/chat/respondRequest.asp?wh="+wh+"&id="+id,"Chat"+id,"width=400, height=514, location=no, menubar=no, scrollbars=no, resizable=no, toolbar=no, status=no, top=20, left=200");
	playedDingDong = 0;
	timeoutlimit = 1440; // 1440 = 2 hours
}

function popProfile(rid, pid)
{
	timeoutlimit = 1440; // 1440 = 2 hours
	window.open("/chat/person.asp?pID="+pid+"&id="+rid,"Profile","width=510, height=600, location=no, scrollbars=yes, menubar=no, resizable=no, toolbar=no, status=no, top=20, left=500");
}

function chatPop(theID)
{
	window.open("/chat/request.asp?op=1&id="+theID,"Chat"+theID,"width=400, height=514, location=no, menubar=no, scrollbars=no, resizable=no, toolbar=no, status=no, top=20, left=100");
}

var xmlHttpD

function checkForChat()
{ 
xmlHttpD=GetXmlHttpObjectD();
if (xmlHttpD==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/chat/getChatRequests.asp";
url=url+"?sid="+Math.random();
xmlHttpD.onreadystatechange=stateAlter;
xmlHttpD.open("GET",url,true);
xmlHttpD.send(null);
}

function stateAlter() 
{ 
if (xmlHttpD.readyState==4)
{ 
var x = xmlHttpD.responseText;
var objDiv = document.getElementById("ChatRequestDiv");
objDiv.style.display = "none";
if(x == "none")
	{
	objDiv.innerHTML="";
	playedDingDong = 0;
	}
else
	{
	objDiv.innerHTML=x;
	objDiv.style.display = "block";
	if (playedDingDong == 0)
		{
		soundManager.play('dingdong');
		playedDingDong = 1;
		}
	}
}
}


function getNewSignIns()
{ 
xmlHttpZ=GetXmlHttpObjectZ();
if (xmlHttpZ==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/chat/getNewSignIns.asp";
url=url+"?sid="+Math.random();
xmlHttpZ.onreadystatechange=stateAlter10;
xmlHttpZ.open("GET",url,true);
xmlHttpZ.send(null);
}
function stateAlter10() 
{ 
if (xmlHttpZ.readyState==4)
{ 
var x = xmlHttpZ.responseText;
var objDiv = document.getElementById("NewSignInsDiv");
objDiv.style.display = "none";
if(x == "none")
	{
	objDiv.innerHTML="";
	}
else
	{
	objDiv.innerHTML=x;
	objDiv.style.display = "block";
	soundManager.play('pop1');
	}
}
}

function GetXmlHttpObjectD()
{
var xmlHttpD=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpD=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpD=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpD=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpD;
}

function GetXmlHttpObjectZ()
{
var xmlHttpZ=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttpZ=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttpZ=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttpZ=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttpZ;
}

function doFocus(fieldID)
{
	document.getElementById(fieldID).focus();
}

function popVideo(vid)
	{
	var pp = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=600,height=400';
	window.open('/video.asp?vid='+vid,'_blank',pp)
	}