var ZOOM = 50; 
var H = true;  
var V = true;  
var IP = 0;
var IM = 1;
var nxp;
var nyp;
var B0;
var B1;
var imgsrc;

function zOOm(){
	if (IP++ < ZOOM) {
		if (H) {
			B0.style.left   = (parseInt(B0.style.left)  - 1) + "px";
			B0.style.width  = (parseInt(B0.style.width) + 2) + "px";
			B1.style.left   = (parseInt(B1.style.left)  - 1) + "px";
			B1.style.width  = (parseInt(B1.style.width) + 2) + "px";
		}
		if (V) {
			B0.style.top    = (parseInt(B0.style.top)    - 1) + "px";
			B0.style.height = (parseInt(B0.style.height) + 2) + "px";
			B1.style.top    = (parseInt(B1.style.top)    - 1) + "px";
			B1.style.height = (parseInt(B1.style.height) + 2) + "px";
		}
		if (B1.filters) B1.filters.item(0).opacity = Math.round(IP / ZOOM * 100); else B1.style.opacity = IP / ZOOM;
	} else {
		IP = 0;
		if (B1.filters) B1.filters.item(0).opacity = 0; else B1.style.opacity = 0;
		if (H) {
			B1.style.left   = "0px";
			B1.style.width  = nxp + "px";
			B0.style.left   = -ZOOM + "px";
			B0.style.width  = (nxp + (2 * ZOOM)) + "px";
		}
		if (V) {
			B1.style.top    = "0px";
			B1.style.height = nyp + "px";
			B0.style.top    = -ZOOM + "px";
			B0.style.height = (nyp + (2 * ZOOM)) + "px";
		}
		B0.src              = B1.src;
		B1.src              = imgsrc[++IM % imgsrc.length].src;
	}
}

onload = function() {
	imgsrc                  = document.getElementById("images").getElementsByTagName("img");
	nxp                     = document.getElementById("screen").offsetWidth;
	nyp                     = document.getElementById("screen").offsetHeight;
	B0                      = document.createElement("img"); 
	B0.src                  = imgsrc[0].src;
	B0.style.position       = "absolute";
	B0.style.left           = (H ? -ZOOM : 0) + "px";
	B0.style.top            = (V ? -ZOOM : 0) + "px";
	B0.style.width          = (H ? nxp + (2 * ZOOM) : nxp) + "px";
	B0.style.height         = (V ? nyp + (2 * ZOOM) : nxp) + "px";
	document.getElementById("screen").appendChild(B0);
	B1                      = document.createElement("img"); 
	B1.src                  = imgsrc[1].src;
	B1.style.position       = "absolute";
	B1.style.left           = "0px";
	B1.style.top            = "0px";
	B1.style.height         = nyp + "px";
	B1.style.width          = nxp + "px";
	B1.style.filter         = "alpha(opacity=0)";
	B1.style.opacity        = 0;
	document.getElementById("screen").appendChild(B1);
	setInterval("zOOm();", 20);
}

var obj;
var objCnt;
var objL = 0;
var objH = 14;
var objT = 0;
var cnt = 10;
var lock = false;
var rot=0;
function moveoBox(){
	if(cnt<500){
		if(cnt<=250){
		obj.style.height = (objH+=5) + 'px';
		obj.style.top = 55-(objT+=6) + 'px';
		}
		if(cnt>300)	if(objL<100){
			obj.style.width = 2 + (objL+=10) + 'px';
		}
		//objCnt.style.top = 25+cnt/20+'px';
		cnt+=6;
		setTimeout('moveoBox()',1);
	}
	else{
	//	objCnt.style.top = 0+'px';
	//	obj.style.left = (0) + 'px';
		obj.style.zIndex = 0;
		clearTimeout();
		lock = false;
	}
}

function closeoBox(){
	if(cnt<200){
		obj.style.top = -4+(objT+=7) + 'px';
		if(objH>20)obj.style.height = -6+(objH-=10) + 'px';
		//objCnt.style.top = 25+cnt/20+'px';
		cnt+=6;
		setTimeout('closeoBox()',1);
	}
	else{
		obj.style.zIndex = 0;
		clearTimeout();
		lock = false;
	}
}

var box1 = false;
var box2 = false;

function openBox(name){
	if(!lock){
		lock = true;
		objL = 0;
		objH = 0;
		objT = 0;
		cnt = 10;
		obj = document.getElementById(name);

		if(name=='boxText1')
		if(box1 == false) box1 = true;
		else{objH=200; objT=-220; closeoBox(name); box1 = false; return;}
		if(name=='boxText2')
		if(box2 == false)box2 = true;
		else{objH=200; objT=-220; closeoBox(name); box2 = false; return;}		
		
		obj.style.display = 'inline';
		obj.style.zIndex = 100;
		obj.style.width = '0px';
		//objCnt = document.getElementById('boxes');
		moveoBox();
	}
}
