var speed = 10, step = 10, status = 0;
var timer1, timer2, timer3, timer4, timer5;

function switchPanorama()
{
	panHolderHeight = "";
	panShadowTop = "";
	panPanoramaHeight = "";
	panPictureHeight = "";
	panRowHeight = "";
	clearIntervals();
	if(status == 0)
	{
		openupPanorama();
		status = 1;
	}
	else
	{
		shutdownPanorama();
		status = 0;
	}
	timer1 = setInterval("panShadowTop.play()", speed);
	timer2 = setInterval("panHolderHeight.play()", speed);
	timer3 = setInterval("panPanoramaHeight.play()", speed);
	timer4 = setInterval("panPictureHeight.play()", speed);
	timer5 = setInterval("panRowHeight.play()", speed);
}

function clearIntervals()
{
	clearInterval(timer1);
	clearInterval(timer2);
	clearInterval(timer3);
	clearInterval(timer4);
	clearInterval(timer5);
}

function shutdownPanorama()
{
	panHolderHeight = new Animator('panHolder', 'height', 552, 273);
	panShadowTop = new Animator('panShadow', 'marginTop', -167, 0);
	panPanoramaHeight = new Animator('panPanorama', 'height', 591, 311);
	panPictureHeight = new Animator('panPicture', 'height', 580, 301);
	panRowHeight = new Animator('panRow', 'height', 527, 219);
}

function openupPanorama()
{
	panHolderHeight = new Animator('panHolder', 'height', 273, 552);
	panShadowTop = new Animator('panShadow', 'marginTop', 0, -167);
	panPanoramaHeight = new Animator('panPanorama', 'height', 311, 591);
	panPictureHeight = new Animator('panPicture', 'height', 301, 580);
	panRowHeight = new Animator('panRow', 'height', 249, 527);
}


function Animator (id, prop, st, fin, un)
{
	this.obj = $(id);
	this.start = 0;
	this.property = prop;
	this.current = st;
	this.finish = fin;
	this.unit = un;
}

Animator.prototype.play = function (){
	this.current += Math.floor((this.finish - this.current) / step);
	eval('this.obj.style.' + this.property + '="' + this.current + 'px"');
	if(this.current == this.finish)	
	{
		clearIntervals();
	}
}

function $(id)
{
	return document.getElementById(id);
}
