	// Regular expression for email address validation
	function isRegExpEmail(str){
		var regExp = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|([a-zA-Z0-9\-\.]+))\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
		return regExp.test(str);
	}

	
	// Regular expression for phone numbers lets multiple australian numbers through
	function isRegExpPhone(str){
		var regExp = /^(\d{10}|\d{2} \d{4} \d{4}|\d{8}|\d{4} \d{3} \d{3}|\d{2} \d{8}|\d{4} \d{6}|\(\d{4}\) \d{3} \d{3}|\(\d{2}\) \d{4} \d{4}|\(\d{4}\)\d{6}|\(\d{2}\)\d{8})$/;
		return regExp.test(str);
	}
	
	// Regular expression for McDonald's store phone numbers in 00/0000-0000 format
	function isRegExpStorePhone(str){	
		var regExp = /\d{2}\/\d{4}\-\d{4}/;
		return regExp.test(str);
	}
	
	// Regular expression for McDonald's Time of visit in HH:MM format
	function isRegExpTime(str)
	{
		//var regExp = /^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/; 
		var regExp = /^([0-9]|[0-1][0-9]|[2][0-3]):([0-5][0-9])$/; 
		//var regExp = /^([0-9]|[0-1][0-9]|[2][0-3]):([0-5][0-9])$)|(^([0-9]|[1][0-9]|[2][0-3])$/; 
		
		return regExp.test(str);
	}


	// Check for a valid email address using the reg ex function above
	function emailCheck(){
		var fieldName = emailCheck.arguments[0];
		var alertText = emailCheck.arguments[1];
				
		var valid = true;
		var str = fieldName.value;
		
		if(!isRegExpEmail(str)){
			ValidOk = false;
			alert('Please enter ' + alertText);
	    	fieldName.focus();
	    	fieldName.select();
		}
	}
	
	// Check for a valid email address using the reg ex function above
	function timeCheck(){
		var fieldName = timeCheck.arguments[0];
		var valid = true;
		var str = fieldName.value;
		
		if(!isRegExpTime(str)){
			ValidOk = false;
			alert('Please enter a valid time (HH:MM)');
	    	fieldName.focus();
	    	fieldName.select();
		}
	}
	
	
	
	// Check for a valid string
	function strCheck(){
		var fieldName = strCheck.arguments[0];
	  	var compareNumber = strCheck.arguments[1];
	  	var alertText = strCheck.arguments[2];
	  
	  	if ((fieldName.value.length < compareNumber) || (isNaN(fieldName.value) != true)){
	    	ValidOk = false;
	    	alert('Please enter ' + alertText + '.');
	    	fieldName.focus();
	    	fieldName.select();
		}
	}
	
	// Check for a valid string (for Wrigleys's Name Field in the MediaRelease Sign Up page)
	function customStrCheck(){
		var fieldName = customStrCheck.arguments[0];
	  	var compareNumber = customStrCheck.arguments[1];
	  	var alertText = customStrCheck.arguments[2];
			
	  	if ((fieldName.value.length < compareNumber) || (isNaN(fieldName.value) != true) || (fieldName.value == 'Name')){
	    	ValidOk = false;
	    	alert('Please enter ' + alertText + '.');
	    	fieldName.focus();
	    	fieldName.select();
		}
	}
	
	// Check for a valid string (for McDonald's Name Field in the MediaRelease Sign Up page)
	function customStrCheck2(){
		var fieldName = customStrCheck2.arguments[0];
	  	var compareNumber = customStrCheck2.arguments[1];
	  	var alertText = customStrCheck2.arguments[2];
			
	  	if ((fieldName.value.length < compareNumber) || (isNaN(fieldName.value) != true) || (fieldName.value == 'Enter Keywords')){
	    	ValidOk = false;
	    	alert('Please enter ' + alertText + '.');
	    	fieldName.focus();
	    	fieldName.select();
		}
	}
	

	// Check to make sure a date of birth is within agiven range
	function dob_yearCheck(){
		var fieldName = dob_yearCheck.arguments[0];
		var alertText = dob_yearCheck.arguments[1];
		
		if ((fieldName.value.length < 4) || (fieldName.value.length > 4) || (isNaN(fieldName.value)) || (fieldName.value > 2001)){
			ValidOk = false;
			alert('Please enter a valid ' + alertText + '.');
			fieldName.focus();
	    	fieldName.select();
			return false;
		}
		return true;
	}
	
	function yearCheck(){
		var fieldName = yearCheck.arguments[0];
		var alertText = yearCheck.arguments[1];
		
		if ((fieldName.value.length < 4) || (fieldName.value.length > 4) || (isNaN(fieldName.value))) {
			ValidOk = false;
			alert('Please enter a valid ' + alertText + '.');
			fieldName.focus();
	    	fieldName.select();
			return false;
		}
		return true;
	}

	// Make sure the user selects an option from a drop down list
	function selectCheck(){
		var fieldName = selectCheck.arguments[0];
		var alertText = selectCheck.arguments[1];
		
		if (((parseInt(navigator.appName.indexOf("Netscape")) == 0) && (parseInt(fieldName.selectedIndex) == 0))){
			ValidOk = false;
	    	alert('Please select ' + alertText + '.');
	  	}else if(document.all){
	    	if (parseInt(fieldName.selectedIndex) == 0){
        		ValidOk = false;
	      		alert('Please select ' + alertText + '.');
		  		fieldName.focus();
			}  
		}  
	}
    
	// Checks that a field is a number and if it is equal to the compare number		
	function numCheck(){
		var fieldName = numCheck.arguments[0];
		var compareNumber = numCheck.arguments[1];
		var alertText = numCheck.arguments[2];
		
		if ((isNaN(fieldName.value)) || (fieldName.value.length != compareNumber)){
			ValidOk = false;
	    	alert('Please enter ' + alertText + '.');
	    	fieldName.focus();
	    	fieldName.select();
	  	}
	}
	

	//CHecks for a valid phone number using the reg ex function above
	function phoneCheck(){
		var fieldName = phoneCheck.arguments[0];
		var valid = true;
		var str = fieldName.value;
	    
		if(!isRegExpPhone(str)){
			ValidOk = false;
			alert('Please enter a valid phone number');
	    	fieldName.focus();
	    	fieldName.select();
		}
	}
	
	//CHecks for a valid phone number using the reg ex function above
	function storePhoneCheck(){
		var fieldName = storePhoneCheck.arguments[0];
		var valid = true;
		var str = fieldName.value;
	    
		if(!isRegExpStorePhone(str)){
			ValidOk = false;
			alert('Please enter a valid store phone number in the format show.');
	    	fieldName.focus();
	    	fieldName.select();
		}
	}

	//Checks to make sure at least one radio button is checked.
	function radioCheck(){
		var fieldName = radioCheck.arguments[0];
		var alertText = radioCheck.arguments[1];
		var intNumOfButtons = fieldName.length;
		var i=0;
  
		while (i < intNumOfButtons){
			if (fieldName[i].checked == true){
				break;
			}
			i++;
  		}
		if (i == intNumOfButtons){
    		alert('Please select ' + alertText + '.');
			ValidOk = false;
		}
	}	
	
	//radio button checks gender
	function methodofContactCheck(){
		var fieldName = methodofContactCheck.arguments[0];
	  
		if (fieldName[0].checked != true && fieldName[1].checked != true){
			ValidOk = false;
			alert("Please select your method of contact");
		}
	}
	
	/*
		Multiple Field Processes
		This process checks that if the checkbox has been checked then something must be selected in the dropdown
		if checkbox is selected then the drop down box must not equal 0 (0 = the first field)
	*/
	
	function checkboxDropdownCheck(){
	  var checkBoxFieldName = checkboxDropdownCheck.arguments[0];
	  var selectFieldName = checkboxDropdownCheck.arguments[1];
	  var alertText = checkboxDropdownCheck.arguments[2];
 	  if (checkBoxFieldName.checked == true && ((parseInt(navigator.appName.indexOf("Netscape")) == 0) && (parseInt(selectFieldName.selectedIndex) == 0)) ||
		checkBoxFieldName.checked == true && ((parseInt(navigator.appName.indexOf("Netscape")) != 0) && (parseInt(selectFieldName.selectedIndex) <= 0))){
		ValidOk = false;
		alert(alertText);
	  }
 	}
	
	
	//Checks to make sure at least one radio button or check box is checked.
	function isChecked(){
		var fieldName = isChecked.arguments[0];
		var alertText = isChecked.arguments[1];
		var intNumOfButtons = fieldName.length;
		var i=0;
  
		while(i < intNumOfButtons){
			if (fieldName[i].checked == true){
				break;
			}
			i++;
  		}
		if(i == intNumOfButtons){
    		alert(alertText + '.');
			ValidOk = false;
			fieldName[0].focus();
		}
	}

	function isSubscribed(formName){
		if(formName.bitOnlinePromotions.checked == false &&
		 formName.bitMediaReleases.checked == false && 
		 formName.bitNewTastesMenu.checked == false && 
		 formName.bitStatePromotions.checked == false && 
		 formName.bitHappyMeal.checked == false){
    		alert('Please select at least one category of interest.');
			ValidOk = false;
		}
	}


	// is at least one check box checked????
	function isCheckBoxChecked(){
		var formName = isCheckBoxChecked.arguments[0];
		var count = isCheckBoxChecked.arguments[1];
		var counter=0;
		while (count < 6){
			if (formName.elements[count].checked == true){
				counter++;
				break;
			}
			count++;
		}
		if (counter == 0){
			alert("Please check at least one box");
			ValidOk = false;
		}
	}