function chkPrice(){
	val=item_price.innerHTML;
	if(item_price.innerHTML.substring(0,4)=="Call"){
		qty.innerHTML="";
		buy_btn.innerHTML="";
	}
}

function chkDesc(){
	Cstatus=(description.innerText=="");
	if(Cstatus==true){content_head.innerHTML="";}}

function chkUpgrade(){
	Cstatus=(upgrade.innerText=="");
	if(Cstatus==true){upgrade.innerHTML="<tr><td>None</td></tr>";}
}
function preprocess(iWishList){ 
	var retval, iItemqty, iTotalqty;
	for (count=0;count<document.forms.length;count++){
		if (document.forms[count].name=="frmRelated"){
			var sItemList="";
			for(index=0;index<(document.frmRelated.elements.length);index++) {
				if(document.frmRelated.elements[index].checked){
					sItemList+=document.frmRelated.elements[index].value + "," ;
					iItemqty++;
				}
			}
			sItemList = sItemList.substring(0,sItemList.length-1)
			document.frmAdd.chkItems.value = sItemList;
		}
	}
	document.frmAdd.submit();
}

function preprocess2(iIndex,iType,ic,agent){ 
	var qtyVal,submitString
	submitString=""
	qtyVal=document.frmAdd["qty"+iIndex].value
	submitString="http://www.energyalternatives.ca/shop/includes/add_item.asp?ic=" + ic + "&Ic=" + ic + "&Type=" + iType + "&Tp=" + iType + "&qty=" + qtyVal
	//submitString="http://www.energyalternatives.ca/shop/includes/add_item2.asp?ic=" + ic + "&Ic=" + ic + "&Type=" + iType + "&Tp=" + iType + "&qty=" + qtyVal
	//submitString="http://www.energyalternatives.ca/shop/GoCart.asp?ic=" + ic + "&Type=" + iType + "&qty=" + qtyVal
	document.location=submitString
}

var enableSelected;
var catSelected;

function  selectthis(){
	catSelected=document.selectcombo.combo1.options[document.selectcombo.combo1.options.selectedIndex].text
	enableSelected=document.selectcombo.combo1.options[document.selectcombo.combo1.options.selectedIndex].value
	if(enableSelected=="default")
		return false;
	else location.href=enableSelected;
}

function submitMainsearch(){ 
	if (document.frmMainsearch.SearchWord.value.indexOf(" ") == 0){
		alert("Search string should not start with spaces.");
		document.frmMainsearch.SearchWord.focus();
		return false;
	}
	if (document.frmMainsearch.SearchWord.value == ""){
		alert("Please enter a Search String.");
		document.frmMainsearch.SearchWord.focus();
		return false;
	}
	document.frmMainsearch.submit();
	return true;
}

iMaxCount = ""
bMaxItem = ""

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function checks whether the entered qty is correct or not.
//  @   Pages Affected  : Index,Items, searchresult,Psearchresult
//  @		Function Name		: preproc(frm,index,code,type)
//	@		Input Parameters: frm = Form Name, index = Index value, code = Item Code, type = Item Type
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function preproc(frm,index,code,type,eqCode,iWishList, iUnits)
{ var element, retval, qty, iItemqty, iTotalqty;

	element = "document." + frm + ".qty" + index + ".value";
	qty = eval(element);
	retval=IsNumeric(qty)

	if(retval == 1)
	{
		alert(getMessage("iValidQuantity"));
		eval("document." + frm + ".qty" + index + ".value=iUnits");
		eval("document." + frm + ".qty" + index + ".focus()");
		return;
	}


	if (iWishList == 0){
		iItemqty = qty*1
		if ((iMaxCount != "") && (bMaxItem.toLowerCase()=="true")){
			iTotalqty = parseInt(0)
			if((iItemqty + iTotalqty)>parseInt(iMaxCount)){
				alert(getMessage("iTotalQtyExceed") +" "+ iMaxCount);
				eval("document." + frm + ".qty" + index + ".value=iUnits");
				//eval("document." + frm + ".qty" + index + ".focus()");
				return;
			}
		}
	document.frmAdditem.qty.value = qty;
	document.frmAdditem.ic.value = code;
	document.frmAdditem.type.value=type;
	document.frmAdditem.EqCode.value=eqCode;
	document.frmAdditem.action = "http://www.energyalternatives.ca/shop/includes/add_item.asp?Tp="
	document.frmAdditem.submit();
	}
	else{
	document.frmAdditem.qty.value = qty;
	document.frmAdditem.ic.value = code;
	document.frmAdditem.EqCode.value=eqCode;
	document.frmAdditem.action = "http://www.energyalternatives.ca/shop/includes/AddWishitem.asp?Tp="
	document.frmAdditem.submit();
	}
}
// End of the function preproc(frm,index,code,type)


//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: Function IsNumeric checks whether the entered value is a
//	@											numeric and greater than Zero
//  @		Function Name		: IsNumeric(value)
//	@		Input Parameters: value to be tested
//	@		Return Value		: 0 - Success	  1 - Failure
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function IsNumeric(value)
{
	var validate=/(^\d+$)/
	if ((validate.test(value)) && (value > 0))
		return 0;
	else
		return 1;
}
// End of the function IsNumeric(value)

//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: This function is called before submiting page, to validate
//	@											float value.
//  @   Pages Affected  : PowerSearch
//  @		Function Name		: IsFloat()
//	@		Input Parameters: price value(Minimum or Maximum)
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


function IsFloat(value)
{
	var pattern1 = /^(\d+)(\.){0,1}(\d*)$/
	var pattern2 = /^(\d*)(\.){0,1}(\d+)$/
	return pattern1.test(value) || pattern2.test(value);
}

// End of the function IsFloat()


//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//	@		Description			: Function is to validate the alphanumeric characters and  string.
//  @  		Pages Affected 		: Shipcalculator
//  @		Function Name		: isAlphanumeric(str,cSpace)
//	@		Input Parameters	: formname = name of the form
//	@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

function isAlphanumeric(str,cSpace){
    var sSpacepat = /^(((\w+)[\s,\-*\.]*)+)$/
     var sPat = /^(((\w+)[*,\-\.]*)+)$/
     if (cSpace=="1"){
		if(!(sSpacepat.test(str)))
		   {
			 alert(getMessage("iValidText"));
			 return false;
	       }
		}
	  else{

		if(!(sPat.test(str)))
			{
				alert(getMessage("iValidText"));
				return false;
	        }
	        }
     return true;
}
// End of the function isAlphanumeric(str,cSpace)


////////////////////////////////////////////////////////////////////////////////////////
/////////              G O O G L E     A N A L Y T I C S    C O D E         ////////////
////////////////////////////////////////////////////////////////////////////////////////

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-17537915-1']);
  _gaq.push(['_setDomainName', 'none']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

