// Rollovers Object
// ver 1.11 - 17.09.2003
// Copyright (c) 2001-2003 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') {
		if (x == this.imto) { docImg[this.name+((ver)? ver : '')].src = eval(this.imname+((this.z != 0)? this.z : x)+'.src'); }
		else { 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,topx,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 && topx!=null)? '#'+id+' {position:absolute; left:'+left+'px; top:'+topx+'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
  var ua = navigator.userAgent;
	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.o = (ua.indexOf("Opera") > -1 );
	this.o5 = (ua.indexOf("Opera/5") > -1 || ua.indexOf("Opera 5") > -1);
	this.o6 = (ua.indexOf("Opera/6") > -1 || ua.indexOf("Opera 6") > -1);
	this.o56 = (this.o5 || this.o6);
	this.o7 = (ua.indexOf("Opera/7") > -1 || ua.indexOf("Opera 7") > -1);
	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.o)
	this.ie4 = (this.version.indexOf('MSIE 4')>0 && !this.o)
	this.ie5 = (this.version.indexOf('MSIE 5.0')>0 && !this.o)
	this.ie55 = (this.version.indexOf('MSIE 5.5')>0 && !this.o)
	this.ie6 = (this.version.indexOf('MSIE 6.0')>0 && !this.o)
	this.min = (this.ns||this.ie)
}
is = new BrowserCheck()

// 
function setCookie(name, value, expire) {
   document.cookie = name + "=" + escape(value)  + "; path=/" + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}
// Reads cookie values. 
function getCookie(Name) {
   var search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search) 
      if (offset != -1) { // if cookie exists 
         offset += search.length 
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset) 
         // set index of end of cookie value
         if (end == -1) 
			 end = document.cookie.length
	         return unescape(document.cookie.substring(offset, end))
      } 
   }
}
// Random number
function getRndNum(sum,cor) {
	var x = parseInt(Math.random() * sum + 1) + ((cor)? cor : 0);
	return x;
}
// Object caller
function obj(id) {
	return document.getElementById(id);
}
