
$(document).ready(function(){

	// lightbox
	$('a[rel^=lightbox]').lightBox();

	// form validation configured in key value pairs
	$('#contact_form').validate({
		rules: {
			Name: "required",
			Email_Address: {
				required: true,
				email: true
			},
			Phone_Number: "required"
		},
		messages: {
			Name: "Please specify your name",
			Email_Address: {
				required: "Please specify your email address",
				email: "Your email address must be in the format of name@domain.com"
			},
			Phone_Number: "Please specify your phone number"
		}
	});
	
	$('#nav1 li').each(function() {
		$(this).mouseenter(function() {
			$(this).children('div.dropdown').fadeIn(200);
		});
		$(this).mouseleave(function() {
			$(this).children('div.dropdown').fadeOut(100);
		});
	});	
	
	$('#nav2 li').each(function() {
		$(this).mouseenter(function() {
			$(this).children('div.dropdown').fadeIn(200);
		});
		$(this).mouseleave(function() {
			$(this).children('div.dropdown').fadeOut(100);
		});
	});		

});

function jsNameHack( objField, str ) {
	if( objField.value == str ) {
		objField.value = "";
	} else if( objField.value == "" ) {
		objField.value = str;
	}
}

function jsSearchForm() {
	if( document.search_form.q.value == "" ) {
		alert("Please enter what you'd like to search for");
		document.search_form.q.focus();
		return;
	}
	document.search_form.submit();
}

function jsNewsletterForm() {
	if( document.newsletter_form.email_address.value == "" || document.newsletter_form.email_address.value == "enter your email address" ) {
		alert("Please enter your email address");
		document.newsletter_form.email_address.focus();
		return;
	}
	document.newsletter_form.submit();
}

function submitForm(frm, l) {

	if (l) {
	
		var radioObj = frm.elements['location'];

		if (radioObj) {

			var radioLength = radioObj.length;
			
			if (radioLength != undefined) {			
				for (var i = 0; i < radioLength; i++) {
				
					radioObj[i].checked = false;
					
					if (radioObj[i].value == l.toString()) {
						radioObj[i].checked = true;
					}
				}
			}
		}
	
		frm.elements['location'].value = l;
		
	}
	frm.submit();
}




