var docsize = [];

    $(function(){
        setDocsize();
        $(window).resize(function(){setDocsize();});
    	$('.thumb').click(function(){initShowroom(this);return false;});
    });

    function setDocsize() {docsize[0] = $(document).width();docsize[1] = $(window).height();}
        
	function initShowroom(img_a)
		{
		var uid = new Date().getTime();
    	$('body')
          .append('<div class="showroom"><a href="javascript:;" onclick="hideShowroom();"></a><div><img id="'+uid+'" src="'+$(img_a).attr("href")+'" /></div></div>')
    	  .append('<div class="shadowscreen" style="height:'+docsize[1]+'px;"></div>');
    	
        if(document.all) $('#'+uid).load(function(){displayShowroom(this,this.offsetWidth,this.offsetHeight);});
        else $('#'+uid).load(function(){displayShowroom(this,this.naturalWidth,this.naturalHeight);});
		}

    function displayShowroom(img,w,h)
    	{
    	if(w>1300) {$(img).css({'height':h+'px','width':'auto'});w=1200;h+=15;}
    	else if(h>700) {h=700;$(img).css({'height':'auto','width':w+'px'});w+=15;}
	    $('.showroom').css({'top':parseInt((docsize[1]-h)/2)+'px', 'left':parseInt((docsize[0]-w)/2)+'px','opacity':'1.0'});
        $('.showroom div')
	      .css({'margin-left':parseInt(w/2)+'px','margin-top':parseInt(h/2)+'px','height':'0px','width':'0px'})
          .animate({'width':w,'height':h,"marginTop":0,"marginLeft":0},250,function(){$('.showroom a').show();$('.shadowscreen').fadeIn(200);});
    	$('.shadowscreen').click(function(){hideShowroom();});
    	}

    function hideShowroom()
    	{
    	$('.shadowscreen').fadeOut(200,function(){$('.shadowscreen').remove();});
    	$('.showroom a').hide();
    	$('.showroom div').animate({'marginLeft':$('.showroom div').width()/2,'marginTop':$('.showroom div').height()/2,'width':0,'height':0},200,function(){$('.showroom').remove();});
    	}
