var r=Math.floor(Math.random()*noofs_pics)
var curr_work="none";
var curr_i=1;
var b="";
$(document).ready(function(){
	$("#main_menu").hide();
	$("#logo").fadeIn();
	setHeights();
	//alert($(window).height());
	setTimeout("showMenu(1200)",600);
	setTimeout("hideLogo()",1200);
	setTimeout("showCarrousel("+r+")",1800);
	$(window).resize(function(){
		setHeights();
	});
	$(".work_img").click(function(){
		showCarrousel(curr_i);
	});
});

function setHeights(){
	$(".work_img").each(function(){
		var orig_width=$(this).attr("this_width");
		var orig_height=$(this).attr("this_height");
		var height=$(window).height()-90;
		var width=$(window).width()-90;
		var new_width=(height/orig_height)*orig_width;
		var new_height=(width/orig_width)*orig_height;
		if(new_width>width){
			var padding_top=(height-new_height-90)/2
			$(this).css({width:width+"px",height:new_height+"px"});		
			$(this).parent().css({paddingTop:padding_top+"px"});		
		}
		else {
			$(this).css({height:height+"px",width:new_width+"px"});		
			$(this).parent().css({paddingTop:"0px"});		
		}
	});
}

function hideLogo(){
	$("#logo").fadeOut();
}

function showCarrousel(i){
	clearTimeout(b);
	$("#work"+i).fadeIn(800);
	if(curr_work!="none"){
		$("#work"+curr_work).fadeOut(800);
	}
	curr_work=i;
	i++;
	if(i>noofs_pics-1){
		i=0;
	}
	curr_i=i;
	b=setTimeout("showCarrousel("+i+")",5000);
}
wall_width=10;
