
function trim(inputString)
{
	inputString=inputString.replace(/^\s+/g,"");
	inputString=inputString.replace(/\s+$/g,"");
	return inputString;
}

var xmlHttp

function showResultData(str,psotert)
{  
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		 alert ("Browser does not support HTTP Request");
    }
	
	var url="http://www.cherrygirls.co.uk/fcgphp/message-escorts_agency_new.php"
	url = url+"?id="+str+"&"+psotert;
	
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	  document.getElementById("send_message_id").innerHTML=xmlHttp.responseText;
	  document.getElementById("send_message_id").style.display="block";
	  /*
	  w = window.screen.width-20;
	  h = window.screen.height;
	  tl = window.screen.width-300;
	  l = (tl/2);
	  t = (window.screen.height-500)/2;
	  document.getElementById('send_message_id').style.position = "absolute";
	  document.getElementById('send_message_id').style.width = w + 'px';
	  document.getElementById('send_message_id').style.height = h + 'px';
	  document.getElementById('send_message_id').style.left = '0px';
	  document.getElementById('send_message_id').style.top = t + 'px';
	  */
	  
	}
	
}

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;
}


function check2()
{
	if(trim(document.agency_sendfrm.name.value)=="")
	{
		alert("Please enter your name");
		document.agency_sendfrm.name.focus();
		return false
	}
	
	
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,5})+$/.test(document.agency_sendfrm.email.value))
	{
		//return (true)
	}
	else{
		alert("Invalid E-mail Address! Please re-enter.")
		document.agency_sendfrm.email.focus();
		return (false);

	}
	
	if(trim(document.agency_sendfrm.subject.value)=="")
	{
		alert("Please enter your subject");
		document.agency_sendfrm.subject.focus();
		return false
	}
	
	if(trim(document.agency_sendfrm.message.value)=="")
	{
		alert("Please enter your message");
		document.agency_sendfrm.message.focus();
		return false
	}
	
	if(document.agency_sendfrm.security_code.value == "Enter above security code" || trim(document.agency_sendfrm.security_code.value)=="")
	{
		alert("Please enter security code");
		document.agency_sendfrm.security_code.select();
		return false
	}
        var ids = document.getElementById("agnecy_id").value;

        var poststr = "name=" + encodeURI( document.getElementById("name").value );
		poststr = poststr + "&email=" + encodeURI( document.getElementById("email").value );
		poststr = poststr + "&subject=" + encodeURI( document.getElementById("subject").value );
	    poststr = poststr + "&message=" + encodeURI( document.getElementById("message").value );
		poststr = poststr + "&security_code=" + encodeURI( document.getElementById("security_code").value );
		poststr = poststr + "&agnecy_id=" + encodeURI( document.getElementById("agnecy_id").value );
		poststr = poststr + "&send_from=" + encodeURI( document.getElementById("send_from").value );
		showResultData(ids,poststr);
			
			

}

function hide_me()
{
 document.getElementById("send_message_id").style.display="none";
}

function showResultLuckdip(str)
{  
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		 alert ("Browser does not support HTTP Request");
    }
	
	var url="http://www.cherrygirls.co.uk/fcgphp/cherry_lucky_dip.php"
	url = url+"?id="+str;
	
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateOutput 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateOutput() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	  document.getElementById("onload_dispaly_id").style.display="none";
	  document.getElementById("ajx_cherry_div").innerHTML=xmlHttp.responseText;
	 	  
	}
	
}


function showResultNewJoke(str)
{  
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		 alert ("Browser does not support HTTP Request");
    }
	
	var url="http://www.cherrygirls.co.uk/fcgphp/cherry_new_joke.php"
	url = url+"?id="+str;
	
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateOutputJoke 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateOutputJoke() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	  document.getElementById("onload_display_joke_id").style.display="none";
	  document.getElementById("ajax_joke_id").innerHTML=xmlHttp.responseText;
	 	  
	}
	
}


