var xmlhttp=false;
var vInterval=5000
var t=0;
var t0=""
var t4=""
var ot4=""
var vHold="";
var c=0;
var fName=""
var vPC=0
var vBulk=""
var vLast=""
var vFont="Yellow"
var vT0="";
var msg1="";
var txtFile="";
var xmlhttp=""; 
var vxmlhttpType="";

//document.all.S3.Style.Add("background-image", "url(http://www.desktopstarships.com/AbstractsGallery/Ab_1.html";vPl[vPc]="images/ab_yes_mistressz.jpg)");
//txtSearch.Attributes.Add("onclick", "this.style.background-image: url(Images/blank.jpg)");  - this is not JavaScript. You've applied CSS to onclick attribute, which expects JavaScript. Make following changes: txtSearch.Attributes.Add("onclick", "this.style.backgroundImage = 'url(Images/blank.jpg)';");

//t=setInterval("fCommunicate()",5000)     

	var t="";
	t=setInterval("tnext()",3000)



    try { xmlhttp = new XMLHttpRequest(); vxmlhttpType=1;    }
    catch (e)     {
        try { xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); vxmlhttpType=2;  }
        catch (e2)         {
          try {   xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); vxmlhttpType=3  }
          catch (e3) {  xmlhttp = false;   }
        }
     }


function tnext() {

//alert("Testing site, please wait 10 minutes....");



	if (vT0.toUpperCase()!=document.all.T0.value.toUpperCase()) {
		document.all.S1.value=""
		document.all.T1.value=0
		vPC=0
		vBulk=""
		vT0=document.all.T0.value		
	}
	

	
	t0=document.all.T0.value;
	
	vPC=document.all.T1.value;
	
	clearTimeout(t);

	t=setInterval("tnext()",vInterval)
	
	
	
	if (t0 !="") {
	


		txtFile = xmlhttp;	

		//http://www.411Chat.com
		
		fName="/Chat/" + document.all.T0.value + vPC + ".txt";		
		

		
		document.all.T2.value="Attempting to connect...."
		
		document.all.T3.value=vInterval
		
	
		
		txtFile.open("GET", fName,true);
		
		//alert("Congratulations, your device works with 411Chat.com!")



		txtFile.onreadystatechange = function() {
		
		
  if (txtFile.readyState===4) {  // Makes sure the document is ready to parse.
  
			document.all.T2.value=txtFile.status

			
			
  	if (txtFile.status ===200) {
				ot4=t4
				
				vHold=txtFile.responseText;
				if (vHold.length>-1) {
					//alert(vHold)
				}
				if (vHold.toUpperCase().indexOf("VF=")>-1) {
					vHold=vHold.slice(0,vHold.toUpperCase().indexOf("VF=")) + vHold.slice(vHold.toUpperCase().indexOf("VF=")+3)
				}
	
				
				if (vHold.toUpperCase().indexOf("|")>-1) {
					vHold=vHold.slice(vHold.toUpperCase().indexOf("|")+1,vHold.length-2) + " - " + vHold.slice(1,vHold.toUpperCase().indexOf("]"))
				}				
				
				c=document.all.T1.value;
				c=eval(c)+1;				
				document.all.T1.value=c;
				vPC=document.all.T1.value				
				clearTimeout(t);
				
				
				if (vLast==vHold){
					t=setInterval("tnext()",vInterval)
					document.all.T3.value=vInterval;
					return;
				} else {				

					vLast=vHold
					vBulk=vHold + "\n" + vBulk

					if (vBulk.length>1000) {
						vBulk=vBulk.slice(0,1000)
					}				
					document.all.S1.value=vBulk													
					t=setInterval("tnext()",500)
					document.all.T3.value="500";
					dMsg.innerText="Loading"
				}
				
		}  else if (dMsg.innerText.length>0) {
		dMsg.innerText=""
	}
  }
}
	txtFile.send(null);
}	

}

function fsend(){
	dMsg.innerText=""
	var t5="";
	t0=document.all.T0.value; // meeting place
	t5=document.all.T4.value; // name
	t3=document.all.T3.value.length
	var vMsg=""
	
	//document.all.T47.value="Ready #1"
	if (document.all.T4.value.length<1){
		vMsg="Nothing to send!" + "\n"
	}
	
	if (document.all.TName.value.length<1){
		vMsg="Your name is missing!" + "\n"		
	}	
	
	if (vMsg!="") {
		alert(vMsg)
		vMsg="";
		return;
	}

				clearTimeout(t);
				//t=setTimeout("tnext()",vInterval);
				t=setInterval("tnext()",vInterval)
				str=document.all.TName.value;
				document.all.TName.value=str.replace(/\n/,"");
				
				str=document.all.TName.value;
				document.all.TName.value=str.replace(/#/,"");
				
				str=document.all.TName.value;
				document.all.TName.value=str.replace(/</,"");
				
				str=document.all.TName.value;
				document.all.TName.value=str.replace(/>/,"");
				
				str=document.all.TName.value;				
				document.all.TName.value=str.replace(/=/,"");
				
				//str=document.all.TName.value;				
				//document.all.TName.value=str.replace(/+/,"");
				
				str=document.all.TName.value;								
				document.all.TName.value=str.replace(/%/,"");
				
				str=document.all.TName.value;				
				document.all.TName.value=str.replace(/@/,"");
				
				str=document.all.TName.value;
				document.all.TName.value=str.replace(/&/,"");
				
				str=document.all.TName.value;
				document.all.TName.value=str.replace(/$/,"");

	t0=document.all.T0.value;	

				str=document.all.T0.value;				
				document.all.T0.value=str.replace(/\n/,"");
				
				str=document.all.T0.value;
				document.all.T0.value=str.replace(/#/,"");
				
				str=document.all.T0.value;
				document.all.T0.value=str.replace(/</,"");
				
				str=document.all.T0.value;
				document.all.T0.value=str.replace(/>/,"");
				
				str=document.all.T0.value;
				document.all.T0.value=str.replace(/=/,"");
				
				//str=document.all.T0.value;
				//document.all.T0.value=str.replace(/+/,"");
				
				//str=document.all.T0.value;
				//document.all.T0.value=str.replace(/*/,"");
				
				str=document.all.T0.value;
				document.all.T0.value=str.replace(/%/,"");
				
				str=document.all.T0.value;
				document.all.T0.value=str.replace(/@/,"");
				
				str=document.all.T0.value;
				document.all.T0.value=str.replace(/&/,"");
				
				str=document.all.T0.value;
				document.all.T0.value=str.replace(/$/,"");
				

	if (t0 !="") {	
		if (t5 !=""){
			if (t3 >0){
				//document.all.C1.style.background="#ECECD9"
				//var txtMsg = new XMLHttpRequest();
				

				str=document.all.T4.value;								
				document.all.T4.value=str.replace(/\n/g,"~n~");
				
				str=document.all.T4.value;				
				document.all.T4.value=str.replace(/&/g,"~u~");
								
				str=document.all.T4.value;
				document.all.T4.value=str.replace(/#/g,"~p~");

				str=document.all.T4.value;
				document.all.T4.value=str.replace(/</g,"~1~");

				str=document.all.T4.value;
				document.all.T4.value=str.replace(/>/g,"~r~");

				str=document.all.T4.value;
				
				document.all.T4.value=str.replace(/=/g,"~e~");	
				// D=page number
				// P= password
				

				


				msg1="http://www.411Chat.com/asp/ReadLong.asp?R=" + document.all.T0.value + "&D=" + document.all.T1.value + "&P=" + '' + "&C=" + document.all.TName.value + "&F=" + '' + "&M=" + document.all.T4.value
				txtMsg.open("GET", msg1, true);
				txtMsg.send(null);	
				document.all.T4.value="";				
				clearTimeout(t);
				t=setInterval("tnext()",500)
			}
			
		}
	}
}










function fTimer(){
	vInterval=document.all.D1.value
}

function fCI(){
	beep
}


document.all.T47.value="Browser not supported!"



t=setInterval("tnext()",3000)

document.all.T47.value="Ready"


dMsg.innerHTML=""

/*
//alert("Congratulations, your device works with 411Chat.com!")
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
document.write("Browser name: "+ browser);
document.write("<br>" + "Browser version: "+ version + "<br>");
if (browser.toUpperCase()=="OBIGO") {
document.write ("Sprint<BR>");
document.write ("Mobile<BR>")
} else if (browser.toUpperCase()=="OPERA") {
document.write ("Mobile<BR>");

}
*/

TName.focus();
