/*
#
# $Id: common.js,v 1.6 2005/08/04 00:24:15 wwwadm Exp $
#

*/
function gebi(id){
	return document.getElementById(id)
}
function dd(id){
	gebi(id).style.display=(gebi(id).style.display=='none'?'block':'none')
	return false
}
String.prototype.trim=function(){return this.replace(/^\s+/,'').replace(/\s+$/,'')}
function isDelete(){
	return confirm('Подтвердите удаление'+((arguments.length>0)?'\n'+arguments[0]:''))
}
function chName(obj,old,name,prom){
	var res=prompt((prom ? prom : "Введите новое название "+(name?name:'')),old)
	if(!res) return false
	obj.href+=res.replace(/&/g,'%26').replace(/#/g,'%23')
	return true
}

var win_err=null

function err(err){
	if(window.showModelessDialog){
		err=err.replace(/\n/g,'<br>')
		if(win_err && !win_err.closed) 
			win_err.err(err)
		else
			win_err=showModelessDialog('/error.html',[window, err]
			,'dialogWidth:500px;dialogHeight:200px;help:0;edge:sunken;scroll:0;resizable:1;status:0;')
	}else{
		alert(err)
	}
}
function chk1(t){
	t.previousSibling.value=t.checked ? 1 : 0
}
function ch_chk(pfx){
	var set;
	var chk=document.getElementsByTagName('INPUT')
	for(var i=0;i<chk.length;i++){
		if(chk[i].name.indexOf(pfx)==0){
			if(typeof set=='undefined') set=!chk[i].checked
			chk[i].checked=set
		}
	}
}
function getCoords(obj){
	var o=typeof(obj) == 'string' ? gebi(obj) : obj
	var ret={'l':o.offsetLeft,'t':o.offsetTop,'w':o.offsetWidth,'h':o.offsetHeight}
	while(o=o.offsetParent){
		ret.l+=o.offsetLeft
		ret.t+=o.offsetTop
	}
	return ret
}

