// Rollovers Object
// ver 1.07 - 18.7.2001
// Copyright (c) 2001 Sabbagh 

// Rollovers method:
// 'out-ovr' ........ meni obrazky na "ovr" varianty u vsech odkazu
// 'same-other' ..... meni stale stejny obrazek na jine u vsech odkazu
// 'same-same' ...... meni stale stejny obrazek na stale stejny jiny u vsech odkazu
// 'other' .......... meni obrazek na jinem miste nez je aktivacni odkaz

function Rollovers(numitems,name,roll,layer,imdiv) {
	this.imfr = 1;
	this.imto = numitems;
	this.name = name;
	this.roll = (roll != null)? roll : 'out-ovr';	// or 'same-other' or 'same-same' or 'other'
	this.imarray = null;	// pro variantu s pismeny
	this.doclayer = 'document.';
	this.layer = (layer != null)? eval('new Array('+layer+')') : null;
	this.imdiv = (imdiv != null)? imdiv : null;
	this.spr = '_';
	this.imname = this.name+this.spr;
	this.dir = 'img';
	this.ext = 'gif';
	//alert("roll = "+this.roll+"\nimto = "+this.imto+"\ndir = "+this.dir+"\nname = "+this.name+"\next = "+this.ext);
	this.z = 0;
	this.testOver = -1;
	this.testClick = 0;
	
	if (document.layers && (this.layer != null) && (this.imdiv != null)) {
		for (var i=0; i<this.layer.length; i++) {
			this.doclayer += this.layer[i]+'.document.';
		}
		this.doclayer += this.imdiv+this.spr;
	}
	
	this.Activate = Activate;
	this.Preload = Preload;
	this.Mouse = Mouse;
	this.Click = Click;
	this.Resize = Resize;
}
function Activate() {
	for (i = this.imfr; i <= this.imto; i++) {
		if (this.imarray != null) {n = this.imarray[i-1];}
		else {n = i;}
		this.Preload(this.imname+n);
		if (this.roll == 'out-ovr') {
			this.Preload(this.imname+n+'_ovr');
		}
	}
}
function Preload(imgsrc) {
	if (document.images) {
		eval(imgsrc+' = new Image()');
		var imsrc = '/'+this.dir+'/'+imgsrc+'.'+this.ext;
		eval(imgsrc+'.src = "'+imsrc+'"');
		//alert(imgsrc+'.src = "'+imsrc+'"');
	}
}
function Mouse(x,obj) {
	var docImg = (this.doclayer != 'document.')? eval(this.doclayer+this.testClick+'ns.document.menuDiv_1.document.images[this.imname+x]') : eval(this.doclayer+'images[this.imname+x]');
	if (this.roll == 'out-ovr') {
		if (x != this.z) {
			if (obj == 'ovr') {
				docImg.src = eval(this.imname+x+'_ovr.src');
				this.testOver = x;
			} else {
				docImg.src = eval(this.imname+x+'.src');
				this.testOver = 0;
			}
		}
	} else if (this.roll == 'same-other') {
		if (x != this.z) {
			if (obj == 'ovr') {
				docImg.src = eval(this.imname+x+'.src');
				this.testOver = x;
			} else {
				docImg.src = eval(this.imname+this.imto+'.src');
				this.testOver = 0;
			}
		}
	} else if (this.roll == 'same-same') {
		if (x != this.z) {
			if (obj == 'ovr') {
				docImg.src = eval(this.imname+this.imto+'.src');
				this.testOver = x;
			} else {
				docImg.src = eval(this.imname+this.imfr+'.src');
				this.testOver = 0;
			}
		}
	} else if (this.roll == 'other') {
		document.images[this.name].src = eval(this.imname+x+'.src');
	}
}
function Click(x) {
	if (this.z > 0 && this.z != x) { document.images[this.imname+this.z].src = eval(this.imname+this.z+'.src'); }
	if (x > 0) { this.Mouse(x,'ovr'); }
	this.z = x;
}
function Resize() {
	var z = this.z;
	this.z = 0;
	this.Click(z);
}
// CSS Function
function css(id,left,top,width,height,color,vis,z,other) {
	if (id=="START") return '<STYLE TYPE="text/css">\n'
	else if (id=="END") return '</STYLE>'
	var str = (left!=null && top!=null)? '#'+id+' {position:absolute; left:'+left+'px; top:'+top+'px;' : '#'+id+' {position:relative;'
	if (arguments.length>=4 && width!=null) str += ' width:'+width+'px;'
	if (arguments.length>=5 && height!=null) {
		str += ' height:'+height+'px;'
		if (arguments.length<9 || other.indexOf('clip')==-1) str += ' clip:rect(0px '+width+'px '+height+'px 0px);'
	}
	if (arguments.length>=6 && color!=null) str += (is.ns)? ' layer-background-color:'+color+';' : ' background-color:'+color+';'
	if (arguments.length>=7 && vis!=null) str += ' visibility:'+vis+';'
	if (arguments.length>=8 && z!=null) str += ' z-index:'+z+';'
	if (arguments.length==9 && other!=null) str += ' '+other
	str += '}\n'
	return str
}
function writeCSS(str,showAlert) {
	str = css('START')+str+css('END')
	document.write(str)
	if (showAlert) alert(str)
}
// Window Status Text
function rs(txt) {
	text = txt;
	window.status = text;
	return true;
}
// BrowserCheck Object
function BrowserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.version = navigator.appVersion
	this.v = parseInt(this.version)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (this.version.indexOf('MSIE 4')>0)
	this.ie5 = (this.version.indexOf('MSIE 5')>0)
	this.min = (this.ns||this.ie)
}
is = new BrowserCheck()


// otevření nového okna

function openWin( path, width, height ) {
	divadlowin=window.open(path,'divadlowin','scrollbars=no,resizable=no,resize=no,width='+width+',height='+height+',screenX='+getCenterW(width)+',screenY='+getCenterH(height)+',top='+getCenterH(height)+',left='+getCenterW(width));
	divadlowin.focus();
}

function getCenterW(width) {
	return parseInt( eval( (screen.width-parseInt(width))/2 ) );
}
function getCenterH(height) {
	return parseInt( eval( (screen.height-parseInt(height))/2 ) );
}

// funkce pro submenu na HP:
function getstatStr( layerName, show )	{
statStr = "";
	if (is.ie) {
		if( show ) {	
			statStr = "document.all[ '" + layerName + "' ].style.visibility = 'visible'";
		} else {
			statStr = "document.all[ '" + layerName + "' ].style.visibility = 'hidden'";
		}
	}
	else if (is.ns4) {
		if( show ) {
			statStr = "document.layers[ '" + layerName + "' ].visibility = 'show'";
		} else {
			statStr = "document.layers[ '" + layerName + "' ].visibility = 'hide'";
		}
	}
	else if (is.ns5) {
		nsLayer = document.getElementById(layerName);
	if( show ) {
		statStr = "nsLayer.style.visibility = 'visible'";
	} else {
		statStr = "nsLayer.style.visibility = 'hidden'";
	}
}
return statStr;
}

var timer;

function hmenu( prep )	{
clearInterval(timer);
timer = null;
	for (id=1; id<=2; id++)	{
		if (id != prep) {
			eval( getstatStr( "mnu"+id, false ) );
		} 
	}
}

function viewto( num )	{
	hmenu(num);
	eval( getstatStr( "mnu"+num, true ) );
}

function obj_out()	{
	statStr = "hmenu(2)";
	timer = setInterval( statStr, 500 );
}

function obj_on()	{
	clearInterval(timer);
	timer = null;
}

// function get (x,y) for submenu HP
function getCenterW(w) {
myW = (is.ns4)? window.innerWidth-16 : document.body.offsetWidth-20;
myW = (is.ns5)? window.innerWidth : myW;	
	if (myW < 780) {
		return 84;
	} else {
		return parseInt( eval( (myW-parseInt(w))/2 ) );
	}
}
// Netscape Resize Fix - for submenu HP also
	if (document.layers) {
		widthCheck = window.innerWidth
		heightCheck = window.innerHeight
		window.onResize = resizeFix
	}
	
function resizeFix() {
	if (widthCheck != window.innerWidth || heightCheck != window.innerHeight)
	document.location.href = document.location.href
}