jQuery(document).ready(function($){

	$('ul.sf-menu').superfish( {
		
		animation: { opacity:'show', height:'show' }, 
		speed: 'fast'
			
	});
	
	$("#primetime").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
	$("#home-feature").tabs();
			
	$('div.flickr_badge_image a').attr("target","_blank");
	
	$('#header-signup input:text').each(function() {
		
		//alert($(this).val());
		
		$(this).data("originalValue",$(this).val());
		
		$(this).click(function() {
			
			if($(this).val() == $(this).data("originalValue")) {
				$(this).val('');
			}
			
		});
		
		$(this).blur(function() {
		
			if($(this).val() == '') {
				$(this).val($(this).data("originalValue"));
			}
			
		});
	
	});
	
	if($('#content').height() > $('#sidebar').height()) {
		$('#sidebar').height($('#content').height());
	}
	else {
		$('#content').height($('#sidebar').height());
	}
	
	jQuery.validator.addMethod("postalcode", function(postalcode, element) {
		return this.optional(element) || postalcode.match(/(^\d{5}(-\d{4})?$)|(^[ABCEGHJKLMNPRSTVXYabceghjklmnpstvxy]{1}\d{1}[A-Za-z]{1} ?\d{1}[A-Za-z]{1}\d{1})$/);
	}, "Please specify a valid zip code.");
	
	jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
	    phone_number = phone_number.replace(/\s+/g, ""); 
		return this.optional(element) || phone_number.length > 9 &&
			phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
	}, "Please specify a valid phone number");

	
	$('#volunteerForm').validate({
		
		rules: {
			postalcode: {
				postalcode: true
			}
		}
	
	});
	
	$('#emailForm').validate({
		
		rules: {
			postalcode: {
				postalcode: true
			}
		}
	
	});	
	
	$('#map_wrap').hide();
	
	$("#toggle_map").click(function () {
		$("#map_wrap").slideToggle("slow");
		initialize();
	});
	
	$('#contributeForm').validate({
		
		rules: {
			postalcode: {
				postalcode: true
			}
		}
	
	});
	
	$('#contribute-employment-faq-toggle').click(function() {
	
		$('#contribute-employment-faq').toggle();
	
	});
	

});