jQuery(document).ready(function() {
    // scrollable list
	$(".scrollable").scrollable({
		size: 1,
		items: '.items',
		speed: 400 //0
	});

    // get handle to the scrollable api
    var api = $(".scrollable").data("scrollable");

	api.onSeek(function(e, i) {
     id = $(api.getItems()[api.getIndex()]).attr('rel');
	 //$.history.load(id);
	 
	 if(parseInt(id)==0) id="";
	 window.location.replace("#"+id);

    });
	
	$.history.init(function(hash){
        if(!hash) hash = 0;
		
		if(hash!=api.getIndex()) {
			api.move(parseInt(hash));
		}
		
    },
    { unescape: ",/" });

	
	// jquery '10000px bug' walkaround (jQ 1.4.4)
    /*api.onBeforeSeek(function(e, i) {
     api.getItemWrap().animate({opacity:0}, 100);
    });
    api.onSeek(function(e, i) {
     api.getItemWrap().animate({opacity:1}, 100);
    });*/


    if( $("a[rel^='prettyPhoto']").length ) {
         $("a[rel^='prettyPhoto']").prettyPhoto({theme: 'dark_rounded', opacity: 0.8});
    }


    $(".gal_selection, .gal_return, .tabs a").click(function() {
        $('.scrollable').fadeOut("fast");
    })
    //$(".pane *").hide().fadeIn("fast");


    $(".gal_selection img").each( function() {
        $(this).rotate( Math.random()*30 - 15 );
    });
});
