// execute your scripts when the DOM is ready. this is mostly a good habit
$(document).ready(function($){

	try{Typekit.load();}catch(e){}
	populate_twitter_feeds();
	// initialize scrollable

	$("#mainstyleslideshow").scrollable().autoscroll({ interval: 4000 });
	$("#slideshow").scrollable({
		onBeforeSeek: function(event, i) {
			$(".subnav a").removeClass("active");
			
			var arrSlides = $("#slideshow .items").children();	
			var arrayClasses = $(arrSlides[i]).attr("class").split(" ");
    		$.each( arrayClasses, function(index, value) { 
    			$(".subnav #" + value).addClass("active");
    		});
    		
 
   			if ( i==0 ) {
   				$.history.load("");
   			} else {
				$.history.load("page" + i);
   			}

		},
	});	

/*
    $(".subnav a").click(function(){
    	var strId = this.id;
    	
    	$.each( $("#slideshow .items").children(), function(index,value) {
    		if ( jQuery.inArray( strId, $(value).attr("class").split(" ") ) > -1 ) {
    			$('#slideshow').scrollable().seekTo(index);
    			return false;
    		}
    	}); 
    	return false;
    });
*/    


    $.history.init(function(hash){
        if(hash == "") {
            // initialize your app
            console.log('history plugin: hello world');
        } else {
            // restore the state from hash
            console.log('hash from history', hash);


    		if ( window.location.hash.substring(0,5) == '#page' ) {
    			$('#slideshow').scrollable().seekTo(parseInt(window.location.hash.substr(5), 0));
    		} 


        }
    },
    { unescape: ",/" });


});







