	//	var triedonce=false;   //debug

		var activeXtimeout=null
		var newwindow = null
		var objHttp=null
		var visiting=false
		var ready=false
		var serverTooBusy=false
			
 		var agt=navigator.userAgent.toLowerCase();
		var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
            && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
		var is_mac    = (agt.indexOf("mac")!=-1);
		var is_linux = (agt.indexOf("inux")!=-1);
		var is_safari = (agt.indexOf("safari")!=-1);
		var is_AOL = (agt.indexOf("aol")!=-1);
		var is_IE = (navigator.appName == "Microsoft Internet Explorer")
		
		function Start()		
		{
			if (objHttp!=null) return
			
			activeXtimeout=null
			activeXwaits=0
			
			if (!is_mac) document.getElementById('BodyTag').style.cursor = 'default';
										
			if (is_AOL) {
				alert("* Warning: AOL's Internet Explorer may not be compatible with Wordslide.  Try download the latest IE from Microsoft.")
			}
			
			if (is_mac && !(is_nav || is_safari)) {
				alert("* Warning: Wordslide will probably only run on a Mac that is using Safari, Netscape or Mozilla. (must also be running OSX)")
			}
						
			if (is_linux && !is_nav) {
				alert("* Warning: Wordslide will probably only run on Linux using Netscape or Mozilla.")
			}
										
			var strversion=navigator.appVersion
	
			if (is_IE && strversion.indexOf("MSIE 6")<0 && strversion.indexOf("MSIE 5.5")<0 && strversion.indexOf("MSIE 7")<0 ) {
				alert("* Warning: Internet Explorer must be version 5.5 or better to play Wordslide.")
			}

			//activeX control test//	
			try {
				var sw=screen.width
				var sh=screen.height
				
				var windowwidth=1000
				var windowheight=660
				var screensize=1.0
						
				objHttp=null
				if (window.ActiveXObject) {
					objHttp = new ActiveXObject("Microsoft.XMLHTTP")
					objHttp.Open('GET',"commandcomm.aspx?screensize="+screensize+"&rev=1.20&command=TESTACTIVEX",true)
					objHttp.Send()
				}
				else if (window.XMLHttpRequest) {	
					objHttp = new XMLHttpRequest();
					objHttp.open('GET',"commandcomm.aspx?screensize="+screensize+"&rev=1.20&command=TESTACTIVEX",true)
					objHttp.send(null)
				}
				objHttp.onreadystatechange = ActiveXSuccess

			}			
			catch(errorObject) {
				//ActiveXFailure()
				alert(errorObject.message);		
				return
			}
	
			if (!is_mac) document.getElementById('BodyTag').style.cursor = 'wait'
			activeXtimeout=setTimeout("ActiveXFailure()",10000)					
		}
		
		
		function ActiveXFailure() 
		{
			if (ready==true) return
			
			if (is_nav || is_safari) errormsg="Sorry, there was a problem starting communications with the server.<br>"
			if (is_IE) errormsg="Sorry, there was a problem starting communications with the server."
			if (!is_nav && !is_safari && !is_IE) errormsg="Sorry, there was a problem starting communications.<br>Your browser is probably not compatible."
	
			document.getElementById("StartMsgD").innerHTML=errormsg
			document.getElementById("StartMsgD").style.display="block"

			if (!is_mac) document.getElementById('BodyTag').style.cursor = 'default'
		}
		
		function ActiveXSuccess()
		{	
			if (objHttp.readyState==4) {
				var response=objHttp.responseText	
				if (response=="OK" || (response=="BUSY" && window.location.href.indexOf("allow")>0)) {
					ready=true
					document.getElementById("StartMsgD").innerHTML="."	
					if (!is_mac) document.getElementById('BodyTag').style.cursor = 'default'
					return
				}

				if (response=="BUSY") {
					ready=true
					serverTooBusy=true;
					document.getElementById("StartMsgD").innerHTML="Sorry, the game is currently at its limit of 150 players.<br>Please come back another time."	
					document.getElementById("StartMsgD").style.display="block"
					if (!is_mac) document.getElementById('BodyTag').style.cursor = 'default'
					objHttp=null
					return
				}

				objHttp=null
			}
		}
		
		
		function RedirectNow()
		{			
			if (!ready || serverTooBusy) return;
				
			if (newwindow==null) {
				RedirectNowConfirmed()
				return;
			}
			
			if (newwindow.closed)
			{
				objHttp=null
			
				if (window.ActiveXObject) {
					objHttp = new ActiveXObject("Microsoft.XMLHTTP")
					objHttp.Open('GET',"commandcomm.aspx?rev=1.20&command=STILLACTIVE",true)
					objHttp.Send()
				}
				else if (window.XMLHttpRequest) {	
					objHttp = new XMLHttpRequest();
					objHttp.open('GET',"commandcomm.aspx?rev=1.20&command=STILLACTIVE",true)
					objHttp.send(null)
				}
				else return		
					
				objHttp.onreadystatechange = SessionActiveCheckCallback
			}
			else alert("You already have a Wordslide window open.")
		}	
	
		function SessionActiveCheckCallback()
		{
			if (objHttp.readyState!=4) return;
			var response = objHttp.responseText
			objHttp=null;
			
			if (response=="BUSY" && window.location.href.indexOf("allow")<0) {
				document.getElementById("StartMsgD").innerHTML="Sorry, the game is currently at its limit of 150 players.<br>Please come back another time."	
				document.getElementById("StartMsgD").style.display="block"
				serverTooBusy=true;
				return
			}
			
			if (response=="TRUE") alert("You already have a Wordslide session active, wait a minute or restart your browser.")
			else RedirectNowConfirmed()
		}
			
		function RedirectNowConfirmed()
		{
			var sw=screen.width
			var sh=screen.height
			
			var windowwidth=1000
			var windowheight=660
			var screensize=1.0
			
			var day = new Date()
			var timeStamp = ""+day.getTime()
			
			newwindow=window.open((visiting?"entry.aspx":"signin.aspx")+"?screensize="+screensize,"WordslidePlay"+timeStamp, "toolbar=0, directories=0, location=0, status=0, menubar=0, resizable=1, scrollbars=1, width=" + windowwidth + ", height=" + windowheight+", top="+(sh>900?((sh-windowheight-140)/2):0)+", left="+(sw-windowwidth)/2+",screenY=0,screenX="+(sw-windowwidth)/2);		
						
			if (!is_mac) document.getElementById('BodyTag').style.cursor = 'default'

			if (!newwindow) {
				document.getElementById("StartMsgD").innerHTML="An error occurred opening the next window.  Your browser must have popups enabled."	
				document.getElementById("StartMsgD").style.display="block"
				LogError();			
				HttpSend("commandcomm.aspx?rev=1.20&command=ENDSESSION")
			}
			else newwindow.focus()
			
			document.getElementById('StartGeoButton').style.color = 'silver'	
			document.getElementById('VisitGeoButton').style.color = 'silver'	
		}
		
			
		function dp() {	
			location.replace("dp.aspx?rev=1.20")
			if (!is_mac) document.getElementById('BodyTag').style.cursor = 'default'
		}
		
		function LogError()
		{							
			HttpSend("commandcomm.aspx?rev=1.20&command=LOGERROR&errormsg="+document.getElementById("StartMsgD").innerHTML)	
		}

		function CancelSession()
		{			
			if (!is_IE && !is_nav && !is_safari) return; 
			HttpSend("commandcomm.aspx?rev=1.20&command=ENDSESSION")
		}

		function HttpSend(sendstr)
		{		
			var objHttp=null
			if (window.ActiveXObject) {
				objHttp = new ActiveXObject("Microsoft.XMLHTTP")
				objHttp.Open('GET',sendstr,true)
				objHttp.Send()
			}
			else if (window.XMLHttpRequest) {		
				objHttp = new XMLHttpRequest();
				objHttp.open('GET',sendstr,true)
				objHttp.send(null)
			}
				
	//		return objHttp.responseText
		}



