///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

if(!document.getElementById) {
	if(document.all) {
		document.getElementById = function() {
			if(typeof document.all[arguments[0]] != "undefined") {
				return document.all[arguments[0]];
			} else { return null; }
		}
	} else if(document.layers) {
		document.getElementById = function() {
			if(typeof document[arguments[0]] != "undefined") {
				return document[arguments[0]];
			} else { return null; }
		}
	}
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//Get the offset depending on browser
function showBOX(n)
{
    document.getElementById(n).style.display = 'block';
}
function hideBOX(n)
{
    document.getElementById(n).style.display = 'none';
}
function swapBOX(n)
{
	document.getElementById(n).style.display = document.getElementById(n).style.display=='none'?'block':'none';
} 

function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return [ scrOfY ];
}

var imBusy = 0;
var yPos = 0;
var xPos = 0;
var zoomTimer;
var scale = 100;
var step = 0;
var yDistance = 0;
var y1 = 0;
var y2 = 0;
var onFrame = 0;
var div1 = 0;
var div2 = 0;
var winPad = -50;
var winOFFSET = getScrollY();

DIV_COORDS = new Array(0, 1153 + winPad, 1986 + winPad, 2821 + winPad, 4062 + winPad, 6075 + winPad);

MOVE_COORDS_PLUS = new Array(0, 1, 4, 7, 11, 17, 23, 30, 38, 47, 56, 66, 75, 84, 92, 99, 100);
MOVE_COORDS_MINUS = new Array(100, 99, 92, 84, 75, 66, 56, 47, 38, 30, 23, 17, 11, 7, 4, 1, 0);

var frameTotal = MOVE_COORDS_PLUS.length;

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

function zoomInit(pTO){
	//alert(getScrollY());
	//alert("test");
	if (imBusy == 0){
		//winOFFSET = pageYOffset;
		winOFFSET = getScrollY();
		imBusy = 1;
		zoomTo(pTO);
	}
}

function zoomTo(pTO) {
	
	if (step < frameTotal){
		y1 = winOFFSET;
		y2 = DIV_COORDS[pTO];
		//alert(y1 + ' / ' + y2);
		
		yDistance = y2 - y1;
		
		//alert("dis:" + yDistance);
		
		if (yDistance < 0){
			yPos = parseInt((MOVE_COORDS_MINUS[step]/100) * Math.abs(yDistance)) + parseInt(y2);
		} else {
			yPos = parseInt((MOVE_COORDS_PLUS[step]/100) * Math.abs(yDistance)) + parseInt(y1);
		}
		//alert("Pos:" + yPos);
		
		//document.getElementById('BX').style.top = yPos + 13;
		//alert(document.getElementById('BX').style.left);

		//window.scroll(xPos, yPos)
		window.scroll(0, yPos);
		//window.scrollTo(0, yPos);
		
		step++;
		zoomTimer = setTimeout("zoomTo("+pTO+")", 50);
	} else{
		//alert("ELSE");
		zoomStop();
		onFrame = pTO;
	}
}


function testIE(){
	alert("v.1");
	window.scroll(500, 500);	
}





function zoomTo_BACKUP(pFROM, pTO) {
	
	if (step < frameTotal){
		
		//y1 = document.getElementById('B' + pFROM).style.top;
		//y2 = document.getElementById('B' + pTO).style.top;
		
		div1 = document.getElementById(pFROM);
		div2 = document.getElementById(pTO);
		y1 = (document.all)? div1.offsetTop : document.defaultView.getComputedStyle(div1, "").getPropertyValue("top");
		y2 = (document.all)? div2.offsetTop : document.defaultView.getComputedStyle(div2, "").getPropertyValue("top");
		
		alert(y1 + ' / ' + y2);
		
		y1 = y1.replace(/px/gi,"");
		y2 = y2.replace(/px/gi,"");
		
		y1 = y1.replace(/pt/gi,"");
		y2 = y2.replace(/pt/gi,"");
		
		alert(y1 + ' / ' + y2);
		
		y1 -= winPad;
		y2 -= winPad;
		
		alert(y1 + ' / ' + y2);
		
		yDistance = y2 - y1;
		
		alert("dis:" + yDistance);
		
		if (yDistance < 0){
			yPos = parseInt((MOVE_COORDS_MINUS[step]/100) * Math.abs(yDistance)) + parseInt(y2);
		} else {
			yPos = parseInt((MOVE_COORDS_PLUS[step]/100) * Math.abs(yDistance)) + parseInt(y1);
		}
		alert("Pos:" + yPos);
		
		//document.getElementById('BX').style.top = yPos + 13;
		//alert(document.getElementById('BX').style.left);

		//window.scroll(xPos, yPos)
		window.scroll(0, 500);
		
		step++;
		zoomTimer = setTimeout("zoomTo("+pFROM+", "+pTO+")", 50);
	} else{
		alert("ELSE");
		zoomStop();
		onFrame = pTO;
	}
}

function zoomStop(){
	//alert("STOP");
	if (zoomTimer) clearTimeout(zoomTimer);
	step = 0;
	imBusy = 0;
}