// JavaScript Document

function switchInputs(el1,el2) {
	if (el1.value == "_switch") {
		el2.style.display = "inline";
		el1.style.display = "none";
		el2.focus();
	}
}

//returns strParamName's value if it exists in the current URL
function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
	strQueryString = strQueryString.replace("#","");
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if ( aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
}

function toggleVisibility(elId) {
	var el = document.getElementById(elId);
	if (el.style.display == "none") el.style.display = "";
	else el.style.display = "none";
	document.body.focus();
}

/* ----- AJAX RELATED FUNCTIONS ----- */
function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

var http = createRequestObject(); 
