var active = 0;
var imgsrc = '';

function showpic(id){
	window.open("../pic_small_show.php?id="+id,"x","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=auto,resizable=no,width=100,height=100");
}

function showel(id){
	document.getElementById(id).style.visibility = 'visible';
	document.getElementById(id).style.display = 'block';
}

function hideel(id){
	document.getElementById(id).style.visibility = 'hidden';
	document.getElementById(id).style.display = 'none';
}

function moimg(e){
	imgsrc = e.src;
	e.src = '../img/mo.gif';
}

function moutimg(e){
	e.src = imgsrc;
	imgsrc = '';
}

function moimgs(e){
	imgsrc = e.src;
	e.src = '../img/mos.gif';
}

function format_number(pnumber,decimals){
	if (isNaN(pnumber)) { return 0};
		if (pnumber=='') { return 0};
		if (decimals == 0) { return Math.round(pnumber)};
		var snum = new String(pnumber);
		var sec = snum.split('.');
		var whole = parseFloat(sec[0]);
		var result = '';
		if(sec.length > 1){
			var dec = new String(sec[1]);
			dec = String(parseFloat(sec[1])/Math.pow(10,(dec.length - decimals)));
			dec = String(whole + Math.round(parseFloat(dec))/Math.pow(10,decimals));
			var dot = dec.indexOf('.');
			if(dot == -1){
				dec += '.';
				dot = dec.indexOf('.');
			}
			while(dec.length <= dot + decimals) { dec += '0'; }
			result = dec;
		} else{
			var dot;
			var dec = new String(whole);
			dec += '.';
			dot = dec.indexOf('.');
			while(dec.length <= dot + decimals) { dec += '0'; }
			result = dec;
		}
	result = add_commas(result);
	return result;
}

function add_commas(nStr) {
	nStr = Math.round(nStr);
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
   		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, '$1' + ' ' + '$2');
		}
	return x1 + x2;
}

//form functions
function isblank(co){
	for (var i=0; i < co.length; i++)
	{
		var c=co.charAt(i);
   		if ((c != " ") && (c != "\n") && (c != "\t")) return false;
	}
	return true;
}

function isnum(co){
	ok = true;
	for (var i=0; i < co.length; i++)
	{
		var c=co.charAt(i);
   		if ((c < "0") || (c > "9")) ok = false;
	}
	return ok;
}

function istel(co){
	ok = true;
	for (var i=0; i < co.length; i++)
	{
		var c=co.charAt(i);
   		if (((c < "0") || (c > "9")) && (c != "+")) ok = false;
	}
	return ok;
}

function isemil(co){
	ok = false;
	for (var i=0; i < co.length; i++)
	{
		var c=co.charAt(i);
   		if ((c == "@")) ok = true;
	}
	return ok;
}

function isradiochecked(co){
	var pocet = co.length;
	ok = true;
	if (pocet > 0){
		ok = false;
		for (var i=0; i < pocet; i++)
		{
			if (co[i].checked == true){
				ok = true;
			}
		}
	}
	return ok;
}

//table highligt function
function mohl(theRow){
	var newColor = '#eceae7';
    if (typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (newColor) {
		theRow.style.backgroundColor = newColor;
		theRow.style.cursor = 'pointer';
    }
    return true;
}

function moout(theRow, col){
	var newColor = '#'+col;
    if (typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (newColor) {
		theRow.style.backgroundColor = newColor;
    }
    return true;
}