







enable_errorhandler = 1;
errstr = "";
disable_errors = 0;
on_errorhandler = 0;
body_loaded = 0;

if (typeof(user_is_admin) == "undefined")
	user_is_admin = 0;





function common_setCookieF(name, value)
{
	strCookieF = name + "=" + escape(value);
	document.cookie = strCookieF;
}





function common_setCookieF_noEscape(name, value)
{
	strCookieF = name + "=" + value;
	document.cookie = strCookieF;
}





function common_stp_getCookieF(Name)
{
	var search = Name + "=";
	if (document.cookie.length > 0) {
		
		offset = document.cookie.indexOf(search)
		if (offset != -1) {
			
			offset += search.length

			
			end = document.cookie.indexOf("; ", offset)
			

			
			if (end == -1)
				end = document.cookie.length

			
			return unescape(document.cookie.substring(offset, end))
		}
	}

	return "0";
}





in_os_onbeforeunload_handler = false;
onbeforeunload_prev_ErrorHandler = window.onbeforeunload;
window.onbeforeunload = function() {

	if (in_os_onbeforeunload_handler)							
		return;


	var rval = null;


	in_os_onbeforeunload_handler = true;


	
	if (onbeforeunload_prev_ErrorHandler)
		rval = onbeforeunload_prev_ErrorHandler();
	
	


	in_os_onbeforeunload_handler = false;

	if (rval != null)
		return rval;
	else
		return;
};





function ErrorHandler(err, file, line) {


	var rval = true;

	



	if (disable_errors)
		return true;	

	if (on_errorhandler)
		return true;	

	on_errorhandler = 1;


	req_reload = 0;

	
	


	if ((err == "Object expected") && (line == 1))
	{
		var stp_ck = parseInt(common_stp_getCookieF("stp_ck"), 10);
		stp_ck = stp_ck + 1;
		common_setCookieF("stp_ck", stp_ck);

		
	}


	if (


		(



			( (err == "Invalid character") && ((line == 2) || (line == 1)) )
			|| ((err == "'IconList' is undefined") )
			|| ((err == "'MTMUA.document' is null or not an object") )
			
			|| ((err == "Object expected") && ((line == 1) || (line == 9) || (line == 11) || (line == 50) || (line == 67) || (line == 70) || (line == 71) || (line == 72) || (line == 89) || (line == 399) || (line == 418) || (line == 443) || (line == 542)) )
			|| ((err == "Expected ';'") && ((line == 2) || (line == 4)) )
			|| ((err == "Expected ')'") && ((line == 1320)))
			|| ((err == "'stpd[...]' is null or not an object") )

			|| ((err == "Unterminated string constant") && (line == 1053))
			|| ((err == "Expected '}'") && (line == 1690))
			|| ((err == "Access is denied.") && (line == 9))

			|| ((err == "Expected identifier") && (line == 286))

			|| ((err == "Syntax error") && ((line == 1) || (line == 4693)) )

			|| ((err == "'editor_toolbars_init' is undefined") )
			|| ((err == "'editor_win_unload' is undefined") )

			|| ((err == "'_oDiv' is undefined") )
			|| ((err == "'_editor_doc' is undefined") )

			|| ((err == "'scroll_odiv_to_top' is undefined") )

			|| ((err == "'selected_rows' is undefined") && ((line == 539)))

			|| ((err == "Unspecified error") && ((line == 14) || (line == 129) || (line == 1981)) )

		)
	)
	{
		

		





		req_reload = 1;

			
			


		
	}


	if (typeof(window.propName) != "undefined")
		propname = window.propName;
	else
		propname = "";

	var str = "reload: " + req_reload + "\nerr: " + err + "\nfile: " + file + "\nline: " + line + "\npropname: " + propname;
	errstr = str;




	adm_alert(str);




	if (!body_loaded)
	{
		add_to_onload_cmd("send_data('js_err', errstr);");
		on_errorhandler = 0;
		return rval;
	}
	else
		send_data("js_err", str);




	if (req_reload)
	{
		my_alert("Lehekülje skriptid Sinu browseri caches vajavad värskendamist.\nVajuta OK, siis need laaditakse uuesti.");

		document.location.reload(true);
	}



	on_errorhandler = 0;

	return rval;
}





function adm_alert(str) {

	
	if (user_is_admin)
	{
		my_alert(str);
	}
}





function adm_alert2(yes, str) {

	
	if (yes)
	{
		
		adm_alert(str);
	}
}





TipObj_extension_loaded = 0;

ns4 = (document.layers) ? true : false;
ie4 = (document.all) ? true : false;



var isDOM=document.getElementById?1:0;
var isIE=document.all?1:0;
var isMoz = isDOM && !isIE;
var isNS4=navigator.appName=='Netscape'&&!isDOM?1:0;
var isIE4=isIE&&!isMoz?1:0;
var isOp=window.opera?1:0;
var isDyn=isDOM||isIE||isNS4;
var isWin=navigator.platform.indexOf('Win')!=-1?1:0;
var isIE55 = ie4&&!isOp;






MSIE55p = 0;
MSIE70p = 0;
IE_version = 0;
if (ie4)
{
	useragent_exception_occured = 0;

	try
	{
		browser = navigator.userAgent;	
		IE_version = navigator.appVersion;
		
	}
	catch(e)
	{
		MSIE55p = 1;
		MSIE70p = 1;	
		ver = "7.0";
		browser = "Mozilla/4.0 (compatible; MSIE 7.0)";
		IE_version = "4.0 (compatible; MSIE 7.0)";
		useragent_exception_occured = 1;
	}

	if (!useragent_exception_occured)
	{
		pos = browser.indexOf("MSIE");
		if (pos != -1)
		{
			ver = browser.substr(pos + 4);

			
			pos_end = ver.indexOf(";");
			if (pos_end == -1)
				pos_end = ver.indexOf(")");
			ver = ver.substr(0, pos_end);

			

			if (ver.valueOf() >= 5.5)
			{
				MSIE55p = 1;
				
			}
			if (ver.valueOf() >= 7.0)
			{
				MSIE70p = 1;
			}
		}	
	} 	
}	
else
{
	var browser = navigator.userAgent;
}







if (ie4 && !isOp && enable_errorhandler)
{
	window.onerror = ErrorHandler;
}




















if (!window.gusEvts) var gusEvts=new Array();





function addEvent(obj, eName, fn, cap)
{
 var g=gusEvts, n=g.length, old=obj[eName], i=old?old.toString().indexOf('gEvtId'):-1;
 if (!old||i==-1){obj[eName]=new Function('e','var gEvtId='+n+'; return runEvent(e,gEvtId,'+
  !obj.navigator+')'); g[n]=[obj]; if (old) g[n][1]=old}
 else n=parseInt(old.toString().substring(i+7));
 g[n][g[n].length]=fn;
 if (isNS4&&cap) obj.captureEvents(Event[eName.substring(2).toUpperCase()]);
}





function runEvent(e, num, rval)
{
 var ret=1, fns=gusEvts[num], e=e?e:event;
 for (var i=1;i<fns.length;i++)
  ret=((typeof(fns[i])=='string' ? new Function('e',fns[i]) : fns[i])(e)!=false)&&ret;
 if (rval) return (ret ? (isNS4?fns[0].routeEvent(e):true) : false);
}












function getRef(id, par)
{
 par = !par ? document : (par.navigator ? par.document : par);
 return (isIE ? par.all[id] :
  (isMoz ? (par.getElementById ? par : par.ownerDocument).getElementById(id) :
  par.layers[id]));
}


var $ = getRef;





function getSty(id, par)
{
 return (isNS4 ? getRef(id, par) : getRef(id, par).style)
}





if (!window.LayerObj) var LayerObj = new Function('id', 'par', 'this.ref=getRef(id, par); this.sty=getSty(id, par); return this');





function getLyr(id, par) { return new LayerObj(id, par) }





function LyrFn(fn, fc)
{
	
	
	LayerObj.prototype[fn] = new Function('var a=arguments,p=a[0]; with (this) { '+fc+' }');
}

LyrFn('x','if (!isNaN(p)) sty.left=p; else return parseInt(sty.left)');
LyrFn('y','if (!isNaN(p)) sty.top=p; else return parseInt(sty.top)');
LyrFn('vis','sty.visibility=p');
LyrFn('bgColor','if (isNS4) sty.bgColor=(p?p:null); ' + 'else sty.background=p?p:"transparent"');
LyrFn('bgImage','if (isNS4) sty.background.src=(p?p:null); ' + 'else sty.background=(p?"url("+p+")":"") ');
LyrFn('clip','if (isNS4) with(sty.clip) { left=a[0]; top=a[1]; right=a[2]; bottom=a[3] } ' + 'else sty.clip="rect("+a[1]+"px "+a[2]+"px "+a[3]+"px "+a[0]+"px)" ');
LyrFn('write','if (isNS4) with (ref.document) {write(p);close()} else ref.innerHTML=p');
LyrFn('alpha','var f=ref.filters; if (f) {' + 'if (sty.filter.indexOf("alpha")==-1) sty.filter+="alpha()"; ' + 'if (f.length&&f.alpha) f.alpha.opacity=p } else if (isMoz) sty.MozOpacity=(p/100)');





function setLyr(lVis, docW, par)
{
 if (!setLyr.seq) setLyr.seq=0;
 if (!docW) docW=0;
 var obj = (!par ? (isNS4 ? window : document.body) :
  (!isNS4 && par.navigator ? par.document.body : par));
 var newID='_js_layer_'+setLyr.seq++;

 if (isIE&&!window.opera) obj.insertAdjacentHTML('beforeEnd', '<div id="'+newID+
  '" style="position:absolute"></div>');
 else if (isMoz)
 {
  var newL=document.createElement('div');
  obj.appendChild(newL);
  newL.id=newID; newL.style.position='absolute';
 }
 else if (isNS4)
 {
  var newL=new Layer(docW, obj);
  newID=newL.id;
 }

 var lObj=getLyr(newID, par);
 with (lObj.sty) { visibility=lVis; left=0; top=0; width=docW }
 return lObj;
}


















var CSSmode=document.compatMode;
CSSmode=(CSSmode&&CSSmode.indexOf('CSS')!=-1)||isMoz&&!isIE||isOp?1:0;

 

if (!window.page) var page = { win: window, minW: 0, minH: 0, MS: isIE&&!isOp, db: CSSmode?'documentElement':'body' }







page.winW=function()
 { with (this) return Math.max(minW, MS?win.document[db].clientWidth:win.innerWidth) }
page.winH=function()
 { with (this) return Math.max(minH, MS?win.document[db].clientHeight:win.innerHeight) }


page.scrollX=function()
 { with (this) return MS?win.document[db].scrollLeft:win.pageXOffset }
page.scrollY=function()
 { with (this) return MS?win.document[db].scrollTop:win.pageYOffset }


page.docW=function()
 { with (this) return Math.max(minW, isNS4?win.document.width:win.document.offsetWidth) }
page.docH=function()
 { with (this) return Math.max(minH, isNS4?win.document.height:win.document.offsetHeight) }















function getbodysize() {

	if (ns4) pw = window.innerWidth - 20;
	else pw = page.winW() - 15;

	

	

	return pw;
}





function getbodywidth() {

	return getbodysize();
}





function getbodyheight() {

	if (ns4) ph = window.innerHeight - 20;
	else ph = page.winH() - 20;

	

	

	
	
	return ph;
}





function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}





function findPosY(obj)
{
	var curtop = 0;
	
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	
	return curtop;
}












function replace_url_key_val(key, newval, url) {

	if (!url)
		url = location.href;

	var key = "&" + key + "=";
	var pos = url.search(key);
	if (pos == -1)
	{
		return url + key + newval;
	}
	else
	{
		var temp = url.substr(pos + key.length);
		var pos2 = temp.search("&");
		if (pos2 == -1)
			pos2 = url.length;
		else
			pos2 = pos2 + pos + key.length;

		return url.substr(0, pos) + key + newval + url.substr(pos2);
	}
}





function get_obj_xy(obj) {

	var objItem = obj;
	var objParent = null;
	var intX = 0;
	var intY = 0;
	do
	{ 
		
		intX += objItem.offsetLeft;
		intY += objItem.offsetTop;
		objParent = objItem.offsetParent.tagName;
		objItem = objItem.offsetParent;
	}
	while(objParent != 'BODY');

	rval = Array(intX, intY);
	return rval;

}





function get_obj_x(obj) {

	rval = get_obj_xy(obj);
	return rval[0];
}





function get_obj_y(obj) {

	rval = get_obj_xy(obj);
	return rval[1];
}





function get_option_selected_value(option_obj) {

	var rval = "";
	for (i = 0; i < option_obj.length; i++)
	{
		if (option_obj[i].checked)
		{
			rval = option_obj[i].value;
			break;
		}
	}

	return rval;
}





function getparent(child) {

	var e;

	if (ie4)
		e = child.parentElement;
	else
		e = child.parentNode;

	return e;
}





function get_parent_obj(tagname, child) {

	var e = getparent(child);

	if (e.tagName == tagname)
		return e;
	else
		return get_parent_obj(tagname, e);
}





function set_innertext(obj, val_str) {

	

	if (document.all)
		obj.innerText = val_str;
	else
		obj.textContent = val_str;
}





function set_innerhtml(obj, val_str) {

	

	
		obj.innerHTML = val_str;
	
	
}





function remove_andamp(str) {

	var temp = str;

	

	var re_andamp1 = new RegExp("\\&amp\\;\\#", "gi");		
	temp = temp.replace(re_andamp1, "&#");

	var re_andamp2 = new RegExp("\\&amp\\;nbsp\\;", "gi");
	temp = temp.replace(re_andamp2, "&nbsp;");

	var re_nbsp = new RegExp("\\&nbsp\\;", "gi");
	temp = temp.replace(re_nbsp, " ");

	

	return temp;

}





function moz_html_decode(str) {

	

	

	
	

	


	var re_htmlcode;
	var out;
	var pos;
	var entrylen;
	var entrychars;
	var charcode;
	var character;


	re_htmlcode = new RegExp("&#[0-9]{1,4};", "i");

	

	out = "";
	pos = str.search(re_htmlcode);
	while(pos != -1)
	{
		out = out + str.substr(0, pos);
		str = str.substr(pos);

		entrylen = str.search(";") + 1;
		entrychars = str.substr(2, entrylen - 3);

		charcode = entrychars.valueOf();	
		character = String.fromCharCode(charcode);

		out = out + character;

		str = str.substr(entrylen);

		pos = str.search(re_htmlcode);  
	};

	out = out + str;




	re_htmlcode = new RegExp("&#x[0-9a-f]{1,4};", "i");

	


	str = out;

	out = "";
	pos = str.search(re_htmlcode);
	while(pos != -1)
	{
		out = out + str.substr(0, pos);
		str = str.substr(pos);

		entrylen = str.search(";") + 1;
		entrychars = str.substr(3, entrylen - 4);

		
		charcode = parseInt(entrychars, 16);
		character = String.fromCharCode(charcode);

		out = out + character;

		str = str.substr(entrylen);

		pos = str.search(re_htmlcode);  
	};

	out = out + str;



	

	return out;

}





function my_alert(txt) {

	var txt2 = moz_html_decode(remove_andamp(txt));

	window.alert(txt2);
}





function my_confirm(txt) {

	var txt2 = moz_html_decode(remove_andamp(txt));

	return window.confirm(txt2);
}





function my_prompt(txt, val) {

	var txt2 = moz_html_decode(remove_andamp(txt));
	var val2 = moz_html_decode(remove_andamp(val));

	return window.prompt(txt2, val2);
}









if (typeof(units_loaded) != "undefined")
	units_loaded++;








