jQuery(document).ready(function(){

	jQuery(".thumbsnext").bind('click', function(event) {
		th = jQuery(".thumbs");
		th.scrollLeft(th.scrollLeft()+440);
	    return false;
	});
	
	jQuery(".thumbsprevious").bind('click', function(event) {
		th = jQuery(".thumbs");
		th.scrollLeft(th.scrollLeft()-440);
	    return false;
	});
	
	jQuery(".thumbs a").bind('click', function(event) {
		//console.log(this.href);
	    name =this.href.split("/").pop();
		if (name=="#") return false;
	    location.href = "#"+name.substr(0,name.length-4);
	    return false;
	}); 
	
	jQuery('#collectionlarge').load(function() { 
	  jQuery('#collectionlarge').css("visibility","visible");
	}); 
	
	currentAnchor = "";
	    
    function checkAnchor(){ 
	    if(currentAnchor != document.location.hash){  
	        currentAnchor = document.location.hash;
	        currentPicture = currentAnchor.substring(1,currentAnchor.length);
	        if(jQuery("#picture"+currentPicture)[0]) {
	       		//console.log(currentAnchor);
		     	jQuery("#collectionlarge").css("visibility","hidden");
				jQuery("#collectionlarge").attr({ src: jQuery("#picture"+currentPicture)[0].href });
			    jQuery('#collectiondescription').html(jQuery("#picture"+currentPicture)[0].title);   
	        } else {
	        	console.log("item not found: #picture"+currentAnchor);
	        }
	    }
	}
	
	//setInterval(checkAnchor, 300); 
});