var done = false

function waitDownload(){
	if(!done){
		setTimeout("waitDownload()",300);
	}else{
		done = false;
		$('#imagecanvas').html($('#hiddenimg').html()).animate({'opacity':1},500,function() {
		if (jQuery.browser.msie)
			this.style.removeAttribute('filter');
	});
		$('#hiddenimg').empty();
		generateWallButtons($(".wall_arrow"))
		$('img.fadebutton').cross();
	}
}

function generateWallButtons(buttons) {
	buttons.unbind('click');
	buttons.unbind('mouseout');

	buttons.hover(function () {
		$(this).addClass("button_image_hover");
	}, function () {
		$(this).removeClass("button_image_hover");
	});

	$(".logo").mouseenter(function () {
		$(this).hide();
		$(".logohid").show();
	});
	$(".logohid").mouseleave(function () {
		$(this).hide();
		$(".logo").show();
	});


	buttons.click(function (e) {
		//$("#hideme").hide();
		$('#hiddenimg').empty();
		var imgid = $(this).attr('imgid')
		//$(this).addClass("button_image_clicked");
		var newdata = "";
		jQuery.get(pagePath + 'getwall/' + imgid + "/", function(data) {
			$('#hiddenimg').html(data);
			done = true;
		});
		$('html,body').animate({scrollTop: 0}, 200);
		$('#imagecanvas').animate({
			opacity: 0
		  },500, function(){
			  setTimeout("waitDownload()",300);
		});

	});
	$(".wall_thumb,.wall_arrow").css('cursor','pointer');
}

$(window).load( function(){
	$('img.projfadebutton').cross();
});

$(document).ready( function(){
	$(".wall_thumb,.wall_arrow").css('cursor','arrow');
	generateWallButtons($(".wall_thumb,.wall_arrow"));
	/*
	$('.proj_thumb img').hover(function(){
		$(this).animate({ 'opacity' : 0.6 });
	}, function(){
		$(this).animate({ 'opacity' : 1 });
	})
	*/
});


