$(document).ready(function(){
	$(".watch").fancybox();
	$("[id^=embedded]").hide()
	$("a[href$=pdf]").attr('target', '_blank');
	if($("#menu")) {
		$("#menu dd").hide();		
		$("dt a").prepend('<img src="/images/arrow.gif" alt="" class="arrow" />');
		$(".toplevel a").click(function() {
			if(this.className.indexOf("clicked") != -1) {
				$(this).parent().next().slideUp(200);
				$(this).removeClass("clicked");
			}
			else {
				$(this).addClass("clicked");
				
				$(this).parent().next().slideDown(500);
			}
			return false;
		});
	}
	// Place ID's of all required fields here. If using ID's other than #email, #cardnum, or #card_brand, replace them here
	required = ["Name", "email"];
	errornotice = $("#error");
			
	$("#quick").submit(function(){	
		email = $("#email");
		
		//Validate required fields
		for (i=0;i<required.length;i++) {
			var input = $('#'+required[i]);
			if ((input.val() == "") || (input.val() == "Please fill out this field")) {
				input.addClass("needsfilled");
				input.val("Please fill out this field");
				errornotice.slideDown(750);
			} else {input.removeClass("needsfilled");}
		}
		// Validate the e-mail.
		if (!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(email.val())) {
			email.addClass("needsfilled");
			email.val("Please enter a valid e-mail.");
		}
		//if any inputs on the page have the class 'needsfilled' the form will not submit
		if ($(":input").hasClass("needsfilled")) {
			return false;
		} else {
			errornotice.hide();
			return true;
		}
	});
	
	// Clears any fields in the form when the user clicks on them
	$(":input").click(function(){		
	   if ($(this).hasClass("needsfilled") ) {
			$(this).val("");
	   }
	});

});

