document.write('<style type="text/css">.hide-from-js{display:none;}</style>')


function confirmation(text){
  return confirm('Opravdu chcete \n\n'+text+' ???');
}


function popup(href, w, h, name) {
    if (isNaN(w) || w+0==0) w=640;
    if (isNaN(h) || h+0==0) h=480;
    return window.open(href,
                name,
                'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+w+',height='+h+'');
}


function windowOpen (href, w, h, name)
{
    if (isNaN(w) || w+0==0) w=640;
    if (isNaN(h) || h+0==0) h=480;
    return window.open(href,
                name,
                'toolbar=yes,location=no,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+w+',height='+h+'');
}


function resizePopupWindowAfterOnLoad(fotoElementId) {
    window.resizeTo(getE(fotoElementId).width + 40, getE(fotoElementId).height + 70);
    window.self.focus();
}




function popupProductFoto(src)
{
  return popup(src, 0, 0, '');
}

function getE(objectID) {
    return document.getElementById(objectID);
}


function setCookie(name, value, expire) {
  // Sets cookie values. Expiration date is optional
  document.cookie = name + "=" + escape(value)
  + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}


function getCookie(Name) {
  var search = Name + "="
  if (document.cookie.length > 0) { // if there are any cookies
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset)
      // set index of end of cookie value
      if (end == -1)
        end = document.cookie.length
      return unescape(document.cookie.substring(offset, end))
    }
  }
}



var toogleHiddenElmStatus = new Array();
function toggleHidden (idName)
{
  element = document.getElementById(idName);
  if (!element) return false;
  

  if (toogleHiddenElmStatus[idName]==null) 
  {
    toogleHiddenElmStatus[idName] = 'show';
    element.style.display='block';
  }
  else
  {
    if (toogleHiddenElmStatus[idName] == 'hidden')
    {
      toogleHiddenElmStatus[idName] = 'show';
      if (element.tagName != "tr") element.style.display = 'block';
      else element.style.display = 'block';
    }
    else
    {
      toogleHiddenElmStatus[idName] = 'hidden';
      element.style.display = 'none';
    }
    
  }
  
  return false;

}


function validCellphone(phone)
{
  phone = phone.replace(/ /,'');
  
  if (phone.substring(0,4) == "+420") phone = phone.substring(4,phone.length);
  
  if (isNaN(phone)) return false;
  
  if (phone.substring(0, 1)!='6'&&phone.substring(0, 1)!='7') return false;
  
  if (phone.length != 9) return false;
  
  return true;
}



function validPhone(phone)
{
  phone = phone.replace(/ /,'');
  
  if (phone.substring(0,4) == "+420") phone = phone.substring(4,phone.length);
  
  if (isNaN(phone)) return false;
  
  if (phone.substring(0, 1)=='6' || phone.substring(0, 1)=='0' || phone.substring(0, 1)=='7') return false;
  
  if (phone.length != 9) return false;
  
  return true;
}


function validEmail(mail)
{
  filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(mail)) return true;
	else return false;
}


function changeContentAndScrollTop (response)
{
  changeContent(response);
  
  window.scrollTo(0,0);
}
 

function changeContent (response)
{
  
  
  rewriteId = response.vars.rewrite_id[0]; // ktera cast HTML se ma prepsat timto novym obsahem
  
  elmForRewrite = document.getElementById(rewriteId); // zjistm objekt pro prepsani
  
  elmForRewrite.innerHTML = response.response; // prepisu objekt
  
  if (typeof aTinyMCEElements !=='undefined')
  {
    for (i=0; i<aTinyMCEElements.length; i++)
    {
      tinyMCE.execCommand('mceAddEditor', true, aTinyMCEElements[i]);
    }
  }
}


document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) retnode.push(elem[i]);
}
return retnode;
};


window.onload = function()
{
  if(document.all && navigator.appVersion.indexOf("MSIE")>-1 && navigator.appVersion.indexOf("Windows")>-1)
  {
    var a = document.getElementsByTagName("label");
    for(var i=0,j=a.length;i<j;i++){
      if(a[i].hasChildNodes && a[i].childNodes.item(0).tagName == "IMG")
      {
        a[i].childNodes.item(0).forid = a[i].htmlFor;
        a[i].childNodes.item(0).onclick = function(){
          var e = document.getElementById(this.forid);
          switch(e.type){
            case "radio": e.checked|=1;break;
            case "checkbox": e.checked=!e.checked;break;
            case "text": case "password": case "textarea": e.focus(); break;
          }
        }
      }
    }
  }
  }

