$(function() {
	
	$("#tabs").tabs();
	$("#tabs").bind('tabsselect', function(event, ui) {
 		window.location.hash='#'+(ui.panel.id);
	});
	if(document.location.hash!='') {
		var dHash = document.location.hash;
		if (dHash != '#photo' && dHash != '#press') { 
			var dHash = '#press';
		}
		window.location.hash = dHash;
		$("#tabs").tabs('select',dHash+'Tab');
		
	}
	function loadImage(intIndex) {
		var a = $('td#'+intIndex+' a').attr('id');
		$('table.thumbs td img').css('background','none');
		$('td#'+intIndex+' img').css('background-color','#DFDFDF');
		if (a) {
			$('.photoHolder').html(Step[intIndex]).append('<div style="border-top:1px solid #8e8d8d;margin:5px;background:#efeeee;text-align:right;"><div style="margin:5px;font-weight:bold;font-size:12px;">'+$('td#'+intIndex+' .image-desc').html()+'</div><div style="font-size:10px;color:#818181;margin:5px;margin-top:0px;padding-bottom:0px;">'+$('td#'+intIndex+' .uploader').html()+'</div><div style="font-size:10px;color:#818181;margin:5px;margin-top:0px;padding-bottom:5px;">'+$('td#'+intIndex+' .imageLink').html()+'</div></div>').show();
		}
		else { 
			loadImage(0);
		}
	}
	if ( $("#tableThumbs").length > 0 ) {
		var Step = [];
		$("a.thumb").each(
			function(intIndex){
				Step[intIndex] = new Image();
				Step[intIndex].src = 'http://img.deadformat.net/'+$(this).attr('id');
			}
		);
		loadImage(0);
		
		$("a.thumb").bind(
			"click",
			function(){
				loadImage($(this).parent().attr('id'));
			}
		);
		
		
	}
});