function setVisibility(elementID,visible) {
	var el  = document.getElementById(elementID);
	el.style.visibility = visible;
}
function enableButton(btnID,ceknuto) {
	el = document.getElementById(btnID);
	el.disabled = !el.disabled;
}

function showContent(){
	document.body.style.display = 'block';
	document.getElementById('preloader').display = none;
}

function provazDopravuPlatbu(sender,mozneKombinace) {
	//alert(sender + "\n" + mozneKombinace);
	elPlatba = document.getElementById('shop_kosik_platba');
	elDoprava = document.getElementById('shop_kosik_doprava');
	
	if(sender.id == 'shop_kosik_platba') target = elDoprava;
	else if(sender.id == 'shop_kosik_doprava') target = elPlatba;
	
	for (i=0;i<mozneKombinace.length;i++) {
		//alert(mozneKombinace[i][0]);
		if(sender.value==mozneKombinace[i][0]) target.value=mozneKombinace[i][0];	
	}
	
}


function checkEmail(elementID, formID) {
var email = document.getElementById(elementID);
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email.value)) {
alert('Prosím zadejte správný email');
email.focus();
return false;
}
else document.getElementById(formID).submit();
}


function prepinacKusu(elementBarva,elementVelikost,elementOF)
{
	
	for (i=0;i<elementOF.length;i++) {
		element = document.getElementById('shop_polozka_obrazek_kus-'+elementOF[i]);
		setClass(element,'shop_polozka_obrazek_kus_inactive');
		
		
	}
	
	
	
	elementBarva = document.getElementById(elementBarva);
	barva = elementBarva.value;
	
	elementVelikost = document.getElementById(elementVelikost);
	velikost = elementVelikost.value;
	
	
	elementON = document.getElementById('shop_polozka_obrazek_kus-'+barva+'_'+velikost);
	setClass(elementON,'shop_polozka_obrazek_kus_active');
	
	
	

	
	
}

function setClass(element,trida)
{
		element=document.getElementById(element);
		if(element.setAttribute) element.setAttribute('class', trida);
		if(element.className) element.className=trida;
	
}


function dropdown_OnMouseout(e, idToHide)
{
  if (e && typeof e.relatedTarget != 'undefined')
  {
    // During a mouseout event relatedTarget points to
    // the element the mouse has moved to. If this element
    // is contained by an element with className == 'dropdown'
    // then we know the mouse is still over the submenu and
    // we should not hide it.
    var ele = e.relatedTarget;
    while(ele && ele.className != 'dropdown') {
      ele = ele.parentNode;
    }
    if (!ele) {
      // The mouse is not over the submenu so hide the sub.
      setVisibility(idToHide,'hidden');
    }
  }
  else {
    // if the browser doesn't support 'relatedTarget'
    // then proceed as you had it originally.
    setVisibility(idToHide,'hidden');
  }
}

function setBgColor (id, color) {
  if (document.layers)
    document[id].bgColor = color == 'transparent' ? null : color;
  else if (document.all)
    document.all[id].style.backgroundColor = color;
  else if (document.getElementById)
    document.getElementById(id).style.backgroundColor = color;
}


function startLytebox(elementId) {

  var el   = document.getElementById(elementId);
  myLytebox.start(el, false, true);
}



function checkKupForm(what) {
	message = "";
	
	for (i=0;i<what.length;i+=2) {
		element = document.getElementById(what[i]);
		if (element.value=="0" || element.value=="") message += "\t" + what[i+1] + "\n";
	}
	/*
	elementVelikost = document.getElementById('vybrana_velikost');
	elementBarva = document.getElementById('vybrana_barva');
	elementPocet = document.getElementById('vybrany_pocet');
	
	if (elementVelikost.value=="0") message += "velikost, ";
	if (elementBarva.value=="0") message += "barvu a ";
	if (elementPocet.value=="0" || elementPocet.value=="") message += "počet";
	*/
		
	if (message!="") {
		message = "Pro obědnání musíte vyplnit \n" + message;
		alert(message);
		message = null;
		return false;
	}
		else return true;
	
}
function sort(podleCeho,smer) {
	elementSort = document.getElementById('sort');
	elementSortSmer = document.getElementById('sort_smer');
	elementSort.value = podleCeho;
	elementSortSmer.value = smer;
	
	
	document.shop_kategorie_sort_form.submit();
}
function checkform(form,what,file) {
	message = "";
	if (file) {
		element = document.form.filesent;
		if (element.value=="") message += "\t" + file[i+1] + "\n";
		else message+="file jo";
	}
	
	for (i=0;i<what.length;i+=2) {
		element = document.getElementById(what[i]);
	/*	if (i==0 && file) {
			if (element.file=="") message += "\t" + what[i+1] + "\n";
		}*/
		if (element.value=="") message += "\t" + what[i+1] + "\n";
	}
	
	if (message!="") {
		message = "Musíte vyplnit následující položku/-ky:\n\n" + message;
		alert(message);
		message = null;
		return false;
	}
		else return true;
	
}
function setBackgroundImage (id, imageURL) {
  if (document.layers)
    document[id].background.src = imageURL == 'none' ? null : imageURL;
  else if (document.all)
    document.all[id].style.backgroundImage = imageURL == 'none' ? 'none' 
: 'url(' + imageURL + ')';
  else if (document.getElementById)
    document.getElementById(id).style.backgroundImage = imageURL == 
'none' ? 'none' : 'url(' + imageURL + ')';
}
function showhide(element1)
{
	element1 = document.getElementById(element1);
	el1 = element1.getAttribute('class');
	if (el1 == 'user_new_faktura_invisible') element1.setAttribute('class', 'user_new_faktura_invisible_visible');
	else element1.setAttribute('class', 'user_new_faktura_invisible');
}
function showhideZoom(element1,element2)
{
    
	element1 = document.getElementById(element1);
	el1 = element1.getAttribute('class');

	if (el1 == 'shop_kategorie_oddelovac_invisible') setClass(element1,'shop_kategorie_oddelovac');
	else setClass(element1, 'shop_kategorie_oddelovac_invisible');

	element2 = document.getElementById(element2);
	el2 = element2.getAttribute('class');
	if (el2 == 'zoomout') setClass(element2,'zoom_in');
	else setClass(element2,'zoomout');
}

function setClass(element,trida)
{
	if(element.setAttribute || element.className) {

		if(element.setAttribute) element.setAttribute('class', trida);
		if(element.className) element.className=trida;
	}

	else
	{

		element=document.getElementById(element);
		if(element.setAttribute) element.setAttribute('class', trida);
		if(element.className) element.className=trida;
	}

}

function confirmDelete(query)
{
	pokracuj = confirm("Opravdu chcete tuto polo\u017eku smazat?");
	if (pokracuj) document.location = query;
}

function prenesText(text, element2)
{
	element2 = document.getElementById(element2);
	element2.value = text;
}


function prenesHodnotu(element1, element2)
{
	element1 = document.getElementById(element1);
	element2 = document.getElementById(element2);
	element2.value = element1.value;
}

function winH() {
	   if (window.innerHeight)
	      /* NN4 a kompatibilní prohlížeče */
	      return window.innerHeight;
	   else if
	   (document.documentElement &&
	   document.documentElement.clientHeight)
	      /* MSIE6 v std. režimu - Opera a Mozilla
	      již uspěly s window.innerHeight */
	      return document.documentElement.clientHeight;
	   else if
	   (document.body && document.body.clientHeight)
	      /* starší MSIE + MSIE6 v quirk režimu */
	      return document.body.clientHeight;
	   else
	      return null;
	}
	
	function init_imgover(imgsrc,imgw,imgh)
	{
		fromtop=document.body.scrollTop;
		e=document.getElementById('ol');
		eio=document.getElementById('io');
		e.className='imgover';
		height=winH();
		bheight=document.body.scrollHeight;
		if (bheight>height) oh=bheight; else oh=height;
		e.style.height=oh;
	
		et=(height-imgh-22)/2+fromtop;	// 2x border override
		eio.className='imgover-img';
		eio.style.top=et+'px';
		eio.innerHTML='<img src="'+imgsrc+'" alt="" width="'+imgw+'" height="'+imgh+'" border="0" onclick="closeimgover()" id="iim" title="Klikem zavřít obrázek"><img src="images/img_over_close.gif" alt="" width="18" height="18" border="0" class="close" id="oiclose">';
		document.getElementById('oiclose').style.left=(document.body.scrollWidth+imgw)/2-18;
		document.getElementById('oiclose').style.top=9;
	}
	
	function closeimgover()
	{
		e=document.getElementById('ol');
		eio=document.getElementById('io');
		e.className='imgover-hidden';
		eio.className='imgover-hidden';
	}
