// v 1.2 

PATH = "http://www.muzikland.sk/";

function confirmDelete(actionUrl) {
  if (confirm("Skutočne zmazať?")) {
    document.location = actionUrl;
  }
}

function confirmAction(actionUrl) {
  if (confirm("Skutočne vykonať?")) {
    document.location = actionUrl;
  }
}

function zobraz(id){

el=document.getElementById(id).style; 

el.display=(el.display == 'none')?'block':'block';

}


function zobrazskry(id){

el=document.getElementById(id).style; 

  if(el.display == 'none')
  {
  el.display=(el.display == 'none')?'block':'block';
  }
  else
  {
  el.display=(el.display == 'block')?'none':'none';
  }
}

function vizitka_kap(id) {
      
      viz=window.open(PATH+"info_kap.php?id="+id+"","okno","toolbar=no width=580 height=400 scrollbars=yes resizable=yes");

with (viz.document)
    {
    
    focus();
    }
}

function vizitka_hud(id) {
      viz=window.open(PATH+"info_hud.php?id="+id+"","okno","toolbar=no width=580 height=400 scrollbars=yes resizable=yes");    
  
  with (viz.document)
    {
    
    focus();
      
    }
}

function vizitka_stud(id_stud) {
      
      viz=window.open(PATH+"info_stud.php?id_stud="+id_stud+"","okno","toolbar=no width=580 height=400 scrollbars=yes resizable=yes")
      
    with (viz.document)
    {
    
    focus();
      
    }
}
function pic(cesta) {
      
      obr=window.open("","okno2","toolbar=no, width=800, height=600, resizeable=yes, scrollbars=yes");
      
     with (obr.document)
    {
   //open();
    writeln("<html><title>Fotka</title><body leftmargin=0 topmargin=0><img src="+PATH+""+cesta+"></body></html>");
    
   // close();
    obr.document.focus();
    
    }
}

function pic2(cesta) {
      
      obr=window.open("","okno2","toolbar=no, width=600, height=800, resizeable=yes, scrollbars=yes");
      
     with (obr.document)
    {
   //open();
    writeln("<html><title>Fotka</title><body leftmargin=0 topmargin=0><img src="+PATH+""+cesta+"></body></html>");
    
   // close();
     obr.document.focus();
    
    }
}

function pic_uni(cesta) {
      
      obr=window.open("","okno2","toolbar=no, width=800, height=600, resizeable=yes");
      
     with (obr.document)
    {
   //open();
    writeln("<html><title>Fotka</title><body leftmargin=0 topmargin=0><img src="+PATH+""+cesta+"></body></html>");
    
   // close();
     obr.document.focus();
    
    }
}
function info(sub) {
      viz=window.open(PATH+"informacie/info_"+sub+".php","okno","toolbar=no width=580 height=500 scrollbars=yes resizable=yes");    
  
  with (viz.document)
    {
    
    focus();
      
    }
}

function page(sek) {
    window.location.href=sek+".php";
}
function noveokno(cesta) {
    window.open(PATH+""+cesta+"","okno2","");
}

function bug() {
    window.open(PATH+"bug.php","okno","toolbar=no width=500 height=350");
}

function okno(subor) {
  window.open(PATH+""+subor+"","okno","toolbar=no width=550 height=500 scrollbars=yes resizable=yes");
}

// JavaScript Document

var NS4 = (document.layers);    // Which browser?
var IE4 = (document.all);

var win = window;    // window to search.
var n   = 0;

function findInPage(str) {

  var txt, i, found;

  if (str == "")
    return false;

  // Find next occurance of the given string on the page, wrap around to the
  // start of the page if necessary.

  if (NS4) {

    // Look for match starting at the current point. If not found, rewind
    // back to the first match.

    if (!win.find(str))
      while(win.find(str, false, true))
        n++;
    else
      n++;

    // If not found in either direction, give message.

    if (n == 0)
      alert("Not found.");
  }

  if (IE4) {
    txt = win.document.body.createTextRange();

    // Find the nth match from the top of the page.

    for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
      txt.moveStart("character", 1);
      txt.moveEnd("textedit");
    }

    // If found, mark it and scroll it into view.

    if (found) {
      txt.moveStart("character", -1);
      txt.findText(str);
      txt.select();
      txt.scrollIntoView();
      n++;
    }

    // Otherwise, start over at the top of the page and find first match.

    else {
      if (n > 0) {
        n = 0;
        findInPage(str);
      }

      // Not found anywhere, give message.

      else
        alert("Položka nenájdená.");
    }
  }

  return false;
}

function submitpage(pg){

window.location.href="#"+pg;

return false;
}


function value()
{
document.hladatkapelu.type.value ="<i>Hľadať kapelu alebo muzikanta</i>";
}

function watermark (nameform, nameinput)
{
//document.getelementbyname(name).value = 'Hľadať kapelu alebo muzikanta';

}

function setFocus(nameform, nameinput, hladaj, defaultText)
{
  if(hladaj == defaultText)
  {
  document.forms[nameform].elements[nameinput].focus();

  document.forms[nameform].elements[nameinput].style.color = 'gray';

  document.forms[nameform].elements[nameinput].style.fontStyle = 'italic';
  }
}

function setBlur(nameform, nameinput, hladaj, defaultText)
{
  if(hladaj == defaultText)
  {
  document.forms[nameform].elements[nameinput].style.color = 'gray';

  document.forms[nameform].elements[nameinput].style.fontStyle = 'italic';

  document.forms[nameform].elements[nameinput].value = hladaj;  
  }

}

function onwork (nameform, nameinput, hladaj, defaultText)
{
  if(hladaj == defaultText)
  {
  document.forms[nameform].elements[nameinput].value = '';
  
  document.forms[nameform].elements[nameinput].style.color = 'black';

  document.forms[nameform].elements[nameinput].style.fontStyle = 'normal';    
  }
  else
  {
  document.forms[nameform].elements[nameinput].style.color = 'black';

  document.forms[nameform].elements[nameinput].style.fontStyle = 'normal';
  }
}

function setHomepage(url)
{
 if (document.all)
    {
    document.body.style.behavior='url(#default#homepage)';
    document.body.setHomePage(url);
 
    }
    else if (window.sidebar)
    {
    if(window.netscape)
    {
         try
    {  
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
         }  
         catch(e)  
         {  
    alert("Bohužiaľ, Váš prehliadač neumožňuje automatické nastavenie domovskej stránky. Musíte tak urobiť svojpomocne v nastaveniach prehliadača.");  
         }
    } 
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
    prefs.setCharPref('browser.startup.homepage',url);
 }
}

















var NS4 = (document.layers);    // Which browser?
var IE4 = (document.all);

var win = window;    // window to search.
var n   = 0;

function findInPage(str) {

  var txt, i, found;

  if (str == "")
    return false;

  // Find next occurance of the given string on the page, wrap around to the
  // start of the page if necessary.

  if (NS4) {

    // Look for match starting at the current point. If not found, rewind
    // back to the first match.

    if (!win.find(str))
      while(win.find(str, false, true))
        n++;
    else
      n++;

    // If not found in either direction, give message.

    if (n == 0)
      alert("Not found.");
  }

  if (IE4) {
    txt = win.document.body.createTextRange();

    // Find the nth match from the top of the page.

    for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
      txt.moveStart("character", 1);
      txt.moveEnd("textedit");
    }

    // If found, mark it and scroll it into view.

    if (found) {
      txt.moveStart("character", -1);
      txt.findText(str);
      txt.select();
      txt.scrollIntoView();
      n++;
    }

    // Otherwise, start over at the top of the page and find first match.

    else {
      if (n > 0) {
        n = 0;
        findInPage(str);
      }

      // Not found anywhere, give message.

      else
        alert("Položka nenájdená.");
    }
  }

  return false;
}

function submitpage(pg){

window.location.href="#"+pg;

return false;
}


function ajax(stranka, kam)
{

    var httpRequest;
    
    if(typeof window.ActiveXObject != 'undefined')
    {
        httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {  
        httpRequest = new XMLHttpRequest();
    }
    httpRequest.open("GET", stranka, true);
    httpRequest.onreadystatechange= function () 
    {
        processRequest(httpRequest, kam) 
    };
    httpRequest.send(null);

return false;
}


function processRequest(httpRequest, kam) 
{
    if (httpRequest.readyState == 4)
    {
        if(httpRequest.status == 200)
        {
            if (typeof kam == 'string') 
            {
                document.getElementById(kam).innerHTML = httpRequest.responseText;
            }
            if (typeof kam == 'function') 
            {
                kam(httpRequest.responseText);
            }
        }
        else
        {
            alert("Chyba pri nacitani stanky " + httpRequest.status +" : "+ httpRequest.statusText);
        }
    }
    else
    {
        if (typeof kam == 'string' && kam != '') 
        {
            document.getElementById(kam).innerHTML = 'Loading...';
        }
    }
      
}



