$(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
	 });
	
	$(".lightbox").fancybox({
		'titlePosition': 'over'
	});
	 
	$(".comment").click(function(e) {
	 	e.preventDefault();
	});
	
	$('#rotator a');
	setInterval(function(){
		$('#rotator a').filter(':visible').fadeOut(5000,function(){
			if($(this).next('a').size()){
				$(this).next().fadeIn(2000);
			}
			else{
				$('#rotator a').eq(0).fadeIn(2000);
			}
		});
	},2000);
	
});

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);
}
