	function fixPostal( pc ) {
	
		var newpc = "";
		var output = "";
	
		// strip out non-alphanumeric
		for ( var i = 0; i < pc.value.length; i++ )
			if ( pc.value.charAt( i ).match(/\w/) )
				newpc += pc.value.charAt( i );
				if ( newpc ) {
					// rebuild number with space
					for ( var i = 0; i < 6; i++ ) {
						output += newpc.charAt( i )
						if ( i == 2 )
							output += " ";
					}
				}
				// return value in uppercase
				pc.value = output.toUpperCase();
	}
	
	function fixPhone( phone ) {
	
		var num = phone.value;
		var newnum = "";
		var output = "";
	
		// strip out non-numbers
		for ( var i = 0; i < num.length; i++ )
			if ( num.charAt( i ).match(/\d/) )
				newnum += num.charAt( i );
				if ( newnum ) {
					// rebuild number with hyphen
					for ( var i = 0; i < newnum.length; i++ ) {
						if ( i == 3 || i == 6 )
							output += "-";
						else if ( i == 10 )
							output += " ";
							output += newnum.charAt( i )
					}
				}
				// return value
				phone.value = output;
	}
	
	function isName( string ) {
	
		if ( string.match(/^[A-Za-z\'\- ]+$/)) {
		
			return true;
		}
		
		return false;
	}
	
	function isEmail( string ) {
	
		if ( string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1 ) {
		
			return true;
			
		} else {
		
			return false;
		}
	}
	
	function isEmailMulti( string ) {
	
		// email addresses separated by commas
		if ( string.search(/^(\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+(,( )?)?)+$/) != -1 ) {
		
			return true;
			
		} else {
		
			return false;
		}
	}
	
	function isZip( zip ) {
	
		// 5 digit zips
		if(zip.match(/^\d\d\d\d\d$/)) {
		
			return true;
		}
			
		// 5+4 digit zips
		if((zip.match(/^\d\d\d\d\d\d\d\d\d$/)) || (zip.match(/^\d\d\d\d\d\-\d\d\d\d$/))) {
		
			return true;
		}
			
		return false;
	}
	
	function isPhone( phone ) {
	
		// 3+3+4 digit
		if(phone.match(/^\d\d\d\-\d\d\d\-\d\d\d\d$/)) {
		
			return true;
		}
		
		return false;
	}
	
	function isPostalCode( pc ) {
	
		// canadian postal codes (6 or 7 characters)
		if((pc.match(/^[A-Za-z]\d[A-Za-z]\d[A-Za-z]\d$/)) || (pc.match(/^[A-Za-z]\d[A-Za-z] \d[A-Za-z]\d$/))) {
		
			return true;
		}
		
		return false;
	}
	
	function CheckNumeric(frmEvent) {
	
	   //Get ASCII value of key that the user typed
	   var key;
	
		if ( "which" in frmEvent ) {
		
			key = frmEvent.which;
			
		} else {
		
			if ( "keyCode" in window.event ) { 
			
				key = window.event.keyCode;
			}
		} 
		
		//Check is the key is a numeric character
		if ( key <= 47 || key >= 58 ) {
		
		    //Otherwise, don't show it
		    frmEvent.returnValue = false; 
		}
	}
	
	function isNumeric(field) {
	
		if (field == null || field == "") {
		
			return false;
		}
		
		var number = '0123456789';		
		
		for (i = 0; i < field.length; i++) {
		
			if(number.indexOf(field.charAt(i),0) == -1) {
			
				return false;
			}
		}
		
		return true;
	}
	
	function GetRadioValue(RadioName) {
		
		if(isObject(RadioName)) {	
		
			for (i=0;i < RadioName.length; i++) {
			
			    if (RadioName[i].checked == true){
			    
					return(RadioName[i].value);
			    }
			}
		}
			
		return null;
	}
	
	function GetCheckBoxValue(CheckboxName){
	
		var values = "";
		
		if(isObject(CheckboxName)){
		
			for (i=0;i < CheckboxName.length; i++) {
			
			    if (CheckboxName[i].checked == true) {
			    
			    	if (values == "") {
			    	
				        values = CheckboxName[i].value;
				        
				    }
				    else {
				    
				        values = values + "," + CheckboxName[i].value;
				    }
			    }
			}
		}
		
		if (values == "") {
		
		    return null;
		    
		}
		else {
		
		    return values;
		}
	}
	
	
	function setOptions(frm) {
	
		o = frm.subject.options[frm.subject.selectedIndex].value;
		
		if (o == "Concern or Complaint") {
			document.getElementById('corctable').style.display='block';
			frm.lotNumber.value='';
			frm.expMonth.value='';
			frm.expYear.value='';
			frm.upcCode.value='';
			frm.productName.value='';
			frm.wherePurchased.value='';
		} else {
			document.getElementById('corctable').style.display='none';
			frm.lotNumber.value='';
			frm.expMonth.value='';
			frm.expYear.value='';
			frm.upcCode.value='';
			frm.productName.value='';
			frm.wherePurchased.value='';
		}
	}
	
	function pickGender(frm) {
	
		switch(frm.salutation.value) {
		
			case "Mr.":
				frm.gender[0].checked = true;
				break;
				
			case "Ms.":
				frm.gender[1].checked = true;
				break;		
					
			case "Mrs.":
				frm.gender[1].checked = true;
				break;
				
			case "Dr.":
				frm.gender[0].checked = true;
				break;	
									
			default:	
				frm.gender[0].checked = false;
				frm.gender[1].checked = false;
				break;
		}
	}
	
	function resetForm(frm) {
	
	    if (confirm("All fields above will be cleared.  Click OK to continue.")) {
	    
	        frm.reset();
	    }
	    
	    return false;
	}
	
	function clearForm(frm) {
	
		if (frm != null) {
		
		    frm.reset();
		}
	}	
	 		
	function createAgeCookie(value) {
	 		
		age = (value != null && isNumeric(value)) ? value : 13;
		cookieName = "over" + age;   		
		setCookie(cookieName, 'yes');
	}
	 		
	function hasAgeCookie(value) {
	 		
		var age = (value != null && isNumeric(value)) ? value : 13;
		var cookieName = "over" + age;
	    var ageOK = getCookie(cookieName);		    
	    
	    if (ageOK == null) {
	    
	    	return false;
	    }
	    
	    return true;
	}
	 		
	function openPopup (width, height, url, name) {
	   
		var windowWidth = window.screen.width;
		var windowHeight = window.screen.height;
		
		var popupWidth = width;
		var popupHeight = height;
		
		var popupTop = (windowHeight - popupHeight) / 2;
		var popupLeft = (windowWidth - popupWidth) / 2;
		
		var features = "width=" +  popupWidth + ",height=" + popupHeight + ",top=" + popupTop + ",left=" + popupLeft;
		
		window.open(url, name, features);			
	}
