// avoid jQuery namespace issues with mootools library
jQuery.noConflict();

jQuery(document).ready(function() {
	
	// add pseudo-class functionality
	jQuery('#nav-wrapper #nav ul li:first-child a').addClass('nav-start');
	jQuery('#nav-wrapper #nav ul li:last-child ul').addClass('nav-end');
	//jQuery('#nav-wrapper #nav ul li ul li:first-child a').css('border-left','0');
	jQuery('#footer ul li:last-child').css('border','0');
	
	// ensure all pdf hyperlinks open in new window
	jQuery('a.pdf').attr('rel','external');
	
	// force target="_blank" equivalent
	jQuery('a[rel="external"]').click(function(){
		window.open(this.href);
		return false;
	});
	
	// decrypt mailto hyperlinks
	jQuery('span.mailme').mailme();
	
	// keep nav bar highlighted on dropdown
	/*jQuery('#nav-wrapper #nav ul li ul li a').hover(function () {
		jQuery(this).parents().eq(2).find('a:first').addClass('dropdown-parent-highlight');
	});
	jQuery('#nav-wrapper #nav ul li ul li a').mouseout(function () {
		jQuery(this).parents().eq(2).find('a:first').removeClass('dropdown-parent-highlight');
	});*/

	// Ship Estimate box

	jQuery("#shipestimate").fancybox({
		'scrolling'			: 'no',
		'titleShow'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'onComplete'		: function() {
			jQuery('#dest_zip').focus();
		}
	});
	
	jQuery("form#estimate_form").submit(function(){
		
		if (jQuery("#dest_zip").val().length < 1)
		{
			alert("Please enter Zip Code");
			return false;
		}
		
		jQuery.fancybox.showActivity();
				
		jQuery.ajax({
			type	: "POST",
			cache	: false,
			url		: "/squirrelcart/_estimate_shipping.php",
			data		: jQuery(this).serializeArray(),
			success: function(data) {
				jQuery.fancybox(data);
			}
		});
		
		return false;
	});
	//Esitmate Order Shipping				jQuery("#eos_button").click(function(){					if (jQuery("#eos_zip").val().length < 1)					{						alert("Please enter Zip Code");						return false;					}					jQuery.ajax({						url		:	"/squirrelcart/_estimate_order_shipping.php",						cache	: false,						data	:	{eos_zip:jQuery("#eos_zip").val()},						success: function(data) {								jQuery('#eos_result').html(data);							  }						});				});				jQuery("#eos_button").ajaxStart(function(){					  jQuery('#eos_result').html('<br />&nbsp;&nbsp;<img src="/squirrelcart/themes/phillycase/images/ajax-loader.gif" />');					});
});
