
	// Validation for promo competition forms
	
	/*
		NOTE: _errorLabel, _normalLabel function within modules.js file
	*/
	
	function toggleBox(szDivID, iState) // 1 visible, 0 hidden
	{
		if(document.layers) {
		   document.layers[szDivID].display = iState ? "block" : "none";
		} else if(document.getElementById) {
			var obj = document.getElementById(szDivID);
			obj.style.display = iState ? "block" : "none";
		} else if(document.all) {
			document.all[szDivID].style.display = iState ? "block" : "none";
		}
	}
	
	function showErrorMsg()
	{
		var error = document.getElementById('errorMSG');
		error.innerHTML = '<p>Please make sure that the fields highlighted below are correct before submitting:</p>';
	}
	
	function toggleErrorMsg(state)
	{
		if(state=='show') {
			toggleBox('errorMSG',1);
		} else {
			toggleBox('errorMSG',0);
		}
	}
	
	function checkIpodComp()
	{
		var submitForm = true;
		var question1  = document.getElementById('question1').value;
		var question2  = document.getElementById('question2').value;
		var question3  = document.getElementById('question3').value;		
		
		if (question1 == "") {
			submitForm = false;
			_errorLabel('lblQ1');
		} else {
			_normalLabel('lblQ1');
		}
		if (question2 == "") {
			submitForm = false;
			_errorLabel('lblQ2');
		} else {
			_normalLabel('lblQ2');
		}
		if (question3 == "") {
			submitForm = false;
			_errorLabel('lblQ3');
		} else {
			_normalLabel('lblQ3');
		}
		submitForm = _checkStandardDetails();
		
		if (submitForm) {
			toggleErrorMsg('hide');
			return true;
		} else {
			showErrorMsg();
			toggleErrorMsg('show');
			return false;
		}
	}
	
	function _checkStandardDetails()
	{
		var submitForm  = true;
		var personName  = document.getElementById('personName').value;
		var companyName = document.getElementById('companyName').value;
		var email       = document.getElementById('email_address').value;
		var address     = document.getElementById('address').value;
		
		if (personName == "") {
			submitForm = false;
			_errorLabel('lblName');
		} else {
			_normalLabel('lblName');
		}
		if (companyName == "") {
			submitForm = false;
			_errorLabel('lblCompany');
		} else {
			_normalLabel('lblCompany');
		}
		if (email == "" ||  email.indexOf('@') == -1 || email.indexOf('.') == -1) {
			submitForm = false;
			_errorLabel('lblEmail');
		} else {
			_normalLabel('lblEmail');
		}
		if (address == "") {
			submitForm = false;
			_errorLabel('lblAddress');
		} else {
			_normalLabel('lblAddress');
		}
		
		return submitForm;
	}
	
	