// JavaScript Document
//Listing
$(document).ready(function () {
    $("ul li:nth-child(odd)").addClass('odd');
    $("ul li:nth-child(even)").addClass('even');
    $('li:first-child').addClass('first_item');
    $('li:last-child').addClass('last_item');
    $('.brands_listing li:nth-child(4n)').addClass('fourth_item');
    $('.clearfix').parent().append('<div class="clear"></div>'); //apply jquery clearfix
    $('.clearafter').after('<div class="clear"></div>'); //apply jquery clearfix
    $('.contentbox li:nth-child(5n)').addClass('fifth-child');
    $('.picture-gallery li:nth-child(3n)').addClass('third-child');
    $(".contact-form li:nth-child(even)").addClass('even');
    $(".contact-form li:last-child").addClass('last-child');
    equalHeight($(".contentbox li"));
    equalHeight($("ul.retail_listing li "));
    equalHeight($("ul.retail_listing li p"));
    equalHeight($(".sub_right_pane, .sub_left_pane"));
    equalHeight($(".add-bottom"));

    //Secondary Navigation Background Effect

    $('ul.secondary_nav li a').hover(function () {
        $(this).parent().find('div').find('span').animate({ left: '-50px' }, { queue: false, duration: 300 });
    }, function () {
        $(this).parent().find('div').find('span').animate({ left: '4px' }, { queue: false, duration: 300 });
    });
    //menu dropdown functions
    $('ul.nav>li').hover(function () {
        //var dropWidth = ($(this).children('ul.submenu').width()/2);
        //$(this).children('ul.submenu').css('margin-left', dropWidth);
        $(this).addClass('hover');
        $(this).children('div.submenu').slideDown(100);
    }, function () {
        $(this).removeClass('hover');
        $(this).children('div.submenu').fadeOut(100);
    });
    /*$(".offer_box").easySlider({
        continuous: true,
        auto: true,
        controlsShow: false
    });*/
	$(".slide09").easySlider({
        continuous: true,
        auto: true,
        controlsShow: false
    });
	$(".slide10").easySlider({
        continuous: true,
        auto: true,
        controlsShow: false
    });

    $('[name=Subscribe]').click(function () {
        var email = $(this).prev('input').val();
        var txtBox = $(this).prev('input');
        $.post('subscribe.aspx', {
            email: email
        }, function (response) {
            alert(response);
            txtBox.val('');
        });

        return false;
    });
	
	
	
	
	//Examples of how to assign the ColorBox event to elements
//			$("a[rel='example1']").colorbox();
//			$("a[rel='example2']").colorbox({transition:"fade"});
//			$("a[rel='example3']").colorbox({transition:"none", width:"75%", height:"75%"});
//			$("a[rel='example4']").colorbox({slideshow:true});
//			$(".example5").colorbox();
//			$(".example6").colorbox({iframe:true, innerWidth:825, innerHeight:344});
//			$(".example7").colorbox({width:"810px", height:"80%", iframe:true});
//			$(".example9").colorbox({
//				onOpen:function(){ alert('onOpen: colorbox is about to open'); },
//				onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
//				onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
//				onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
//				onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
//			});
			
			//Example of preserving a JavaScript event for inline calls.
			$("#click").click(function(){ 
				$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
				return false;
			});	
			
});

window.onload = function(){
	imageReset();
}

//image allingment function//
function imageReset(){
	$('.contentbox li').each(function(){
		var boxheight = $(this).find('div.whitebox').height();
		var imgHeight = $(this).find('div.whitebox').children('img').height();
		var difference = (boxheight-imgHeight)/2;
		$(this).find('div.whitebox').children('img').css('margin-top', difference);
		})
	}
	
function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}	
	

		

