﻿// menubar animation
window.addEvent('domready', function(){
	$("trOther").setStyle("visibility", "hidden");
});

function VerifyOther()
{
	if ($("ddlFindUs").SelectedValue() == "Other")
	{
		$("trOther").setStyle("visibility", "visible");
	}
	else
	{
		$("trOther").setStyle("visibility", "hidden");
	}
}

function ShowMap()
{
	mywin =  window.open ("map.html","mywindow","menubar=0,resizable=0,width=550,height=290"); 
}

function Verify()
{
	var valerr = 0;
	var msg = "";
	if ($("txtName").value.clean().length == 0)
	{
		valerr++;
		msg = msg + "Please enter your name.\n";
	}
	if ($("txtEmail").value.clean().length == 0)
	{
		valerr++;
		msg = msg + "Please enter a valid email address.\n";
	}
	if ($("ddlFindUs").SelectedValue().length == 0)
	{
		valerr++;
		msg = msg + "Can you tell us how you found us?\n";
	}
	if (($("ddlFindUs").SelectedValue() == "Other") && ($("txtOther").value.clean().length == 0))
	{
		valerr++;
		msg = msg + "You chose 'Other'. Can you tell us how you found us?.\n";
	}
	if ($("txtComments").value.clean().length == 0)
	{
		valerr++;
		msg = msg + "Please enter your enquiry.\n";
	}
	
	if (valerr > 0)
	{
		alert(msg);
	}
	else
	{
		document.contactform.submit();
	}
}


Element.extend({
	SelectedValue: function() { 
		if (this.nodeName.toLowerCase() == "select") {
			return this.options[this.selectedIndex].value;
		} else {
			return false;	
		}; 
	},
	SelectedLabel: function() {
		if (this.nodeName.toLowerCase() == "select") {
			return this.options[this.selectedIndex].text;
		} else {
			return false;	
		}; 
	},
	cleanWhitespace: function() {
        $A(this.childNodes).each(function(node){
            if ($type(node) == 'whitespace') {
                this.removeChild(node);
            }
        }, this);
        return this;
    }
});

