// UNIVERZALNI FUNKCE ZACATEK
function get(id) 
{
	if (document.getElementById)
		return document.getElementById(id);
	else
		return false;
}
function ow(URL, name, width, height)
{
	if (width == -1) width = screen.width - 62;
	if (height == -1) height = screen.height - 62;
	width = width + 22;
	window.open(URL, name, 'width='+width+',height='+height+',directories=no,toolbar=no,resizable=yes,menubar=no,scrollbars=1,top=0,left=0');
}
function dm(mail)
{
	while(mail.indexOf("$")!=-1) mail=mail.replace("$","@");
	while(mail.indexOf("*")!=-1) mail=mail.replace("*",".");
	document.write('<a href="m'+'a'+'i'+'l'+'t'+'o:'+mail+'\">'+mail+'<\/a>');
}
function gm(mail)
{
	while(mail.indexOf("$")!=-1) mail=mail.replace("$","@");
	while(mail.indexOf("*")!=-1) mail=mail.replace("*",".");
	return mail;
}
// UNIVERZALNI FUNKCE KONEC

// MENU INZERATU ZACATEK
function on(obj)
{
	get(obj).style.visibility = "visible";
}
function off(obj)
{
	get(obj).style.visibility = "hidden";
}

function toff(obj)
{
	setTimeout('off(\''+obj+'\')', 150);
}

function notepad_delete()
{
	document.location.href='notepad_remove.php?ID=0';
}

function ignored_delete()
{
	document.location.href='ignored_remove.php?ID=0';
}
// MENU INZERATU KONEC

// kontrola spravnosti emailove adresy
function checkmail(pole)
{
	if (new RegExp(/^test$/).test("test"))
	{
		re = new RegExp(/^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+\.[A-Za-z]{2,5}$/).test(pole.value);
		if (!re)
		{
			alert(ERROR_no_valid_email);
			pole.focus();
			return false;
		}
		else return true;
	}
	else return true;
}

function checkftxtform(pole)
{
	if (pole.value=="")
	{	
		alert(ERROR_no_ftxt);
		pole.focus();
		return false;
	}
	else return true;
}

function setURL(pole)
{
	document.location.href = pole[pole.selectedIndex].value;
}

function add_fav(fav)
{
	ow('/wfavorite.php?fav='+fav, 'favorite', 300, 200);
}

function chngr(rID)
{
	get(rID).style.visibility = "visible";
}

function rstr(rID)
{
	get(rID).style.visibility = "hidden";
}

//Odstrani mezery ze zacatku a z konce
function Trim(str)
{
    return str.replace(/^\s*|\s*$/g,"");
}

//Otestuje, jestli je parametr platne cele cislo
function jeCeleCislo(number)
{
	number=Trim(number);

	if ((number==null)||(number==''))
		return false;

	var cisla='0123456789';

	for(var i=0;i<number.length;i++)
	{
		if(cisla.indexOf(number.charAt(i))==-1)
		{
			return false;
		}
	}
	return true;	
}

// FUNKCE PRO STROM ODDELENI
function ob(kID)
{
	document.navig.kID.value = kID;
	document.navig.submit();
}
function pb(kID)
{
	document.getcat.kID.value = kID;
	document.getcat.submit();
}
function xb(url, name)
{
	alert(INFO_xlink + name);
	//window.location.href = url;
}
function xob(kID, name)
{
	alert(INFO_xlink + name);
	document.navig.kID.value = kID;
	document.navig.submit();
}
function setCategory()
{
  if (window.opener.document.getElementById('frmadd'))
  {
	 window.opener.document.forms.frmadd.kID.value = document.category.kID.value;
	 window.opener.document.forms.frmadd.nazev_kat.value = document.category.nazev_kat.value;
	}
	window.close();
}
function opb(url)
{
	document.location.href = url;
}

function ukazVice(odkaz, vice)
{
  odkaz.style.display = "none";
	get(vice).style.display = "inline";
}
