// JavaScript Document
var sam;
function get_receipt_no(){
	email_rec=location.href.split("?");

	if (email_rec[1] !=null){
		//rec_terms=email_rec[1].split(",");
		add = email_rec[1];
		document.getElementById("email").setAttribute("value",add);
		//document.getElementById("email_receipt_no").setAttribute("value",rec);
		if (email_rec[2] !=null){
			rec = email_rec[2];	
			document.getElementById("email_receipt_no").setAttribute("value",rec);
			//document.getElementById("email").setAttribute("value",add);
		}
	}
}
//--------------------------------------------------------------------------------------------
function checkForm(form){
var realname;
var email;
  /* Verifies form elements */
	if (form["privacy_statement_read"].checked == false) {
		alert("Please ensure that you have read and \nunderstand the department's Privacy Statement");
		form["privacy_statement_read"].focus();
		return false;
	}
	if (form["security_statement_read"].checked == false) {
		alert("Please ensure that you have read and \nunderstand the department's Security Statement");
		form["security_statement_read"].focus();
		return false;
	}
		if (form["family_name"].value == ""){

		alert("Please enter your family name.");

		form["family_name"].focus();

		form["family_name"].style.backgroundColor="#EBCF5F";

		return false;

	}	

	if (form["given_name"].value == ""){

		alert("Please enter your given name(s).");

		form["given_name"].focus();

		form["given_name"].style.backgroundColor="#EBCF5F";

		return false;

	}

	if ((form["given_name"].value != "") && (form["family_name"].value != "")) {
		
		realname=form["given_name"].value+" "+form["family_name"].value;

		document.getElementById("realnameJS").setAttribute('value',realname);

		document.getElementById("subjectJS").setAttribute('value','GSM post-lodgement enquiry '+realname);

	}
	/*if (form["day"].selectedIndex == 0) {
		alert("Please select your birth day.");
		form["day"].focus();
		form["day"].style.backgroundColor="#EBCF5F";
		return false;
	}
	if (form["month"].selectedIndex == 0) {
		alert("Please select your birth month.");
		form["month"].focus();
		form["month"].style.backgroundColor="#EBCF5F";
		return false;
	}
	if (form["year"].selectedIndex == 0) {
		alert("Please select your birth year.");
		form["year"].focus();
		form["year"].style.backgroundColor="#EBCF5F";
		return false;
	}*/
	if ((form["email_address"].value.indexOf("@")==-1) || (form["email_address"].value.indexOf(".")==-1) || (form["email_address"].value.indexOf(" ")!=-1) || (form["email_address"].value.length<6)) {
		alert("Please enter a valid Email Address.");
		form["email_address"].focus();
		form["email_address"].style.backgroundColor="#EBCF5F";
		return false;
	}
	else {
		email = (form["email_address"].value);
	}
	if (form["day_lodge"].selectedIndex == 0) {
		alert("Please select the day you\nlodged your application.");
		form["day_lodge"].focus();
		form["day_lodge"].style.backgroundColor="#EBCF5F";
		return false;
	}
	if (form["month_lodge"].selectedIndex == 0) {
		alert("Please select the month you\nlodged your application.");
		form["month_lodge"].focus();
		form["month_lodge"].style.backgroundColor="#EBCF5F";
		return false;
	}
		if (form["year_lodge"].selectedIndex == 0) {
		alert("Please select the year you\nlodged your application.");
		form["year_lodge"].focus();
		form["year_lodge"].style.backgroundColor="#EBCF5F";
		return false;
	}
	if((form["clients_authorised_agent_yes"].checked == false) && (form["clients_authorised_agent_no"].checked == false)){
		alert("Please select if you are the client's agent\nor authorised recipient.");
		form["clients_authorised_agent_yes"].focus();
		return false;
	} 

	var enquiry;
	var checkcounter =0;
	for(i=1; i<=13; i=i+1){
		enquiry= "myenquiry"+i;
		if(form[enquiry].checked){
			checkcounter = checkcounter +1;
		}
	}
	if(checkcounter <1){
		alert("You must select at least one topic that your enquiry relates to.");
		form["myenquiry1"].focus();
		return false;
	}
	if((form["myenquiry13"].checked) && (form["additional-info"].value == "")){
		alert("You have selected that your enquiry is about \"Other\"\nPlease enter your enquiry into the Additional Information\ntext field below. (limit 350 words)");
		form["additional-info"].focus();
		form["additional-info"].style.backgroundColor="#EBCF5F";
		return false;
	}
	if (form["additional-info"].value.length >26000) {
		alert("Your message is too large.");
		form["additional-info"].focus();
    return false;
	}
	document.getElementById("realnameJS").setAttribute("value",realname);
	document.getElementById("emailJS").setAttribute("value",email);
	
}




function clearForms()
{
  var i;
  for (i = 0; (i < document.forms.length); i++) {
    document.forms[i].reset();
  }
}

window.onload=function(){
	clearForms();
}
