<!--

function SubmitFeedback(){
	var intErrors = 0;
	var strErrors = "Sorry, your feedback could not be sent for the following reasons:\n\n";

	SetFieldBackgroundColour("feedback");

	/* Phone, Email are only mandatory depending on the contact method chosen */
	if(document.frm.selContactMethod.options[document.frm.selContactMethod.selectedIndex].value == "Phone"){
		if(Trim(document.frm.txtPhone.value).length == 0){
			intErrors++;
			strErrors+= intErrors +") Please enter your phone number\n";
			document.frm.txtPhone.style.backgroundColor = "#eeeeee";
		}
	}
	else
	if(document.frm.selContactMethod.options[document.frm.selContactMethod.selectedIndex].value == "Email"){
		if(!IsValidEmail(document.frm.txtEmail.value)){
			intErrors++;
			strErrors+= intErrors +") Please enter a valid email address\n";
			document.frm.txtEmail.style.backgroundColor = "#eeeeee";
		}
	}

	if(Trim(document.frm.txtFeedback.value).length == 0){
		intErrors++;
		strErrors+= intErrors +") Please enter feedback detail\n";
		document.frm.txtFeedback.style.backgroundColor = "#eeeeee";
	}
	
	if (ScriptTags("feedback")) {
		var openScriptTag="\<\%";
		intErrors++;
		strErrors+= intErrors +") The string " + openScriptTag + " must not be present in any input data\n";
	}
	
	if(0 == intErrors){
		document.frm.IsPostBack.value = "1";
		document.frm.ft.value = getQueryVariable("f");
		document.frm.submit();
	} else {
		alert(strErrors);
	}

	//alert("end SubmitFeedback");	
}

function SubmitEnquiry(){
	var intErrors = 0;
	var strErrors = "Sorry, your enquiry could not be sent for the following reasons:\n\n";

	SetFieldBackgroundColour("enquiry");
	
	if(document.frm.txtFullName.value == "")
	{
		intErrors++;
		strErrors+= intErrors +") Please enter your full name\n";
		document.frm.txtFullName.style.backgroundColor = "#eeeeee";
	}	

	/* Phone, Email are only mandatory depending on the contact method chosen */
	if(document.frm.selContactMethod.options[document.frm.selContactMethod.selectedIndex].value == "")
	{
		intErrors++;
		strErrors+= intErrors +") Please select your preferred contact method\n";
		document.frm.selContactMethod.style.backgroundColor = "#eeeeee";
	}
	else	
	if(document.frm.selContactMethod.options[document.frm.selContactMethod.selectedIndex].value == "Phone"){
		if(Trim(document.frm.txtPhone.value).length == 0){
			intErrors++;
			strErrors+= intErrors +") Please enter your phone number\n";
			document.frm.txtPhone.style.backgroundColor = "#eeeeee";
		}
	}
	else
	if(document.frm.selContactMethod.options[document.frm.selContactMethod.selectedIndex].value == "Email"){
		if(!IsValidEmail(document.frm.txtEmail.value)){
			intErrors++;
			strErrors+= intErrors +") Please enter a valid email address\n";
			document.frm.txtEmail.style.backgroundColor = "#eeeeee";
		}
	}

	if(document.frm.selEnquiryType.options[document.frm.selEnquiryType.selectedIndex].value == ""){
		intErrors++;
		strErrors+= intErrors +") Please select an enquiry type\n";
		document.frm.selEnquiryType.style.backgroundColor = "#eeeeee";
	}
	
	if(document.frm.selEnquiryType.value == "Staff"){
		if(document.frm.selStaff.value.length == 0){
			intErrors++;
			strErrors+= intErrors +") Please select a staff member\n";
			document.frm.selStaff.style.backgroundColor = "#eeeeee";
		}
	}	

	if(Trim(document.frm.txtEnquiry.value).length == 0){
		intErrors++;
		strErrors+= intErrors +") Please enter enquiry detail\n";
		document.frm.txtEnquiry.style.backgroundColor = "#eeeeee";
	}
	
	if (ScriptTags("enquiry")) {
		var openScriptTag="\<\%";
		intErrors++;
		strErrors+= intErrors +") The string " + openScriptTag + " must not be present in any input data\n";
	}
	
	if(0 == intErrors){
		document.frm.IsPostBack.value = "1";
		document.frm.ft.value = getQueryVariable("f");
		document.frm.submit();
	} else {
		alert(strErrors);
	}	

	//alert("end SubmitEnquiry");	
}

function SubmitFeedback2(){
	var intErrors = 0;

        //alert("test");
	
        var rad_val = "";
        for (var i=0; i < document.frm.radWeb.length; i++)
        {
                if (document.frm.radWeb[i].checked)
                {
                        rad_val = document.frm.radWeb[i].value;
                }
        }
	
        var rad_val2 = "";
        for (var i=0; i < document.frm.radQR.length; i++)
        {
                if (document.frm.radQR[i].checked)
                {
                        rad_val2 = document.frm.radQR[i].value;
                }
        }

        if ((rad_val == "No Comment") && (rad_val2 == "No Comment") && Trim(document.frm.txtFeedback.value).length == 0)
	{
		intErrors++;
                strErrors = "Sorry, you have provided no feedback\n";		
	}
	else
	{
	        re=/^(.|\n)*(\<\%)(.|\n)*$/
	        if (re.test(Trim(document.frm.txtFeedback.value)))
                {
		        var openScriptTag="\<\%";
		        intErrors++;
		        strErrors = "The string " + openScriptTag + " must not be present in the comments field\n";
	        }
	}		
	
	if(0 == intErrors){
		document.frm.IsPostBack.value = "1";
		//document.frm.ft.value = getQueryVariable("f");
		document.frm.submit();
		//alert("data OK");
	} else {
		alert(strErrors);
	}
}

function SetFieldBackgroundColour(formType)
{
        if (formType == "feedback")
        {
	        document.frm.txtEmail.style.backgroundColor = "#ffffff";
	        document.frm.txtPhone.style.backgroundColor = "#ffffff";
	        document.frm.txtFeedback.style.backgroundColor = "#ffffff";
	}
	else
        if (formType == "enquiry")
        {
                document.frm.txtFullName.style.backgroundColor = "#ffffff";
	        document.frm.txtEmail.style.backgroundColor = "#ffffff";
	        document.frm.txtPhone.style.backgroundColor = "#ffffff";
	        document.frm.selEnquiryType.style.backgroundColor = "#ffffff";
	        //document.frm.selStaff.style.backgroundColor = "#ffffff";	        
	        document.frm.txtEnquiry.style.backgroundColor = "#ffffff";
	}	 
}

function ScriptTags(formType)
{
// Check for opening script tag anywhere in fields where text in inputted (not selected)
	re=/^(.|\n)*(\<\%)(.|\n)*$/
	if (formType == "feedback")
        {
	        if ((re.test(Trim(document.frm.txtFullName.value))) ||
	            (re.test(Trim(document.frm.txtEmail.value))) ||
	            (re.test(Trim(document.frm.txtPhone.value))) ||
	            (re.test(Trim(document.frm.txtReferral.value))) ||
	            (re.test(Trim(document.frm.txtFeedback.value))))
		        return true;
	        else
		        return false;
	}
	else
	if (formType == "enquiry")
        {
	        if ((re.test(Trim(document.frm.txtFullName.value))) ||
	            (re.test(Trim(document.frm.txtEmail.value))) ||
	            (re.test(Trim(document.frm.txtPhone.value))) ||
	            (re.test(Trim(document.frm.txtEnquiry.value))))
		        return true;
	        else
		        return false;
	}	
}

function ShowHideOther(field)
{
        //alert("1");
	// Show or hide 'Staff Member' field
	if (field == 'sm')
	{
		var objSpan = document.getElementById("selStaff");
		//alert("2");
	
		if(document.frm.selEnquiryType.value == "Staff"){
		        //objSpan.style.display = "block";
			objSpan.style.visibility = "visible";
			objSpan.style.backgroundColor = "#eeeeee";
			//alert("3a");
		} else {
		        //objSpan.style.display = "none";
			objSpan.style.visibility = "hidden";
			//alert("3b");
		}
		//alert("4");
	}

	objSpan = null;
}

function Set_Contact_Mandatory_field()
{
	document.frm.txtPhone.style.backgroundColor = "#ffffff";
	document.frm.txtEmail.style.backgroundColor = "#ffffff";

	if(document.frm.selContactMethod.options[document.frm.selContactMethod.selectedIndex].value == "Phone"){
		document.frm.txtPhone.style.backgroundColor = "#eeeeee";
	}
	else
	if(document.frm.selContactMethod.options[document.frm.selContactMethod.selectedIndex].value == "Email"){
		document.frm.txtEmail.style.backgroundColor = "#eeeeee";
	}
}

function getQueryVariable(variable) 
{
	var query = window.location.search.substring(1);
	var pair = query.split("=");
	if (pair[0] == variable) 
	{
		//alert (pair[1]);
		return pair[1];
	}
	else
		return "";
}

// -->