/*
 * Táto funkcia overuje správnosť zadania emilovej adresy určenej na zápis do MAILLIST databázy
 * Tiež umožňuje vstup pre ADMINISTRÁCIU stránky
 */
function fmaillist(maillist)
{
	if (maillist.mail.value=="admin") {return true;} else {return false;}
}
/* End of function fmaillist */

/*
 * Táto funkcia overuje spravnost vyplnenia formulara na polozky v JEDALNOM LISTKU
 */
function fformmail(formmail)
{
	if (formmail.text.value=="") {alert("Zadajte text!"); formmail.text.focus(); return false;}
}
/* End of function fformmail */


/*
 * Funkcia na zobrazovanie rozbalovacieho menu
 */
var timer, i, menuId;

var dom = document.getElementById ? true : false;
var ie4 = ((document.all) && (!dom)) ? true : false;
var ns4 = document.layers ? true : false;
var opera = navigator.userAgent.indexOf('Opera') != -1 ? true : false;
var dhtml = dom ? true : ie4 ? true : ns4 ? true : false;


function setVisibility(element,newVisibility)
{ 
  if (dhtml)
  {
    if (dom) document.getElementById(element).style.visibility = newVisibility;
    else if (ie4) document.all[element].style.visibility = newVisibility;
    else if (ns4) eval('document.' + element + '.visibility = newVisibility');
  }
}

function menu()
{
  if (dhtml)
  {
    if (opera) for (i = 1; i <= 2; i++) document.getElementById('hiddenMenu' + i).style.top = 20;
    if (ie4) for (i = 1; i <= 2; i++) document.all['hiddenMenu' + i].style.top = 18;
    setVisibility('menuHolder','visible');
  }
}

function showMenu(id)
{
  if (dhtml)
  {
    clearTimeout(timer);
    for (i = 1; i <= 2; i++) if (i != id) setVisibility((ns4 ? 'menuHolder.document.' : '') + 'hiddenMenu' + i,'hidden');
    setVisibility((ns4 ? 'menuHolder.document.' : '') + 'hiddenMenu' + id,'visible');
  }
}

function hideMenu(id)
{
  if (dhtml)
  {
    menuId = (ns4 ? 'menuHolder.document.' : '') + 'hiddenMenu' + id;
    timer = setTimeout("setVisibility(menuId,'hidden')",300);
  }
}

function dontHideMenu()
{
  if (dhtml) clearTimeout(timer);
}


//zvyrazni (aktualnu) polozku pod kurzorom 
function TabSel(cispol)
{
	var pol=eval("document.all.polozka"+cispol)
//	pol.style.backgroundColor="#CAA66C";
//	pol.style.color="#000000";
}
	
//zrusi zvyraznenie aktualnej polozky
function TabUnSel(cispol)
{
	var pol=eval("document.all.polozka"+cispol)
//	pol.style.backgroundColor="#AF3B02";
//	pol.style.color="#000000";
}		 
		 
//vysvieti sa nadpis akurat otvoreneho menu
function MenuSel(cispol)
{
	var i, menu;
	menu=eval("document.all.visibleMenu"+cispol)
//	menu.style.backgroundColor="#023BAC";
//	menu.style.color="white";
}

//zrusia sa vsetky vysvietenia nadpisov menu
function MenuUnSel()
{
	var i, menu;
	for(i=1; i<=2; i++)
	{
		menu=eval("document.all.visibleMenu"+i);
//		menu.style.backgroundColor="#D2C46C";
//		menu.style.color="#000000";
	}
}

//zavrie vsetky menu
function Hide()
{
	var menu, i;
	MenuUnSel();
	for(i=1; i<=2; i++)
	{
		menu=eval("document.all.x"+i);
		menu.style.visibility="hidden";
	}
}
/* End funkcie na zobrazovanie rozbalovacieho menu */


/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;


/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0) 
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function



///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////      //////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////


/*
	 * Táto funkcia overuje spravnost vyplnenia formulara na polozky v JEDALNOM LISTKU
	 */
	function fpoh_text(poh_text)
	{
		if (poh_text.komu.value=="") {alert("Zadajte komu!"); poh_text.komu.focus(); return false;}
		if (poh_text.email.value=="") {alert("Zadajte email!"); poh_text.email.focus(); return false;}
		re=new RegExp("^[^@]+@[^.]+\..+$");
		if (!re.test(poh_text.email.value)) {alert("Nesprávne zadaný email!"); poh_text.email.focus(); return false;}
		if (poh_text.text.value=="") {alert("Zadajte text!"); poh_text.text.focus(); return false;}
		if (poh_text.od.value=="") {alert("Zadajte od koho!"); poh_text.od.focus(); return false;}
		if (!(poh_text.email_od.value==""))
		{
			re=new RegExp("^[^@]+@[^.]+\..+$");
			if (!re.test(poh_text.email_od.value)) {alert("Nesprávne zadaný email!"); poh_text.email_od.focus(); return false;}
		}
	}
	/* End of function fformmail */	
	
	

	/*
	 * Táto funkcia overuje spravnost vyplnenia formulara na polozky v JEDALNOM LISTKU
	 */
	function fformpol(formpol)
	{
		if (formpol.nazovS.value=="") {alert("Zadajte slovenský názov!"); formpol.nazovS.focus(); return false;}
	}
	/* End of function fformpol */
	
	/*
	 * Táto funkcia overuje spravnost vyplnenia formulara na pridavanie prispevkov do MESSAGEBOARDu
	 */
	function fformkal(formkal)
	{
		if (formkal.name.value=="") {alert("Zadajte názov!"); formkal.name.focus(); return false;}
		if (formkal.text.value=="") {alert("Zadajte text!"); formkal.text.focus(); return false;}
	}
	/* End of function fformkal */
	
	/*
	 * Táto funkcia overuje spravnost vyplnenia formulara na pridavanie prispevkov do MESSAGEBOARDu
	 */
	function fanketaadd(anketaadd)
	{
		if (anketaadd.question.value=="") {alert("Zadajte otázku!"); anketaadd.question.focus(); return false;}
		if (anketaadd.reply1.value=="") {alert("Zadajte odpoveď 1!"); anketaadd.reply1.focus(); return false;}
		if (anketaadd.name.value=="") {alert("Zadajte meno!"); anketaadd.name.focus(); return false;}
	}
	/* End of function fanketaadd */
	
	/*
	 * Táto funkcia overuje spravnost vyplnenia formulara na pridavanie prispevkov do MESSAGEBOARDu
	 */
	function fknihaadd(knihaadd)
	{
		if (knihaadd.meno.value=="") {alert("Zadajte meno!"); knihaadd.meno.focus(); return false;}
		if (!(knihaadd.email.value==""))
		{
			re=new RegExp("^[^@]+@[^.]+\..+$");
			if (!re.test(knihaadd.email.value)) {alert("Nesprávne zadaný email!"); knihaadd.email.focus(); return false;}
		}
		if (knihaadd.clanok.value=="") {alert("Zadajte text!"); knihaadd.clanok.focus(); return false;}
	}
	/* End of function fknihaadd */
	
	/*
	 * Táto funkcia overuje zadanie pola s prispevkom pri EDIT MESSAGEBOARD
	 */
	function fknihaedit(knihaedit)
	{
		if (knihaedit.clanok.value=="") {alert("Zadajte text!"); knihaedit.clanok.focus(); return false;}
	}
	/* End of function knihaedit */
	
	/*
	 * Táto funkcia overuje správnosť vyplnenia REGISTRACNEHO formulara
	 */
	function check_reg(registerform)
	{
		if (registerform.name.value=="") {alert("Zadajte meno!"); registerform.name.focus(); return false;}
		if (!(registerform.mail.value==""))
		{
			re=new RegExp("^[^@]+@[^.]+\..+$");
			if (!re.test(registerform.mail.value)) {alert("Nesprávne zadaný email!"); registerform.mail.focus(); return false;}
		}
		if (registerform.pin.value=="") {alert("Zadajte prihlasovacie meno!"); registerform.pin.focus(); return false;}
		if (registerform.xpsswd.value=="") {alert("Zadajte heslo!"); registerform.xpsswd.focus(); return false;}
		if (registerform.xpsswd2.value=="") {alert("Zadajte overovacie heslo!"); registerform.xpsswd2.focus(); return false;}
		if (!(registerform.xpsswd.value==registerform.xpsswd2.value)) {alert("Heslo a heslo pre overenie nesúhlasia!"); registerform.xpsswd2.focus(); return false;}
		registerform.psswd.value=registerform.xpsswd2.value;
	}
	/* End of function check_reg */
	
	/*
	 * Táto funkcia overuje správnosť zmeny profilu
	 */
	function check_edit_user(editform)
	{
		if (editform.name.value=="") {alert("Zadajte meno!"); editform.name.focus(); return false;}
		if (editform.mail.value=="") {alert("Zadajte email!"); editform.mail.focus(); return false;}
		if (!(editform.mail.value==""))
		{
			re=new RegExp("^[^@]+@[^.]+\..+$");
			if (!re.test(editform.mail.value))
			{
				alert("Nesprávne zadaný email!");
				editform.mail.focus();
				return false;
			}
		}
		if (editform.pin.value=="") {alert("Zadajte prihlasovacie meno!"); editform.pin.focus(); return false;}
		if (!(editform.xpsswd.value==""))
		{
			if (editform.xpsswd2.value=="") {alert("Zadajte nové overovacie heslo!"); editform.xpsswd2.focus(); return false;}
			if (!(editform.xpsswd.value==editform.xpsswd2.value)) {alert("Nové heslo a nové heslo pre overenie nesúhlasia!"); editform.xpsswd2.focus(); return false;}
			editform.psswd.value=editform.xpsswd2.value;
		}
	}
	/* End of function check_edit_user */
	
	/*  Bez popisu  */
	function FindObject(n, d)
	{
		var p,i,x;  if(!d) d=document;
		if((p=n.indexOf("?"))>0&&parent.frames.length)
		{
			d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
		}
		if(!(x=d[n])&&d.all) x=d.all[n];
		for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		return x;
	}
	function Img_Neg()
	{
		var i,j=0,x,a=Img_Neg.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		if ((x=FindObject(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	
	
	if (document.all) document.getElementById = document.all;
	function menu(co) 
	{
		if (co==1)
		{
			document.getElementById('strava').style.visibility = 'visible';
			return;
		}
		if (co==2)
		{
			document.getElementById('sluzba').style.visibility = 'visible';
			document.getElementById('strava').style.visibility = 'hidden';
			co=1;
			return;
		}
	}
	
//-->
