popUp = new Array; //array of popup handlers
isDOM=document.getElementById?true:false
isOpera=isOpera5=window.opera && isDOM
isOpera6=isOpera && window.print
isOpera7=isOpera && document.readyState
isMSIE=isIE=document.all && document.all.item && !isOpera
isStrict=document.compatMode=='CSS1Compat'
isNN=isNC=navigator.appName=="Netscape"
isNN4=isNC4=isNN && !isDOM
isMozilla=isNN6=isNN && isDOM

var t,l,win

function ld_img() {
if(document.images){ if(!aLDImg) var aLDImg=new Array()
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]}}
//props(aLDImg)
}
// disable buttons
function btns_off() {
	ic=document.getElementsByTagName('INPUT')
	for(i = 0; i<ic.length; i++){
	    e=ic[i]
		t=e.type.toLowerCase()
		if (t=='submit' || t=='reset' || t=='button') e.disabled = true
	}
	ic=document.getElementsByTagName('BUTTON')
	for(i = 0; i<ic.length; i++) ic[i].disabled = true
}
// popup window (multiple instances)
function new_win(lnk,w,h) {
	if (typeof(window.opera) == 'undefined') { // not opera
		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; //screen.height/2-h/2
		l=screen.width/2-w/2
	}
	d = new Date
	n = d.getTime()
	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)
	popUp[n] = window.open('<?=($vars['rootUrl'].($vars['pathLang'] ? $vars['pathLang'].'/' : ''))?>'+lnk,'void_win_'+n,win)
	popUp[n].focus()
}

// popup window modal mode (no multiple instances)
// n - win name
function new_win_m(lnk,w,h,n) {
	if (typeof(window.opera) == 'undefined') { // not opera
		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; //screen.height/2-h/2
		l=screen.width/2-w/2
	}
	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()
	}
	popUp[n] = window.open('<?=($vars['rootUrl'].($vars['pathLang'] ? $vars['pathLang'].'/' : ''))?>'+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=0 cellspacing=1 cellpadding=3 bgcolor=gray style="font:11px tahoma;">'
    for (var i in o) s+='<tr bgcolor=#eeeeee><td style="color:maroon;">'+i+'<\/td><td>'+o[i]+'<\/td><\/tr>'
    document.write(s+'<\/table>')
}
// toggle tree node
function tt(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
}
//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) {
new_win_m('<?=$cfg['infoPage'].$vars['uPage']?>admin=<?=$vars['admin']?>&cid='+cid+'&id='+id,w,h,'info')
}
function iwr(cid,id) {
new_win_m('<?=$cfg['infoPage'].$vars['uPage']?>admin=<?=$vars['admin']?>&cid='+cid+'&id='+id+'&resize=1',<?=$cfg['infoWdt']?>,<?=$cfg['infoHgt']?>,'info')
}
function ews(cid,id,w,h) {
new_win_m('<?=$cfg['editPage'].$vars['uPage']?>admin=<?=$vars['admin']?>&mode=edit&cid='+cid+'&id='+id,w,h,'edit')
}
function ewr(cid,id) {
new_win_m('<?=$cfg['editPage'].$vars['uPage']?>admin=<?=$vars['admin']?>&mode=edit&cid='+cid+'&id='+id+'&resize=1',<?=$cfg['editWdt']?>,<?=$cfg['editHgt']?>,'edit')
}
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] : "";}