// Custom Javascript

jQuery.noConflict();

// Tab functionality courtesy of http://stilbuero.de/tabs/
jQuery.tabs = function(containerId, start) {
    var ON_CLASS = 'on';
    var id = '#' + containerId;
    var i = (typeof start == "number") ? start - 1 : 0;
    jQuery(id + '>div:lt(' + i + ')').add(id + '>div:gt(' + i + ')').hide();
    jQuery(id + '>ul>li:nth-child(' + i + ')').addClass(ON_CLASS);
    jQuery(id + '>ul>li>a').click(function() {
        if (!jQuery(this.parentNode).is('.' + ON_CLASS)) {
            var re = /([_\\-\\w]+$)/i;
			var target = jQuery('#'+this.href.split('#')[1]);
            if (target.size() > 0) {
                jQuery(id + '>div:visible').hide();
                target.show();
                jQuery(id + '>ul>li').removeClass(ON_CLASS);
                jQuery(this.parentNode).addClass(ON_CLASS);
            } else {
                alert('There is no such container.');
            }
        }
        return false;
    });
};

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};


jQuery(document).ready(function() {
				
	jQuery("#twitter").tweet({
		username: "fashconscience",
		count: 1
	});
	
	jQuery('#Carousel .grid_wrap').css('display', 'block');
			
	// Load the Carousel
	jQuery('#HomeCarousel, #CatalogueCarouselUl').jcarousel({
		scroll: 1,
		auto: 5,
        wrap: 'last',
        initCallback: mycarousel_initCallback
	});
	
	
	// Load the tabs
	 jQuery.tabs("tabs");
	 
	 var setTabHeight = jQuery('#tabs .tabNav').height();
	 jQuery('#tabs .tabNav li a').height(setTabHeight);
	
	 
});




