var moving = false;
var toswitch;
var toswitch2;
var scrlDir;
var vyska = 268;
var he = 212;
var scrlSpeed = 3;
var cas = 30;

var ns;
var ie;
var dom;

function init() {
	ns = (document.layers) ? true:false;
	ie = (document.all) ? true:false;
	dom = (document.getElementById) ? true:false;

	if (dom) block1 = document.getElementById('onasDivText').style;
	else if (ie) block1 = document.all['onasDivText'].style;
	else if (ns) block1 = document.onasDivText;
	block1.ypos = parseInt(block1.top);
	block1.h = he;
	if (dom) block2 = document.getElementById('referenceDivText').style;
	else if (ie) block2 = document.all['referenceDivText'].style;
	else if (ns) block2 = document.referenceDivText;
	block2.ypos = parseInt(block2.top);
	block2.h = he;

	showDiv('menuDiv');
}

function scrollUp(arg) {
	if (arg) {
		scrlDir = 'down';
	}
	if ((parseInt(block1.top) < 0) && (scrlDir == 'down')) {
		h = parseInt(block1.top) + scrlSpeed;
		block1.top = h+'px';
		setTimeout('scrollUp()',cas);
	}
}

function scrollUp1(arg) {
	if (arg) {
		scrlDir = 'down';
	}
	if ((parseInt(block2.top) < 0) && (scrlDir == 'down')) {
		h = parseInt(block2.top) + scrlSpeed;
		block2.top = h+'px';
		setTimeout('scrollUp1()',cas);
	}
}

function scrollDown(arg) {
	if (arg) {
		scrlDir = 'up';
	}
	if (dom) divH = document.getElementById('onasDivText').offsetHeight;
	else if (ie) divH = document.all['onasDivText'].offsetHeight;
	else if (ns) block1.document.height;
	divBottom = parseInt(block1.top)*-1;
	if ((divBottom<divH-165) && (scrlDir == 'up')) {
		h = parseInt(block1.top)-scrlSpeed;
		block1.top = h+'px';
		setTimeout('scrollDown()',cas);
	}
}

function scrollDown1(arg) {
	if (arg) {
		scrlDir = 'up';
	}
	if (dom) divH = document.getElementById('referenceDivText').offsetHeight;
	else if (ie) divH = document.all['referenceDivText'].offsetHeight;
	else if (ns) block2.document.height;
	divBottom = parseInt(block2.top)*-1;
	if ((divBottom<divH-165) && (scrlDir == 'up')) {
		h = parseInt(block2.top)-scrlSpeed;
		block2.top = h+'px';
		setTimeout('scrollDown1()',cas);
	}
}

function stop() {
	scrlDir = false;
}

function getreadytorumble(which,which2) {
	if (!moving) {
		if (which2) {
			if (which == "onas"){
				block1.top = 0;
			}
			if (which == 'reference'){
				block2.top = 0;
			}
		}
		if (dom) mycara = document.getElementById(which + 'caraDiv').style;
		else if (ie) mycara = document.all[which + 'caraDiv'].style;
		else if (ns) mycara = document[which + 'caraDiv'];
		mycara.ypos = parseInt(mycara.top);
		toswitch = which + 'Div';
		if (which2) toswitch2 = which2;
		else if (!which2) toswitch2 = false;
		moving = true;
		if (mycara.ypos < 300) {
			slideDown();
		}
		if (mycara.ypos > 300) {
			slideUp('1');
		}
	}
}

function slideDown() {
	if (mycara.ypos < 433) {
		mycara.ypos += 7;
		mycara.top = mycara.ypos+'px';
		if (mycara.ypos > 433) {
			mycara.ypos = 433;
			mycara.top = mycara.ypos+'px';
		}
		setTimeout('slideDown()',10)
	}
	else {
		showDiv(toswitch)
		if (toswitch2) { showDiv(toswitch2) }
		moving = false;
	}
}

function slideUp(arg) {
	if (arg) {
		hideDiv(toswitch)
		if (toswitch2) { hideDiv(toswitch2) }
	}
	if (mycara.ypos > 267) {
		mycara.ypos -= 7;
		mycara.top = mycara.ypos+'px';
		if (mycara.ypos < 267) {
			mycara.ypos = 267;
			mycara.top = mycara.ypos+'px';
		}
		setTimeout('slideUp()',30)
	}
	else {
		moving = false;
	}
}

function showDiv(name) {
	if (dom) document.getElementById(name).style.visibility = 'visible';
	else if (ie) document.all[name].style.visibility = 'visible';
	else if (ns) document[name].visibility = 'show';
}

function hideDiv(name) {
	if (dom) document.getElementById(name).style.visibility = 'hidden';
	else if (ie) document.all[name].style.visibility = 'hidden';
	else if (ns) document[name].visibility = 'hide';
}


function MM_reloadPage(init) {
	if (init==true) with (navigator) {
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
			document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage;
		}
	}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() {
	var i,x,a=document.MM_sr;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) {
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	}
  if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n);
	return x;
}

function MM_swapImage() {
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3){
		if ((x=MM_findObj(a[i]))!=null){
			document.MM_sr[j++]=x;
			if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
		}
	}
}

var d = document;

var isNav, isIE, isNS6;
if(d.layers) {isNav = 1;}
else if(d.all) {isIE = 1;}
else if (d.getElementByID) {isNS6 = 1;}

function getObj(obj) {
	if(isIE) {theObj = eval("d.all."+obj+".style");}
	else if(isNav) {theObj = eval("d."+obj);}
	else {theObj = eval("d.getElementById('"+obj+"')");}
	return theObj;
}

function shiftTo(obj, x, y) {
	if(isIE) {
		obj.pixelLeft = x;
		obj.pixelTop = y;
	}
	else if(isNav) {
		obj.moveTo(x,y);
	}
	else {
		obj.style.top = y+'px';
		obj.style.left = x+'px';
	}
}

function pageheight() {
	if(isIE) {
		if (document.body.clientHeight<document.documentElement.clientHeight) h = document.documentElement.clientHeight;
		else h = document.body.clientHeight;
		return h-18;
	}
	else {return window.innerHeight-18;}
}

function pagewidth() {
	if(isIE) {return document.body.clientWidth-18;}
	else {return window.innerWidth-18;}
}

var mx, my;

function mousemove(e) {
	if (isIE) {
		mx = window.event.clientX;
		my = window.event.clientY;
	}
	else {
		mx = e.pageX;
		my = e.pageY;
	}
	px=pagewidth();
	py=pageheight();
	//alert(px+';'+py+';;'+mx+';'+my);

	shiftTo(om1,py-mx,py-my);
	shiftTo(om2,px-mx,my);
	shiftTo(om3,px-mx,py-my);
	shiftTo(om4,px-my,py-mx);
	shiftTo(om5,mx,py-my);
}

var om1, om2, om3, om4, om5;

function startupa() {
	om1 = getObj('m1');
	om2 = getObj('m2');
	om3 = getObj('m3');
	om4 = getObj('m4');
	om5 = getObj('m5');
	if (isNav) d.captureEvents(Event.MOUSEMOVE);
	d.onmousemove = mousemove;
}

function tmt_findObj(n){
	var x,t;
	if((n.indexOf("?"))>0&&parent.frames.length){
		t=n.split("?");
		x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
	}
	else{
		x=document.getElementById(n)
	}
	return x;
}

function MM_showHideLayers() {
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	if(document.getElementById){
		for (i=0; i<(args.length-2); i+=3){
			obj=tmt_findObj(args[i]);v=args[i+2];
			v=(v=='show')?'visible':(v='hide')?'hidden':v;
			if(obj)obj.style.visibility=v;
		}
	}
	else{
		for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) {
			v=args[i+2];
			if (obj.style) {
				obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v;
			}
			obj.visibility=v;
		}
	}
}
