var ajax;
var ajax2;

var sPage = "Home";

function init(){
	loadHome();
}

function initAjax(){
  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 && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
	  xmlhttp.overrideMimeType("text/xml");
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

function initAjaxOld(){
	var objXMLHttp=null
	if (window.XMLHttpRequest)
		{
		objXMLHttp=new XMLHttpRequest()
		}
	else if (window.ActiveXObject)
		{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
	return objXMLHttp
}

function checkReadyState(obj){if(obj.readyState == 4){if(obj.status == 200){return true;}else{alert("Problem retrieving XML data");}}}
function buildLoadingScreen(sText){return "<table align=center><tr><td align=center class=loadingText>" + sText + "</td></tr><tr><td align=center><img src=images/loaderBar.gif></td></tr></table>"}
function makeModalScreen(divName){
	document.getElementById("modalBackground").style.height = parseInt(document.documentElement.scrollHeight) + "px";
	document.getElementById("modalBackground").style.width = parseInt(document.documentElement.scrollWidth) + "px";
	document.getElementById("modalBackground").style.display="block";
	
	document.getElementById(divName).style.left = getMidWidth() - parseInt(parseInt(document.getElementById(divName).style.width)/2) + "px";
	document.getElementById(divName).style.top = getMidHeight() - 100 + "px";
	
	document.getElementById(divName).style.display="block";
}

function clearModal(divName){document.getElementById(divName).style.display="none";document.getElementById("modalBackground").style.display="none";}
function getMidHeight(){return parseInt(parseInt(document.documentElement.scrollHeight)/2);}
function getMidWidth(){return parseInt(parseInt(document.documentElement.scrollWidth)/2);}
function isEven (num){if(num % 2 == 0){return num;}} 
function buildLoadingScreen(sText){return "<table align=center><tr><td align=center class=loadingText>" + sText + "</td></tr><tr><td align=center><img src=images/loaderBar.gif></td></tr></table>"}

/****************************************************/
function checkForNull(sVal){
	if(sVal == null || sVal == 'null' || sVal == 'NULL')
		return "";
	else 
		return sVal;
}

/**************************************************/
function isInteger(s){
	var i;

	if (isEmpty(s))
	if (isInteger.arguments.length == 1) return 0;
	else return (isInteger.arguments[1] == true);

	for (i = 0; i < s.length; i++){
		 var c = s.charAt(i);
		 if (!isDigit(c)) return false;
	}

	return true;
}

/**************************************************/
function isEmpty(s){
	return ((s == null) || (s.length == 0))
}

/**************************************************/
function isDigit(c){
	return ((c >= "0") && (c <= "9"))
}

/*************************************************/
function isEven(num){
	if(num % 2 == 0)
		return true;
	else
		return false;
} 

/************************************************/
function checkUncheckAll(theElement){
	var theForm = theElement.form, z = 0;
	for(z=0; z<theForm.length;z++){
		if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall')
			theForm[z].checked = theElement.checked;
	}
}

/************************************************/
function returnDateTime(sVal){
	if(sVal != ""){

		sYear = sVal.substring(0,4)
		sMonth = sVal.substring(5,7)
		sDay = sVal.substring(8,10)
		sTime = sVal.substring(11,19)

		return sMonth + "/" + sDay + "/" + sYear + " " + sTime
	}else
		return "";
}

//*******************************************************//
function addToCart(desc, item, amount){
	document.forms["paypalForm"].elements["item_name"].value = desc;
	document.forms["paypalForm"].elements["item_number"].value = item;
	document.forms["paypalForm"].elements["amount"].value = amount;
	document.forms["paypalForm"].submit();
	
	clearModal('divPopUp');
}

//*******************************************************//
function cancelBuy(){
	clearModal("divPopUp")
}



