/*================================  
 Backyard Discovery
  
 Last Updated By: Ryan Perry
 Last Updated: 03/22/2011
================================*/
jQuery.noConflict();
jQuery(document).ready(function(){

/*================================================
 Alt Background Color
================================================*/
/*---- Customer Facing Registered Products ---*/
jQuery('#customer-service .registered-products .product:odd').addClass('alt-bg');

/*---- Customer Facing Product Search Results ----*/
jQuery('#customer-service .results .item:odd').addClass('alt-bg');


/*================================================
 First/Last
================================================*/
/*---- Customer Facing Product Search Results ----*/
jQuery('#customer-service .results .item:first').addClass('first');
jQuery('#customer-service .results .item:last').addClass('last');

/*---- UL/OL ----*/
jQuery('ul li:first-child').addClass('first');
jQuery('ul li:last-child').addClass('last');

/*---- Order Part Line Item ----*/
jQuery('div.parts div.part:last').addClass('last');

/*---- Split Order Line ----*/
jQuery('#container.split-order .parts .line:last').addClass('last');


/*================================================
 File Input Replacement
================================================*/
if(jQuery().filestyle) {
   //Plugin Installed
	jQuery('.respond-status input[type=file]').filestyle({
		image: "images/btn-Browse.png",
		imageheight : 18,
		imagewidth : 74,
		width : 194
	});

	/*---- Adjust Button Postion in IE ----*/
	if (jQuery.browser.msie) {
		jQuery('.respond-status ul.form li.browse div').css({
			'margin-left' : '-10px',
			'width' : '84px',
			'height' : '22px'
		});
	}		
} else {
	//Plugin Not Installed
}


/*================================================
 Hover Fix
================================================*/
jQuery("input[type=button], input[type=submit]").hover(
	function() {jQuery(this).addClass("hover");}, 
	function() {jQuery(this).removeClass("hover");
});

jQuery('#customer-service.library .library-section ul li div.image').hover(
	function() {jQuery(this).addClass("hover");}, 
	function() {jQuery(this).removeClass("hover");
});


jQuery('#customer-service.library .library-section h2').hover(
	function() {jQuery(this).addClass("hover");}, 
	function() {jQuery(this).removeClass("hover");
});


/*================================================
 Split Order Backorder Checkbox Position
================================================*/
jQuery('#container.split-order .parts .line .item').each(function(idx) {
	/*---- Height of Part Item Content ----*/
	var $lineHT = jQuery(this).height();
	
	/*---- Adjusting the Backorder Checkbox to be Vertically Center to the Line Item ----*/	
	jQuery(this).closest('.line').children('.backorder').children('input').css({'top' : $lineHT / 2});
	
});


/*================================================
 Master Queue Table
================================================*/
/*---- First Row of Table Data ----*/
jQuery('#container.queue table.master-queue tr:eq(1)').addClass('first');

/*---- Alternating Background Color ----*/
jQuery('#container.queue table.master-queue tr:even').addClass('alt-bg');


/*================================================
 Add Custom Part
================================================*/
/*---- Adjusting Column Heights so they Match ----*/
var $addInfoHT = jQuery('#container.custom-part .add-part .info').height();
var $addDescHT = jQuery('#container.custom-part .add-part .description').height();

if($addInfoHT > $addDescHT) {
	jQuery('#container.custom-part .add-part .description').height($addInfoHT);
}else {
	jQuery('#container.custom-part .add-part .info').height($addDescHT);
}


/*================================================
 Manuals Library
================================================*/
jQuery('#customer-service.library .my-products ul li:odd').addClass('alt-bg');
jQuery('#customer-service.library .library-section div.toggle-content  div.toggle-row:nth-child(even)').addClass('alt-bg');

/*
var $esButtonWidth = jQuery('#customer-service.library .library-section ul li div.download a.es-addendum').width();
jQuery('#customer-service.library .library-section ul li div.download a.manual').width($esButtonWidth);
jQuery('#customer-service.library .library-section ul li div.download a.addendum').width($esButtonWidth);
jQuery('#customer-service.library .library-section ul li div.download a.es-manual').width($esButtonWidth);
*/

/*---- Library Toggle ----*/
jQuery('#customer-service.library .library-section h2').click(function(){
	jQuery(this).toggleClass('active').next('.toggle-content').slideToggle(500);
});

/*---- Scroll To Top ----*/
jQuery('#customer-service.library .library-section div.toggle-content div.toggle-row:last-child').append('<span class="scroll-link">Back to Top</span>');

jQuery('#customer-service span.scroll-link').live("click", function() {
	jQuery('html, body').animate({scrollTop:jQuery('#customer-service').offset().top}, 2000);	
});

jQuery('#customer-service.library .library-section span.scroll-link').hover(
	function() {jQuery(this).addClass("hover");}, 
	function() {jQuery(this).removeClass("hover");
});


/*================================================
 Part Search Results
================================================*/
jQuery('#customer-service .results .item .info ul li.buttons input[disabled="disabled"]').addClass('disabled');
jQuery('#customer-service .results .item .info ul li.buttons input[enabled="enabled"]').removeClass('disabled');




});

