function loadXMLDoc(url,strResultFunc,sParam) 
{
	var xmlHttpReq = null;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();
		//xmlHttpReq.overrideMimeType('text/xml');
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");

    }
	
	// add random number to the url, to prevent IE caching like a mofo
	//url = addURLParam( url, "random", Math.random() );
	
	xmlHttpReq.onreadystatechange = function() {
             if (xmlHttpReq.readyState == 4) {
           strResponse = xmlHttpReq.responseText;
           switch (xmlHttpReq.status) {
                   // Page-not-found error
                   case 404:
                           alert('Error: Not Found. The requested URL ' + 
                                   url + ' could not be found.');
                           break;
                   // Display results in a full window for server-side errors
                   case 500:
                           log(strResponse);
                           break;
                   default:
                           // Call JS alert for custom error or debug messages
                           if (strResponse.indexOf('Error:') > -1 || 
                                   strResponse.indexOf('Debug:') > -1) {
                                   log(strResponse);
                           }
                           // Call the desired result function
                           else {
						   			 eval(strResultFunc + '(strResponse,sParam);');
                           }
                           break;
           }
	  }
   	}
	xmlHttpReq.open("GET", url, true);
    xmlHttpReq.send(null);
}


function addURLParam( sURL, sParam, sValue ) {
	if( sURL.indexOf( "?" ) ) {
		sURL = sURL + "&" + sParam + "=" + sValue;
	} else {
		sURL = sURL + "?" + sParam + "=" + sValue;
	}	
	return sURL
}

function xmlHttpPost(strURL, strResultFunc, strSubmit, sParam) {

       var xmlHttpReq = false;
       
       // Mozilla/Safari
       if (window.XMLHttpRequest) {
               xmlHttpReq = new XMLHttpRequest();
               //xmlHttpReq.overrideMimeType('text/xml');
       }
       // IE
       else if (window.ActiveXObject) {
               xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
       }
	
	// add a random number to get round IE caching like a mofo
	//strURL = addURLParam( strURL, "r", Math.random() );
	
	xmlHttpReq.open('POST', strURL, true);
       xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
       xmlHttpReq.onreadystatechange = function() {
              if (xmlHttpReq.readyState == 4) {
	           strResponse = xmlHttpReq.responseText;
	           switch (xmlHttpReq.status) {
	                   // Page-not-found error
	                   case 404:
	                           alert('Error: Not Found. The requested URL ' + 
	                                   strURL + ' could not be found.');
	                           break;
	                   // Display results in a full window for server-side errors
	                   case 500:
	                           log(strResponse);
	                           break;
	                   default:
	                           // Call JS alert for custom error or debug messages
	                           if (strResponse.indexOf('Error:') > -1 || 
	                                   strResponse.indexOf('Debug:') > -1) {
	                                   alert(strResponse);
	                           }
	                           // Call the desired result function
	                           else {
							   			//alert(strResponse);
										var sJSString = strResultFunc + "(strResponse, '" + sParam + "')";
							   			 eval(sJSString);
	                           }
	                           break;
	           }
	   }
       }
	   
	   //log( strURL + strSubmit );
       xmlHttpReq.send(strSubmit);
}

function formToQueryString(objFrm, bFriendlyURLs){
	var arElems = objFrm.elements;
	var sQString = "";
	
	for( var i = 0; i < arElems.length; i++ ){
		if( bFriendlyURLs ){
			sQString += "/" + arElems[i].name + "/" + escape(arElems[i].value);
		} else {
			sQString += "&" + arElems[i].name + "=" + escape(arElems[i].value);
		}
	}
	
	return sQString;
}