/*
	Gallery images by Yan
	2008-07-03 v001
*/
var loading_div=false;
	function show(){
	//try{
		var $div=$(this);
		var $img=$('img',this);
		var duration=100;
		$img.animate(
			{ 
				width: this.end.image.width+'px',
				height: this.end.image.height+'px'
			},
			duration
		);			
		//alert(this.end.zIndex);
		$div.animate(
			{ 
				left: this.end.left+'px',
				top: this.end.top+'px'//,
			},
			duration
		);
		var zEnd=this.end.zIndex;
		/*
		var zM=Math.ceil((this.start.zIndex+zEnd)/2);		
		setTimeout(function(){
			$div.css('z-index',zEnd);
		},duration);
		*/
		$div.css('z-index',zEnd);
		/*
		setTimeout(function(){
			$div.css('z-index',zEnd);
		},2*duration/3);		
		*/
	//}catch(e){
		//alert('show'+e);
	//}		
	};
	function hide(){
	//try{
		var $div=$(this);
		var $img=$('img',this);
		var duration=100;
		$img.animate(
			{ 
				width: this.start.image.width+'px',
				height: this.start.image.height+'px'
			},
			duration
		);
		//alert(this.start.zIndex);
		$div.css('z-index',this.start.zIndex).animate(
			{ 
				left: this.start.left+'px',
				top: this.start.top+'px'
			},
			duration
		);
	//}catch(e){
//		alert('hide'+e.message);
	//}		
	}
$(document).ready(function() {
	$('.shadow').each(function(i){
	//try{
			//$(this).css('z-index',8-i);
				var $div=$(this);
				var $img=$('img',this);

			
				this.start={};this.end={};this.start.image={};this.end.image={};
				this.start.left=parseInt($div.css('left'));
				this.start.top=parseInt($div.css('top'));
				this.start.image.width=$img.attr('width');
				this.start.image.height=$img.attr('height');
				this.start.zIndex=parseInt($div.css('z-index'))||1;			
				//alert(this.start.zIndex);
					//var k=1.075;
					//this.end.image.width=Math.round(this.start.image.width*k);
					//this.end.image.height=Math.round(this.start.image.height*k);
					this.end.image.width=$img.attr('_width');
					this.end.image.height=$img.attr('_height');			
				this.end.zIndex=9;
				this.end.top=this.start.top-Math.round((this.end.image.height-this.start.image.height)/2);
				this.end.left=this.start.left-Math.round((this.end.image.width-this.start.image.width)/2);
	//}catch(e){
	//	alert('each'+e);
	//}
	});
	$('.shadow').hover(function(){
	//try{
		if (loading_div!=false) return;
		this.hovered=true;

		if ($(this).attr('zoomlock')=='true'){
			this.zoomToOut=false;
			return;
		}
		show.apply(this);
	//}catch(e){
	//	alert('hover_on'+e);
	//}		
/**/
	},function(){
	//try{
		if (loading_div!=false) return;
		this.hovered=false;

		
		if ($(this).attr('zoomlock')=='true'){
			var f=arguments.callee;
			this.zoomToOut=true;
			if (typeof this.zoomOut=='undefined'){
				this.zoomOut=function(){
				};				
			};
			return;
		}	
		
		hide.apply(this);
	//}catch(e){
	//	alert('hover_off'+e);
	//}		
	});
});
