//<!--usedvwaudi.com changed to govwaudi.com on 15 Nov 2007 by Drew LeSueur -->
var whoyouare
var towho
var req
var sendreq
var getreq
function sendeml() 
{
	if (window.XMLHttpRequest) {
	//alert('No funciona todavia este parte del sitio .')
		req = new XMLHttpRequest()
			
	}//end safari or mozilla
	else {
		if (window.ActiveXObject) {
		//alert('No funciona todavia este parte del sitio .')
			var typess = ['Microsoft.XMLHTTP','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];
			for (i=1;i<typess.length;i++){
				try {
				req = new ActiveXObject(typess[i]);
				}
				catch(e){
				//alert (i)
				}
			
			}//end for
		}//end if
	}//end else

if (req){
//alert('Thank You')
req.onreadystatechange = doeventt;
req.open("GET","message.asp?eml=drewalex@gmail.com&mess=" + escape(document.getElementById('Message1').value))
req.send("")
}//end req
else{
//alert('Ajax did not work correctly')
}


} //end function sendeml()
	

function doeventt(){
	if (req.readyState && req.readyState == 4) { //if (req.readyState==4) {
		if (req.status == 200) {
		alert(req.responseText)
		}//end if 200
		else {
		 //alert("There was a problem retrieving the XML data:\n" + req.statusText)
		}		
	}//

}//end function doeventt


//-----------------------------------------------------------------------------------------------------------------

function ajaxsend(theurl,theevent) 
{
	if (window.XMLHttpRequest) {
	//alert('No funciona todavia este parte del sitio .')
		sendreq = new XMLHttpRequest()
			
	}//end safari or mozilla
	else {
		if (window.ActiveXObject) {
		//alert('No funciona todavia este parte del sitio .')
			var typess = ['Microsoft.XMLHTTP','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];
			for (i=1;i<typess.length;i++){
				try {
				sendreq = new ActiveXObject(typess[i]);
				}
				catch(e){
				//alert (i)
				}
			
			}//end for
		}//end if
	}//end else

if (sendreq){
//alert('Thank You')//////////
sendreq.onreadystatechange = theevent;

//try {//
sendreq.open("GET", "http://www.govwaudi.com/chat/" + theurl)
sendreq.send("")
//}//
//catch(eee) {//
//alert(eee.description)//
//}//

}//end req
else{
//alert('Ajax did not work correctly')
}
} //end function sendeml()
	
	
	
	
	function ajaxget(theurl,theevent) 
{
	if (window.XMLHttpRequest) {
	//alert('No funciona todavia este parte del sitio .')
		getreq = new XMLHttpRequest()
			
	}//end safari or mozilla
	else {
		if (window.ActiveXObject) {
		//alert('No funciona todavia este parte del sitio .')
			var typess = ['Microsoft.XMLHTTP','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];
			for (i=1;i<typess.length;i++){
				try {
				getreq = new ActiveXObject(typess[i]);
				}
				catch(e){
				//alert (i)
				}
			
			}//end for
		}//end if
	}//end else

if (getreq){
//alert('Thank Youget')//////
getreq.onreadystatechange = theevent;
//alert("http://www.govwaudi.com/chat/" + theurl)
getreq.open("GET", "http://www.govwaudi.com/chat/" + theurl)
getreq.send("")
}//end req
else{
//alert('Ajax did not work correctly')
}
} //end function sendeml()
	
	
	
	

function doeventt2(){
	if (sendreq.readyState==4) {
		if (sendreq.status == 200) {
		
				document.getElementById('mess').disabled=false
				document.getElementById('mess').value = ''
				document.getElementById('mess').focus()	
 			
		//alert("you should be able to write now")
		}//end if 200
		else {
		 //alert("Ajax2: There was a problem retrieving the XML data:\n" + sendreq.statusText)
		}		
	}//
	//else {
	//alert(sendreq.readyState)
	//}
}//end function doeventt





function thegetdoevent(userid,touserid) {

	if (getreq.readyState==4) {
		
		if (getreq.status == 200) {

var d = new Date()
var t
var resp

resp = getreq.responseText
resp = resp.substring(12,resp.length - 27)

t = resp.substring(resp.lastIndexOf('oldtime=') + 'oldtime='.length,resp.lastIndexOf('x'))
resp = resp.substring(0,resp.lastIndexOf('oldtime='))

if (resp != '') {
document.getElementById('chat').innerHTML += resp //+ '\n' //+ 'time  ' + t
//if (resp != '') document.getElementById('chat').innerHTML += resp  //+ 'time  ' + t
document.getElementById('chat').scrollTop = document.getElementById('chat').scrollHeight
}
//document.getElementById('mess').focus() 
				//alert("every 5 seconds")
 			getajax(userid,t,touserid)
		//alert("you should be able to write now")
		}//end if 200
		else {		
		 //alert("getting data: There was a problem retrieving the XML data:\n" + getreq.statusText)
		 getajax(userid,t,touserid)
		}		
	}//

} //end the get do event




//------------------------------------------------------------------------------------
function keydownn(e)
{
//if (document.getElementById('mess').disbled == true){
var keynum
//var keychar
var numcheck
if(window.event) // IE
{
keynum = e.keyCode
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which
}
//keychar = String.fromCharCode(keynum)
if (keynum == 13) {
//ajax("send.asp")

//-------------------------------------
var whatsent = document.getElementById('mess').value.replace(/'/g,"''")
whatsent = whatsent.replace(/\\/g, "\\\\")
//alert(whatsent + "   " + escape(whatsent)) //take this out
sendthestuff(whoyouare,towho, escape(whatsent)) //-----------------------------------look down
//4-27-07 i am adding the   .replace(/\//g, "\/\/") i aslo added new variable


}//end if 13

//document.getElementById('chat').value += keynum + "      " + keychar
//}
}


function ifbuttonsendispressed(){
var whatsent = document.getElementById('mess').value.replace(/'/g,"''")
whatsent = whatsent.replace(/\\/g, "\\\\")
sendthestuff(whoyouare,towho, escape(whatsent)) //-------------------------------------look up
}


function sendthestuff(from,to,message) {


//alert("send.asp?f=" + from + "&t=" + to + "&m=" + message)
//alert("making the textbnox disabled.....")
var d = new Date()
var t = d.getTime()
document.getElementById('mess').disabled=true
//thereplace to fix the ' error (the error with the apostrophe
//do you need the escape? 4-23/07
ajaxsend("send.asp?f=" + from + "&t=" + to + "&m=" + message + "&c=" + t, doeventt2)  // this has to go after the disabling of text box because ajax is so fast that it will get an asnwer and enable it before it goes disabled and then is will disable it for the first time!!
//document.getElementById('chat').value ="http://colormelon.com/send.asp?f=" + from + "&t=" + to + "&m=" + message
} //end function sendthestuff()


function ajaxstatus() {
document.getElementById('status').value = sendreq.readyState + "   " + sendreq.status
} //end function ajaxstatus()


function getajax(userid,theoldtime,touserid) {
whoyouare = userid  //this function should be called getajax and identify yourself
towho = touserid
var d = new Date()
var t = d.getTime() //used no not produce any repeat urls maybe dont send t and see if it works
var pol = setTimeout(function(){ajaxget('get.asp?u=' + userid + '&tt=' + touserid + '&o=' + theoldtime + '&g=' + t,function() {thegetdoevent(userid,touserid)})},500) //think this through
//var pol = setTimeout(function(){ajax("get.asp?u=" + userid + "&h=" + thetime, deltethis),500) //think this through
//var pol = (setTimeout("deletethis()",3000))
}

function deletethis() {
alert("hi")
getajax("hi",3000)
}
