function preproc1(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 = "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 = "includes/AddWishitem.asp?Tp="
	document.frmAdditem.submit();
	}
}

function checkStock(e_val,frm,index,code,type,eqCode,iWishList, iUnits)
{
	var va    = e_val.value;
	var stock = e_val.getAttribute("st");
	var backTotal
	if(parseInt(va)>parseInt(stock))
	{
		backTotal = parseInt(va)-parseInt(stock)
		if(confirm("Quantity is higher than available stock. " + backTotal + " pieces wll be on back order. Additional shipping charge will be incurred. Would you like to continue?"))
		{preproc1(frm,index,code,type,eqCode,iWishList, iUnits);}
		else
		{
			e_val.value="0";
			e_val.focus();
			e_val.select();
			event.returnValue = false;
		}
		 //event.preventDefault=false;
	}
}
							 
function checkStock_(e_val)
{
	var va    = e_val.value;
	var stock = e_val.getAttribute("st");
	//var stock = e_val.st;
	var backTotal
	if(parseInt(va)>parseInt(stock))
	{
		backTotal = parseInt(va)-parseInt(stock)
		if(confirm("Quantity is higher than available stock. " + backTotal + " pieces wll be on back order. Additional shipping charge will be incurred. Would you like to continue?"))
		{}
		else
		{
			e_val.value=stock;
			e_val.focus();
			e_val.select();
		}
	}
}
							 
							 function checkStock1(e_val,num,units)
							 {
							 var va    = e_val.value;
							 var stock = e_val.getAttribute("st");
							  var backTotal
							   if(parseInt(va)>parseInt(stock))
							   {
							     backTotal = parseInt(va)-parseInt(stock)
								if(confirm("Quantity is higher than available stock. " + backTotal + " pieces wll be on back order. Additional shipping charge will be incurred. Would you like to continue?"))
								 {preprocess(num,units);}
								 else
								 {
							     e_val.value="0";
								 e_val.focus();
								 e_val.select();
								 event.returnValue = false;	
								 }
								 //event.preventDefault=false;
							   }
							 }
					function check_focus(user_val)
					{						
						if(checkint(user_val) == true)
							user_val.style.backgroundColor='#E0E0E0';
						else
						{					
							user_val.value="";
							user_val.style.backgroundColor='White';
							user_val.focus();
							user_val.select();
							event.returnValue = false;}					
					}
					
					function checkint(elm) 
					{						
						var elmstr = elm.value + ""; 						
						if (elmstr == "" || elmstr == "0")
							return false;						
					    
						if(elmstr.length > "0")
								return true;
					   
							if (elmstr < "0")
								return false;			       
						return true;
					}

					function toAscii(elm)  {
						
						if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;
					}
					
					function check_entry(user_val)
					{					
						if(checkint(user_val) == true)						
							user_val.style.backgroundColor='#E0E0E0';
						else
						{
							user_val.value="0";
							user_val.style.backgroundColor='White';						
						}
					}
					

 /// Track back to back and forward button
var x="1";
var isBack;
function handleBackButton()
{
   var trackBackObj = document.getElementById("trackBackHidden");
   isBack = (x != trackBackObj.value);
   trackBackObj.value=2;
   trackBackObj.defaultValue=2;
   checkReload();
}

function isBackButtonUsed()
{
 return isBack;
}
function checkReload()
{
    if(isBackButtonUsed())
        location.reload(true);
}

/*function window.confirm(str)
{
    execScript('n = msgbox("'+str+'","4132")', "vbscript");
    return(n == 6);
}*/
