//index.frm
$(function () {
		$('a.lightbox').lightBox();
	});

function zobrazSkryj(idecko) {
	var el = document.getElementById(idecko);
	el.className = (el.className == 'skryj') ? '' : 'skryj';
}

function obarviPozadi(zalozka) {
	if (document.getElementById("tretiZalozka") != null) {
		document.getElementById("tretiZalozka").className = '';
	}
	if (document.getElementById("prvniZalozka") != null) {
		document.getElementById("prvniZalozka").className = '';
	}
	if (document.getElementById("druhaZalozka") != null) {
		document.getElementById("druhaZalozka").className = '';
	}
	if (document.getElementById("ctvrtaZalozka") != null) {
		document.getElementById("ctvrtaZalozka").className = '';
	}
	document.getElementById(zalozka).className = 'aktivni'
}

function zobraz(polozka, zalozka) {
	if (document.getElementById) {
		document.getElementById(zobrazena).style.display = "none"; // skryje predchozí polozku
		document.getElementById(polozka).style.display = "block"; // zobrazi se nakliknuta polozka
		zobrazena = polozka; // aktualne zobrazena polozka se ulozi do globalni promenne, aby se pozdeji dala skryt
		obarviPozadi(zalozka);
		return false; // odkaz neproklikne na href
	} else {
		if (document.stylesheets)
			document.stylesheets["zalozky"].disabled = true; // v nekterych browserech (IE 4) vypne styl nezobrazovani, aby se polozky alespon zobrazily
		return true; // odkazy budou proklikavat na href
	}
}
var zobrazena = "prvni"; // pomocna promenna, na zacatku nastavena na jmeno zobrazene polozky

//search.frm
function GetKeyCode(e) {
  if (e) {
    return e.charCode ? e.charCode : e.keyCode;
  }
  else {
    return window.event.charCode ? window.event.charCode : window.event.keyCode;
  }
} 

function generujNaseptavac(e) {
  var unicode = GetKeyCode(e);
  var str = document.getElementById("inputText").value;
  if (unicode != 38 && unicode != 40 && str != lastSelected) {
    if (str != "") {
      // IE/zbytek sveta
      if (window.ActiveXObject) {
      httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
      } else {
        httpRequest = new XMLHttpRequest();
      }    
      var url = "/naseptavac.php?web=halshop&str=" + encodeURI(str);
      httpRequest.open("GET", url, true);     
      httpRequest.onreadystatechange= function () {processRequest(); } ;
      httpRequest.send(null);     
    }
    else {     
      document.getElementById("naseptavacDiv").style.visibility = "hidden";
    }
  }
}

function posunNaseptavac(e) {
  var unicode = GetKeyCode(e);
  var naseptavac = document.getElementById("naseptavac");
    
    
    getChangeHandler();
    return;
  
  if (unicode == 13) {
    lastSelected = document.getElementById("inputText").value;
    // na enter ve textovém poli nechceme odesílat formulár
   
    document.getElementById("naseptavacDiv").style.visibility = "hidden";
  }
} 

function processRequest() {
  if (httpRequest.readyState == 4) {
    if(httpRequest.status == 200) {
      
      var response = httpRequest.responseText;
  
      if (response == 'EMPTY') {
        document.getElementById("naseptavacDiv").style.visibility = "hidden";
      }
      else {        
        document.getElementById("naseptavacDiv").innerHTML = response;
        document.getElementById("naseptavac").size =
          document.getElementById("naseptavac").options.length;
        document.getElementById("naseptavacDiv").style.visibility = "visible";
        
      } 
    }
  }
}

function getChangeHandler() {
    
  var select = document.getElementById("naseptavac");
  var nazev = select.options[select.selectedIndex].innerHTML;
  document.getElementById("inputText").value = nazev.replace(/\&amp;/g,'&');
  
}
 
function getResultClickHandler() {
  getChangeHandler();
  
  var obsah_value_option = document.getElementById("naseptavac"); 
  var promenna = obsah_value_option.value;
  document.getElementById("inputTextValue").value = promenna.replace(/\&amp;/g,'&');
  lastSelected = document.getElementById("inputText").value;  
  document.getElementById("naseptavacDiv").style.visibility = "hidden";
  
}
