// normal.js Copyright Tonn Talpsepp ttalpsepp@hotmail.com
var imgtimer;
var nnimi;
var nnr;
var unr;
var timer;
var ptimer;
var utimer;
var muudatimer;
var timerdivratas;
var liikur1="#B60000"
var liikur2="#B60000"
var liikur3="#B60000"
var liikur4="#B60000"
var liikur5="#B60000"
var juur='http://localhost/author2008/'
//var juur='http://www.author.ee/'

graphic1=new Image();
graphic1.src=juur+"elemendid/tab-active.gif";
graphic2=new Image();
graphic2.src=juur+"elemendid/tab-passive.gif"; 

function imgvaheta(nr) {
	var avanev;
	nnr=nr;
	nnimi="mm"+nr;
	animi="ava"+nr;
	//alert(animi)
	clearTimeout(imgtimer);
	kinni(1);
	avanev=document.getElementById("avanevdiv"+nr);
	avanev.style.visibility="visible";
	if (document.images){
		document[nnimi].src=juur+'elemendid/tab-active.gif'
		document.getElementById(animi).style.color="#000000";
	}
}

function kinni(ss){
	var avanev;
	var liikuv;
	var nimi;
	var avanimi;
	for (var i=1;i<6;i++){
		
		if (i!=nnr || ss!=1){
			avanev=document.getElementById("avanevdiv"+i);
			avanev.style.visibility="hidden";
			liikuv=document.getElementById("ll"+i);
			//liikuv.style.backgroundColor="#edf6f9";
			liikuv.style.backgroundColor="#eeeeee";
			nimi="mm"+i;
			avanimi="ava"+i;
			document[nimi].src=juur+'elemendid/tab-passive.gif';
			document.getElementById(avanimi).style.color="#ffffff";
		}
	}
	if (flag && ss!=1){
		avanimi="ava"+flag.substring(2);
		//alert(flag.substring(2))
		document[flag].src=juur+'elemendid/tab-active.gif';
		document.getElementById(avanimi).style.color="#000000";
	}
}

function imgvahetatagasi(nr) {
nnimi="mm"+nr;
imgtimer=setTimeout("imgtagasi1()",300);
}

function imgtagasi1(){
kinni();
}

function bbrowser() {
	var b=navigator.appName;
	if (b=="Netscape") this.b="ns";
	else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) this.b = "opera";
	else if (b=="Microsoft Internet Explorer") this.b="ie";
	if (!b) alert('Tundmatu brauser./nPuudub toetus sellele brauserile,');
	this.version=navigator.appVersion;
	this.v=parseInt(this.version);
	this.ns=(this.b=="ns" && this.v>=4)?true:false;
	this.ie=(this.b=="ie" && this.v>=4)?true:false;
	this.opera=(this.b=="opera")?true:false;
	this.dom=(document.childNodes)?true:false;
}
on = new bbrowser();

function too(kuhu){
clearInterval(timer);
clearInterval(ptimer);
clearTimeout(muudatimer);
hlp=document.getElementById("ll"+nnr);
hlp.style.backgroundColor=eval("liikur"+nnr);
topKuhu=kuhu.offsetTop;
leftKuhu=kuhu.offsetLeft;
if (on.opera && !document.defaultView){
hlp.style.zIndex=-1;
leftKuhu=kuhu.parentElement.offsetLeft;
topKuhu=topKuhu+10;
}
if (hlp.style.top=="")
hlp.style.top=0;
if (hlp.style.left=="")
hlp.style.left=0;
ptimer=setInterval('pii()',1)
}

function muuda(){
hlp=document.getElementById("ll"+nnr);
muudatimer=setTimeout('fade()',50)
}

function fade(){
var varv;
var v= new Array()
var vv="#";
var vk;
var varv1;
//var c= new Array("#", "ed", "f6", "f9");
var c= new Array("#", "ee", "ee", "ee");
var lipp=false;
if (hlp.currentStyle){
varv=hlp.currentStyle.backgroundColor
}
else if (document.defaultView && document.defaultView.getComputedStyle){
varv1=document.defaultView.getComputedStyle(hlp, "");
varv=varv1.getPropertyValue("background-color");
}
else if (hlp.style){
varv=hlp.style.backgroundColor
}
if (varv.indexOf("rgb")!=-1){
v[1]=parseInt(varv.substring(varv.indexOf("(")+1, varv.length));
v[2]=parseInt(varv.substring(varv.indexOf(",")+2, varv.length));
v[3]=parseInt(varv.substring(varv.lastIndexOf(",")+2, varv.length));
}
else {
v[1]=parseInt(varv.substring(1,3), 16);
v[2]=parseInt(varv.substring(3,5), 16);
v[3]=parseInt(varv.substring(5,7), 16);
}
for (var i=1; i<4; i++){
if (v[i]>parseInt(c[i], 16)){
v[i]--;
lipp=true;
}
else if (v[i]<parseInt(c[i], 16)){
v[i]++;
lipp=true;
}
if (v[i]<16){
vk="0"+v[i].toString(16);
}
else {
vk=v[i].toString(16);
}
vv+=vk;
}
hlp.style.backgroundColor=vv;
if (lipp){
muudatimer=setTimeout('fade()',5);
}
}

function vii(){
	if (parseInt(hlp.style.top)>topKuhu){
			if (Math.abs(parseInt(hlp.style.top)-topKuhu)<15){
			sum=parseInt(hlp.style.top)-5
			hlp.style.top=sum
			}
		else if (Math.abs(parseInt(hlp.style.top)-topKuhu)<5){
				sum=parseInt(hlp.style.top)-1
				hlp.style.top=sum
				}
		else{
			sum=parseInt(hlp.style.top)-15
			hlp.style.top=sum
			}
		}
	else if (parseInt(hlp.style.top)<topKuhu){
		if (Math.abs(parseInt(hlp.style.top)-topKuhu<15)){
			sum=parseInt(hlp.style.top)+5
			hlp.style.top=sum
		}
		else if (Math.abs(parseInt(hlp.style.top)-topKuhu)<5){
			sum=parseInt(hlp.style.top)+1
			hlp.style.top=sum
		}
		else{
			sum=parseInt(hlp.style.top)+15
			hlp.style.top=sum
		}
	}
	else {
	clearInterval(timer);
	}
}

function pii(){
	if (parseInt(hlp.style.left)>leftKuhu){
		if (Math.abs(parseInt(hlp.style.left)-leftKuhu)<15){
			sum=parseInt(hlp.style.left)-5
			hlp.style.left=sum
		}
		else if (Math.abs(parseInt(hlp.style.left)-leftKuhu)<5){
			sum=parseInt(hlp.style.left)-1
			hlp.style.left=sum
		}	
		else{
			sum=parseInt(hlp.style.left)-25
			hlp.style.left=sum
		}
	}
	else if (parseInt(hlp.style.left)<leftKuhu){
		if (Math.abs(parseInt(hlp.style.left)-leftKuhu)<15){
			sum=parseInt(hlp.style.left)+5
			hlp.style.left=sum
		}
		else if (Math.abs(parseInt(hlp.style.left)-leftKuhu)<5){
			sum=parseInt(hlp.style.left)+1
			hlp.style.left=sum
		}	
		else{
			sum=parseInt(hlp.style.left)+25
			hlp.style.left=sum
		}
	}
	else {
		clearInterval(ptimer);
		if (hlp.style.top!=topKuhu){
			timer=setInterval('vii()',1)
		}
	}
}
if (document.addEventListener){
document.addEventListener("mouseover",aaa,true);
document.addEventListener("mouseout",bbb,false);
}
else{
document.onmouseover = aaa;
document.onmouseout = bbb;
}

function bbb(event){
if(on.ie){
ccc = window.event.srcElement
while (ccc){
if (ccc.id.substring(0,6)!="avanev" && ccc.id.substring(0,6)!="divava" && ccc.id.substring(0,2)!="uu" && ccc.id.substring(0,9)!="divvratas"){
ccc=ccc.parentElement;}
else{
break;}
}
}
else{
ccc = event.target
while (ccc){
if (ccc.id){
if ((ccc.id.substring(0,6)!="avanev" && ccc.id.substring(0,6)!="divava" && ccc.id.substring(0,2)!="uu" && ccc.id.substring(0,9)!="divvratas") || ccc.id==null || ccc.id==""){
ccc=ccc.parentNode;}
else{
break;}
}
else{
ccc=ccc.parentNode;
}
}
}
if (ccc){
if (ccc.id){
if (ccc.id.substring(0,2)=="uu"){
ccc.style.visibility="hidden"
imgvahetatagasi(nnimi);
}
else if (ccc.id.substring(0,6)=="divava"){
imgvahetatagasi(ccc.id.charAt(6));
var rr=document.getElementById("divava"+ccc.id.charAt(6)+"a");
rr.style.visibility="hidden"
}
else if (ccc.id.substring(0,9)=="divvratas"){
timerdivratas=setTimeout('fdivvrataskinni()',300);
}
else{
imgvahetatagasi(nnimi);
}
}}}

function aaa(event){
if(on.ie){
ccc = window.event.srcElement
while (ccc){
if (ccc.id.substring(0,6)!="avanev" && ccc.id.substring(0,6)!="divava" && ccc.id.substring(0,2)!="uu" && ccc.id.substring(0,9)!="divvratas"){
ccc=ccc.parentElement;}
else{
break;}
}
}
else{
ccc = event.target
while (ccc){
if (ccc.id){
if ((ccc.id.substring(0,6)!="avanev" && ccc.id.substring(0,6)!="divava" && ccc.id.substring(0,2)!="uu" && ccc.id.substring(0,9)!="divvratas") || ccc.id==null || ccc.id==""){
ccc=ccc.parentNode;}
else{
break;}
}
else{
ccc=ccc.parentNode;
}
}
}
if (ccc){
if (ccc.id){
if (ccc.id.substring(0,2)=="uu"){
clearTimeout(utimer);
ccc.style.visibility="visible"
clearTimeout(imgtimer);
}
else if (ccc.id.substring(0,6)=="divava"){
imgvaheta(ccc.id.charAt(6));
var rr=document.getElementById("divava"+ccc.id.charAt(6)+"a");
rr.style.visibility="visible"
}
else if (ccc.id.substring(0,9)=="divvratas"){
fdivvratas();
}
else{
clearTimeout(imgtimer);
}
}}
}

function uu(nr){
unr=nr
clearTimeout(utimer);
ukinni();
var uu=document.getElementById("uu"+nr);
uu.style.visibility="visible"
}

function ukinni(){
var udoc
for (var i=1;i<21;i++){
udoc=document.getElementById("uu"+i);
if(udoc){
udoc.style.visibility="hidden"
}
}
}

function uu1(nr){
unr=nr
utimer=setTimeout('uu2()',300)
}

function uu2(){
var uu=document.getElementById("uu"+unr);
uu.style.visibility="hidden"
}

function ava1(aadr){
newwin=window.open(aadr,'am','width=650,height=450')
newwin.focus();
return false;
}

function ava(aadr){
newwin=window.open(aadr,'m','width=700,height=500,scrollbars')
newwin.focus();
return false;
}
function fdivvratas(){
clearTimeout(timerdivratas);
var divratas=document.getElementById("divvratas");
divratas.style.visibility="visible";
}
function fdivvrataskinni(){
var rs=document.getElementById("divvratas");
rs.style.visibility="hidden";
}
function fdivvratas1(){
fdivvratas();
timerdivratas=setTimeout('fdivvrataskinni()',2000); 
return false;
}
var teh_kiri_memory="#B60000";
var geo_kiri_memory="#545454";
function ratas_element_active1(see){
	see.style.backgroundColor="#aaaaaa";
}
function ratas_element_passive1(see){
	see.style.backgroundColor=teh_kiri_memory;
}
function ratas_element_active2(see){
	see.style.backgroundColor="#aaaaaa";
}
function ratas_element_passive2(see){
	see.style.backgroundColor=geo_kiri_memory;
}
function teh_andmed(mis){
	teh=document.getElementById("teh_andmed");
	geo=document.getElementById("raami_geomeetria");
	teh_kiri=document.getElementById("teh_andmed_kiri");
	geo_kiri=document.getElementById("raami_geomeetria_kiri");
	if (mis>0){
		teh.style.display="block";
		geo.style.display="none";
		teh_kiri.style.backgroundColor="#B60000";		
		geo_kiri.style.backgroundColor="#545454";
		teh_kiri_memory="#B60000";
		geo_kiri_memory="#545454";
	} else {
		geo.style.display="block";
		teh.style.display="none";
		geo_kiri.style.backgroundColor="#B60000";
		teh_kiri.style.backgroundColor="#545454";
		geo_kiri_memory="#B60000";
		teh_kiri_memory="#545454";
	}
}
function ratta_pilt_vaheta(mis,mis1){
	document.getElementById("ratta_pilt").src=mis;
	document.getElementById("ratta_pilt_href").href=mis1;
}
function view360(aadr){
	newwin=window.open(aadr,'_blank','width=400,height=300,scrollbars=no')
	newwin.focus();
	return false;
}
