var xmlHttp

function doSendJoke()
{ 
if (
document.forms.sendform.youremail.value == "" ||
document.forms.sendform.friendemail.value == "" ||
document.forms.sendform.friendname.value == "" ||
document.forms.sendform.jokeid.value == "" 
)

{
document.getElementById('formerror2').style.display="inline";
}
else
{

var strfriendemail = document.forms.sendform.friendemail.value;
var strfriendname = document.forms.sendform.friendname.value;
var strfriendmessage = document.forms.sendform.friendmessage.value;
var stryouremail = document.forms.sendform.youremail.value;
var stryourname = document.forms.sendform.yourname.value;
var strjokeid  = document.forms.sendform.jokeid.value;
var struser  = document.forms.sendform.user.value;
//alert (strcategory);


  //alert ("doSubmitJoke initiated!");
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser must support AJAX to use this feature!");
  return;
  } 
var url="dosendtoafriend.asp";
url=url+"?youremail="+ encodeURIComponent(stryouremail);
url=url+"&yourname="+ encodeURIComponent(stryourname);
url=url+"&friendemail="+ encodeURIComponent(strfriendemail);
url=url+"&friendname="+ encodeURIComponent(strfriendname);
url=url+"&friendmessage="+ encodeURIComponent(strfriendmessage);
url=url+"&jokeid="+strjokeid;
url=url+"&user="+struser;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
}

function stateChanged()
{ 
if (xmlHttp.readyState==4)
{ 
  //alert ("Good!");

document.getElementById("sendresponse").innerHTML=xmlHttp.responseText;
dofadeout("sendcontainer");
document.forms.sendform.friendemail.value = ""
document.forms.sendform.friendname.value = "" 
document.forms.sendform.friendmessage.value = ""
document.forms.sendform.youremail.value = ""
document.forms.sendform.yourname.value = ""

}
if (xmlHttp.readyState==0){
  document.getElementById("sendresponse").innerHTML="Sorry, an error occured!";
}
}

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;
}
