


function valEmptyFld(pFrmName,pFldName,pFldType)
{
	//1 -- Text field
	//2 -- Drop down
	//3 -- Radio button
	
	var intFldType;
	var objFrm;
	var objFld;
	var intCountChk = 0;
	
	
	intFldType = eval(pFldType);
	objFrm = eval("document."+pFrmName);
	objFld = eval("document."+pFrmName+"."+pFldName);
	
	switch(intFldType)
	{
		case 1:
			if(objFld.value==""){
				return false;
			}
			
	
		break
		case 2:
			if(objFld[objFld.selectedIndex].value==""){
				return false;
			}
			
		break
		case 3:	
			for(i=0;i<=objFld.length-1;i++)
			{
				if(objFld[i].checked==true){
					intCountChk++;
				}
			}
				
			if(intCountChk==0){
				return false;
			}
	}
	
	return true;
	
}

function fn_ValidateStep1(frmFullName)
	{
		
		if(!document.getElementById)
		{
			alert("You must use IE5 or later, Firefox, or NN 7 to continue.");		
			return false;
		}

		var strMsg = "";
		var strFld = "";
		var objFld = "";
		var blnTest=false;
		var frmObject;
		
		eval( "frmObject = document." + frmFullName +";" );
		 
		if(!valEmptyFld(frmFullName,"chkCat",3)){
			strMsg="Please select at least one category from the Product Category list before proceeding.\n";
			strFld = "chkCat,";
			
		}
		
		
		if(!strMsg==""){
			strMsg = "The following needs to be corrected before the form can be submitted:\n\n"+strMsg;
			alert(strMsg);
			
				if(!strFld==""){
					objFld = eval("document."+frmFullName+"."+strFld.substr(0,strFld.indexOf(",")));
					//objFld.focus()
				}
				
			return false;
		}
		
	}
	
function clearChk(frmFullName) {

	if(!document.frmProductLine.chkCatAll.checked){
		
		for (i=0; i<document.frmProductLine.chkCat.length;i++)
			{
				document.frmProductLine.chkCat[i].checked=false;
			}
	
	} else{

		for (i=0; i<document.frmProductLine.chkCat.length;i++)
			{
				document.frmProductLine.chkCat[i].checked=true;
			}
			
	}
	

}

function clearChkAll(frmFullName) {

	if(document.frmProductLine.chkCatAll.checked)
		{
			document.frmProductLine.chkCatAll.checked=false;
		}

}

function fn_FillQty(txtEl) {
	
	var countnow = document.frmProductLine.hdnQtyCount.value
	var notempty = 0;
	
	for(i=0; i < document.frmProductLine.txtQty.length;i++){

		if(!trim(document.frmProductLine.txtQty[i].value)==""){
			document.frmProductLine.txtQty[i].value = trim(document.frmProductLine.txtQty[i].value);
			notempty++;
		}
		
	}

	if(notempty > countnow){
		document.frmProductLine.hdnQtyCount.value++;
	}
	else if(notempty < countnow){
		document.frmProductLine.hdnQtyCount.value--;
	}

}

function trim(str)
{
	return str.replace(/\s*|\s*$/g,"");
}

function fn_ValidateStep2(frmFullName)
	{
		
		if(!document.getElementById)
		{
			alert("You must use IE5 or later or NN 7 to continue.");		
			return false;
		}

		var strMsg = "";
		var strFld = "";
		var objFld = "";
		
		if(document.frmProductLine.hdnQtyCount.value==0){
			strMsg=strMsg+"Please enter the quantity for at least one product.\n";
			strFld = strFld+"hdnQtyCount,";
		}
		else
		{
			
				for(i=0; i < document.frmProductLine.txtQty.length;i++){

					if(!document.frmProductLine.txtQty[i].value=="" && !document.frmProductLine.txtQty[i].value.match(/^\d+$/)){
						strMsg=strMsg+"You must use digits only (0-9) to indicated the product quantity.\n";
						strFld = strFld+"txtQty"+[i]+",";
						//break;
					}
					
				}

		}

		if(!strMsg=="")
		{
			strMsg = "The following needs to be corrected before the form can be submitted:\n\n"+strMsg;
			alert(strMsg);
			
				if(!strFld=="")
				{
					objFld = eval("document."+frmFullName+"."+strFld.substr(0,strFld.indexOf(",")));
					//alert(objFld.name);
					//objFld.focus()
				}
				
			return false;
		}
		return true;
		
	}

function fn_ValidateStep3(frmFullName){
	
	if(!document.getElementById)
		{
			alert("You must use IE5 or later or NN 7 to continue.");		
			return false;
		}

		var strMsg = "";
		var strFld = "";
		var objFld = "";
		
		
		eval( "frmObject = document." + frmFullName +";" );
		
	
		if(!valEmptyFld(frmFullName,"email_address",1)){
			strMsg=strMsg+"Please enter Email\n";
			strFld = strFld+"email_address,";
		}
		else
		{		
			if(valEmptyFld(frmFullName,"email_address",1) && !eval("document."+frmFullName).email_address.value.match(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/)){
					strMsg=strMsg+"You must enter correct Email Address\n";
					strFld = strFld+"email_address,";
			}
		}
		
		if(!valEmptyFld(frmFullName,"password",1)){
			strMsg=strMsg+"Please enter password.\n";
			strFld = strFld+"password,";
		}
	
	

		if(!strMsg=="")
		{
			strMsg = "The following needs to be corrected before the form can be submitted:\n\n"+strMsg;
			alert(strMsg);
			
				if(!strFld=="")
				{
					objFld = eval("document."+frmFullName+"."+strFld.substr(0,strFld.indexOf(",")));
					//alert(objFld.name);
					objFld.focus()
				}
				
			return false;
		}
		return true;
}

function fn_PrintThis(){
			   version = parseInt(navigator.appVersion)
			   if (version >= 4) window.print()
}