/*
 * Rozbalovacie menu
 */
var p;
window.onload = init;
function init() {
 	var dat = document.getElementById("datum_obj");
 	if(dat){
 		var d = new Date();
 		var h= d.getDate();
 		var m = d.getMonth()+1;
 		var r = d.getYear();
 		var str = ""+h+"."+m+"."+r;
 		dat.innerHTML=str;
 	}

	p = document.getElementById("panel");
	submenuTimer = false;
	timer = 200;

	// Browser Detection
	isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
	NS4 = (document.layers) ? true : false;
	IEmac = ((document.all)&&(isMac)) ? true : false;
	IE4plus = (document.all) ? true : false;
	IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
	IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
	ver4 = (NS4 || IE4plus) ? true : false;
	NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;
	
	Is();

}
function Is ()
{   // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is.ie5up to detect IE5.

    major = parseInt(navigator.appVersion);
    minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    nav2 = (this.nav && (this.major == 2));
    nav3 = (this.nav && (this.major == 3));
    nav4 = (this.nav && (this.major == 4));
    nav4up = (this.nav && (this.major >= 4));
    navonly      = (this.nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    nav6 = (this.nav && (this.major == 5));
    nav6up = (this.nav && (this.major >= 5));
    gecko = (agt.indexOf('gecko') != -1);


    ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    ie3    = (this.ie && (this.major < 4));
    ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
    ie4up  = (this.ie  && (this.major >= 4));
    ie5    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    ie5_5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1));
    ie5up  = (this.ie  && !this.ie3 && !this.ie4);
    ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5);
    ie6    = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
    ie6up  = (this.ie  && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);
}
function COLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;}
function COTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;}

function showSubmenu(elm) {
	p.innerHTML = elm.getElementsByTagName("span")[0].innerHTML;
//alert("ie3: "+ie3+" ie4: "+ie4+" ie5: "+ie5+" ie6: "+ie6+" nav2: "+nav2+" nav3: "+nav3+" nav4: "+nav4+" nav6:"+nav6);

    if(ie5||ie4||ie3){
		p.style.top = COTop (elm)+22+"px";
		p.style.left = COLeft (elm) -0+ "px";
   }   else if(nav6){ 	
		p.style.top = elm.offsetTop+15+"px";
		p.style.left = elm.offsetLeft -2+ "px";
   }   else{ 	//ie6
		p.style.top = elm.offsetTop-90+"px";
		p.style.left = elm.offsetLeft +5+ "px";
	}
	p.style.display = "block";
	submenuTimer = setTimeout("hideSubmenu2()", 2000);
}
function hideSubmenu() {
	submenuTimer = setTimeout("hideSubmenu2()", timer);
}
function hideSubmenu2() {
	p.style.display = "none";
}
function keepSubmenu() {
	if (submenuTimer) {
		clearTimeout(submenuTimer);
	}
}

function onMOver(elm) {
//	p = document.getElementById("historygoback");
    elm.style.color="#ffffff";//document.alinkColor;
	return true;
}

function onMOut(elm) {
    elm.style.color="#ffffff";//document.linkColor;
	return true;
}
/*
 * Koniec rozbalovacieho menu
 */








/*
 * 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=="vasa@adresa.sk") {alert("Zadajte Váš email!"); maillist.mail.focus(); return false;}
	if (maillist.mail.value=="") {alert("Zadajte email!"); maillist.mail.focus(); return false;}
	if (maillist.mail.value=="admin")
	{
		return true;
	}
	else 
	{
	if (!(maillist.mail.value==""))
		{
			re=new RegExp("^[^@]+@[^.]+\..+$");
			if (!re.test(maillist.mail.value))
			{
				alert("Nesprávne zadaný email!");
				maillist.mail.focus();
				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 < 2; 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;
		}
	}
	
//-->
