function openTerms()
{
	newwin = window.open("http://www.greencrossaustralia.org/terms-and-conditions.aspx","terms","width=405,height=400,scrollbars=yes");
}

function openPrivacy()
{
	newwin = window.open("http://www.greencrossaustralia.org/privacy-policy.aspx","terms","width=405,height=400,scrollbars=yes");
}

function securityCodeSample()
{
	newwin = window.open("/securitycode.html","terms","width=300,height=230,scrollbars=no");
}

function navOver(imgName)
{
	var theImage = document.getElementById(imgName);
	
	if(theImage.src.indexOf("_off.gif") != -1)
	{
		theImage.src = theImage.src.replace("_off.gif","_on.gif");
	}
	
	else
	{
		theImage.src = theImage.src.replace("_on.gif","_off.gif");
	}
}

function getWindowWidth() 
{
	var windowWidth = 0;
	
	if (typeof(window.innerWidth) == 'number') 
	{		
		windowWidth = window.innerWidth;				
		
		theDiv = document.getElementById("mainContainer");
		theWidth = theDiv.offsetLeft * 2 + theDiv.offsetWidth;

		if(window.innerWidth > theWidth)
		{
		  windowWidth = theWidth;
		}  
	}
	else 
	{
		if (document.documentElement && document.documentElement.clientWidth) 
		{		
			windowWidth = document.documentElement.clientWidth;
		}
		
		else 
		{
			if (document.body && document.body.clientWidth) 
			{
				windowWidth = document.body.clientWidth;
			}
		}
	}
	
	return windowWidth;
}


function displayMenu(menuId)
{
	document.getElementById(menuId).style.visibility = "visible";
}

function hideMenu(menuId)
{
	document.getElementById(menuId).style.visibility = "hidden";
}

function changeBorder(id)
{		
	document.getElementById(id).style.borderColor = "#000000";											
}
function resetBorder(id)
{		
	document.getElementById(id).style.borderColor = "#999999";									
}	


function setFrequency(selection)
{
	if(selection == "once")
	{
		document.getElementById("frequencyOption1").innerHTML = "$30";
		document.getElementById("frequencyOption2").innerHTML = "$50";
		document.getElementById("frequencyOption3").innerHTML = "$100";
		document.getElementById("frequencyOption4").innerHTML = "Other";
	}
	else if (selection == "monthly")								
	{
		document.getElementById("frequencyOption1").innerHTML = "$30 / mth";
		document.getElementById("frequencyOption2").innerHTML = "$50 / mth";
		document.getElementById("frequencyOption3").innerHTML = "$100 / mth";
		document.getElementById("frequencyOption4").innerHTML = "Other / mth";								
	}
}

	
var viewTypes = new Array;
viewTypes[0]='htmlCode';
viewTypes[1]='htmlVersion';
viewTypes[2]='textCode';

function displayOption(option)
{
	var storeOption = option;
	var profileId = document.getElementById(option);
	profileId.style.display = "block";
	
	for(i=0;i<viewTypes.length;i++)
	{								
		if (viewTypes[i] != storeOption)
		{
			var tempId = document.getElementById(viewTypes[i]);			
			tempId.style.display = "none";
		}
	}
}  

function validateNominationForm(theForm)
{
	contactNumber = false;
	valid = true;
	message = "Please enter the following sections before proceeding:\n\n";
	
	if(theForm.elements["ddlTitle"].value == "")
	{
		message += "- your title\n";	
		valid = false;
	}

	if(theForm.elements["txtFirstName"].value == "")
	{
		message += "- your first name\n";
		valid = false
	}

	if(theForm.elements["txtSurname"].value == "")
	{
		message += "- your surname\n";
		valid = false
	}
	
	if(theForm.elements["txtAddress"].value == "")
	{
		message += "- your residential address\n";
		valid = false
	}

	if(theForm.elements["txtSuburb"].value == "")
	{
		message += "- your suburb\n";
		valid = false
	}	
	
	if(theForm.elements["ddlState"].value == "")
	{
		message += "- your state\n";
		valid = false
	}

	if(theForm.elements["txtPostcode"].value == "")
	{
		message += "- your postcode\n";
		valid = false
	}
	
	if (
		(theForm.elements["txtHomePhoneNumber"].value == "") && 
		(theForm.elements["txtMobilePhoneNumber"].value == "") && 
		(theForm.elements["txtWorkPhoneNumber"].value == "")
		)
	{
		message += "- please enter at least 2 contact numbers\n";
		valid = false
	}
	else 	if 
	(
		(theForm.elements["txtHomePhoneNumber"].value != "") && 
		(theForm.elements["txtMobilePhoneNumber"].value == "") && 
		(theForm.elements["txtWorkPhoneNumber"].value == "")
	)
	{
		message += "- please enter at least 2 contact numbers\n";
		valid = false
	}
	else 	if 
	(
		(theForm.elements["txtHomePhoneNumber"].value == "") && 
		(theForm.elements["txtMobilePhoneNumber"].value != "") && 
		(theForm.elements["txtWorkPhoneNumber"].value == "")
	)
	{
		message += "- please enter at least 2 contact numbers\n";
		valid = false
	}
	else 	if 
	(
		(theForm.elements["txtHomePhoneNumber"].value == "") && 
		(theForm.elements["txtMobilePhoneNumber"].value == "") && 
		(theForm.elements["txtWorkPhoneNumber"].value != "")
	)
	{
		message += "- please enter at least 2 contact numbers\n";
		valid = false
	}
	
	if(theForm.elements["txtEmailAddress"].value == "")
	{
		message += "- your email address\n";
		valid = false
	}	
		
	if(theForm.elements["txtEmailAddress"].value != "")	
	{	
		var supEmail = theForm.elements["txtEmailAddress"].value;
		var emLen = supEmail.length;
		var posAt = supEmail.indexOf('@')
		var posDot = supEmail.lastIndexOf('.')
		if((emLen < 7) || (posAt < 1) || (posDot <= (posAt + 1)) || (posDot >= (emLen - 1)))
		{
			message += "- valid email address\n";
			valid = false;
		}
	}	
	
	if(theForm.elements["txtAge"].value == "")
	{
		message += "- your age at 26th January 2008\n";
		valid = false
	}	
	
	if(theForm.elements["txtPlaceOfBirth"].value == "")
	{
		message += "- your place of birth\n";
		valid = false
	}		
	
	if(
		(document.getElementById("rdMale").checked == false) && 
		(document.getElementById("rdFemale").checked == false)
		) 
	{
		message += "- your gender\n";
		valid = false	
	}	
	
	if(
		(document.getElementById("rdHighSchool").checked == false) && 
		(document.getElementById("rdCollege").checked == false) && 
		(document.getElementById("rdDegree").checked == false)
		) 
	{
		message += "- your education level\n";
		valid = false
	}			
	
	if(document.getElementById("chkConfirmAvailability").checked == false)
	{
		message += "- confirm your availability\n";
		valid = false
	}				
	
	if(theForm.elements["txtWhyIsThisImportant"].value == "")
	{
		message += "- please state why this issue is important to you\n";
		valid = false
	}			

	if(theForm.elements["txtRefereeOneName"].value == "")
	{
		message += "- referee one name\n";
		valid = false
	}			
	
	if(theForm.elements["txtRefereeOneNumber"].value == "")
	{
		message += "- referee one contact number\n";
		valid = false
	}				
	
	if(theForm.elements["txtRefereeTwoName"].value == "")
	{
		message += "- referee two name\n";
		valid = false
	}			
	
	if(theForm.elements["txtRefereeTwoNumber"].value == "")
	{
		message += "- referee two contact number\n";
		valid = false
	}				

	if(document.getElementById("chkIHaveRead").checked == false)
	{
		message += "- indicate you have read and accept the criteria and conditions for participation\n";
		valid = false
	}			
	
	if(valid)
	{			
		return true;
	}
	else
	{		
		alert(message);
		return false;
	}
}

