var popUp=new Array() //array of popup handlers
var isDOM=document.getElementById?true:false
var isOpera=isOpera5=window.opera && isDOM
var isOpera6=isOpera && window.print
var isOpera7=isOpera && document.readyState
var isMSIE=isIE=document.all && document.all.item && !isOpera
var isStrict=document.compatMode=='CSS1Compat'
var isNN=isNC=navigator.appName=="Netscape"
var isNN4=isNC4=isNN && !isDOM
var isMozilla=isNN6=isNN && isDOM
var t,l,win
function ld_img(){
if(document.images){
if(!aLDImg) var aLDImg=new Array();
var j=aLDImg.length,a=ld_img.arguments;
for(i=0;i<a.length;i++){if(a[i].indexOf("#")!=0){aLDImg[j]=new Image; aLDImg[j++].src=a[i]}}
}}
// disable buttons
function btns_off(){
	var e,t,o=document.body.getElementsByTagName('INPUT')
	for(var i=0;i<o.length;i++){
	    e=o[i]
	    if(e && typeof(e)!='undefined'){
			var t=e.type.toLowerCase()
			if(t=='submit' || t=='reset' || t=='button') e.disabled=true
		}
	}
	ic=document.body.getElementsByTagName('BUTTON')
	for(i=0; i<ic.length; i++) ic[i].disabled=true
}
// popup window (multiple instances)
// ar - 1=use link as is, 0=add root URL to link
function nw(lnk,w,h,ar){
	if(typeof(ar)=='undefined'){var ar=0}
	if(typeof(window.opera)=='undefined'){
		if(w==0)w=screen.width-100
		if(h==0)h=screen.height-75
		t=screen.height/2-h/2-20
		l=screen.width/2-w/2
	}else{//opera
		if(w==0)w=screen.width-100
		if(h==0)h=screen.height-210
		t=36
		l=screen.width/2-w/2
	}
	var d=new Date
	var n=d.getTime()
	var win="width="+w+",height="+h+",status=yes,menubar=no,location=no,resizable=yes,scrollbars=yes,top="+(screen.height/2-h/2)+",left="+(screen.width/2-w/2)
	if(!ar)lnk='<?=($vars['rootUrl'].($vars['pathLang'] ? $vars['pathLang'].'/':''))?>'+lnk
	popUp[n]=window.open(lnk,'void_win_'+n,win)
	popUp[n].focus()
}
// popup window modal mode (no multiple instances)
// n - win name
// ar - 1=use link as is, 0=add root URL to link
function nwm(lnk,w,h,n,ar){
	if(typeof(ar)=='undefined'){var ar=0}
	if(typeof(window.opera)=='undefined'){
		if(w==0)w=screen.width-100
		if(h==0)h=screen.height-75
		t=screen.height/2-h/2-20
		l=screen.width/2-w/2
	}else{//opera
		if(w==0)w=screen.width-100
		if(h==0)h=screen.height-210
		t=36
		l=screen.width/2-w/2
	}
	var win="width="+w+",height="+h+",status=yes,menubar=no,location=no,resizable=yes,scrollbars=yes,top="+t+",left="+l
	if(popUp[n] && typeof(popUp[n]) != 'undefined'){if(typeof(window.opera)=='undefined') popUp[n].close()}
	if(!ar) var lnk='<?=($vars['rootUrl'].($vars['pathLang'] ? $vars['pathLang'].'/':''))?>'+lnk
	popUp[n]=window.open(lnk,'void_win_'+n,win)
	popUp[n].focus()
}
function go(l){btns_off();window.location='<?=($vars['pathUrl'])?>'+l}
function go2(l){btns_off();window.location=l}
// confirmation dlg
function sure(q,l){if(window.confirm(q))go(l)}
// changing mouse cursor style
function csr(it,over,cur,force){if(typeof(window.opera)=='undefined'||force)it.style.cursor=over?cur:'auto'}
//show object properties
function props(o){
    s='<table border=1 cellspacing=2 cellpadding=3 bgcolor=gray style="font:normal 11px tahoma" class=dbg>'
    for (var i in o)s+='<tr bgcolor=#eeeeee><td style="color:maroon">'+i+'<\/td><td>'+o[i]+'<\/td><\/tr>'
    s+=s+'<\/table>'
	if(typeof(console)!='undefined')console.out(s)
	else document.write(s)
}
// toggle tree node + save tree nodes state into cookie
function tt(it){
	tn(it)
	if(typeof(window.CID)=='undefined') window.CID=0
	var i,id=0,a2,cid=window.CID,s='',aa
	var o=document.getElementById('tree'+cid)
	var as=new Array() // states array
	// parse state data from cookie
	s=readCookie('tree'+cid)
	if(s!=null){
		var a=s.split('|')
		if(a.length>0){for (i=0;i<a.length;i++){aa=a[i].split(':');if(aa[0]!='') as[aa[0]]=aa[1]}}
	}
	// get current state of tree nodes
	var a=document.body.getElementsByTagName('TD')
	for(i=0;i<a.length;i++){
		if(typeof(a[i].id)!='undefined'){
			a2=a[i].id.split('_')
			if(a2[0]==cid){b=(a[i].className=='k12'||a[i].className=='lk12'?0:1);as[a2[1]]=b}
		}
	}
	// save new data to cookie
	s=''
	for (i in as){s+=i+':'+as[i]+'|'}
	createCookie('tree'+cid,s,30)
}
// toggle tree node
function tn(it){
	p=it.parentNode.parentNode.childNodes
	v=(it.parentNode.parentNode.lastChild.style.display != 'none')
	d=(v)?'none':''
	tk=p[0].childNodes[0].className
	tf=p[0].childNodes[1].className
	if(v){tk=tk.replace('k11','k12');tf=tf.replace('f1','f2')}
	else{tk=tk.replace('k12','k11');tf=tf.replace('f2','f1')}
	p[0].childNodes[0].className=tk
	p[0].childNodes[1].className=tf
	for (var i=1;i<p.length;i++)p[i].style.display=d
}
function createCookie(n,v,d){
	if(d){
		var dt=new Date()
		dt.setTime(dt.getTime()+(d*24*60*60*1000))
		var e="; expires="+dt.toGMTString()
	}else var e=""
	document.cookie=escape(n)+"="+escape(v)+e+"; path=/"
}
function readCookie(n){
	var eq=escape(n)+"="
	var ca=document.cookie.split(";")
	for(var i=0;i<ca.length;i++){
		var c=ca[i]
		while (c.charAt(0)==" ") c=c.substring(1,c.length)
		if(c.indexOf(eq)==0) return unescape(c.substring(eq.length,c.length))
	}
	return null
}
function eraseCookie(n){createCookie(escape(n),"",-1)}
//trim the string
function trim(s){
	while (s.substr(0,1)==' ') s=s.substr(1)
	while (s.substr(s.length-1,1)==' ') s=s.substr(0,s.length-1)
	return(s)
}
// change image SRC
function img_src(id,s){o=document.getElementById(id);if(!o) o=document.all(id);o.src=s}
// popup functions
function iws(cid,id,w,h){nwm('<?=$cfg['infoPage'].$vars['uPage']?>admin=<?=$vars['admin']?>&cid='+cid+'&id='+id,w,h,'info',0)}
function iwr(cid,id){nwm('<?=$cfg['infoPage'].$vars['uPage']?>admin=<?=$vars['admin']?>&cid='+cid+'&id='+id+'&resize=1',<?=$cfg['infoWdt']?>,<?=$cfg['infoHgt']?>,'info',0)}
function ews(cid,id,w,h){nwm('<?=$cfg['editPage'].$vars['uPage']?>admin=<?=$vars['admin']?>&mode=edit&cid='+cid+'&id='+id,w,h,'edit',0)}
function ewr(cid,id){nwm('<?=$cfg['editPage'].$vars['uPage']?>admin=<?=$vars['admin']?>&mode=edit&cid='+cid+'&id='+id+'&resize=1',<?=$cfg['editWdt']?>,<?=$cfg['editHgt']?>,'edit',0)}
function dump(d,l){
if(l==null)l=1;var s=''
if(typeof(d)=="object"){s+=typeof(d)+"{<br>";for (var k in d){for (var i=0;i<l;i++) s+=" ";s+=k+" => "+dump(d[k],l+1)}for (var i=0;i<l-1;i++) s+=" ";s+="}<br>"}
else{s+=""+d+"<br>"}
return s+''}
String.prototype.trim=function(){return this.replace(/(^\s+)|\s+$/g,"")}
String.prototype.dirname=function(){return this.replace(/\/[^\/]*$/,"")}
String.prototype.basename=function(){var match=this.match(/([^\/]*$)/);return match ? match[1]:""}
function round_dec(f,d){//rounds float to spec decimals
if(d>0){
f=Math.round(f*Math.pow(10,d))/Math.pow(10,d)
var s=f.toString()
var p=(s.search(/\./ig));if(p<=0){s+='.';p=(s.search(/\./ig))}
var l=s.substr(p+1).length;while(l<d){s+='0';l++}
return s*1
}else return Math.round(f)}
function writeFlash(p){writeEmbed('D27CDB6E-AE6D-11cf-96B8-444553540000','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0','application/x-shockwave-flash',p);}
function writeShockWave(p){writeEmbed('166B1BCA-3F9C-11CF-8075-444553540000','http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0','application/x-director',p);}
function writeQuickTime(p){writeEmbed('02BF25D5-8C17-4B23-BC80-D3488ABDDC6B','http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0','video/quicktime',p);}
function writeRealMedia(p){writeEmbed('CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0','audio/x-pn-realaudio-plugin',p);}
function writeWindowsMedia(p){p.url = p.src;writeEmbed('6BF52A52-394A-11D3-B153-00C04F79FAA6','http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701','application/x-mplayer2',p);}
function writeEmbed(cls,cb,mt,p){
var h='',n
h+='<object classid="clsid:'+cls+'" codebase="'+cb+'"'+(typeof(p.id)!="undefined" ? 'id="'+p.id+'"':'')+(typeof(p.name)!="undefined" ? 'name="'+p.name+'"':'')+(typeof(p.width)!="undefined" ? 'width="'+p.width+'"':'')+(typeof(p.height)!="undefined" ? 'height="'+p.height+'"':'')+(typeof(p.align)!="undefined" ? 'align="'+p.align+'"':'')+'>'
for(n in p)h+='<param name="'+n+'" value="'+p[n]+'">'
h+='<embed type="'+mt+'"'
for(n in p)h+=n+'="'+p[n]+'" '
h+='></embed></object>'
document.write(h)
}