function setupNavigation()
{
//	var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
//	if (!IE6)
		$$('#navigation-main a').addEvents({'mouseover': function () {setNav(this);} });
}

function setNav(obj)
{
	obj = $(obj);
	var subMenu = $('navigation-sub-'+obj.getParent().id);

	$$('ul.subnav').setStyles({'position':'absolute','left':'-9000em'});

	subMenu.setStyles({'position':'relative', 'left': '0em'});
}

function validateForm()
{
	var fields = ['FirstName', 'LastName', 'Address', 'City', 'State', 'ZipCode', 'PhoneNumber'];
	var errorFound = false;
	for (var x=0; x < fields.length; x++)
	{
		var field = document.getElementById(fields[x]);
		field.className = field.className.replace(/[ ]?formError/g, '');
		if (field.value.length == 0)
		{
			field.className += ' error';
			errorFound = true;
		}
	}
	
	var email = document.getElementById('Email');
	email.className = email.className.replace(/[ ]?formError/g, '');
	if (email.value.match(/[^@]+[@][^.]+\.[^.]+/) == null)
	{
		email.className += ' error';	
		errorFound = true;
	}

	if (errorFound)
	{
		document.getElementById('errMsg').className = '';
	}
	
	return !errorFound;
}
var directionsUsabilityText = 'Please enter an address';
function addressChanged()
{
	var selectBox = document.getElementById('from');
	var textBox = document.getElementById('textfield');
	if (selectBox == null || textBox == null)
		return;
	
	if (selectBox.value == '')
	{
		textBox.className = 'usability';
		textBox.value = directionsUsabilityText;
	}
	else
	{
		textBox.className = 'hide';
		textBox.value = '';
	}
}

function enterTextbox()
{
	var textBox = document.getElementById('textfield');
	textBox.className = '';
	if (textBox.value == directionsUsabilityText)
		textBox.value = '';
}

function exitTextbox()
{
	var textBox = document.getElementById('textfield');
	if (textBox.value == '')
	{
		textBox.value = directionsUsabilityText;
		textBox.className = 'usability';
	}
}

/* attach function to onload */
function addLoadListener(fn)
{
  if (typeof window.addEventListener != 'undefined') {
    window.addEventListener('load', fn, false);
  } else if (typeof document.addEventListener != 'undefined') {
    document.addEventListener('load', fn, false);
  } else if (typeof window.attachEvent != 'undefined') {
    window.attachEvent('onload', fn);
  } else {
    var oldfn = window.onload;
    if (typeof window.onload != 'function') {
      window.onload = fn;
    } else {
      window.onload = function() {
        oldfn();
        fn();
      };
    }
  }
}

window.addEvent('load', setupNavigation);
