/* Ajax functions */

function AJAXInteraction(div,url, callback, currID) {
    var req = init();

req.onreadystatechange = processRequest;

function init() {

      if (window.XMLHttpRequest) {

        return new XMLHttpRequest();

      } else if (window.ActiveXObject) {

        return new ActiveXObject("Microsoft.XMLHTTP");

      }

    }



function processRequest (currID) {
if (req.readyState == 4 && (req.status==200 || window.location.href.indexOf("http")==-1)){
          if (callback) {
            if(document.getElementById(div) != null) {
            	  callback(document.getElementById(div).innerHTML=req.responseText);

            	  if(div=="overlaybox")
									overlayopen(url,"overlaycontentsDIV","blackoverlay");
            }

            }
		}}



this.doGet = function() {

if(url.indexOf("thankyou_friend.php")>=0)
{
	var yname=document.tellfriend.your_name.value;
	var yemail=document.tellfriend.your_email.value;
	var fname=document.tellfriend.friend_name.value;
	var femail = document.tellfriend.friend_email.value;
	var message = document.tellfriend.message.value;
		
  req.open("GET", url+"&your_name="+yname+"&your_email="+yemail+"&friend_name="+fname+"&friend_email="+femail+"&message="+message, true);
}
else{
	    req.open("GET", url, true);
	  }
      req.send(null);
    }

this.doPost = function(body) {

      req.open("POST", url, true);

      req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

      req.send(body);

    }

}

function makeRequest(url,div,currId) {
	
	if(url.indexOf("thankyou_friend")==-1)
	{
		document.getElementById(div).innerHTML="<div><img src='common/images/generic/b4formloading.gif' /></div>";
	}
	//url=url+"&rnd="+Math.random();

if(arguments.length==3)
{
	var ai = new AJAXInteraction(div,url, function() { },currId);
}
else
{
	var ai = new AJAXInteraction(div,url, function() { });
}
  ai.doGet();
}

/* Ajax functions */