function checkIt(string)
	{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
	}
	
var detect = navigator.userAgent.toLowerCase();
	var OS,browser,version,total,thestring;
	var _ai=0;
	
	if (checkIt('konqueror'))
	{
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt('safari')) browser = "Safari"
	else if (checkIt('omniweb')) browser = "OmniWeb"
	else if (checkIt('opera')) browser = "Opera"
	else if (checkIt('webtv')) browser = "WebTV";
	else if (checkIt('icab')) browser = "iCab"
	else if (checkIt('msie')) browser = "InternetExplorer"
	else if (!checkIt('compatible'))
	{
		browser = "Netscape"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";

		var xmlhttp=false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		// JScript gives us Conditional compilation, we can cope with old IE versions.
		// and security blocked creation of the objects.
		try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
		xmlhttp = false;
		}
		}
		/*@end @*/
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
		}
		
		function methDataGet(strMethod,strValue)
		{
		
		xmlhttp.open("GET", "dataget.asp?method=" + strMethod + "&str=" + strValue + "&ID=" + GetBID(),true);
		
		
		//if(strMethod=="GetChat")
		//	{
				xmlhttp.onreadystatechange=function() 
				{
					if (xmlhttp.readyState==4) 
					{
						var msg = xmlhttp.responseText;
					
						if(msg!="")
						{
						//xmlhttp.send(null);
						SendChatServer(msg);
						}
						
						resetclock();
					}
				}
		//	}
			xmlhttp.send(null)
			
			
		

		}	





var limit="0:02"

if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}

function resetclock()
{
 limit="0:02";
 parselimit=limit.split(":")
 parselimit=parselimit[0]*60+parselimit[1]*1

 beginrefresh();
 
}
		
function beginrefresh()
{
	if (!document.images)
	return
	if (parselimit==1)
	{
	
	methDataGet("GetChat","Check")
	
	}
	else{ 
	parselimit-=1
	curmin=Math.floor(parselimit/60)
	cursec=parselimit%60
	if (curmin!=0)
	curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
	else
	curtime=cursec+" seconds left until page refresh!"
	window.status=curtime
	setTimeout("beginrefresh()",1000)
	}
}
		
function SendChatServer(strChat)
{
	
	document.getElementById("chatSession").innerHTML = document.getElementById("chatSession").innerHTML + strChat + "<br/>";
	document.getElementById("chatSession").scrollTop = document.getElementById("chatSession").scrollHeight;
}

function ChatWindow()
{
	document.getElementById("dChatWindow").style.visibility = "visible";
	Drag.init(document.getElementById("dChatWindow"));
}

function chatClose()
{
	document.getElementById("dChatWindow").style.visibility = "hidden";
	document.getElementById("chatTwo").style.visibility = "hidden";
	methDataGet("SendChat",document.getElementById("iChatName").value + "¬" + GetPage() + "¬User has closed chat window")
}

function callChat()
{
	//alert(document.getElementById("chatOne").style.visibility)
	document.getElementById("chatOne").style.visibility = "hidden";
	
	document.getElementById("chatTwo").style.visibility = "visible";
	document.getElementById("chatSession").innerHTML = "<br>&nbsp;Please wait a customer service rep is being paged<br>"
	methDataGet("SendChat",document.getElementById("iChatName").value + "¬" + GetPage() + "¬Chat Session has started")
	resetclock();
		
	
}

function sendChat()
{
	document.getElementById("chatSession").innerHTML = document.getElementById("chatSession").innerHTML + "<b>" + document.getElementById("iChatName").value + "</b>:" + document.getElementById("chatSessionText").value + "<br/>";
	document.getElementById("chatSession").scrollTop = document.getElementById("chatSession").scrollHeight;
	methDataGet("SendChat",document.getElementById("iChatName").value + "¬" + GetPage() + "¬" + document.getElementById("iChatName").value + ": " + document.getElementById("chatSessionText").value)
	document.getElementById("chatSessionText").value = "";
}