$(document).ready(function(){
	callBack();
    lastBlock = $("#a1");
    maxWidth = 591;
    minWidth = 11;	
	xOffset = 187;
	yOffset = 50;
	popupStatus = 0;
	$(".itemLink").css({ color: "#D80880", cursor: "pointer"});

    $("#colorChooser ul li a").click(
      function(){
	  	$("#colorChooser .itemHolder").css({
		"width":591,
		"height":258,
		"overflow":"hidden"
		});
		$("#colorChooser .item").css({
		"overflow":"hidden"
		});
        $(lastBlock).animate({width: minWidth+"px"}, { queue:false, duration:600 });
		lastBlock = this;
		$(this).animate({width: maxWidth+"px"}, { queue:false, duration:600, complete:callBack});

      }
    );

	 $("#colorChooser .itemLink").click(
      function(){
	  	window.open('pdf/'+($(this).attr('meta')));
		return false;
      }
    );

	$("#colorChooser .button").click(
      function(){
	  	window.open('foto/'+($(this).attr('meta')));
		return false;
      }
    );
	$("#colorChooser .preview").click(function(e)
	{
		if(popupStatus == 0)
		{
			popupStatus = 1;
			var windowWidth = document.documentElement.clientWidth;
			var windowHeight = document.documentElement.clientHeight;
			this.t = this.title;
			this.title = "";	
			var c = (this.t != "") ? "<br/>" + this.t : "";
			$("body").append("<div id='container'>&nbsp;</div>");								
			$("body").append("<div id='preview'><img src='fotos/"+ ($(this).attr('id')) +".jpg' alt='Image preview' />"+ c +"</div>");						 
			$("#preview")
				.css("top",yOffset + "px")
				.css("left",(windowWidth/2 - xOffset) + "px")
				.fadeIn("slow");		
			$("#container")
				.css("top",0 + "px")
				.css("left",0 + "px")
				.css("display", "none")
				.css("position","fixed")
				.css("position","absolute")
				.css("width",99.8+"%")
				.css("height",windowHeight-2)
				.css("opacity", "0.7")
				.fadeIn("slow");
		}
		else
		{
			popupStatus = 0;
			this.title = this.t;	
			$("#container").remove();
			$("#preview").remove();	
		}
		$("#preview").click(function(e)
		{
			popupStatus = 0;
			this.title = this.t;	
			$("#container").remove();
			$("#preview").remove();
		});
		$("#colorChooser #container").click(function(e)
		{
			popupStatus = 0;
			this.title = this.t;	
			$("#container").remove();
			$("#preview").remove();
		});
    });	


});

function callBack()
{
	$(".itemHolder").css({
		"width":591,
		"height":258,
		"overflow":"auto"
		});
	$(".item").css({
		"overflow":"hidden"
		});
}