<!--//

function checkvalues2(frm){
	var i= 0 ;
	var fname = "";
	var ret = "";
	var qret = "";
	var fval="";
	for (i=0;i<frm.length;i++){
		fname = frm.elements[i].name;
		fval = frm.elements[i].value;
		if (fname=="price")ret+=vertheprice(fval, 0);
		if (fname.substr(0,7) == "USERST_") ret+=verselection(fname.substr(6,fname.length), fval);
		if (fname=="quantity")ret+=vertheprice(fval, 1);
		if (fname=="stknum") {
			/* verify the stock numbers and warn if necessary this only exists if the check has been specified by the retailor */
			
			if ((fval*1) < (frm.elements['quantity'].value*1)){
				if (fval==1){qret="Sorry, but we can`t supply your order of "+frm.elements['quantity'].value+" items\n\nWe can only ship one item";}
				else{qret="Sorry, but we can`t supply your order of "+frm.elements['quantity'].value+" items\n\nWe can only ship "+fval+" items";}
			}
		}
	}
	
	if (ret!=""){
		alert(ret);return false;
	}else{
		if (qret!=""){
			alert(qret);
			frm.elements['quantity'].value=frm.elements['stknum'].value;
		}		
		return true;
	}
}

function checkvalues(frm){
	var i= 0 ;
	var fname = "";
	var ret = "";
	var qret = "";
	var fval="";
	for (i=0;i<frm.length;i++){
		fname = frm.elements[i].name;
		fval = frm.elements[i].value;
		if (fname=="price")ret+=vertheprice(fval, 0);
		if (fname.substr(0,7) == "USERST_") ret+=verselection(fname.substr(6,fname.length), fval);
		if (fname=="quantity")ret+=vertheprice(fval, 1);
		if (fname=="stknum") {
			/* verify the stock numbers and warn if necessary this only exists if the check has been specified by the retailor */
			
			if ((fval*1) < (frm.elements['quantity'].value*1)){
				if (fval==1){qret="Sorry, but we can`t supply your order of "+frm.elements['quantity'].value+" items\n\nWe can only ship one item";}
				else{qret="Sorry, but we can`t supply your order of "+frm.elements['quantity'].value+" items\n\nWe can only ship "+fval+" items";}
			}
		}
	}
	
	if (ret!=""){
		alert(ret);return false;
	}else{
		if (qret!=""){
			alert(qret);
			frm.elements['quantity'].value=frm.elements['stknum'].value;
		}		
		return true;
	}
}

function vertheprice(val, wo){
	var rx = "";
	if (!wo) comm="The value of the item is $0.00 - (invalid sale price)"; else comm="The number of items you are adding is invalid";
	if (IsNumeric(val)) val = val * 1; else val = 0;
	if (!val) rx= "Nothing to add - "+comm+" \n";
	return rx;
}

function verselection(selname, val){
	var rx = "";
	re = /_/gi;
	sn = selname.replace(re," ");
	if (val=="Please Select"){rx= "Please select from "+sn+" \n";}
	return rx;
}

function IsNumeric(passedVal){
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	if(passedVal == "") {IsNumber=false;}
	if (IsNumber){
		for (i = 0; i < passedVal.length && IsNumber == true; i++){
			Char = passedVal.charAt(i);
			if (ValidChars.indexOf(Char) == -1){IsNumber = false;}
		}
	}
	return IsNumber;
}
//-->