var messageCount = 0;
function exitChat()
{
	document.getElementById('chatDiv').style.display = 'none';
}
function minimizeChat()
{
	messageCount = 0;
	document.getElementById('chatDiv').style.display = 'none';
}
function enlargeChat()
{
	var windowWidth = window.innerWidth;
	var windowHeight = window.innerHeight;
	document.getElementById('chatDiv').style.width = (windowWidth - 15) + 'px';
	document.getElementById('chatDiv').style.height = (windowHeight - 20) + 'px';
	
}
function chatSubmit()
{
	document.getElementById('talkBox').style.display = 'none';
	document.getElementById('loginBox').style.display = 'block';
	return false;
}
function requestChat()
{
	
	ajaxFunction();
	var url = "chat.ajax.php?act=receive4";
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function ajaxResponse(body)
{
	document.getElementById('talkBox').innerHTML += body;
	scrollBottom();
	setTimeout("requestChat()", 1200);
	
	if(body.length > 10)
		chatPopup();
}
function chatShow()
{
	document.getElementById('chatDiv').style.display = 'block';
	document.getElementById('chatPopup').style.display = 'none';
}
function chatLogin()
{
	setTimeout ( "invalidCaptcha()", 1500 );
}
function chatPopup()
{
	
	if(document.getElementById('chatDiv').style.display == 'none')
	{
		document.getElementById('chatPopup').style.display = 'block';
		messageCount++;
		document.getElementById('chatPopupContent').innerHTML = messageCount + " new messages";
	}
}
function invalidCaptcha()
{
	alert("Incorrect code for security image. Please verify to prove you are human.");
}
function loginCancel()
{
	document.getElementById('loginBox').style.display = 'none';
	document.getElementById('talkBox').style.display = 'block';
}

function scrollBottom()
{
	var objDiv = document.getElementById("talkBox");
	objDiv.scrollTop = objDiv.scrollHeight;

}