//form
	document.forms["contactForm"].onSubmit = function() 
	{
		contactValidate();
	}
	document.forms["feedbackForm"].onSubmit = function()
	{
		feedbackValidate();
	}
	
	document.forms["searchForm"].onSubmit = function ()
	{
		searchValidate();
	}
	document.forms["competitionForm"].onSubmit = function ()
	{
		competitionValidate();
	}


function hideWarning(ValidatorId)
{
	
	//alert(document.getElementById(ValidatorId).className);
	var style = document.getElementById(ValidatorId).className;
	var newStyle = style.replace(/alert/,"background-none");
	//document.getElementById(ValidatorId).className += 'background-none';
	document.getElementById(ValidatorId).className += newStyle;
	//alert(document.getElementById(ValidatorId).className);
}

function checkLength(fieldId,area,length)
{
	var result = false;
	if(document.getElementById(fieldId).value.length > length)
	{
		//780
		document.getElementById(fieldId).focus();
		document.getElementById(fieldId).className = 'alert';
		result = false;
	}
	else
	{/*
		if(area == "comp")
		{
			document.getElementById(fieldId).className = 'textAreaComp';
		}
		else
		{
			document.getElementById(fieldId).className = 'textArea';
		}*/
		document.getElementById(fieldId).className = ' textArea';
		result = true;
	}
	return result;
}
function contactValidate()
{
	
	
	if(document.getElementById('name').value == '')
	{
		document.getElementById('name').focus();
		document.getElementById('name').className = 'alert';
		return false;
	}
	if(document.getElementById('organisation').value == '')
	{
		document.getElementById('organisation').focus();
		document.getElementById('organisation').className = 'alert';
		return false;
	}
	if(document.getElementById('jobtitle').value == '')
	{
		document.getElementById('jobtitle').focus();
		document.getElementById('jobtitle').className = 'alert';
		return false;
	}
	if(document.getElementById('email').value == '')
	{
		document.getElementById('email').focus();
		document.getElementById('email').className = 'alert';
		return false;
	}
	if(document.getElementById('email').value.indexOf('@') < 0 || document.getElementById('email').value.indexOf('.') < 0)
	{
		document.getElementById('email').select();
		document.getElementById('email').className = 'alert';
		return false;
	}
	var fieldLength = checkLength('message');
	if(!fieldLength)
	{
		return false;
	}
	
	var boxes = checkBoxes();
	if(!boxes)
	{
		return false;
	}
}

function feedbackValidate()
{
	if(document.getElementById('name').value == '')
	{
		document.getElementById('name').focus();
		document.getElementById('name').className = 'alert';
		return false;
	}
	
	if(document.getElementById('organisation').value == '')
	{
		document.getElementById('organisation').focus();
		document.getElementById('organisation').className = 'alert';
		return false;
	}
	if(document.getElementById('jobtitle').value == '')
	{
		document.getElementById('jobtitle').focus();
		document.getElementById('jobtitle').className = 'alert';
		return false;
	}
	
	if(document.getElementById('email').value == '')
	{
		document.getElementById('email').focus();
		document.getElementById('email').className = 'alert';
		return false;
	}
	if(document.getElementById('email').value.indexOf('@') < 0 || document.getElementById('email').value.indexOf('.') < 0)
	{
		document.getElementById('email').select();
		document.getElementById('email').className = 'alert';
		return false;
	}
	
	if(document.getElementById('message').value == '')
	{
		document.getElementById('message').focus();
		document.getElementById('message').className = 'alert';
		return false;
	}
}

function checkBoxes()
{
	//alert("checkBoxes");
	//var boxes = document.forms["contactForm"].contactMethod.length;
	//alert(boxes);
	//alert("boxes " + document.forms.contactForm.contactMethod.length);
	//var valid = false;
	/*for (var i = 0; i < boxes; i++)
	{
		if (document.forms["contactForm"].contactMethod[i].checked) 
		{
			if(document.forms["contactForm"].contactMethod[i].value == "none")
			{
				document.forms["contactForm"].contactMethod[0].checked = false;
				document.forms["contactForm"].contactMethod[1].checked = false;
				//document.forms.contactForm.contactMethod[1].checked = false;
				valid = true;
			}
		}
	}
	return valid;*/
	
	var valid = false
	var chks = document.getElementsByName('contactMethod[]');
	for(var i = 0; i < chks.length; i++)
	{
		if(chks[i].checked)
		{
			if(chks[i].value == "none")
			{
				chks[0].checked = false;
				chks[1].checked = false;
				valid = true;
			}
			else
			{
				valid = true;
			}
		}
	}
	return valid;
}

function searchValidate()
{
	if(document.getElementById('search').value == '')
	{
		document.getElementById('search').focus();
		document.getElementById('search').className = 'alert';
		return false;
	}
}

function competitionValidate()
{
	/*if(document.getElementById('reasonForVisit').value == '')
	{
		document.getElementById('reasonForVisit').focus();
		
		var style = document.getElementById('reasonForVisit').className;
		if(!style.match("alert"))
		{
			document.getElementById('reasonForVisit').className += 'alert';
		}
		
		//alert(document.getElementById('reasonForVisit').className)
		return false;
	}
	
	if(document.getElementById('whyDoYouSayThat').value == '')
	{
		document.getElementById('whyDoYouSayThat').focus();
		document.getElementById('whyDoYouSayThat').className += ' alert';
		return false;
	}
	
	
	if(document.getElementById('otherFeaturestoInclude').value == '')
	{
		document.getElementById('otherFeaturestoInclude').focus();
		document.getElementById('otherFeaturestoInclude').className += 'alert';
		return false;
	}
	
	if(document.getElementById('trainingNeeds').value == '')
	{
		document.getElementById('trainingNeeds').focus();
		document.getElementById('trainingNeeds').className += ' alert';
		return false;
	}
	
	if(document.getElementById('name').value == '')
	{
		document.getElementById('name').focus();
		document.getElementById('name').className = ' alert';
		return false;
	}
	
	if(document.getElementById('jobtitle').value == '')
	{
		document.getElementById('jobtitle').focus();
		document.getElementById('jobtitle').className = 'alert';
		return false;
	}
	
	if(document.getElementById('organisation').value == '')
	{
		document.getElementById('organisation').focus();
		document.getElementById('organisation').className = 'alert';
		return false;
	}
	
	if(document.getElementById('businessSector').value == '')
	{
		document.getElementById('businessSector').focus();
		document.getElementById('businessSector').className = 'alert';
		return false;
	}
	
	if(document.getElementById('email').value == '')
	{
		document.getElementById('email').focus();
		document.getElementById('email').className = 'alert';
		return false;
	}
	if(document.getElementById('email').value.indexOf('@') < 0 || document.getElementById('email').value.indexOf('.') < 0)
	{
		document.getElementById('email').select();
		document.getElementById('email').className = 'alert';
		return false;
	}
	
	if(document.getElementById('phone').value == '')
	{
		document.getElementById('phone').focus();
		document.getElementById('phone').className = 'alert';
		return false;
	}*/
	
	/*if(document.getElementById('reasonForVisit').value == '')
	{
		alert("Please complete the field labeled \"Why are you visiting the site today?\"");
		
		//alert(document.getElementById('reasonForVisit').className)
		return false;
	}*/
	
	/*if(document.getElementById('whyDoYouSayThat').value == '')
	{
		alert("Please complete the field labeled \"why\"");
		return false;
	}
	
	
	if(document.getElementById('otherFeaturestoInclude').value == '')
	{
		alert("Please complete the field labeled \"What other information/features could we include on the website to improve it?\"");
		return false;
	}
	
	if(document.getElementById('trainingNeeds').value == '')
	{
		alert("Please complete the field labeled \"Please tell us about any training needs you have that you don't think we address?\"");
		return false;
	}*/
	
	
	/*var hearResult = "";
	hearResult = validateHearBoxes();*/
	
	/*if(hearResult == false)
	{
		alert("Please choose values for \"How did you hear about the Fast Forward website?\"");
		return false;
	}*/
	
	
	
	
	
	//var reasonResult = false;
	
	//reasonResult = validatereasonBoxes();
	/*if(reasonResult == false)
	{
		alert("Please choose values for \"Why are you visiting the site today?" or complete the \"Other\" field");
		return false;
	}*/



if(document.getElementById('visitFrequency').value == "null")
	{
		alert("Please choose a value for \"How often do you visit?\"");
		return false;
	}
	
	if(document.getElementById('satisfactionRating').value == "null")
	{
		alert("Please choose a value for \"Overall, how satisfied are you with the Fast Forward website?\"");
		return false;
	}
	
	if(document.getElementById('designRating').value == "null")
	{
		alert("Please rate \"Overall design and appearance\"");
		return false;
	}
	
	if(document.getElementById('searchRating').value == "null")
	{
		alert("Please rate \"Course Search\" or select \"N/A\" if you did not use this feature");
		return false;
	}
	
	if(document.getElementById('browsingRating').value == "null")
	{
		alert("Please rate \"Ease of browsing the site\"");
		return false;
	}
	
	
	
	/*if(document.getElementById('searchRating').value == "null")
	{
		alert("Please rate \"Ease of browsing the site\"");
		return false;
	}*/
	
	if(document.getElementById('clarityRating').value == "null")
	{
		alert("Please rate \"Clarity of course/training information\" or select \"N/A\" if you did not use this feature");
		return false;
	}
	
	if(document.getElementById('relevanceRating').value == "null")
	{
		alert("Please rate \"Relevance and usefulness of content\"");
		return false;
	}
	
	if(document.getElementById('contactRating').value == "null")
	{
		alert("Please rate \"Contact us\" or select \"N/A\" if you did not use this feature");
		return false;
	}
	
	if(document.getElementById('websiteOverallRating').value == "null")
	{
		alert("Please rate \"Website Overall\"");
		return false;
	}

	if(document.getElementById('name').value == '')
	{
		alert("Please complete the field labeled \"Name\"");
		return false;
	}
	
	if(document.getElementById('jobtitle').value == '')
	{
		alert("Please complete the field labeled \"Job Title\"");
		return false;
	}
	
	if(document.getElementById('organisation').value == '')
	{
		alert("Please complete the field labeled \"Organisation\"");
		return false;
	}
	
	if(document.getElementById('businessSector').value == '')
	{
		alert("Please complete the field labeled \"Business Sector\"");
		return false;
	}
	
	if(document.getElementById('email').value == '')
	{
		alert("Please complete the field labeled \"Email\"");
		return false;
	}
	if(document.getElementById('email').value.indexOf('@') < 0 || document.getElementById('email').value.indexOf('.') < 0)
	{
		alert("Please make sure you enter a valid email address");
		return false;
	}
	
	if(document.getElementById('phone').value == '')
	{
		alert("Please complete the field labeled \"Phone\"");
		return false;
	}
}

function validateHearBoxes()
	{
	var hearBoxes = document.forms["competitionForm"].hear.length;
	var hearSelected = false;
	for (var idx = 0; idx < hearBoxes; idx++) 
	{
		if(eval("document.competitionForm.hear[" + idx + "].checked") != true)
		{
			//alert("Please select some boxes");
			hearSelected = false;
		}
		else
		{
			hearSelected = true;
			break;
		}
	}
	return hearSelected;
	}
	
function validatereasonBoxes()
	{
	var reasonBoxes = document.forms["competitionForm"].reasonForVisit.length;
	var reasonSelected = false;
	for (var idx = 0; idx < reasonBoxes; idx++) 
	{
		if(eval("document.competitionForm.reasonForVisit[" + idx + "].checked") != true)
		{
			reasonSelected = false;
		}
		else if(document.getElementById('other').value == '')
		{
			reasonSelected = false;
		}
		else
		{
			reasonSelected = true;
		}
	}
	return reasonSelected;
	}