//stewarts.js

$(function () {
			
	//Configure Subnav links to work onClick (they don't work as regular links because of the tabs plugin used)

    $('#agri').click(function () {
        $(this).children('a').attr('href', '/equipment/agriculture');
    });

    $('#construction').click(function () {
        $(this).children('a').attr('href', '/equipment/construction');
    });

    $('#commercial').click(function () {
        $(this).children('a').attr('href', '/equipment/commercial');
    });

    $('#homeowner').click(function () {
        $(this).children('a').attr('href', '/equipment/homeowner');
    });

    $('#recreational').click(function () {
        $(this).children('a').attr('href', '/equipment/recreational');
    });

    $('#golf').click(function () {
        $(this).children('a').attr('href', '/equipment/golf');
    });

    $('#snow').click(function () {
        $(this).children('a').attr('href', '/equipment/snow');
    });

    //Subnav hover effect:

    $('#tabs li').hover(function () {
        $(this).children('.subnav-no-hover').css('display', 'none');

    }, function () {
        $(this).children('.subnav-no-hover').css('display', 'block');
    });

	//Map shadows delay until page load

    $('.map-frame').load(function () {
        $('.google-map-shadow').css('display', 'block');
    });


	//Product Cell Formatting

    $('div.pro_row1 > div:nth-child(3n)').addClass("last-cell");
	$('div.pro_row1 > div:nth-child(3n)').after('<div class="divider"></div>');
	
	//See All button for equip display

	$('div.pro_row1 > div:nth-child(7)').nextAll().css('display', 'none');
	
	$('a.see-all').click(function() {
		$(this).css('display', 'none');
		$(this).prev('div.pro_row_outer').find('div.pro_row1 > div:nth-child(7)').nextAll().fadeIn('slow');
	});
	
	//eliminate bottom border on last post in what's new
	
	$('.post:last').css('border-bottom', 'none');
	
	
	//Custom select boxes
	
	$('option').append('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');

	(function($){
	 $.fn.extend({
 
 	customStyle : function(options) {
	  if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
	  return this.each(function() {
	  
			var currentSelected = $(this).find(':selected');
			$(this).after('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">'+currentSelected.text()+'</span></span>').css({position:'absolute', opacity:0,fontSize:$(this).next().css('font-size')});
			var selectBoxSpan = $(this).next();
			var selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));			
			var selectBoxSpanInner = selectBoxSpan.find(':first-child');
			selectBoxSpan.css({display:'inline-block'});
			selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
			var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
			/*$(this).height(selectBoxHeight).change(function(){
				selectBoxSpanInner.text($(this).val()).parent().addClass('changed');
			});*/
			
	  });
	  }
	}
 });
})(jQuery);


$(function(){

$('select.styled').customStyle();
$('select.select').css('display', 'block');
$('select.select').css('height', '30px');
$('select.select').css('margin-top', '7px');

});
	
});





