/* Basic Functions */
function TrimF(jsStrVar)
{
   while(jsStrVar != jsStrVar.replace(" ",""))jsStrVar = jsStrVar.replace(" ","");
   return jsStrVar;
}

/* AJAX Functions */
function createRequestObject() {
   //The PHP's no-cache header must be present to avoid the caching-related errors...
   var obj;

   if(window.XMLHttpRequest){ 
      // Firefox, Safari, Opera...
      obj = new XMLHttpRequest();
   } else if(window.ActiveXObject) {
      // Internet Explorer 5+...
      obj = new ActiveXObject("Microsoft.XMLHTTP");
   } else {
      // There is an error creating the object, just as an old browser is being used...
      //alert('Problem creating the XMLHttpRequest object');
   }
   return obj;
}
function errorNotifyByEmail(msg, url, linenumber) {
	// Block sending of any further emails if javascript errors is in infinite loop while web events or browser is running...
	if (maxJsErrorEmailCount < 10) {
		var http = createRequestObject();  //Make the XMLHttpRequest object...

		/* 06/12/2006 - Discontinued and is replaced below... */
		/*
       var httpStr = url.substring(0,7);
		 if (httpStr == "http://") { httpStr = "http"; } 
       else if (httpStr == "https:/") { httpStr = "https"; } 
       else { httpStr = "http"; }
		*/ 

		/* httpPort variable exist from the parent's web page... */
		if (httpPort == "80") {
			httpPort = "http";
		} else if (httpPort == "443") {
			httpPort = "https";
		} else {
			httpPort = "http";
		}

      /* alert(window.location.protocol);  //Another option to use ports... */

		/* Do the conversion to a code-name and convert it back in php via javascript_error.php... */
		httpQueryStr = httpQueryStr.replace(/&/g,"**ampersand**");
		httpQueryStr = httpQueryStr.replace(/=/g,"**equal**");

		/* httpHost & httpUrlFile variable exist from the parent's web page... */
		// Open PHP script for requests...
		http.open("get", httpPort+"://"+httpHost+"/javascript_error.php?httpWebFile="+httpWebFile+"&httpQueryStr="+httpQueryStr+"&Url="+url+"&Line="+linenumber+"&Msg="+msg);
		http.send(null);
		maxJsErrorEmailCount++;
		http = null;
	}

	return true;
}

/* General Functions */
function noUglySelection_link(x) {
   x.blur();
}

