Cufon.replace('.formheader',{fontFamily:'Myriad Pro'}).replace('h2',{fontFamily:'Myriad Pro'}).replace('h1',{fontFamily:'Chaparral Pro'});
Cufon.now();

$(document).ready(function() {
	$('#navigation a.active').parents('ul:first').show();
	
//worldwide
	$("#worldwide").bind("mouseenter", function() {
		$("#worldwideexpanded").fadeIn("fast");
	});
	
	$("#worldwideexpanded").bind("mouseleave", function() {
		$("#worldwideexpanded").fadeOut("fast");
	});

// Search label text to input and button image rollover											 
	var searchLabel = $('#ttp-search label').remove().text();
	$('#qt').addClass('placeholder').val(searchLabel).focus(function() {
			if(this.value == searchLabel) {
				$(this).removeClass('placeholder').val('');
			};
		}).blur(function() {
			if(this.value == '') {
				$(this).addClass('placeholder').val(searchLabel);
			}
		});
	$('#ttp-search').submit(function() {
		if($('#qt').val() == searchLabel) {
			$('#qt').val('');
		}
	 });
// end Search enhancements



// Email a Friend thickbox
	$("a[rel='email-page']").each(function(){
		var thickbox_href = "?TB_iframe=true&height=450&width=360";
		var this_href = $(this).attr("href");
		$(this).attr('href', this_href + thickbox_href);
	});
	
// Video thickbox
	$("a[rel='video']").each(function(){
		var thickbox_href = "?TB_iframe=true&height=360&width=550";
		var this_href = $(this).attr("href");
		$(this).attr('href', this_href + thickbox_href);
	});

// Video promo thickbox
	$("div.promo a.thickbox[rel!='external']").each(function(){
		var thickbox_href = "?TB_iframe=true&height=360&width=550";
		var this_href = $(this).attr("href");
		$(this).attr('href', this_href + thickbox_href);
	});


// Print page
	//remove link to print-this-page.html, which remains if javascript is disabled
	//must repopulate href with location.href for IE
	$('#print, #print-button').click(function() {
		$(this).attr("href",location.href);	
		window.print();
		return false;
	});

// end Print page

	
// Form Validation

	$("form :input").blur(function() {
 		$(this).parents('li:first').removeClass('warning');
		
		if ($(this).is('.required')) {
 			var $listItem = $(this).parents('li:first');
 			if (this.value == '') {
 			$listItem.addClass('warning');
 			};
 		};
 		if ($(this).is('.email')) {
 			var $listItem = $(this).parents('li:first');
 			if (this.value != '' && !/.+@.+\.[a-zA-Z]{2,4}$/.test(this.value)) {
 			$listItem.addClass('warning');
 			};
 		};
 		if ($(this).is('.zip')) {
 			var $listItem = $(this).parents('li:first');
 			if (this.value != '' && !/^\d{5}([\-]\d{4})?$/.test(this.value)) {
 			$listItem.addClass('warning');
 			};
 		};
	});
	
	$("form").submit(function() {
		 $('#submit-message').remove();
		 $(':input.required').trigger('blur');
		 
	// Call local validation
		 
		localValidation();
		
		 var numWarnings = $('.warning', this).length;
		 if (numWarnings) {
			 var fieldList = [];
			 $('.warning label').each(function() {
				fieldList.push($(this).text());
			  });
		 $('<div></div>').attr({'id': 'submit-message', 'class': 'warning'})
		 .append('<strong>Please correct errors with the following ' + numWarnings + ' fields:</strong><br />')
		 .append('&bull; ' + fieldList.join('<br />&bull; '))
		 .insertBefore('#submit');
		 return false;
		 };							 
	});

// end Form Validation
	
}); // end document.ready	
