function popupWindow(url,width,height,scroll) {
	var popUpWin = 0;

	if (scroll==null) scroll=false;

	if(popUpWin) {
		if(!popUpWin.closed) popUpWin.close();
	}

	var left = (screen.width/2) - width/2;
  	var top = (screen.height/2) - height/2;
  	var scrolling = (scroll)?'yes':'no';
	if (scroll=='auto') scrolling = 'auto';
	popUpWin = open(url, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scrolling+',resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	popUpWin.focus();
}


function doZoom(what,w,h,root) {
	var scroll=0;
	if (w>screen.width) {
		w=screen.width;
		scroll=1;
	}
	if (h>screen.height) {
		h=screen.height;
		scroll=1;
	}

	var left = (screen.width/2) - w/2;
  	var top = (screen.height/2) - h/2;

	var opt='toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+scroll+',height='+h+',width='+w+',top='+top+',left='+left;

	var wnd= window.open(root+'zoom.php?name='+what,'',opt);
	wnd.focus();
}

function trimString(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function isInteger(value) {
	if (window.RegExp) {
		var r = new RegExp('^([0-9]+)$');
		if (!r.test(value)) return false;
	}
	return true;
}


function selectInputValue(obj) {
	if (obj.type && obj.type=='text') {
		obj.select();
	}
}

function alertObjProps(obj, showValues) {
	var buf = '';
	for (var prop in obj) {
		buf += ' ' + prop;
		if (showValues) buf += '=' + obj[prop] + ' '
	}
	alert(buf);
}

function blockDisplayToggle(id) {
	if (jQuery("#"+id).is(':hidden'))
	{
		jQuery("#"+id).show();
	}
	else
	{
		jQuery("#"+id).hide();
	}
}

function goToolboxLink() {
	var elem = document.getElementById('idQlinks');
	if (elem.value!='') {
		document.location = elem.value;
	}

}


function formElementsToHash(formId)
{
	var hash = new Object();
	var form = document.getElementById(formId);
	if (form && form.elements)
	{
		for(var i=0;i<form.elements.length; i++)
		{
			var one = form.elements[i];
			hash[one.name] = one.value;
		}
	}
	return hash;
}

function strToInteger(value)
{
	var i = parseInt(value);
	if (isNaN(i)) i = 0;
	return i;
}

function strToFloat(value)
{
	var i = parseFloat(value);
	if (isNaN(i)) i = 0;
	return i;
}

function numRound(number, to)
{
	if (!to) to = 2;
	var powered = Math.pow(10, to);
	return Math.round( number*powered ) / powered;
}

function stringSplitToParts(str, cnt)
{
	if (!cnt) cnt = 25;

	if (str.length<cnt) return str;
	var rez = '';
	while (str.length>cnt)
	{
		var temp = str.substr(0, cnt);

		rez += temp + ' ';
        str = str.substr(cnt, str.length);
        //alert("cnt:" + cnt + " lengh:"+str.length);
	}

	return rez + str;
	/*var all = str.split(' ');
	var parts = new Array();

	for (var i=0; i<all.length; i++)
	{
		var word = all[i];
		if (word.length>partLength)
		{
			var chunks = word.length / partLength;
			alert(chunks);
		}
		else parts.push(word);
	}

	return parts.join(' ');*/
}