// 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.roll == 'same-same')? this.imfr : 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()

// Open new window
function newWin(src,winName,w,h,prop,xshift) {
	if (!xshift) { xshift = 0; }
	var winLeft = (screen.width - w) / 2;
	var winTop = (screen.height - h) / 2;
	if (prop == '') { var winProp = 'menubar=no,resizable=no,scrollbars=0,status=no,toolbar=no,locationbar=no,directories=no'; }
	else { var winProp = prop; }
	winProp += ',width='+w+',height='+h+',left='+eval(winLeft+xshift)+',top='+winTop;
	Win = window.open(src,winName,winProp);
	Win.focus();
}

// Open new window for image
function imgWin(imgsrc,imgname,w,h,sekce) {
	var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
	newWin('','foto',w,h);
	if(isOpera) {
		if (w != Win.innerWidth || h != Win.innerHeight) { 
			Win.resizeTo(w+10,h+30); 
		}
	}
	else if(!is.ns4) {
		if (w != Win.document.body.clientWidth || h != Win.document.body.clientHeight) { Win.resizeTo(w+10,h+30); }
	}
	else {
		if (w != Win.innerWidth || h != Win.innerHeight) { Win.resizeTo(w+10,h+30); }
	}
	Win.document.open();
	Win.document.write('<html>\n');
	Win.document.write('<head>\n');
	Win.document.write('	<title>'+imgname+'</title>\n');
	Win.document.write('	<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">\n');	
	Win.document.write('</head>\n');
	if (sekce == "vk") {
		Win.document.write('<body bgcolor="#FFFFFF" leftmargin="35" topmargin="25" marginwidth="35" marginheight="25">\n');
		Win.document.write('<a href="javascript:window.close()"><img src="'+imgsrc+'" width="208" height="439" border="0" alt="'+imgname+'"></a>\n');
	}
	else {
		Win.document.write('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">\n');
		Win.document.write('<a href="javascript:window.close()"><img src="'+imgsrc+'" width="'+w+'" height="'+h+'" border="0" alt="'+imgname+'"></a>\n');
	}
	Win.document.write('</body>\n');
	Win.document.write('</html>\n');
	Win.document.close();
	Win.focus();
}

//
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))
      } 
   }
}

