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(sCartItems)
			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 = sNonSecurePath + "includes/add_item.asp?Tp=" + sTpCatalog
	document.frmAdditem.submit();
	}
	else{
	document.frmAdditem.qty.value = qty;
	document.frmAdditem.ic.value = code;
	document.frmAdditem.EqCode.value=eqCode;
	document.frmAdditem.action = sNonSecurePath + "includes/AddWishitem.asp?Tp=" + sTpCatalog
	document.frmAdditem.submit();
	}
}

function getattribute(frm,index,code,type) {
	var iIndex,matrix,arrTemp,strselected,len;
	iItemCount=index
	matrix = false;
	arrTemp = eval("arrSelItems" + iItemCount)
	strselected = eval("document.frmAdd.SelMatrixAtt1" + iItemCount + ".options[document.frmAdd.SelMatrixAtt1" + iItemCount + ".selectedIndex].value"); 
	strselected = strselected + eval("document.frmAdd.SelMatrixAtt2" + iItemCount + ".options[document.frmAdd.SelMatrixAtt2" + iItemCount + ".selectedIndex].value"); 
	
	len = document.frmAdd.elements.length;
	for(iCount=0;iCount<=parseInt(len)-1;iCount++){
		if((document.frmAdd.elements[iCount].name.substring(0,13) == "SelMatrixAtt3") && (document.frmAdd.elements[iCount].name.substring(13,14) == iItemCount))
			strselected = strselected + eval("document.frmAdd.SelMatrixAtt3" + iItemCount + ".options[document.frmAdd.SelMatrixAtt3" + iItemCount + ".selectedIndex].value"); 
	}		
	for(iIndex=0;iIndex<=arrTemp.length-1;iIndex++){
		if(arrTemp[iIndex][1]==strselected){
			code = arrTemp[iIndex][0];
			matrix = true;
			break;
		}
	}
	if(matrix){
		preproc(frm,index,code,type,"",0)
		return;
	}
	else{
		alert(getMessage("iMatrixCombNotPresent"));
		return;
	}
}

function IsNumeric(value) {
	var validate=/(^\d+$)/
	if ((validate.test(value)) && (value > 0))
		return 0; 
	else
		return 1; 
}

function submitlist(sBc) {
	var value,sCatText;
	value=document.frmList.lstSubCategory.options[document.frmList.lstSubCategory.selectedIndex].value;
	sCatText=document.frmList.lstSubCategory.options[document.frmList.lstSubCategory.selectedIndex].text;
	if(value != "0") {
		document.frmList.action = sNonSecurePath + "items.asp?Cc=" + value + "&CatName=" + sCatText + "&Bc="+sBc+"&BrandName="+sBrandName+"&Tp="+sTpCatalog+"&iTpStatus=1";
		document.frmList.submit();
	}
}

function submitSearch(iPageNo) {	
	document.frmPSearch.PageNo.value= iPageNo;
	document.frmPSearch.submit();
}