function $(id)
{
	return document.getElementById(id);
}

function toggle(id)
{
	$(id).style.display = $(id).style.display=='none'?"block":"none";
}

function testEmail(src) {
     var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
     var regex = new RegExp(emailReg);
     return regex.test(src);
}

function validateContactForm()
{
	var errMsg = "";
	with( document.contactUsForm )
	{
		if( contactName.value.length < 3 ) errMsg += "\r\nPlease enter your name.";
		if( contactEmail.value.length < 3 ) errMsg += "\r\nPlease enter your email address.";
		else if( !testEmail( contactEmail.value ) ) errMsg += "\r\nYour email address is invalid.";
		if( contactPhone.value.length < 3 ) errMsg += "\r\nPlease enter your phone number.";
		if( yourEnquiry.value.length < 3 ) errMsg += "\r\nPlease provide a message.";
	}
	if( errMsg.length )
	{
		alert( "Missing some required information:\r\n" + errMsg );
		return false;
	}
	document.contactUsForm.action = "index.cfm";
	return true;
}

function bookmark()
{
	if (window.external) { window.external.AddFavorite(location.href, document.title); }
	else if (navigator.appName == "Netscape") {
    	window.sidebar.addPanel(title,url,"");
  	} else {
    	alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
  	}
}

function winBRopen(theURL, Name, scroll)
{
   var is_mac = navigator.userAgent.toLowerCase().indexOf("mac")!=-1;

   if(is_mac)
   {
      var popW = "407";
      var popH = "510";
   } else {
      var popW = "407";
      var popH = "510";
   } 
   var winleft = (screen.width - popW) / 2;
   var winUp = (screen.height - popH)/ 3;
   
   winProp = 'width='+popW+',height='+popH+',left='+winleft+',top='+winUp+',scrollbars='+scroll+',resizable=no, status=no, toolbar=no,location=no, menubar=no, scrollbars=no'
   Win = window.open(theURL, Name, winProp)
   if (parseInt(navigator.appVersion) >= 4) { Win.window.focus(); }
}