var fullInterval = new Array();
var fullStep = new Array();
var fullAcceleration = new Array();
var fullSpeed = new Array();
var fullTopSpeed = 2;
var fullStartW = new Array();
var fullStartH = new Array();
var fullEndW = new Array();
var fullEndH = new Array();
var fullSpeedK = new Array();
var fsAnimate = new Array();

function setElementOpacity(sElemId, nOpacity)
{
	var opacityProp = getOpacityProperty();
	var elem = document.getElementById(sElemId);

	if (!elem || !opacityProp) return;
    
	if (opacityProp=="filter")
	{
		nOpacity *= 100;
	
		var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
		if (oAlpha)
			oAlpha.opacity = nOpacity;
		else
			elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")";
	}
	else
		elem.style[opacityProp] = nOpacity;
}

function getOpacityProperty()
{
	if (typeof document.body.style.opacity == 'string') // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9, IE7)
		return 'opacity';
	else
	if (typeof document.body.style.MozOpacity == 'string') // Mozilla 1.6 ט לכאהרו, Firefox 0.8 
		return 'MozOpacity';
	else
	if (typeof document.body.style.KhtmlOpacity == 'string') // Konqueror 3.1, Safari 1.1
		return 'KhtmlOpacity';
	else
	if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) // Internet Exploder 5.5+
		return 'filter';

	return false;
}

function hideZoom(id,sW,sH)
{
	var zoomBlock = document.getElementById('zoomBlock'+id);
	zoomBlock.style.display = 'none';
	zoomBlock.style.visibility = 'hidden';
	var fsPhoto = document.getElementById('fullScreenPhotoBlock'+id);
	fsPhoto.style.width = sW + 'px';
	fsPhoto.style.height = sH + 'px';
	fsPhoto.style.marginLeft = Math.round((document.documentElement.clientWidth - sW)/2) + 'px';
	fsPhoto.style.marginTop = Math.round((document.documentElement.clientHeight - sH)/2) -(-(document.documentElement.scrollTop||document.body.scrollTop)) + 'px';
	fsPhoto.style.display = 'none';
	fsPhoto.style.visibility = 'hidden';

	var fsImage = document.getElementById('fsImage'+id);
	fsImage.style.height = sH + 'px';
	fsImage.style.width = sW + 'px';
	fsImage.style.display = 'none';
	fsImage.style.visibility = 'hidden';
	
	delta = new Array(0,4,6,8,8);
	
	for (i = 1; i <= 5; i++)
	{
		nH = sH + delta[i-1];
		document.getElementById('left'+id+'_'+i).style.height = nH + 'px';
		document.getElementById('right'+id+'_'+(6-i)).style.height = nH + 'px';
	}
	
	for (i = 1; i <= 5; i++)
	{
		document.getElementById('right'+id+'_'+i).style.marginLeft = sW -(-i) -1 + 'px';
	}
	
	document.getElementById('top'+id).style.width = sW + 'px';
	document.getElementById('bottom'+id).style.width = sW + 'px';

	document.getElementById('bottom'+id).style.marginTop = sW + 'px';

	document.getElementById('point'+id+'_2').style.marginLeft = sW -1 + 'px';
	document.getElementById('point'+id+'_3').style.marginTop = sW -1 + 'px';
	document.getElementById('point'+id+'_4').style.marginLeft = sW -1 + 'px';
	document.getElementById('point'+id+'_4').style.marginTop = sW -1 + 'px';
}

function zoomImage(id,photoPath)
{
	var zoomBlock = document.getElementById('zoomBlock'+id);
	zoomBlock.style.display = 'block';
	zoomBlock.style.visibility = 'visible';
	zoomBlock.style.height = '1px';
	zoomBlock.style.width = '1px';
	bodyHeight = document.body.offsetHeight;
	if (bodyHeight < document.documentElement.offsetHeight)
	{
		bodyHeight = document.documentElement.offsetHeight;
	}
	if (bodyHeight < document.documentElement.clientHeight)
	{
		bodyHeight = document.documentElement.clientHeight;
	}
	if (bodyHeight < document.body.offsetHeight)
	{
		bodyHeight = document.body.offsetHeight;
	}
	if (bodyHeight < document.body.clientHeight)
	{
		bodyHeight = document.body.clientHeight;
	}
	if (bodyHeight < document.documentElement.scrollHeight)
	{
		bodyHeight = document.documentElement.scrollHeight;
	}
	if (bodyHeight < document.body.scrollHeight)
	{
		bodyHeight = document.body.scrollHeight;
	}
	zoomBlock.style.height = bodyHeight + 'px';
	zoomBlock.style.width = document.documentElement.clientWidth + 'px';
	setElementOpacity('zoomBlock'+id,0.8);

	var fsPhoto = document.getElementById('fullScreenPhotoBlock'+id);
	fsPhoto.style.display = 'block';
	fsPhoto.style.visibility = 'visible';
	sW = fsPhoto.offsetWidth;
	sH = fsPhoto.offsetHeight
	fsPhoto.style.marginLeft = Math.round((document.documentElement.clientWidth - sW)/2) + 'px';
	fsPhoto.style.marginTop = Math.round((document.documentElement.clientHeight - sH)/2) -(-(document.documentElement.scrollTop||document.body.scrollTop)) + 'px';
	
	var fsImage = new Image();
	
	fsImage.onload = function()
	{
		document.getElementById('fsImage'+id).src = fsImage.src;
		document.getElementById('fsImage'+id).style.display = 'block';
		document.getElementById('fsImage'+id).style.visibility = 'visible';
		animateImage(id,sW,sH,fsImage.width,fsImage.height);
	}
	
	var curPhotoNum = eval('photoNum'+id);
	fsImage.src = photoPath+id+'/fullscreen_'+eval('gallery'+id+'['+curPhotoNum+'][\'filename\']');
	document.getElementById('fsImage'+id).alt = eval('gallery'+id+'['+curPhotoNum+'][\'caption\']');
	document.getElementById('fsImage'+id).title = eval('gallery'+id+'['+curPhotoNum+'][\'caption\']');
}

function animateImage(id,sW,sH,newWidth,newHeight)
{
	fullStep[id] = sW;
	fullEndW[id] = newWidth;
	fullEndH[id] = newHeight;
	fullAcceleration[id] = 1;
	fullSpeed[id] = 0;
	fullSpeedK[id] = (newHeight - sH)/(newWidth-sW);
	
	fullInterval[id] = setInterval('animateStep('+id+')',50);
}

function animateFsImage(id,src,w,h)
{
	fsAnimate[id] = new Array(1,-0.1);
	fullInterval[id] = setInterval('animateFsStep('+id+',\''+src+'\','+w+','+h+')',50);
}

function animateFsStep(id,src,w,h)
{
	var fsImage = document.getElementById('fsImage'+id);
	fsAnimate[id][0] += fsAnimate[id][1];
	if (fsAnimate[id][0] <= 0)
	{
		fsAnimate[id][0] = 0;
		fsAnimate[id][1] = 0.1;
		fsImage.src = src;
		fsImage.style.width = w+'px';
		fsImage.style.height = h+'px';
		alert(w);
	}
	if ((fsAnimate[id][0] >= 1) && (fsAnimate[id][1] == 0.1))
	{
		clearInterval(fullInterval[id]);
		fsAnimate[id][0] = 1;
	}
	setElementOpacity('fsImage'+id,fsAnimate[id][0]);
}

function animateStep(id)
{
	var fsImage = document.getElementById('fsImage'+id);
	var fsPhoto = document.getElementById('fullScreenPhotoBlock'+id);
	var zoomBlock = document.getElementById('zoomBlock'+id);
	
	fullSpeed[id] += fullAcceleration[id];
	if (fullSpeed[id] > fullTopSpeed)
	{
		fullSpeed[id] = fullTopSpeed;
	}

	if (fullEndW[id] - fullStep[id] <= fullSpeed[id]*fullSpeed[id]/(6*fullAcceleration[id]))
	{
		fullAcceleration[id] = -fullAcceleration[id];
	}
	
	fullStep[id] += fullStep[id];
	
	if (fullAcceleration[id] < 0 && fullSpeed[id] == 0)
	{
		fullStep[id] = fullEndW[id];
	}
	
	if (fullStep[id] >= fullEndW[id])
	{
		fullStep[id] = fullEndW[id];
		clearInterval(fullInterval[id]);
		fullInterval[id] = null;
		fullAcceleration[id] = 0;
		fullSpeed[id] = 0;
	}

	newMarginLeft = Math.round((document.documentElement.clientWidth - fullStep[id])/2);
	if (newMarginLeft < 0)
	{
		newMarginLeft = 30;
	}
	newMarginTop = Math.round((document.documentElement.clientHeight - fullStep[id]*fullSpeedK[id])/2 -(-(document.documentElement.scrollTop||document.body.scrollTop)));
	if (newMarginTop - (document.documentElement.scrollTop||document.body.scrollTop) < 0)
	{
		newMarginTop = 30 + (document.documentElement.scrollTop||document.body.scrollTop);
	}
	
	if (zoomBlock.offsetHeight < (newMarginTop+fullStep[id]*fullSpeedK[id]+30))
	{
		zoomBlock.style.height = newMarginTop - (-fullStep[id]*fullSpeedK[id]) -(-30) + 'px';
	}
	
	if (zoomBlock.offsetWidth < (newMarginLeft+fullStep[id]-1+30))
	{
		zoomBlock.style.width = newMarginLeft - (-fullStep[id]) -(-30) + 'px';
	}
	
	fsPhoto.style.width = fullStep[id] + 'px';
	fsPhoto.style.height = Math.round(fullStep[id]*fullSpeedK[id]) + 'px';

	fsImage.style.width = fullStep[id] + 'px';
	fsImage.style.height = Math.round(fullStep[id]*fullSpeedK[id]) + 'px';
	
	fsPhoto.style.marginLeft = newMarginLeft + 'px';
	fsPhoto.style.marginTop = newMarginTop + 'px';
	
	delta = new Array(0,4,6,8,8);

	for (i = 1; i <= 5; i++)
	{
		nH = fullStep[id]*fullSpeedK[id] + delta[i-1];
		document.getElementById('left'+id+'_'+i).style.height = Math.round(nH) + 'px';
		document.getElementById('right'+id+'_'+(6-i)).style.height = Math.round(nH) + 'px';
	}
	
	for (i = 1; i <= 5; i++)
	{
		document.getElementById('right'+id+'_'+i).style.marginLeft = fullStep[id] -(-i+1) + 'px';
	}
	
	document.getElementById('top'+id).style.width =  fullStep[id] + 'px';
	document.getElementById('bottom'+id).style.width =  fullStep[id] + 'px';

	document.getElementById('bottom'+id).style.marginTop = Math.round(fullStep[id]*fullSpeedK[id]) + 'px';

	document.getElementById('point'+id+'_2').style.marginLeft =  fullStep[id] -1 + 'px';
	document.getElementById('point'+id+'_3').style.marginTop = Math.round(fullStep[id]*fullSpeedK[id]) -1 + 'px';
	document.getElementById('point'+id+'_4').style.marginLeft =  fullStep[id] -1 + 'px';
	document.getElementById('point'+id+'_4').style.marginTop = Math.round(fullStep[id]*fullSpeedK[id]) -1 + 'px';
	
	if (fullStep[id] == fullEndW[id])
	{
		fsPhoto.style.width = fullEndW[id] + 'px';
		fsPhoto.style.height = fullEndH[id] + 'px';
		fsImage.style.width = fullEndW[id] + 'px';
		fsImage.style.height = fullEndH[id] + 'px';
		document.getElementById('bottom'+id).style.marginTop = fullEndH[id] + 'px';
		document.getElementById('point'+id+'_3').style.marginTop = fullEndH[id] -1 + 'px';
		document.getElementById('point'+id+'_4').style.marginTop = fullEndH[id] -1 + 'px';

		for (i = 1; i <= 5; i++)
		{
			nH = fullEndH[id] + delta[i-1];
			document.getElementById('left'+id+'_'+i).style.height = Math.round(nH) + 'px';
			document.getElementById('right'+id+'_'+(6-i)).style.height = Math.round(nH) + 'px';
		}
	}
}

var slideInterval = new Array();
var picPosition = new Array();
var slideAcceleration = new Array();
var slideSpeed = new Array();
var slideTopSpeed = 50;

function changePicture(id,photoPath,num)
{
	var curPhotoNum = eval('photoNum'+id);
	if (slideInterval[id] != null)
	{
		if (curPhotoNum != num)
			clearInterval(slideInterval[id]);
		else
			return false;
	}
	var preloader = document.getElementById('preloader'+id);
	preloader.style.display = 'block';
	preloader.style.visibility = 'visible';
	preloader.style.marginTop = Math.round((eval('galleryPH'+id) - preloader.clientHeight)/2) + 'px';
	preloader.style.marginLeft = Math.round((eval('galleryPW'+id) - preloader.clientWidth)/2) + 'px';
	
	var newFileName = photoPath+id+'/full_'+eval('gallery'+id+'['+num+'][\'filename\']');
	picPosition[id] = 0;
	slideSpeed[id] = 0;
	slideAcceleration[id] = 3;
	var newPhoto = new Image();

	newPhoto.onload = function()
	{
		preloader.style.display = 'none';
		preloader.style.visibility = 'hidden';
		startSlide();
	}
	
	newPhoto.src = newFileName;
	
	function startSlide()
	{
		var fullPhoto1 = document.getElementById('fullPhoto1_'+id);
		var fullPhoto2 = document.getElementById('fullPhoto2_'+id);
		if (num > curPhotoNum)
		{
			fullPhoto1.src = photoPath+id+'/full_'+eval('gallery'+id+'['+curPhotoNum+'][\'filename\']');
			fullPhoto1.alt = eval('gallery'+id+'['+curPhotoNum+'][\'caption\']');
			fullPhoto1.title = eval('gallery'+id+'['+curPhotoNum+'][\'caption\']');
			fullPhoto1.style.paddingTop = Math.round((eval('galleryPH'+id) - eval('gallery'+id+'['+curPhotoNum+'][\'height\']'))/2) + 'px';
			fullPhoto1.style.paddingLeft = Math.ceil((eval('galleryPW'+id) - eval('gallery'+id+'['+curPhotoNum+'][\'width\']'))/2) + 'px';
			fullPhoto1.style.paddingRight = Math.floor((eval('galleryPW'+id) - eval('gallery'+id+'['+curPhotoNum+'][\'width\']'))/2) + 'px';

			document.getElementById('fullPhotoBlock'+id).style.marginLeft = 0;

			fullPhoto2.src = newPhoto.src;
			fullPhoto2.alt = eval('gallery'+id+'['+num+'][\'caption\']');
			fullPhoto2.title = eval('gallery'+id+'['+num+'][\'caption\']');
			fullPhoto2.style.paddingTop = Math.round((eval('galleryPH'+id) - eval('gallery'+id+'['+num+'][\'height\']'))/2) + 'px';
			fullPhoto2.style.paddingLeft = Math.ceil((eval('galleryPW'+id) - eval('gallery'+id+'['+num+'][\'width\']'))/2) + 'px';
			fullPhoto2.style.paddingRight = Math.floor((eval('galleryPW'+id) - eval('gallery'+id+'['+num+'][\'width\']'))/2) + 'px';
			eval('photoNum'+id+' = '+num+';');
			
			slideInterval[id] = setInterval('slideRight('+id+')',50);
		}
		else
		if (num < curPhotoNum)
		{
			fullPhoto2.src = photoPath+id+'/full_'+eval('gallery'+id+'['+curPhotoNum+'][\'filename\']');
			fullPhoto2.alt = eval('gallery'+id+'['+curPhotoNum+'][\'caption\']');
			fullPhoto2.title = eval('gallery'+id+'['+curPhotoNum+'][\'caption\']');
			fullPhoto2.style.paddingTop = Math.round((eval('galleryPH'+id) - eval('gallery'+id+'['+curPhotoNum+'][\'height\']'))/2) + 'px';
			fullPhoto2.style.paddingLeft = Math.ceil((eval('galleryPW'+id) - eval('gallery'+id+'['+curPhotoNum+'][\'width\']'))/2) + 'px';
			fullPhoto2.style.paddingRight = Math.floor((eval('galleryPW'+id) - eval('gallery'+id+'['+curPhotoNum+'][\'width\']'))/2) + 'px';

			document.getElementById('fullPhotoBlock'+id).style.marginLeft = -eval('galleryPW'+id) + 'px';

			fullPhoto1.src = newPhoto.src;
			fullPhoto1.alt = eval('gallery'+id+'['+num+'][\'caption\']');
			fullPhoto1.title = eval('gallery'+id+'['+num+'][\'caption\']');
			fullPhoto1.style.paddingTop = Math.round((eval('galleryPH'+id) - eval('gallery'+id+'['+num+'][\'height\']'))/2) + 'px';
			fullPhoto1.style.paddingLeft = Math.ceil((eval('galleryPW'+id) - eval('gallery'+id+'['+num+'][\'width\']'))/2) + 'px';
			fullPhoto1.style.paddingRight = Math.floor((eval('galleryPW'+id) - eval('gallery'+id+'['+num+'][\'width\']'))/2) + 'px';

			eval('photoNum'+id+' = '+num+';');
			
			slideInterval[id] = setInterval('slideLeft('+id+')',50);
		}
	}
}

function slideRight(id)
{
	slideSpeed[id] += slideAcceleration[id];
	
	if (slideSpeed[id] > slideTopSpeed)
	{
		slideSpeed[id] = slideTopSpeed;
	}
	
	if (eval('galleryPW'+id) - picPosition[id] <= slideSpeed[id]*slideSpeed[id]/(6*slideAcceleration[id]))
	{
		slideAcceleration[id] = -slideAcceleration[id];
	}
	
	picPosition[id] += slideSpeed[id];
	
	if (slideAcceleration[id] < 0 && slideSpeed[id] == 0)
	{
		picPosition[id] = eval('galleryPW'+id);
	}
	
	if (picPosition[id] >= eval('galleryPW'+id))
	{
		picPosition[id] = eval('galleryPW'+id);
		clearInterval(slideInterval[id]);
		slideInterval[id] = null;
		slideAcceleration[id] = 0;
		slideSpeed[id] = 0;
	}
	document.getElementById('fullPhotoBlock'+id).style.marginLeft = -picPosition[id] + 'px';
}

function slideLeft(id)
{
	slideSpeed[id] += slideAcceleration[id];
	
	if (slideSpeed[id] > slideTopSpeed)
	{
		slideSpeed[id] = slideTopSpeed;
	}
	
	if (eval('galleryPW'+id) - picPosition[id] <= slideSpeed[id]*slideSpeed[id]/(6*slideAcceleration[id]))
	{
		slideAcceleration[id] = -slideAcceleration[id];
	}
	
	if (slideAcceleration[id] < 0 && slideSpeed[id] == 0)
	{
		picPosition[id] = eval('galleryPW'+id);
	}

	picPosition[id] += slideSpeed[id];
	if (picPosition[id] >= eval('galleryPW'+id))
	{
		picPosition[id] = eval('galleryPW'+id);
		clearInterval(slideInterval[id]);
		slideInterval[id] = null;
		slideAcceleration[id] = 0;
		slideSpeed[id] = 0;
	}
	document.getElementById('fullPhotoBlock'+id).style.marginLeft = -eval('galleryPW'+id)-(-picPosition[id]) + 'px';
}


var scrollAcceleration = new Array();
var scrollDirection = new Array();
var scrollSpeed = new Array();
var maxScrollSpeed = 50;
var topScrollSpeed = new Array();
var intervalLength = 50;
var scrX = new Array();
var scroller = new Array();
var previews = new Array();
var stopTO = new Array();
var scrollInterval = new Array();

function getX( oElement ) {
    var iReturnValue = 0;
    while( oElement != null ) {
    	iAdd = oElement.offsetLeft;
    	if (iAdd == undefined)
    	{
			iAdd = 0;
		}
        iReturnValue = iReturnValue - (-iAdd);
        oElement = oElement.parentNode;
    }
    return iReturnValue;
}

function startScroll(event,id)
{
	event = event || window.event;
	
	clearTimeout(stopTO[id]);
	
	previews[id] = document.getElementById('previews'+id);
	previewsX = previews[id].offsetLeft;
	if (previewsX == 0)
	{
		previewsX = getX(previews[id]);
	}
	var x = event.clientX - previewsX;
	var w = previews[id].offsetWidth;
	scroller[id] = document.getElementById('scroller'+id);
	if (x > 0 && x < 0.43*w)
	{
		scrollAcceleration[id] = 1;
		scrollDirection[id] = -1;
		dimention = 0.43*w - x;
	}
	else
	if (x > 0.57*w && x < w)
	{
		scrollAcceleration[id] = 1;
		scrollDirection[id] = 1;
		dimention = x - 0.57*w;
	}
	else
	{
		dimention = 0;
	}
	topScrollSpeed[id] = dimention/(0.43*w)*maxScrollSpeed;
	
}

function stopScroll(id)
{
	stopTO[id] = setTimeout('goStop('+id+')',40);
}

function goStop(id)
{
	if (scrollAcceleration[id] > 0)
	{
		scrollAcceleration[id] = -3*scrollAcceleration[id];
	}
}

function moveScroller(id)
{
	if (scrollDirection[id] != 0)
	{
		remeaningDimention = (scrollDirection[id] > 0 ? scroller[id].clientWidth - previews[id].offsetWidth - scrX[id] : scrX[id]);
		if (scrollAcceleration[id] > 0 && remeaningDimention < scrollSpeed[id]*scrollSpeed[id]/(6*scrollAcceleration[id]))
		{
			scrollAcceleration[id] = -3*scrollAcceleration[id];
		}
		scrollSpeed[id] = scrollSpeed[id] -(-scrollAcceleration[id]);
		if (scrollSpeed[id] < 0)
		{
			scrollSpeed[id] = 0;
		}
		if (scrollSpeed[id] > topScrollSpeed[id])
		{
			scrollSpeed[id] = topScrollSpeed[id];
		}
		scrX[id] = scrX[id] -(-scrollSpeed[id]*scrollDirection[id]);
		if (scrX[id] < 0)
		{
			scrX[id] = 0;
		}
		if (scrX[id] > scroller[id].clientWidth - previews[id].offsetWidth)
		{
			scrX[id] = scroller[id].clientWidth - previews[id].offsetWidth;
		}
		scrX[id] = Math.round(scrX[id]);
		scroller[id].style.marginLeft = - scrX[id] + 'px';
	}
}

function fullSlideLeft(id,photoPath)
{
	var curPhotoNum = eval('photoNum'+id);
	if (curPhotoNum == 0) return;

	var num = curPhotoNum - 1;
	changePicture(id,photoPath,num);

	var fsImage = new Image();
	
	fsImage.onload = function()
	{
		document.getElementById('fsImage'+id).src = fsImage.src;
		document.getElementById('fsImage'+id).style.display = 'block';
		document.getElementById('fsImage'+id).style.visibility = 'visible';
		animateImage(id,50,50,this.width,this.height);
//		animateFsImage(id,this.src,this.width,this.height);
/*
		var fsPhoto = document.getElementById('fullScreenPhotoBlock'+id);

		fsPhoto.style.width = fsImage.width + 'px';
		fsPhoto.style.height = fsImage.width + 'px';
		document.getElementById('fsImage'+id).style.width = fsImage.width + 'px';
		document.getElementById('fsImage'+id).style.height = fsImage.width + 'px';
		document.getElementById('bottom'+id).style.marginTop = fsImage.width + 'px';
		document.getElementById('point'+id+'_3').style.marginTop = fsImage.width -1 + 'px';
		document.getElementById('point'+id+'_4').style.marginTop = fsImage.width -1 + 'px';
		for (i = 1; i <= 5; i++)
		{
			nH = fsImage.width;
			document.getElementById('left'+id+'_'+i).style.height = Math.round(nH) + 'px';
			document.getElementById('right'+id+'_'+(6-i)).style.height = Math.round(nH) + 'px';
		}*/
	}
	
	fsImage.src = photoPath+id+'/fullscreen_'+eval('gallery'+id+'['+num+'][\'filename\']');
	document.getElementById('fsImage'+id).alt = eval('gallery'+id+'['+num+'][\'caption\']');
	document.getElementById('fsImage'+id).title = eval('gallery'+id+'['+num+'][\'caption\']');
}

function fullSlideRight(id,photoPath)
{
	var curPhotoNum = eval('photoNum'+id);
	if (curPhotoNum == eval('gallery'+id+'.length -1')) return;

	var num = curPhotoNum + 1;
	changePicture(id,photoPath,num);

	var fsImage = new Image();
	
	fsImage.onload = function()
	{
		document.getElementById('fsImage'+id).src = fsImage.src;
		document.getElementById('fsImage'+id).style.display = 'block';
		document.getElementById('fsImage'+id).style.visibility = 'visible';
		animateImage(id,50,50,this.width,this.height);
//		animateFsImage(id,this.src,this.width,this.height);
/*
		var fsPhoto = document.getElementById('fullScreenPhotoBlock'+id);

		fsPhoto.style.width = fsImage.width + 'px';
		fsPhoto.style.height = fsImage.width + 'px';
		document.getElementById('fsImage'+id).style.width = fsImage.width + 'px';
		document.getElementById('fsImage'+id).style.height = fsImage.width + 'px';
		document.getElementById('bottom'+id).style.marginTop = fsImage.width + 'px';
		document.getElementById('point'+id+'_3').style.marginTop = fsImage.width -1 + 'px';
		document.getElementById('point'+id+'_4').style.marginTop = fsImage.width -1 + 'px';
		for (i = 1; i <= 5; i++)
		{
			nH = fsImage.width;
			document.getElementById('left'+id+'_'+i).style.height = Math.round(nH) + 'px';
			document.getElementById('right'+id+'_'+(6-i)).style.height = Math.round(nH) + 'px';
		}*/
	}
	
	var curPhotoNum = eval('photoNum'+id);
	fsImage.src = photoPath+id+'/fullscreen_'+eval('gallery'+id+'['+num+'][\'filename\']');
	document.getElementById('fsImage'+id).alt = eval('gallery'+id+'['+num+'][\'caption\']');
	document.getElementById('fsImage'+id).title = eval('gallery'+id+'['+num+'][\'caption\']');
}

