// Rollovers Object
// ver 1.10 - 15.12.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 jeden obrazek na jinem miste nez je aktivacni odkaz

function Rollovers(numitems,name,roll,layer) {
	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.';
	
	if (document.layers && layer != null) {
		for (var i=3; i<arguments.length; i++) {
			this.doclayer += arguments[i]+'.document.';
		}
	}
	
	this.spr = '_';
	this.imname = this.name+this.spr;
	this.dir = 'img';
	this.ext = 'gif';
	this.z = 0;
	
	this.Activate = Activate;
	this.Preload = Preload;
	this.Mouse = Mouse;
	this.Click = Click;
	this.Resize = Resize;
}
function Activate() {
	//alert("roll = "+this.roll+"\nimto = "+this.imto+"\ndir = "+this.dir+"\nname = "+this.name+"\next = "+this.ext);
	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,ver) {
	x = (this.imarray != null)? x.toLowerCase() : x;
	var docImg = eval(this.doclayer+'images');
	if (this.roll == 'out-ovr') {
		if (x != this.z) {
			if (obj == 'ovr') { docImg[this.imname+x].src = eval(this.imname+x+'_ovr.src'); }
			else { docImg[this.imname+x].src = eval(this.imname+x+'.src'); }
		}
	} else if (this.roll == 'same-other') {
		if (x != this.z) {
			if (obj == 'ovr') { docImg[this.imname+x].src = eval(this.imname+x+'.src'); }
			else { docImg[this.imname+x].src = eval(this.imname+this.imto+'.src'); }
		}
	} else if (this.roll == 'same-same') {
		if (x != this.z) {
			if (obj == 'ovr') { docImg[this.imname+x].src = eval(this.imname+this.imto+'.src'); }
			else { docImg[this.imname+x].src = eval(this.imname+this.imfr+'.src'); }
		}
	} else if (this.roll == 'other') {
		docImg[this.name+((ver)? ver : '')].src = eval(this.imname+x+'.src');
	}
}
function Click(x,overview) {
	x = (this.imarray != null)? x.toLowerCase() : x;
	var docImg = eval(this.doclayer+'images');
	if (!overview && this.z != 0 && this.z != x) { docImg[this.imname+this.z].src = eval(this.imname+this.z+'.src'); }
	if (x != 0) { this.Mouse(x,'ovr'); }
	if (!overview) { 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')>0)
	this.ie55 = (this.version.indexOf('MSIE 5.5')>0)
	this.ie6 = (this.version.indexOf('MSIE 6.0')>0)
	this.min = (this.ns||this.ie)
}
is = new BrowserCheck()
