/*	$Id: dsm.js,v 1.15.2.4 2006/03/31 14:42:54 belukov Exp $ */


function tougleHide(mode, bhide, bshow, bcont)
{
	_elems = document.getElementsByName(bcont);
	_elems.item(0).style.visibility= mode ? 'visible' : 'hidden';

	if(mode){
		mode = false;
	}else{
		mode = true;
	}
	_elems1 = document.getElementsByName(bshow);
	_elems2 = document.getElementsByName(bhide);
	_elems1.item(0).style.visibility = mode ? 'visible' : 'hidden';
	_elems2.item(0).style.visibility = mode ? 'hidden' : 'visible';
	return mode;
}

function widget_minimize(hide, bhide, bswitch)
{
	_elems = document.getElementsByName(bhide);
	_elems.item(0).style.display = hide ? 'none' : 'inline';

	if( bswitch != '') {
		_elems = document.getElementsByName(bswitch);
		_elems.item(0).innerHTML = hide ? 'show' : 'hide';
	}
	return hide ? false : true;
}

/**
*	Deprecated! Use createbox()
*/
function creategroupbox()
{
	if(name = prompt("Create new group with name")){
		document.creategroup.name.value = name;
		document.creategroup.submit();
	}

	return false;
}

function createbox(object_name, form_name)
{
	if(name = prompt("Create new "+object_name+" with name")){
		forms = document.getElementsByName(form_name);

		forms[0].name.value = name;
	/*	for(i in forms[0].name){
			alert(i+'='+forms[0].name[i]);
		}*/
		forms[0].submit();
	}

	return false;
}

function popup(url, title, params)
{
	//'width=1000,height=400,resizable,scrollbars'
	if(url.indexOf('images/') == 1) {
		url = '/__popup'+url
	}
	win = window.open(url, title, params)
	win.focus()
	win.screenY=0
	win.screenX=0
	return win;
}

function dsm_dump(variable)
{
	msgWindow = window.open('','variable dump', 'toolbar=yes,scrollbars=yes,resizable,width=400,height=300');
	msgWindow.document.open("text/html","replace");

	for(i in variable){
		msgWindow.document.write(i+'='+variable[i]+'<hr>');
	}
}

function notifyBar(tag_name,mess)
{
		bars = document.getElementsByName(tag_name);
		bars.item(0).innerHTML = mess;
}

function pl_check(obj)
{
	if(obj.value>0){
		return true;
	}else{
		alert("Допустимым значением является только положительное число!");
		obj.value=0;
		return false;
	}
}


function AzbukaParse(str){
if(str == '') return '';
azbuka = "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя";
        k = 0;
        stop = false;
        result = '';
        while(!stop){
                a = str.indexOf('#', k);
                b = str.indexOf('#', a+1);
                k=a+1;
                if(b < a){
                        b = str.length;
                        stop = true;
                }
                sub = str.substring(a+1,b);

                if(sub.substring(0,1) == '%'){
                        result += sub.substring(1);
                }else{
                        ind = parseInt(sub);
                        result += azbuka.substring(ind,ind+1);
                }
//alert(a+' '+b+' '+sub+' '+result);
        }
        return result;

}


/* vim: set foldmethod=marker: */

