// 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.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;}
		if (n < 10) {n = '0' + n;}
		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) {
			// test na obsah this.dir - mensi hack pro fixaci menu
			if (obj == 'ovr' || (x == menuInitItem && (this.dir == 'img/cs/menu' || this.dir == '../img/cs/menu'))) { 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);
}
// Window Status Text
function ws(txt) {
	txt = unescape(txt);
	window.status = txt;
	return true;
}
window.defaultStatus = "";

// Cookies
function saveCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = ""
	document.cookie = name + "=" + escape(value) + expires + "; path=/";
}
function readCookie(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))
      } 
   }
}
// Change language
function changeLng(frLng,toLng) {
	var u = document.location.href;
	if (u.indexOf("/"+frLng+"/") != -1) {
		u = u.substring(0,u.indexOf("/"+frLng+"/")) + "/"+toLng+"/" + u.substring(u.indexOf("/"+frLng+"/")+4,u.length);
	} else if (u.indexOf("ng="+frLng) != -1) {
		u = u.substring(0,u.indexOf("ng="+frLng)) + "ng="+toLng + u.substring(u.indexOf("ng="+frLng)+5,u.length);
	}
	saveCookie("lng",toLng);
	//	 else if (u.indexOf("ng="+frLng) == -1 && u.indexOf("NASA") != -1) {
//		u = u + "ng="+toLng + u.substring(u.indexOf("ng="+frLng)+5,u.length);
//	}
	document.location.href = u;
}
// Repair CPS tracking
function saveTrack(name,t) {
	t = t.replace(/\'/, "*");
	t = t.replace(/\'\,\[/, "*,[");
	t = t.replace(/\[\'/g, "[*");
	t = t.replace(/\'\]/g, "*]");
	t = t.replace(/\'\,\'/g, "*,*");
	t = t.replace(/\'/g, "##");
	t = t.replace(/\*/, "'");
	t = t.replace(/\*\,\[/, "',[");
	t = t.replace(/\[\*/g, "['");
	t = t.replace(/\*\]/g, "']");
	t = t.replace(/\*\,\*/g, "','");
	saveCookie(name,t);
}
function repairTrack(name,nt) {
	if (readCookie(name)) {
		var track = '';
		t = readCookie(name);
		t = t +","+ nt;
		eval("var a = new Array("+ t +")");
		if (readCookie("lng") && readCookie("lng") != a[0]) { return; }
		for (var i=1; i<a.length; i++) {
			a[i][0] = a[i][0].replace(/\#\#/g,"'");
			track += '<a href="'+ a[i][1] +'" title="'+ a[i][0] +'" onmouseover="return ws(\''+ escape(a[i][0]) +'\')" class="text-E">'+ a[i][0] +'</a>'+((i<a.length-1)? ' - ' : '');
		}
		document.getElementById('track').innerHTML = track;
	}
}
