var xmlHttp

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}


function gorequest(id)
{
	if (isIE == "yes")  {		
	
		var theirname = document.getElementById('yourname').value;
		var msg = document.getElementById('theirmessage').value;
	}
	
	else { 

		var theirnamecookie=getCookie('requestname');
		
		if (theirnamecookie != null && theirnamecookie != "") {var theirname = theirnamecookie}
		else {var theirname = prompt("Please enter your name:", "");}
	
		var msg = prompt("Would you like to send a message with your request?") 

	}

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
  
var url="sendrequest.php"
url=url+"?id="+id
url=url+"&whatson="+whatson
url=url+"&isIE="+isIE
url=url+"&msg="+msg
url=url+"&theirname="+theirname
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 

 	//IE sucks so just alert the response
 	if (isIE == "yes" || whatson == "shuffle")  {	
		alert(xmlHttp.responseText);
	}
	
	//If it's not IE do it the cool way
	else {
 
  	response = xmlHttp.responseText;	
	
	requeststatus = response.substr(0,1);

	// "myrequests" is the inner div that contains the actual list of requests
	myrequests = document.getElementById("myrequests");
	
	// "myrequestsdiv" is the whole div including the header
	myrequestsdiv = document.getElementById("myrequestsdiv");
	myrequestsdiv.style.opacity = 0;
	myrequestsdiv.style.display = "";
	opacity('myrequestsdiv', 0, 100, 700);
	
	
	// if they have a my request box and the request was accepted, do the scrolly thing
	if (myrequests && requeststatus==1) {
			
			currenthtml = myrequests.innerHTML;
			
			htmlresponse = response.substr(response.indexOf('<'));
			
			ID = response.substr(response.indexOf('"req') + 4);
			ID = ID.substr(0,ID.indexOf('"'));
			
			myrequests.innerHTML = htmlresponse + currenthtml;
			
			ts_initScroll();
		
			setTimeout("opacity('req" + ID + "', 0, 100, 700);",2000);	
				
	}
		
	//else if the request was accepted but they dont have a box, alert the positive response
	else if (requeststatus==1) {			
			
			plainresponse = response.substr(2,response.indexOf('<') -3);
			alert(plainresponse);				
					
	}
	
	//else alert the response (which will be an error)
	else {	alert(response); }


//end if not IE
}


 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
