//offseta za layer:
var xof=17;
var yof=5;
//mish:
var tempX;
var tempY;

//encoding:
var ENCODING = 'iso-8859-2';

//na manj kot kolko pikslov gremo do roba:
snapy=2;
snapx=2;

//za delat imena oz id-je:
c=st=stevc=0;

//kolko cajta ostane layer viden
var tout=500;
//po kolkmu cajtu se pokae:
var tin=700;

//na koliko cajta cekiramo oxmlhttp.responsetext
var tref=100;

//en array ki bo globalen za hranit vrednosti od setTimeout
time_out=new Array();

//kter knof je bil nazadnje prtisnjen:
var keypressed=0;

//error report on/off
var rep=0;

var isIE4 = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? true:false;
var isNS4 = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? true:false;
var isDOM = document.getElementById?true:false;
var isOK = isIE4||isNS4||isDOM;

//da posvarimo cloveka:
if (!isOK) alert("Va brskalnik ne podpira javascripta. Dolocene monosti so vam onemogocene.");


//dobi viino in irino okna:
wh = new Array (2);
function getscwh () {
	if (document.body.offsetWidth) {
		wh['h'] = document.body.offsetWidth;
		wh['w'] = document.body.offsetWidth;
	}
	else if (document.documentElement.scrollHeight) {
		wh['h'] = document.documentElement.scrollHeight;
		wh['w'] = document.documentElement.scrollWidth;
	}
	else{
		wh['h'] = window.innerHeight;
		wh['w'] = window.innerWidth;
	}
	//document.write('h:'+wh['h']+', w:'+wh['w'];
}

/*Array.prototype.keys=function(value) {
	var keys=[],x;
	for(x in this) {
		if(typeof(this[x])=='function') continue;
		if(!value||(this[x]==value)) keys.push(x);
	}
	return keys;
}*/
Array.prototype.search=function(v) {
	var x;
	for (x in this) if(this[x]==v) return true;
	return false;
}



abp=new Object();
abp.a=function(o,xp,yp){
	if(o){
		o=findo(o);
		report('object: '+o.id);
		//else ob=ob;
		if (o.nodeName) {
			this.oxp=o.offsetWidth;
			this.oyp=o.offsetHeight;
			this.ob=o;
			this.x=this.y=0;
			/*if((objct.nodeName=='DIV')&&objct.style.position=='absolute'){
				x+=objct.style.left;
				y+=objct.style.top;
			}
			else {*/
				do {this.x+=o.offsetLeft;this.y+=o.offsetTop;} 
				while(o=o.offsetParent);
			//}
		}
		report('ap->x:'+this.x+', y:'+this.y);
		return Array((xp?this.x+this.oxp:this.x),(yp?this.oyp+this.y:this.y));
	}
	return Array(xp,yp);
}
abp.x=0;
abp.y=0;
//sam zato da ni treba jit 2x skoz zanko.
abp.ob='';
abp.oxp=0;
abp.oyp=0;

function abspos(o,xp,yp) {
	return abp.a(o,xp,yp);
}
//za pozicijo levo dolocit:
function absx(ob,pl) {
	if(mid(ob)==abp.ob&&0) return abp.x+(pl?abp.oxp:0);
	var p=abp.a(ob,pl);
	//p=Array(abp.x,abp.y);
	report('absx: '+p[0]);
	return p[0];
}
//in za zgori:
function absy(ob,pl) {
	if(mid(ob)==abp.ob) return abp.y+(pl?abp.oyp:0);
	var p=abp.a(ob,null,pl);
	//p=Array(abp.x,abp.y);
	report('absy: '+p[1]);
	return p[1];
}

//da ne zgine array, ce ga e enkrat poklicemo - tle noter bo kar cel objekt.
alive=new Array();
//dd=new Object();
function dd(oName){
	if(oName){
		//this.o='';
		if(oName.nodeName) {
			this.o=oName;
			oName=mid(oName);
		}
		else /*if(!this.o)*/{
			if (!(this.o=document.getElementById(oName))) this.o=document.getElementById(oName='showhide');
			//=new Object(obj);
		}
		this.id=oName;
		//if(!alive[oName])alive[oName]=this;
		//this.write('oName:'+oName);
		/*if(this.o)*/return oName;
	}
	return false;
}
//dd.prototype=new Object();
dd.prototype.newtxt='';
dd.prototype.txt='';
dd.prototype.x=0;
dd.prototype.y=0;
dd.prototype.o='';
dd.prototype.id=0;
dd.prototype.ap=false;
dd.prototype.tout=0;
//nastavi text, kmalu fade_in, fade_out
dd.prototype.write=function(str,p,h){
	p=((p=='++')||(p=='--'))?p:false;
	str=unescape(str);
	if((p&&str)||(!p&&(this.txt!=str))) {
		this.txt=str;
		this.hide(0,1);
		//tabelca za razno:
		if ((this.id=='showhide')||((str=='loading...')&&(this.o.tagName!='SPAN')))str='<table cellspacing="0" cellpadding="0" class="showhide"><tbody><tr><td width="5" class="showhide"></td><td class="showhide">'+str+'</td><td width="5" class="showhide"></td></tr></tbody></table>';
		//ce je za slikco source:
		if (this.id=='showpic') str='<img src="'+str+'">';
		with (this.o) {
			if (this.ap=((nodeName=='DIV')&&((style.position=='relative')||(style.position=='absolute')))) {
				style.position='absolute';
				style.width="auto";
				style.height="auto";
				sl=parseInt(style.left);
				style.left=1;
				st=parseInt(style.top);
				style.top=1;
				switch(p) {
					case '++': innerHTML+=str;
					break;
					case '--': innerHTML=str+innerHTML;
					break;
					default: innerHTML=str;
				}
				//this.o.offsetWidth=parseInt(this.o.offsetWidth);
				//this.o.offsetHeight=parseInt(this.o.offsetHeight);
				style.width=offsetWidth;
				style.height=offsetHeight;
				//report(parseInt(style.height));
				getmouseXY(this.o,sl,st);
			}
			else {
				switch(p) {
					case '++': innerHTML+=str;
					break;
					case '--': innerHTML=str+innerHTML;
					break;
					default: innerHTML=str;
				}
			}
		}
		this.hide(1,(h||p)?1:0);
	}
	else this.hide(1,1);
}
dd.prototype.a=false;
dd.prototype.hide=function(h,when){
	if(this.o&&(this.o.nodeName=='DIV')) {
		var when=parseInt(when);
		window.clearTimeout(this.tout);
		if (this.a=h) {
			h = 'visible';
			if(!when) when = tin;
		}
		else {
			h = 'hidden';
			if(!when) when = tout;
		}
		if (when==1){
			this.o.style.visibility=h;
			//this.o.innerHTML = '';
		}
		else {
			this.tout=window.setTimeout('alive["'+this.o.id+'"].hide('+this.a+',1);', when);
		}
	}
}

//kaze layer. glavna funkcija.
function show (string,source,objN,hu,h,m,fresh,send,p) {
	//var e = window.event || arguments.callee.caller.arguments[0];
	//if(e) followMouse(e);
	//report(e.clientX);
	//preverimo sirino/visino zaslona:
	if (!(wh['h']&&wh['w'])) getscwh();
	//report(h+'nana');
	//report('m: '+m);
	var string=string?string:'';
	if(string=='null')string='';
	source=(source&&source!='0')?source:'';
	objN=mid(objN);
	objN=objN?objN:'showhide';
	fresh=fresh?fresh:'';
	hu=hu?hu:'';
	send=send?send:'';
	var a,el=l=td=add=nhide=endo=x=y=false;
	if(source=='++'){add='++';source='';};
	if(source=='--'){add='--';source='';};
	if(string=='++'){add='++';string='';};
	if(string=='--'){add='--';string='';};
	//iz serverja
	//report(source);
	if (source) {
		report('loading from: '+source);
		getFile(add,source,objN,hu,h,m,fresh,send);
		l=true;
	}
	//poicemo moj layer, ce je eval potem evaliram kodo:
	//report('m: '+m);
	if(objN=='eval') {
		report('show->myeval');
		myeval(string);
	}//else if(objN=='evaly') document.a.ev.value=string;
	//drugace pa pogledam kaj lahko nardim:
	else {
		el=findo(hu);
		//sirina/visina od necesa:
		if(h){
			if(isFinite(h)){
				//ce je h number in vecji od 1, je v m lahko podan ce ga skrivamo.
				if(h>1){
					y=h;
					n=0;
					nhide=true;
					if(isFinite(m))x=m;
					else {x=m[0];nhide=!m[1];};
					m=1;
				}
				//report('x: '+x);
			}
			else {
				//ce je podan za h array, potem je prvi argument ime objekta
				//in drugi ce hocem na koncu al zacetku x in / ali y (x=1,y=2,oboje=3)
				//in m argument je potem za hide, ampak je 1 za hide in 0 za leave!
				if(typeof(h)=='object'&&!h.nodeName){
					endo=h[1];
					h=h[0];
				}
				//report(h);
				if(h=findo(h)) {
					report('xy glede na: '+h.id);
					a=abspos(h,endo);
					x=a[0];
					y=a[1];
				}
				nhide=!m;
				m=1;
			}
		}
		//ce ni objekta u arrayu, ga nardim:
		if(!alive[objN]) {
			var objN=new dd(objN);//new Object(dd);
			if(!alive[objN.id])alive[objN.id]=objN;
			objN=objN.id;
			report('created: '+objN);
		}
		if(l&&!add)string='loading...';
		//alive[objN].hide(0,1);
		
		
		//ce ni absolutno pozicjoniran, se ga ne dotikam:
		if (alive[objN].o.style.visibility=='hidden'&&!(m||x||y)) {
			x=tempX;
			y=tempY;
		}
		alive[objN].write(string,add,p);
		//ce sta vec od 1, ga prestavi na tja kamor smo hoteli:
		if (x||y) {			
			//report(x);
			getmouseXY(alive[objN].o,(x<=snapx)?0:x,(y<=snapy)?0:y,0,0);
			if(alive[objN].o.a)report('postavljeno na x:'+x+', y:'+y);
		}
		//tale el je element okol katerga skirvamo in premikamo layer.
		//if(hu)el = el?el:document.getElementById(hu);
		if (el) {
			//var f='';
			if (!m){
				//window.setTimeout(function(){evtadd(el,'onmousemove','getmouseXY(alive["'+objN+'"].o);');},10);
				evtadd(el,'onmousemove','getmouseXY(alive["'+objN+'"].o);');
			}
			if (!nhide){
				//window.setTimeout(function(){evtadd(el,'onmouseout','alive["'+objN+'"].hide();');},10);
				evtadd(el,'onmouseout','alive["'+objN+'"].hide();');
			}
		}
	}
}

function cstm (of,nf,rem){
	//ce najdemo funkcijo:
	if(!of) return rem?0:nf;
	if(!nf) return of;
	var fs=of.indexOf(nf);
	if(fs==-1){
		if(!rem) of+=';'+nf;
		//report('new:'+ofun);
	}
	else {
		if(rem) {
			var st=of.slice(0,fs);
			of=of.slice(fs+nf.length-1,of.length-1);
			of=st+of;
		}
		//report('found:'+fs);
	}
	return of;
}

//skriva oz. pokae layer. kmalu tudi fade in fade out efekt.
function hide (o,h,when) {
	if(o){
		o=findo(o);
		var oo;
		if(!alive[oo=mid(o)]){
			o=new dd(o);
			alive[o.id]=o;
			oo=o.id;
		}
		alive[oo].hide(h,when);
	}
}

function findo (s) {
	if(s) {
		var ss;
		if (s.nodeName) return s;
		if(ss=document.getElementById(s)) return ss;
		if(ss=document[s]) return ss;
		if(ss=document.forms[s]) return ss;
	}
	return false;
}
//premika obj z mijo.
function getmouseXY(o,x,y,xo,yo) {
	//followMouse(window.event || arguments.callee.caller.arguments[0]);
	if(o){
		//report('o: '+o);
		if(!o.nodeName){
			if(alive[o])o=alive[o].o;
			else o=document.getElementById(o);
		}
		//report('ob:'+o+', nodeName:'+o.nodeName+', id:'+o.id+', x:'+x+', y:'+y);
		if(isNaN(yo))yo=yof;
		if(isNaN(xo))xo=xof;	
		if(isNaN(y))y=tempY+yo;
		if(isNaN(x))x=tempX+xo;
		//report(yo+xo+'px');
		//fix flowing over screen:
		if((y+o.offsetHeight+yo)>wh['h'])y-=o.offsetHeight+2*yo;
		if((x+o.offsetWidth+xo)>wh['w'])x-=o.offsetWidth+2*xo;
		if(y<0)y=0;
		if(x<0)x=0;
		//report('mousexy->x: '+x+', y: '+y+', pos:'+o.style.position);
		o.style.top=y+'px';	
		o.style.left=x+'px';
	}
	//else report('ni objekta id: '+o);
}

//sledi objektu.
function followMouse(e){
	if (isIE4) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + ((document.documentElement&&document.documentElement.scrollLeft )?document.documentElement.scrollLeft:document.body.scrollLeft);
		tempY = event.clientY + ((document.documentElement&&document.documentElement.scrollTop )?document.documentElement.scrollTop:document.body.scrollTop);
	}
	else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX;
		tempY = e.pageY;
	}
}


function getFile (string,source,objn,hu,h,m,fresh,send,st) {
	if(!string)string='';
	if(!source)source='';
	if(!objn)objn='';
	if(!hu)hu='';
	if(!h)h='0';
	if(!m)m='0';
	if(!fresh)fresh='';
	if(!send)send='';
	//ce je ze narjen, lahko damo nov zahtevk:
	var s=(send&&document.forms[send].MAX_FILE_SIZE)?'file':objn;
	if(!s||(s=='showhide')){s=0;while(dowork[++s]);};
	if(!dowork[s]) {
		report('created xmlq: '+s);
		dowork[s]=new dw(s);
	}
	else report('using xmlq: '+s);
	if(s!='file'||((s=='file')&&dowork[s].isfree)) {
		dowork[s].go(string,source,objn,hu,h,m,fresh,send,st);
		dowork[s].del=isFinite(s)?s:0;
	}
	else report('xqueries:'+dowork['file'].counter.push('getFile("'+string+'","'+source+'","'+objn+'","'+hu+'","'+h+'","'+m+'","'+fresh+'","'+send+'");'));
}
dowork = Array();

//nardi xml objekt:
function makexml() {
	err=false;
	xmlhttp = null;
	//show(source);
	//tale koncek je za mozillo:
	try {
		xmlhttp = new XMLHttpRequest();
		xmlhttp.overrideMimeType("text/xml");
	}
	//tale pa za IE
	catch(e){
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			err='noce delat.';
		}
	}
	if(!xmlhttp) err='ni active objekta.';
	return xmlhttp;
}

//posilja podatke:
function sender(src,bdy,method) {
	xmlhttp = null;
	if(src) {
		var xmlhttp=new makexml();
		//odpremo in posljemo kar je treba
		try { 
			//report(this.oxmlhttp);
			if(!method) method=bdy?'POST':'GET';
			var snd;
			xmlhttp.open(method,src,true);
			//postamo - pomeni se nekaj headerjev:
			if(method=='POST') {
				xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset='+ENCODING);
				//this.oxmlhttp.setRequestHeader('Content-Type','multipart/form-data');
				xmlhttp.setRequestHeader('Content-Length',bdy.length);				
				//this.oxmlhttp.setRequestHeader('', '\n\r'+bdy);
			}
			//else xmlhttp.setRequestHeader('Content-Type','text/html; charset=ISO-8859-2');
			xmlhttp.send(bdy);
		}
		catch(e){
			report(e);
			report('ni prave destinacije: '+str);
			return false;
		}
	}
	return xmlhttp;
}

//pri mozili dela samo ce je na isti domeni ko fajl od koder smo klicali
function dw (o) {
	this.s=o;
}

dw.prototype.go=function(string,source,objn,hu,h,m,fresh,send) {
	this.source='';
	if(string=='++'){this.source='++';string='';}
	if(string=='--'){this.source='--';string='';}
	this.string=string;
	this.objn=objn;
	this.hu=hu;
	this.h=h;
	this.m=m;
	this.fresh=fresh;
	this.send=send;
	var err;
	this.isfree=true;
	//tale del k nardi refresh:
	this.gotow='';
	if (this.fresh) {
		if (typeof(this.fresh) == 'string'&&this.fresh!='1') this.gotow = this.fresh;
		this.fresh=1;
	}
	else this.fresh=0;
	//tale post del...
	if(0&&send&&document.forms[send]) {
		report('fml.');
		var ac, me, cl;
		err='ne morem submitat'
		this.oxmlhttp=Object();
		this.oxmlhttp.readyState=0;
		this.oxmlhttp.responseText='';
		with(document.forms[send]) {
			report('load form: '+name);
			ac=action;
			target='xframe';
			action='xphp.php?url='+source;
			//source=action;
			if((elements['submit'])&&((elements['submit'].type=='submit')||(elements['submit'].type=='image'))) {
				report('type: '+elements['submit'].type);
				if(cl=elements['submit'].onclick) elements['submit'].onclick='';
				elements['submit'].click();
				if(cl)elements['submit'].onclick=cl;
			}
			else submit();
			action=ac;
			target='';
			err=0;
		}
	}
	else {
		report('xml.');
		//this.oxmlhttp=new makexml();
		//odpremo in posljemo kar je treba
		try { 
			//report(this.oxmlhttp);
			var method='GET',snd,bdy='';
			if(snd=(send&&document.forms[send])) {
				bdy=ff(document.forms[send]).join('&');
				method=String(document.forms[send].method).toUpperCase();
				if(!method) method='GET';
				if(method=='GET') if(snd) source+=((String(source).indexOf('f')==-1)?'?':'&')+bdy;
			}
			//this.oxmlhttp.open(method,source,true);
			//postamo - pomeni se nekaj headerjev:
			/*if(snd&&(method=='POST')) {
				this.oxmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
				//this.oxmlhttp.setRequestHeader('Content-Type','multipart/form-data');
				this.oxmlhttp.setRequestHeader('Content-Length',bdy.length+"\n");				
				//this.oxmlhttp.setRequestHeader('', '\n\r'+bdy);
			}*/
			//this.oxmlhttp.send(bdy);
			this.oxmlhttp=sender(source,bdy,method);
		}
		catch(e){
			report(e);
			err='ni prave destinacije.';
		}
	}
	if(err) report(err);
	else this.start(source);
}

//dw=Object();
//ce ej free za naslednga:
dw.prototype.counter=Array();
dw.prototype.isfree=true;
dw.prototype.string='';
//hm? a to sploh rabm? ja, zarad ++ in --
dw.prototype.source='';
dw.prototype.objn='';
dw.prototype.hu='';
dw.prototype.h='0';
dw.prototype.m='0';
dw.prototype.fresh='';
dw.prototype.send='';
dw.prototype.oxmlhttp=null;
dw.prototype.del=0;
dw.prototype.timeout=0;
dw.prototype.st=new Date();
dw.prototype.et=new Date();
dw.prototype.s='';
dw.prototype.start=function(s,st,sl) {
	report('u: '+s);
	this.oxmlhttp.onreadystatechange=new Function('dowork["'+this.s+'"].response()');
	this.timeout=window.setTimeout('dowork["'+this.s+'"].stop(1)',120000);
	this.st=new Date();
}
dw.prototype.stop=function(e,w){
	this.isfree=true;
	window.clearTimeout(this.timeout);
	this.inte=0;
	this.et=new Date();
	report(e?'timeout ('+120000+'ms)':'loaded ('+(this.et.getTime()-this.st.getTime())+'ms)');
	this.st=this.et=this.k=0;
	this.oxmlhttp=null;
	if(this.counter.length)window.setTimeout(this.counter.shift(),10);
	else if(this.del) delete(dowork[this.del]);
}
dw.prototype.regsc = new RegExp(/\<script [^>]*\>!(\<\/script)+[^>]*>/gi);
dw.prototype.response=function(s,sr){
	if(this.oxmlhttp) {
		if(sr) {
			this.oxmlhttp.responseText=s;
			this.oxmlhttp.readyState=4;
			report('rsset: '+this.oxmlhttp.readyState);
		}
		report('rs: '+this.oxmlhttp.readyState);
		if(this.oxmlhttp.readyState==4){
			report('hl: '+this.oxmlhttp.getAllResponseHeaders());
			//report('hl: '+this.oxmlhttp.getResponseHeader('stupid'));
			//report('c-ctrl: '+this.oxmlhttp.getResponseHeader('Cache-Control'));
			if('eval'==this.objn)myeval(this.string+this.oxmlhttp.responseText);
			else {
				//if(this.objn=='a') document.a.ev.value=this.oxmlhttp.responseText;
				//else {
					//ce server kaj hoce:
					
					var mtcha=this.oxmlhttp.responseText.split('<!--'),mtch=mp=false, stevc;
					if (mtcha.length>1){
						report('izvede se '+mtcha.length+'x');
						//report(mtcha[0]);
						for (stevc=0;stevc<mtcha.length;stevc++) {
							//report(stevc);
							//tole seo vsi deli
							//report(mtcha[stevc]+'a');
							if(mtcha[stevc]) {
								mtch=mtcha[stevc].split('-->');
								//report('a'+mtch);
								//report(mtch[1]);
								if(mtch.length>1) {
									mp=mtch[0].split(',');
									report('params: '+mp);
									show(this.string+(mtch[1]?mtch[1]:this.oxmlhttp.responseText),mp[1]?mp[1]:this.source,mp[0]?mp[0]:this.objn,mp[4]?mp[4]:this.hu,mp[2]?mp[2]:this.h,mp[3]?mp[3]:this.m,0,0,1);
								}
								//else show(this.string+'<!--'+mtcha[stevc],this.source,this.objn,this.hu,this.h,this.m,0,0,1);
							}
						}
					}
					else show(this.string+this.oxmlhttp.responseText,this.source,this.objn,this.hu,this.h,this.m,0,0,1);
					//report('haha');
				//}
			}
			if(this.fresh)gotoUrl(this.gotow);
			this.stop();
		}
		/*else {
			if((this.objn=='a') && (this.oxmlhttp.readyState==3)) document.a.ev.value=this.oxmlhttp.responseText;
		}*/
		//else report('nie');
	}
	else this.stop();
}


//snifa kaj ma dobrega uporabnik
function finduserinfo(s) {
	if(!s) {
		var p = new Array(),date=new Date();
		//p[0] = 'nplat='+navigator.platform;
		p[1] = 'javaen='+navigator.javaEnabled();
		p[2] = 'sche='+screen.height;
		p[3] = 'scwi='+screen.width;
		p[4] = 'plugs='+navigator.plugins.length;
		p[5] = 'mimet='+navigator.mimeTypes.length;
		p[6] = 'pixdep='+screen.colorDepth;
		p[7] = 'hist='+history.length;
		p[8] = 'asche='+screen.availHeight;
		p[9] = 'ascwi='+screen.availWidth;
		p[10] = 'tz='+(-date.getTimezoneOffset());
		p[12] = 'info';
		s = p.join('&');
		report(p.join('<br>'));
	}
	gogo('cherry.php?'+s);
}


//za id-je dodajat:
function mid (o) {
	if(o) {
		if(!o.nodeName)return o;
		if(!o.id) o.id='a'+(++c)+'b';
		//report('mid:'+o.id);
		return o.id;
	}
	return o;
}

//podam ji doloceno polje.
function isful () {
	var i
	for (i=0;i<isful.arguments.length;i++) {
		if (!isful.arguments[i].value) {
			isful.arguments[i].value=window.prompt('Polje "'+isful.arguments[i].name+'" nujno izpolni:','');
			isful.arguments[i].focus();
			//fultitle = false;
			return false;
		}
	}
	return true;
}

//poda ji ime forme.
function firstfocus (fn) {
	var fm,i;
	if (fm=document.forms[fn]) {
		var fl=fm.length,ft;
		for(i=0;i<fl;i++) {
			if ((ft=fm.elements[i].type)=='text'||ft=='textarea'||ft=='password') {
				if(!fm.elements[i].value) {
					fm.elements[i].focus();
					i=fl;
				}
			}
		}
	}
}

//tole bo pa premikal layer pa pika.
moveme=new Object();
moveme.obj=new Object();
moveme.yofst=0;
moveme.xofst=0;
moveme.fn='getmouseXY(moveme.obj, tempY - moveme.yofst, tempX - moveme.xofst);';
moveme.move=function(el){
	//show(elm.style.width);
	if(typeof(el)!='object') elm=document.getElementById(el);
	if(el){
		//elm=new Object(elm);
		this.obj=el;//new Object(el);
		this.yofst=tempY-(this.obj.style.top?parseInt(this.obj.style.top):0);
		this.xofst=tempX-(this.obj.style.left?parseInt(this.obj.style.left):0);

		this.obj.onmousemove=new Function(smartadd(this.obj.onmousemove,this.fn));
		this.obj.onmouseout=new Function(smartadd(this.obj.onmouseout,'moveme.stop();'));
		this.obj.onmouseup=new Function(smartadd(this.obj.onmouseup,'moveme.stop();'));
		
	}
}
moveme.stop=function(){
	this.obj.onmousemove=new Function(smartadd(this.obj.onmousemove,this.fn,1));
	//this.obj.onmouseup=new Function(out=smartadd(this.obj.onmouseup,'moveme.stop(\''+fn+'\');',1));
	//this.obj.onmouseout=new Function(out=smartadd(this.obj.onmouseout,'moveme.stop(\''+fn+'\');',1));
	
	//show(out,0,'out');
}

function change(src,nm,oth,spic){
	nm=findo(nm);
	//za mouseout:
	oth=findo(oth);
	if((nm.tagName=='IMG')&&(nm.src!=src)) {
		//ce je objN objekt, potem onmouseout spremenimo nazaj slikco.
		if (oth&&oth.tagName) {
			evtadd(oth,'onmouseout',"change('"+(spic?spic:nm.src)+"','"+(nm.name?nm.name:mid(nm))+"');");
		}
		nm.src = src;
	}
}

/*function chclass (c,nm,oth,sclass) {
	nm=findo(nm);
	oth=findo(oth);
	if((nm.tagName)&&(nm.className!=c)) {
		//ce je objN objekt, potem onmouseout spremenimo nazaj slikco.
		if (oth&&oth.tagName) {
			evtadd(oth,'onmouseout',"chclass('"+(sclass?sclass:nm.className)+"','"+(nm.name?nm.name:mid(nm))+"');");
		}
		nm.className = c;
	}
}*/

function gotoUrl (url,kje,ask) {  //klice z urljem in 'blank', ee bi rad da bi se odprla v novem oknu.
	if(url){if(url.indexOf('javascript:')==0)return myeval(url.slice(6));}
	else url=window.location;
	if(!ask || window.confirm(ask)){
		switch (kje){
			case "blank":
				window.open(url);
				break;
			default:
				window.location.href=url;
		}
	}
}

function preloadImages() { //prelouda slike.
  var d=document; 
  if(d.images){ 
  	if(!d.MM_p) 
		d.MM_p=new Array();
   		var i,j=d.MM_p.length,a=preloadImages.arguments; 
		for(i=0; i<a.length; i++){
   			if (a[i].indexOf("#")!=0){ 
				d.MM_p[j]=new Image; 
				d.MM_p[j++].src=a[i];
			}
		}
	}
}


//myold = kar je e not, fn=kar hocem da se zgodi, re=ali remuvam.
function smartadd(myold, fnc, rem) {
	if (!myold) return fnc;
	myold=new String(myold);
	if (!fnc) fnc='';

	//fnc=new String(fnc);
	var ano=new String('function anonymous() {');
	var fs=myold.indexOf(ano);
	if(fs!=-1) {
		var fe=myold.lastIndexOf('}');
		fe=(fe!=-1)?fe:myold.length;
		myold=myold.slice(fs+ano.length,fe);
	}
	return cstm(myold,fnc,rem);
}

function evtadd(o,ev,f) {
	if(ev&&f) {
		var t=fff=false;
		//ce so eventi:
		if(o[ev]){
			if(t=o[ev].f)if(fff=(t.indexOf(f)==-1))o[ev]=Function('e','if(!e){e=window.event;e.target=e.srcElement;};'+(t=t+';'+f));
		}
		//ce se ni nc eventov:
		if(!t) {
			fff=true;
			o[ev]=Function('e','if(!e){e=window.event;e.target=e.srcElement;};'+(t=smartadd(o[ev],f)));
		}
		o[ev].f=t;
		//report('e:'+ev+', f:'+t);
	}
	return false;
}

websafeRegExp = new Array();
websafeRegExp[0] = websafeRegExp[null] = websafeRegExp['undefined'] = new RegExp(/[^\w\-]+/gi);
websafeRegExp['n'] = new RegExp(/\D+/gi);
websafeRegExp[1] = new RegExp(/\D+/gi);
function websafe (str,p) {
	if(!p) p = 0;
	str=str.replace(' ','_');
	return str.replace(websafeRegExp[p],'');
}

//tale pa dodaja v prvi parameter iz drugega:
function safe_add(o,to) {
	if((to && o)) {
		var e=t=websafe(o.value), f=o.form.elements[to].value;
		if(f.length>t.length){var t=f;f=e;}
		if((f.length<1)||(t.search(f)!=-1)){
			o.form.elements[to].value=e;
		}
	}
}


//tole kukr da nov stylesheet:)
function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}

num_max_r=50;
num_r=0;
function report(s) {
	var d;
	if(rep&&(d=document.getElementById('errorreport'))) {
		if(!(++num_r%num_max_r)) d.innerHTML='';
		d.innerHTML=s+'<br>'+d.innerHTML;
	}
}
//da ne nardi nic:
function nich() {}

//mytemppic=new Image();
//samo da da neki na server:
function gogo(a) {
	//mytemppic.src=a?a:window.location;
	a=a?a:window.location;
	var p=new Image();
	p.src=a;
	//show(0,a);
}

ffrep = RegExp(/\&/g);
function ff(f) {
	var r=Array(),i=j=k=0,fl,t;
	if(f&&(f.tagName=='FORM')) {
		fl=f.length;
		for(i=0;i<fl;i++) {
			t=false;
			//report('type: '+f.elements[i].type);
			switch(f.elements[i].type) {
				//checkbox:
				case 'checkbox':
				//radio:
				case 'radio':
					if(t=f.elements[i].checked) r[++k]=f.elements[i].name+'='+(f.elements[i].value?f.elements[i].value:1);
					break;
				//select:
				case 'select':
				case 'select-one':
					r[++k]=f.elements[i].name+'='+f.elements[i][f.elements[i].selectedIndex].value;
					t=true;
					break;
				case 'select-multiple':
					for(j=0;j<f.elements[i].length;j++) {
						if(f.elements[i].options[j].selectedIndex) {
							r[++k]=f.elements[i].name+'='+f.elements[i].options[j].value;
							t=true;
						}
					}
					break;
				default:
					r[++k]=f.elements[i].name+'='+f.elements[i].value;
					t=true;
			}
			if(t)report(f.elements[i].type+': '+myencodeURI(r[k],ENCODING));
			if(t)r[k]=(String(myencodeURI(r[k],ENCODING)).split('&')).join('%26');
		}
		//report(r);
	}
	return r;
}
//comments=new RegExp(/^\s*\/\/.*/gi);
//multicom=new RegExp(/^\/\*(!\*\/)*\*\//gi);
function myeval(s) {
	//s=String(s).replace(comments,"",s);
	//s=String(s).replace(multicom,"",s);
	//s=String(s).replace("\n",'',s);
	//document.a.ev.value=s;
	try {
		eval(s+';');
		report('eval OK.');
	}
	catch(e) {
		report('invaliden string: '+s);
		report(e);
	}
}

myencodeURIexp = new RegExp(/(\%\S\%\S)/gi);
myencodeURI_1 = new Array('C5', 'C4');
myencodeURI_2 = new Array('8D', '8C', 'A1', 'A0', 'BE', 'BD', '87', '86', '91', '90');
myencodeURI_3 = new Array();
myencodeURI_3['8D'] = 'E8';//'c';
myencodeURI_3['87'] = 'E6';//'c';
myencodeURI_3['A1'] = 'B9';//'';
myencodeURI_3['BE'] = 'BE';//'';
myencodeURI_3['91'] = 'F0';//'d';
myencodeURI_3['8C'] = 'C8';//'C';
myencodeURI_3['86'] = 'C6';//'C';
myencodeURI_3['BD'] = 'AE';//'';
myencodeURI_3['A0'] = 'A9';//'';
myencodeURI_3['90'] = 'D0';//'';
			/*
			c: %C4%8D
			C: %C4%8C
			: %C5%A1
			: %C5%A0
			: %C5%BE
			: %C5%BD
			c: %C4%87
			C: %C4%86
			d: %C4%91
			: %C4%90
			
			*/
//encodeURI encoda v UTF-8, rabim e druge chartypes:
function myencodeURI(string,type) {
	var a = Array(),i=0,s='',t='',tt='',tt2='';
	string = new String(encodeURI(string));
	type = new String(type);
	switch(type.toLowerCase()) {
		case 'iso-8859-2':
			a = string.split('%');
			s = a[0];
			//document.write(a);
			for(i = 1; i<a.length; i++) {
				t = new String(a[i]);
				tt = new String(a[i+1]);
				tt2 = (tt.length > 2) ? tt.slice(2) : '';
				tt = tt.slice(0,2);
				if((t.length == 2) && myencodeURI_1.search(t.toUpperCase()) && myencodeURI_3[tt=tt.toUpperCase()]) {
					s += '%'+myencodeURI_3[tt]+tt2;
					i++;
				}
				else s += '%'+a[i];
			}
			break;
		default:
			s = string;
	}
	return s;
}
//updejta slikce s sorsom:
function picUpd(s,mo,swwh) {
	if(s) {
		var i=0,o,p='',v='';
		if((o=findo(mo)) && o.src)o.src=s;
		for(i=2;i<arguments.length;i++) {
			p +=v+'"'+arguments[i]+'"';
			v=',';
		}
		if(p)o.onload=new Function('refreshpic('+p+');');
	}
}


function refreshpic() {
	var i=0,n=false,ns=false,na=false;
	for(i=0;i<arguments.length;i++){
		if((nm=arguments[i]) && (n=findo(nm)) && (n.src)) {
			ns=String(n.src);
			na=ns.split('?');
			if(na[1]) n.src=na[0]+'?'+(na[1]-(-1));
			else n.src=na[0]+'?1';
			n=false;
		}
		
	}
}

Cookie = new Object();
Cookie.set = function (sName, sValue) {
//function SetCookie(sName, sValue) {
	if (!document.cookie || !Cookie.get('expires')) {
		date = new Date();
		date.setFullYear(date.getFullYear()+10);
		document.cookie = "expires=" + date.toGMTString() + ";";
	}
	document.cookie = sName + "=" + escape(sValue);
	//document.write(document.cookie);
}

Cookie.del=function(cookie_name) {
//function delete_cookie ( cookie_name ) {
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

Cookie.get=function(cookie_name) {
//function get_cookie ( cookie_name ) {
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

//da se bo zmeri vedlo kje ej mish, kadar se rabi.
document.onmousemove = followMouse;

//ko resizamo da dobimo novo sirino/visino
window.onresize=getscwh;

document.onkeydown=function(e) {
	if(!e)e=window.event;
	keypressed=e.keyCode;
	//gogo('cherry.php?active=1');
}

window.onunload=function(){
	gogo('cherry.php?active=0&off');
	//window.alert('unl');
}

window.onbeforeunload=function() {
	gogo('cherry.php?active=0&off');
	//window.alert('bunl');
}

window.onblur=function(){
	gogo('cherry.php?active=0');
	//window.alert('b');
}

window.onfocus=function(){
	gogo('cherry.php?active=1');
	//window.alert('f');
}



gogo('cherry.php?active=1');
