function vldqty(qty){
	qt = trim(qty);
	
	if (qt == ""){
		alert("Please enter quantity");
		qty.focus();
		return false;
	}
	
	if (isNaN(qt)){
		alert("Please enter valid quantity");
		qty.focus();
		return false;
	}

	qt = parseInt(qt);
	
	if (qt <=0){
		alert("Please enter valid quantity");
		qty.focus();
		return false;
	}

	return true;	
}

function acqSubmitForm(action,target,param1,param2,param3,param4,param5){
	if (document.forms[1].ACQUISITION[0].checked == true)
		action = "/estore/buylesprodtmp.cfm";
	else
	if (document.forms[1].ACQUISITION[1].checked == true)
		action = "/estore/leaseprodtmp.cfm";
	else
	if (document.forms[1].ACQUISITION[2].checked == true)
		action = "/estore/rentprodtmp.cfm";
	else
	if (document.forms[1].ACQUISITION[3].checked == true)
		action = "/estore/prodresrchtmp.cfm";
		
	linkSubmitForm(action,target,param1,param2,param3,param4,param5);		
}
// check the text field is not empty ...
function isEmpty(strVar){
	flag = true;
	if (strVar.length == 0)
		flag =  true;
	else{
		for (var i=0; i<strVar.length; i++){
			if (strVar.charAt(i) != ' '){
				flag = false;
				break;			
			} // end of if 
		} // end of for
	}// end of else
	
	 return flag;
}

function istextareaEmpty()
{
	if (isEmpty(document.forms[1].taspecial.value) == true)
	{ 	alert("Products to Sell and/or Comments are required");
		document.forms[1].taspecial.focus();
	}
	else
		linkValidateForm('','../estore/thankyou.cfm');
}
// check the text field is not empty ...


// Function to reset the form fields in sellquote.cfm page. Blanks out only fields with *
function resetSellQuote(){
	document.forms[1].fname.value="";
	document.forms[1].lname.value="";
	document.forms[1].zip.value="";		
	document.forms[1].email.value="";
	document.forms[1].phone.value="";	
}
// Function usesd in cfinput validation and sets the focus to the respective field if empty..
function setFieldFocus(cfformobj,cfinputobj,cfinputvalue)
{	
	if(isEmpty(cfinputvalue))
	{
		cfinputobj.value = "";
		cfinputobj.focus();		
		return false;
	}
	else return true;
}

function sendFlukeResponse(){

	flag = false;
	for (i=0; i<document.forms[1].product1.length; i++){
		if (document.forms[1].product1[i].checked){
			flag = true;
			break;
		}
	}

	if (!flag){
		alert("Please select yes or no for Fluke OptiView on-site demo and 5-day evaluation trial");
		return;
	}
	

	flag = false;
	for (i=0; i<document.forms[1].product2.length; i++){
		if (document.forms[1].product2[i].checked){
			flag = true;
			break;
		}
	}
	
	if (!flag){
		alert("Please select yes or no for Fluke Networks One Touch on-site demo \nand 5-day evaluation trial");
		return;
	}


	flag = false;
	for (i=0; i<document.forms[1].product3.length; i++){
		if (document.forms[1].product3[i].checked){
			flag = true;
			break;
		}
	}
	
	if (!flag){
		alert("Please select yes or no for Fluke Networks DSP-FTK/AN on-site demo and 5 day evaluation trial");
		return;
	}


	
	if (trim(document.forms[1].name) == ""){
		alert("Please enter your name");
		document.forms[1].name.focus();
		return;
	}
	email = trim(document.forms[1].email);
	if (email == ""){
		alert("Please enter email");
		document.forms[1].email.focus();
		return;
	}
	if (!emailCheck(email)){
		alert("Please enter a valid e-mail");
		document.forms[1].email.focus();
		return;
	}
	if (trim(document.forms[1].phone) == ""){
		alert("Please enter phone number");
		document.forms[1].phone.focus();
		return;
	}

	linkSubmitForm('/estore/productstmp.cfm','../estore/flupromo.cfm','fromsubmit','','','','');
}

function genericValidate(fname,fields,messages,targetPage){
 allFields = mockSplit(fields,",");
 allMessages = mockSplit(messages,",");
 
 for (i=0; i < fname.elements.length;i++){
	validateFlag = false;
	tempName = fname.elements[i].name;
	
	for (j=0; j<allFields.length; j++){
		if (tempName == allFields[j]){
			validateFlag = true;
			break;
		}// end of if	
	}// end of inner for
	
	if (validateFlag){
	// validate the field
//		alert(fname.elements[i].type);
		if (fname.elements[i].type == "text"){
			if (trim(fname.elements[i]) == ""){
				alert(allMessages[j]);
				fname.elements[i].focus();
				return;
			}// end of if (fname.elements[i])	
			
			// e-mail validation 
			if (fname.elements[i].name == "email"){
				if (!emailCheck(fname.elements[i].value)){
					alert("Please enter a valid e-mail address");				
					fname.elements[i].focus();
					return;
				}
			}
		}// end of if
		else
		if (fname.elements[i].type == "radio"){

			flag = false;
			for (k = 0; k < fname.elements[i].length; k++){
					if( fname.elements[i][k].checked )
					{	
						flag = true;
						break; 
					}
			}// end of for

			if (!flag){
				alert(allMessages[j]);
				fname.elements[i].focus();
				return;
			}
		}// end of if else type
     }// end of if (validateFlag)
 }// end of the for statement
 
	linkSubmitForm('/customerservice/customerservicetmp.cfm',targetPage,'fromsubmit','ManufacturerPromotions','');

}

function vldlogin(){
			userid = trim(document.forms[1].userid);
			password = trim(document.forms[1].passwordtxt);

			if (userid==""){
				alert("Please enter the User Id");
				document.forms[1].userid.focus();
				return;	
			}

			if (password==""){
				alert("Please enter Password");
				document.cfForm.passwordtxt.focus();
			    return;
			}
			param1 = document.forms[1].param1.value;
			param2 = document.forms[1].param2.value;
			param3 = document.forms[1].param3.value;
			param4 = document.forms[1].param4.value;
			param5 = document.forms[1].param5.value;
			
    	   	linkSubmitForm("","../registration/loginvalidate.cfm",param1,param2,param3,param4,param5);
	
}						

function processEnter(keypressed) {
        // The Docment Object Model event we need is only available inf Javascript 1.2, MSIE4+ and NN4+
        // This functions is the onKeyPress event handler for the password field

        var key;
        
        // Test of MSIE DOM without all that parsing of the agent string
        // NN and MSIE use different DOMs
        if (document.all) {
            key=window.event.keyCode;
              }
        else {
            key=keypressed.which;
              };
                      
        // Check each key pressed for character code 13 (carriage return), AND
        // then SUBMIT the form for the user
        if (key==13) {
			vldlogin();
        }

}
