$(document).ready(function() {
	
	/* --------- CAROUSEL -------------*/
	if ($.isFunction($.fn.jcarousel)===true) {
		$('#mycarousel').jcarousel();
		$('#sim_carousel').jcarousel();
	}
	
	if ($.isFunction($.fn.fancybox)===true) {
		$("a.my_lightbox").fancybox({ 'hideOnContentClick': true }); 
		$("a.btn_addcart").fancybox({ 'hideOnContentClick': false });
	}

	$('.maillist_btn').toggle(function()
			{
				$('#mailbox_wrapper:hidden').slideDown();
				$('.maillist_btn')[0].blur();
				$(this).addClass('on');
				return false;
			},
			function()
			{
				$('#mailbox_wrapper:visible').slideUp();
				$('.maillist_btn')[0].blur();
				$(this).removeClass('on');
				return false;
			}
	);
   
	var $panels = $('#slider .scrollContainer > div');
    var $container = $('#slider .scrollContainer');

    // collect the scroll object, at the same time apply the hidden overflow
    // to remove the default scrollbars that will appear
    var $scroll = $('#slider .scroll').css('overflow', 'hidden');

    // handle nav selection
    function selectNav() {
        $(this)
            .parents('ul:first')
                .find('a')
                    .removeClass('selected')
                .end()
            .end()
            .addClass('selected');
    }

    $('#slider #tab-nav').find('a').click(selectNav);

    // go find the navigation link that has this target and select the nav
    function trigger(data) {
        var el = $('#slider .navigation').find('a[href$="' + data.id + '"]').get(0);
        selectNav.call(el);
    }

    if (window.location.hash) {
        trigger({ id : window.location.hash.substr(1) });
    } else {
        $('ul.navigation a:first').click();
    }
	
	$('button').hover(function() {
      $(this).addClass('hoverme');
    }, function() {
      $(this).removeClass('hoverme');
    });
	
	
	$(".galThumb img").each(function(){
		
		$(this).removeAttr("width").removeAttr("height");

		if ($(this).height()<$(this).parent().height()) {
			$(this).addClass("notTallEnough");
		}
	
	});


	/* --------- SUPERFISH -------------*/	
	if ($.isFunction($.fn.superfish)===true) {
		$('ul.sf-menu').superfish();	
	}

	$("#ship_method").bind('change',function(){
		
		window.location = 'index.php?id=21&nStepID=2&shippingMethod=' + $(this).val();

	});
	
});


