// load the appropriate xmlHttpRequest for IE or Mozilla 
// this sniffer code can be found at 
// http://jibbering.com/2002/4/httprequest.html 

var xmlHttp 

/*@cc_on @*/ 
/*@if (@_jscript_version >= 5) 
  try { 
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP") 
} catch (e) { 
  try { 
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP") 
  } catch (E) { 
   xmlHttp=false 
  } 
} 
@else 
xmlHttp=false 
@end @*/ 
if (!xmlHttp) { 
try { 
  xmlHttp = new XMLHttpRequest(); 
} 
catch (e) { 
  xmlHttp=false 
} 
} 

// end jibbering.com code 


// the php script to process the form.  var must be global! 

var URLto = 'index.php'; 

// function to build POST requests 
function buildPOST(theFormName) { 
    theForm = document.forms[theFormName]; 
    var qs = '' 
    for (e=0;e<theForm.elements.length;e++) { 
        if (theForm.elements[e].name!='') { 
            var name = theForm.elements[e].name; 
            qs+=(qs=='')?'':'&' 
            qs+= name+'='+escape(theForm.elements[e].value); 
        } 
    } 
    qs+="\n"; 
    return qs 
} 

// function to communicate with remote script 
function send_post(theFormName, theURL) { 
	URLto = theURL;
    var xmlMessage = buildPOST(theFormName); 
    xmlHttp.open("POST", URLto, false) ;
         
    // for ie compatability 
    xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded') ;
    //xmlHttp.setRequestHeader("Content-Type","text/xml") ;
    //xmlHttp.setRequestHeader("Last-Modified");
    //alert(xmlMessage);
    xmlHttp.send(xmlMessage) 
} 

function display_response(responseContainer) { 
    var optionDiv = document.getElementById(responseContainer); 
    optionDiv.innerHTML = xmlHttp.responseText; 
}