	iFrac=0
	iNum = 0
	var yMsg = ""
	function isDate(dateStr) {
	    yMsg = ""
	    var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	    var matchArray = dateStr.match(datePat); // is the format ok?

	    if (matchArray == null) {
	        yMsg = ("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
	        return false;
	    }

	    month = matchArray[1]; // p@rse date into variables
	    day = matchArray[3];
	    year = matchArray[5];

	    if (month < 1 || month > 12) { // check month range
	        yMsg = ("Month must be between 1 and 12.");
	        return false;
	    }

	    if (day < 1 || day > 31) {
	        yMsg = ("Day must be between 1 and 31.");
	        return false;
	    }

	    if ((month == 4 || month == 6 || month == 9 || month == 11) && day == 31) {
	        yMsg = ("Month " + month + " doesn`t have 31 days!")
	        return false;
	    }

	    if (month == 2) { // check for february 29th
	        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	        if (day > 29 || (day == 29 && !isleap)) {
	            yMsg = ("February " + year + " doesn`t have " + day + " days!");
	            return false;
	        }
	    }
	    return true; // date is valid
	}	
	
	function roundit(Num, Places) {
		if (Places > 0) {
			if ((Num.toString().length - Num.toString().lastIndexOf('.')) > (Places + 1)) {
   				var Rounder = Math.pow(10, Places)
   	//			//return Math.round(Num * Rounder) / Rounder
   				iNum= Math.round(Num * Rounder) / Rounder
   			}else{
   				iNum= Num
   			}
   		}else{
   			iNum=Math.round(Num)
		}
	}


	function funcDec2Frac(xDec) {
		var yFrac=""
		//alert("xDec="+xDec)
		//roundit(xDec, 5)
		
		//alert("xDec="+xDec)
		switch(xDec)
		{
		case 0:
			yFrac="0/8"
			iFrac=0
			break;
		case 0.0625:
		case 0.125:
			yFrac="1/8"
			iFrac=1
			break;
		case 0.1875:
		case 0.25:
			yFrac="1/4"
			iFrac=2
			break;
		case 0.3062499999999986:
		case 0.30625:
		case 0.3125:
		case 0.375:
			yFrac="3/8"
			iFrac=3
			break;
		case 0.4375:
		case 0.5:
			yFrac="1/2"
			iFrac=4
			break;
		case 0.5625:
		case 0.6125:
		case 0.625:
			yFrac="5/8"
			iFrac=5
			break;
		case 0.6825:
		case 0.6875:
		case 0.75:
			yFrac="3/4"
			iFrac=6
			break;
		case 0.8062499999999986:
		case 0.8125:
		case 0.875:
			yFrac="7/8"
			iFrac=7
			break;
		default:
			yFrac="0/8"	
			iFrac=0
			break;				
		}
		yyFrac=yFrac
	}	
		
	function funcFrac2Dec(xFrac) {
		var yFrac=0
		//alert("xFrac="+xFrac)
		switch(xFrac)
		{
		case "0/8","0/16":
			yFrac=0
			break;
		case "1/16":
			yFrac=0.0625
			break;	
		case "1/8":
			yFrac=0.125
			break;	
		case "3/16":
			yFrac=0.1875
			break;			
		case "1/4":
			yFrac=0.25
			break;	
		case "5/16":
			yFrac=0.3125
			break;
		case "3/8":
			yFrac=0.375
			break;
		case "7/16":
			yFrac=0.4375
			break;
		case "1/2":
			yFrac=0.5
			break;
		case "9/16":
			yFrac=0.5625
			break;
		case "5/8":
			yFrac=0.625
			break;
		case "11/16":
			yFrac=0.6875
			break;
		case "3/4":
			yFrac=0.75
			break;
		case "13/16":
			yFrac=0.8125
			break;
		case "7/8":
			yFrac=0.875
			break;
		case "15/16":
			yFrac=0.9375
			break;
		default:
			yFrac=0	
			break;				
		}
		yyFrac=yFrac
	}	
	
	function funcOpenMsgWindow(xMid,xH,xMsg){
		openHelpWindow('/MessageWindow.asp?MID=' + xMid + '&H=' + xH + '&Msg=' + xMsg + '','openHelpWindow','width=250,height=250,resizable=0,scrollbars=yes');
	}
		
	function funcDrawValMsg(yName){
		xMsg = xMsg + " - Enter a " + yName + "<br>"
		xCont = "1"
		//alert (yName)
	}

	function funcDrawValMsgNPref(yName){
		xMsg = xMsg + " - " + yName + "<br>"
		xCont = "1"
		//alert (yName)
	}

	var xEmailMsg=""
	function funcValidateEMail(xMailStr){
		xEmailMsg=""
		//then val Email addresses for validity
		var aryEmail = xMailStr.split("@")
		//alert('aryEmail.length='+aryEmail.length)
		
		if(aryEmail.length!=2){
			xEmailMsg = xEmailMsg + "<br>a - Enter a Valid Email address"
		}else{
			//alert('aryEmail[0]='+aryEmail[0]+'/'+aryEmail[0].length)
			//alert('aryEmail[1]='+aryEmail[1]+'/'+aryEmail[1].length)
			//either side is 0 length
			if(aryEmail[0].length==0 || aryEmail[1].length==0){
				xEmailMsg = xEmailMsg + "<br>b - Enter a Valid Email address"
			}else{
				var aryEmail2 = aryEmail[1].split(".")
				var aryL = aryEmail2.length
				//alert('aryEmail2.length='+aryL)
				if(aryL<2){
					xEmailMsg = xEmailMsg + "<br>c - Enter a Valid Email address"
				}else{
					//alert('aryEmail2[aryL-1]='+aryEmail2[aryL-2])
					//alert('aryEmail2[aryL]='+aryEmail2[aryL-1])
					for (i=0 ; i < aryL ; i++) {
						if(aryEmail2[i].length==0){
							xEmailMsg = xEmailMsg + "<br>d - Enter a Valid Email address"
						}
					}
					if(xEmailMsg==""){				
						if (aryEmail2[aryL-1].length<2 || aryEmail2[aryL-1].length>3){
							xEmailMsg = xEmailMsg + "<br>e - .xxx is <> 2 or 3 chars - Enter a Valid Email address"
						}
					}
				}			
			}
		}
		if(xEmailMsg!=""){
			//alert(xEmailMsg)
		}	
		xEmailMsg = xEmailMsg+ xEmailMsg		
	}
	function funcValidateEMailBAK(xMailStr){
		xEmailMsg=""
		//then val Email addresses for validity
		
		var aryEmail = xMailStr.split("@")

		//if no @	
		if (aryEmail[0].length == xMailStr.length){
			xEmailMsg = xEmailMsg + "<br>a - Enter a Valid Email address"
		}else{				
			//if starts with @	
			if (aryEmail[1].length+0 == xMailStr.length){
				xEmailMsg = xEmailMsg + "<br>b - Enter a Valid Email address"
			}
			//if ends with @	
			if (aryEmail[1].length==0){
				xEmailMsg = xEmailMsg + "<br>c - Enter a Valid Email address"
			}
			//@ is ok check for period
			if (xEmailMsg == "") {
				//alert('@ is ok check for period')
				var aryEmail2 = aryEmail[1].split(".")
				var aryL = aryEmail2.length
				//alert('aryEmail2[aryL-1]='+aryEmail2[aryL-1])
				//alert('aryEmail2[aryL]='+aryEmail2[aryL])
				//alert('aryEmail2.length='+aryL)
				//if no .
				alert('aryL='+aryL)	
				if(aryL==1){
				//if (aryEmail2[0].length == aryEmail[1].length){
					xEmailMsg = xEmailMsg + "<br>no . - Enter a Valid Email address"
				}else{
					alert(aryEmail2[aryL])
					//if ends with .
					if(aryEmail2[aryL]==''){
						xEmailMsg = xEmailMsg + "<br>is . - Enter a Valid Email address"
					}
					//if starts with @	
				//	if (aryEmail2[1].length+1 == aryEmail[1].length){
				//		xEmailMsg = xEmailMsg + "<br>starts with @ - Enter a Valid Email address"
				//	}
				//	//if ends with @	
				//	if (aryEmail2[1].length==0){
				//		xEmailMsg = xEmailMsg + "<br>ends with @ - Enter a Valid Email address"
				//	}	
				//	//if .xxx is <> 2 or 3 chars
				//	if (aryEmail2[1].length<2 || aryEmail2[1].length>3){
				//		xEmailMsg = xEmailMsg + "<br>.xxx is <> 2 or 3 chars - Enter a Valid Email address"
				//	}				
				}	
			}	
		}
		if(xEmailMsg!=""){
			alert(xEmailMsg)
		}	
		xEmailMsg = xEmailMsg+ xEmailMsg	

	}

	
	function subValLogin(xForm,yForm)
	{
	    //alert(xForm + '\n' + yForm)
		//alert (yForm)
		var iHeight=250
		var zForm=""
		var today = new Date();
		xCont = "0"
		xMsg = ""
		switch(yForm)
		{
		case 'NoVal':
		    //used for "F" type - cust edits and adds not allowed
		    if(window.document.forms[xForm].cboCustomer.value=="0"){
		        xCont = "1"
		        xMsg = xMsg + "<BR> - Select a Customer"
            }else{
                if (window.document.forms[xForm].cCID.value == "0") {
                    xCont = "1"
                    xMsg = xMsg + "<BR> - Please verify a Customer is selected, then press the VIEW button"
                }        
            }
            break;			
		case 'Login':
			//alert("Looooogin");
			if (window.document.forms[xForm].Email2.value.length == 0) {
				xCont = "1"
				xMsg = xMsg + "<BR> - Enter an Email"
			}else{
				xEmailMsg=""
				funcValidateEMail(window.document.forms[xForm].Email2.value)
				if(xEmailMsg.length>0){
					xCont = "1"
					xMsg = xMsg + "<BR> - Enter a Valid Email address"
				}
			}			
			if (window.document.forms[xForm].Password2.value.length == 0) {
				xCont = "1"
				xMsg = xMsg + "<BR> - Enter a Password"
			}				
			zForm="To Log in to Your Account<BR>Please correct the following fields<BR>"
			window.document.forms[xForm].xProfile.value = "Login" 
			iHeight=250
			break;	
		case 'LoginW':
			//alert("Looooogin");
			if (window.document.forms[xForm].strLogin.value.length == 0) {
				xCont = "1"
				xMsg = xMsg + "<BR> - Enter a Login"
			}			
			if (window.document.forms[xForm].strPassword.value.length == 0) {
				xCont = "1"
				xMsg = xMsg + "<BR> - Enter a Password"
			}				
			zForm="To Log in to Your Account<BR>Please correct the following fields<BR>"
			//window.document.forms[xForm].xProfile.value = "Login" 
			iHeight=250
			break;	
		case 'ForgotPasswordW':
			//alert("Looooogin");
			if (window.document.forms[xForm].strLogin.value.length == 0) {
				xCont = "1"
				xMsg = xMsg + "<BR> - Enter a Login"
			}else{							
				zForm="Before we can email your password<BR>Please correct the following fields<BR>"
				xCont = "2"
				openHelpWindow('MessageWindow.asp?MID=Forgot Password&H=' + jsH + '&EmailLogin=Login&Login=' + window.document.forms[xForm].strLogin.value + '','openHelpWindow','width=250,height=250,resizable=0,scrollbars=yes');			
				//window.document.forms[xForm].xProfile.value = "ForgotPassword" 
			}
			iHeight=250
			break;							
		case 'ForgotPassword':
			//alert('ForgotPassword Here')
			if (window.document.forms[xForm].Email2.value.length == 0) {
				xCont = "1"
				xMsg = xMsg + "<BR> - Enter an Email"
			}else{	
				zForm="To get your password<BR>Please fill out the following fields<BR>"		
				xCont = "2"
				openHelpWindow('MessageWindow.asp?MID=Forgot Password&H=' + jsH + '&EmailLogin=Email&Email=' + window.document.forms[xForm].Email2.value + '','openHelpWindow','width=250,height=250,resizable=0,scrollbars=yes');			
				window.document.forms[xForm].xProfile.value = "ForgotPassword" 
			}
			iHeight=250
			break;	
		case 'NewAccount':
			//alert("Looooogin");
			if (window.document.forms[xForm].Email2.value.length == 0) {
				xCont = "1"
				xMsg = xMsg + "<BR> - Enter an Email"
			}			
			if (window.document.forms[xForm].Password2.value.length == 0) {
				xCont = "1"
				xMsg = xMsg + "<BR> - Enter a Password"
			}				
			zForm="To Create a New Account<BR>Please correct the following fields<BR>"
			window.document.forms[xForm].xProfile.value = "NewAccount" 
			iHeight=250
			break;				
		case 'Edit':
			//alert("editedit");
			zForm="To Save Your Account<BR>Please correct the following fields<BR>"
//alert('jsRW!='+jsRW)
			if(jsXNew=='New'){
				if(jsRW=='R'){
				if (window.document.forms[xForm].Email.value.length == 0) {
					funcDrawValMsg('Email')
				}else{
					xEmailMsg=""
					funcValidateEMail(window.document.forms[xForm].Email.value)
					if(xEmailMsg.length>0){
						xCont = "1"
						xMsg = xMsg + " - Enter a Valid Email address<BR>"
					}
				}
				if (window.document.forms[xForm].Password.value.length == 0) {
					funcDrawValMsg('Password')
				}else{
					if (window.document.forms[xForm].Password.value != window.document.forms[xForm].PasswordEA.value) {
						xMsg = xMsg + " - Same Password Must be entered twice<BR>"
						xCont = "1"
						}
					}
				}
				if(jsRW!='P'){
				    if(window.document.forms[xForm].Password.value.length<5) {funcDrawValMsg('Password with at least 5 characters')}
				    if(window.document.forms[xForm].Password.value.length>15) {funcDrawValMsg('Password with less than 15 characters')}	
				    if(window.document.forms[xForm].Password.value.indexOf("&")>-1){funcDrawValMsg('Password without the ampersand symbol')}
				}    
			}

			
			if (window.document.forms[xForm].FirstName.value.length==0) {funcDrawValMsg('First Name')}
			if(window.document.forms[xForm].FirstName.value.length>50) {funcDrawValMsg('First Name with less than 50 characters')}
			if(window.document.forms[xForm].FirstName.value.indexOf("&")>-1){funcDrawValMsg('First Name without the ampersand symbol')}			
			if (window.document.forms[xForm].LastName.value.length == 0) {funcDrawValMsg('Last Name')}
			if(window.document.forms[xForm].LastName.value.length>50) {funcDrawValMsg('LastName with less than 50 characters')}
			if(window.document.forms[xForm].LastName.value.indexOf("&")>-1){funcDrawValMsg('Last Name without the ampersand symbol')}
			if (window.document.forms[xForm].Address1.value.length == 0) {funcDrawValMsg('Address')}
			if(window.document.forms[xForm].Address1.value.length>50) {funcDrawValMsg('Address with less than 50 characters')}
			if(window.document.forms[xForm].Address1.value.indexOf("&")>-1){funcDrawValMsg('Address without the ampersand symbol')}
			//Address2 not required
			if(window.document.forms[xForm].Address2.value.length>50) {funcDrawValMsg('Suite No. with less than 50 characters')}
			if(window.document.forms[xForm].Address2.value.indexOf("&")>-1){funcDrawValMsg('Suite No. without the ampersand symbol')}
			if (window.document.forms[xForm].City.value.length == 0) {funcDrawValMsg('City')}
			if(window.document.forms[xForm].City.value.length>50) {funcDrawValMsg('City with less than 50 characters')}
			if(window.document.forms[xForm].City.value.indexOf("&")>-1){funcDrawValMsg('City without the ampersand symbol')}
			if (window.document.forms[xForm].State.value.length == 0) {funcDrawValMsg('State')}
			if (window.document.forms[xForm].Zip.value.length != 5) {funcDrawValMsg('5 Digit Zip Code')}
			if (window.document.forms[xForm].Area.value.length + window.document.forms[xForm].Prefix.value.length + window.document.forms[xForm].Number.value.length != 10) 
				{funcDrawValMsg('10 Digit Phone Number')}
			if (window.document.forms[xForm].OArea.value.length + window.document.forms[xForm].OPrefix.value.length + document.forms[xForm].ONumber.value.length > 0) 
				{if (document.forms[xForm].OArea.value.length + document.forms[xForm].OPrefix.value.length + document.forms[xForm].ONumber.value.length != 10)
				{funcDrawValMsg('10 Digit Other Phone Number')}
			}


		if(jsRW=='R'){
			// cc requirements removed 2/7/04
			if (document.forms[xForm].CCNumber.value.length == 0) {
				//funcDrawValMsg('Credit Card Number')
				document.forms[xForm].optPayType.value=""
			}else{
				//alert(xForm)
				//alert(document.forms[xForm].CCType.options[1].value)
				//alert(document.forms[xForm].CCType.options[document.forms[xForm].CCType.selectedIndex].value)
				//switch(document.forms[xForm].CCType.options[document.forms[xForm].CCType.selectedIndex].value)
				//{
				//alert(document.frmSaveProfile.CCType.value)
				//alert(document.frmSaveprofile.CCType.options[document.frmSaveprofile.CCType.selectedIndex].value)
				switch(window.document.forms[xForm].CCType.value)
				//switch(document.frmSaveprofile.CCType.options[document.frmSaveProfile.CCType.selectedIndex].value)
				{
				case 'Amex':{
					if (document.forms[xForm].CCNumber.value.length != 15) {
						funcDrawValMsg('15 Digit Credit Card Number')
					}else{
						if(parseInt(document.forms[xForm].CCNumber.value)!=document.forms[xForm].CCNumber.value){
							funcDrawValMsg('15 Digit Credit Card Number')
						}
					}
				}
					break;
				default:{
					if (document.forms[xForm].CCNumber.value.length != 16) {
						funcDrawValMsg('16 Digit Credit Card Number')
					}else{
						if(parseInt(document.forms[xForm].CCNumber.value)!=document.forms[xForm].CCNumber.value){
							funcDrawValMsg('16 Digit Credit Card Number')
						}
					}
				}
					break;
				}						
				if (today.getFullYear() == document.forms[xForm].CCExpYr.options[document.forms[xForm].CCExpYr.selectedIndex].text){
					if ((today.getMonth()+1) > document.forms[xForm].CCExpMo.options[document.forms[xForm].CCExpMo.selectedIndex].text){
						funcDrawValMsg('Valid Credit Card Date')
					}
				}
			}
		}
			document.forms[xForm].xProfile.value = "Continue" 
			iHeight=350
			break;	
		case 'Find':
			//alert("Looooogin");
			if ((window.document.forms[xForm].strFirstName.value.length+window.document.forms[xForm].strLastName.value.length) == 0) {
				xCont = "1"
				xMsg = xMsg + "<BR> - Enter a First Name and/or a Last Name"
			}				
			zForm="To Find a Customer<BR>Please Fill out one of the following fields<BR>"
			//window.document.forms[xForm].xProfile.value = "Login" 
			iHeight=250
			break;	
		}		
	
		switch(xCont)
		{
		case '0':
			//alert('ok')
			window.document.forms[xForm].submit()
			break;			
		case '1':
			xMsg = zForm + xMsg 
			openHelpWindow('MessageWindow.asp?MID=Please Complete All Fields&H=' + jsH + '&Msg=' + xMsg + '','openHelpWindow','width=250,height=' + iHeight + ',resizable=0,scrollbars=yes');
			break;
		}			
	}	
