$(document).ready(function(){
	$("#lavalamp").lavaLamp({ fx: "backout", speed: 700 });
	var isRunning;
	$("#thumbnailholder a").click(function(e) {
		if(!isRunning){
			isRunning = true;
			$(".hide").hide();
			var id =  $(this).attr("rel");
			$(".thumbs img").css("border","1px solid #eee");
			$("#thumb"+id+" img").css("border","1px solid #5a5a5a");
			$("#photo"+id).fadeIn("slow", function(){ isRunning = false; });
		}
		e.preventDefault();
    });
	
	$("#slider").slider({
	    animate: true,
	    change: handleSliderChange,
	    slide: handleSliderSlide
	 });
	 
	$(".comment").click(function(e) {
	 	e.preventDefault();
	});
	
});

function handleSliderChange(e, ui) {
	var maxScroll = $("#thumbnailholder").attr("scrollWidth") - $("#thumbnailholder").width();
	$("#thumbnailholder").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000);
}

function handleSliderSlide(e, ui) {
	var maxScroll = $("#thumbnailholder").attr("scrollWidth") - $("#thumbnailholder").width();
	$("#thumbnailholder").attr({scrollLeft: ui.value * (maxScroll / 100) });
}

function popup(url,name,windowWidth,windowHeight){
    myleft=(screen.width)?(screen.width-windowWidth)/2:100;
	mytop=(screen.height)?(screen.height-windowHeight)/2:100;
	properties = "width="+windowWidth+",height="+windowHeight+",scrollbars=yes, top="+mytop+",left="+myleft;
    window.open(url,name,properties);
}