Rype= {
    tabs: function(container, startIndex) {
        var root = container || '#tabs';
        var speed = 500; //ms?
        startIndex = startIndex || 0;
        root = $(root);
        root.addClass('js-enabled');
        
        //add click events
        $.each(root.find('ul li a'),function(index) {
            var that = $(this);
            if(index == startIndex) {
                that.parent().addClass('current');
            }
            that.click(function(){
                //set current class
                $(this).parent().addClass('current');
                $.each($(this).parent().siblings(),function() {
                    $(this).removeClass('current');
                });
                //show/hide panels
                $.each($(that.attr('href')).fadeIn(speed).siblings(),function(){
                    $(this).hide();
                });
		$.scrollTo( 0, 800 );
                return false;
            });
        });
        
        //hide all but start index
        $.each(root.find('#tab-panes > *'),function(index, el) {
            if(index != startIndex) {
                $(this).hide();
            } 
        });
    }
}

$(document).ready(function(){
   	
   	// Gallery greyscale effect
   	$("ul.gallery li").hover(function() { //On hover...

		var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'

		//Set a background image(thumbOver) on the <a> tag - Set position to bottom
		$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});

		//Animate the image to 0 opacity (fade it out)
		$(this).find("span").stop().fadeTo('normal', 0 , function() {
			$(this).hide() //Hide the image after fade
		});
	} , function() { //on hover out...
		//Fade the image to full opacity 
		$(this).find("span").stop().fadeTo('normal', 1).show();
	});

   	
   	
   	//pix tabs
   	//UI tabs require too strict markup, roll own tabs function.
   	Rype.tabs('#tabs');

	//portfolio thumb fadein fadeout
	$('#content div.portfolio').hover(function(){
		$(this).find('img').fadeOut();

	}, function(){
		$(this).find('img').fadeIn();
	});

   	   	
});