function gEBI(id) {
    if (Boolean(document.getElementById)) {
        return document.getElementById(id);
    } else if (Boolean(document.all)) {
        return eval('document.all.' + id);
    }
}

function changeSize(image, size) {
  var cWidth = image.clientWidth;
  var cHeight = image.clientHeight;
  var pomer = 0;
    if (cHeight > size) {
        var puvodniHeight = cHeight;
        cHeight = size;
        image.height = cHeight;
        pomer = puvodniHeight / cHeight;
        cWidth = cWidth / pomer;
    }
    else if (cWidth > size) {
      var puvodniWidth = cWidth;
      cWidth = size;
      image.width = cWidth;
      pomer = puvodniWidth / cWidth;
      cHeight = cHeight / pomer;
    }
}

function previewImage(image) {
    var konstH = 270;
    var konstW = 75;
    top.moveTo(5, 5);

    var cWidth = image.clientWidth;
    var cHeight = image.clientHeight;
    var cVersionsHeight = gEBI('versions').clientHeight + 20;

    var liveScreenHeight = screen.availHeight;
    var liveScreenWidth = screen.availWidth;

    var resH = liveScreenHeight;
    var resW = liveScreenWidth;

    if ((cHeight + konstH + cVersionsHeight) < liveScreenHeight) {
        resH = cHeight + konstH + cVersionsHeight
    }

    var pomer = 0;
    if ((cHeight + konstH + cVersionsHeight) > liveScreenHeight) {
        var puvodniHeight = cHeight;
        cHeight = resH - (konstH + cVersionsHeight);
        image.height = cHeight;
        pomer = puvodniHeight / cHeight;
        cWidth = cWidth / pomer;
    }
    if (cWidth > liveScreenWidth) {
      var puvodniWidth = cWidth;
      cWidth = resW - konstW;
      image.width = cWidth;
      pomer = puvodniWidth / cWidth;
      cHeight = cHeight / pomer;
    }

    if ((cWidth ) < liveScreenWidth) {
        resW = cWidth + konstW
    }

    if (null != parent && null != parent.frames['slide'] && null != parent.frames['slide'].document.getElementById('imgPanel')) {
        parent.frames['slide'].document.getElementById('imgPanel').style.width = cWidth;
    }
    var style2 = document.getElementById('loadpreview').style;
    style2.display = style2.display ? "" : "none";

    // omezime minimalni vysku a sirku obsahu okna
    var minHeight = 350;
    var decorHeight = window.outerHeight - window.innerHeight;
    if (resH<minHeight+decorHeight) { resH = minHeight+decorHeight; }
    var minWidth = 600;
    var decorWidth = window.outerWidth - window.innerWidth;
    if (resW<minWidth+decorWidth) { resW = minWidth+decorWidth; }

    top.resizeTo(resW, resH);
}

function imagePopup(mylink) {
    var href = (typeof(mylink) == 'string') ? mylink : mylink.href;
    w = window.innerWidth;
    h = window.innerHeight;

    //var popW = 650, popH = 650;
    //var leftPos = (w - popW) / 2, topPos = (h - popH) / 2;
    //window.open(href,'hirespic', 'width=' + popW + ',height='+popH+',top='+topPos+',left='+leftPos+ ',resizable=yes scrollbars=yes');
    window.open(href, "hirespic", "resizable=yes , scrollbars=yes");
}


/*
CSS Browser Selector v0.3.5 (Feb 05, 2010)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u){
  var ua = u.toLowerCase(),is=function(t){
    return ua.indexOf(t)>-1;
  },g='gecko',w='webkit',s='safari',o='opera',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js'];
  c = b.join(' ');
  h.className += ' '+c;
  return c;
};
css_browser_selector(navigator.userAgent);


//verze produtku
function inc(item) {
  obj = document.getElementById(item);
  var new_val = Number(obj.getAttribute('value'))+1;
  obj.setAttribute('value', new_val);
}

function dec(item) {
  obj=document.getElementById(item);
  if(obj.getAttribute('value') > 0) {
    var new_val = Number(obj.getAttribute('value'))-1;
    obj.setAttribute('value', new_val);
  }
}

function checkVersion(product, count, piece, wanted) {
  for(i=0;i<count;i++) {
    element = document.getElementById('p_'+product+'_pv_'+i+'_k_'+piece);
    if (element.checked) {
      element.checked=0;
    }
  }
  obj=document.getElementById(wanted);
  obj.checked=1;
}

//pridat mezi oblibene
function AddFavorite(linkObj, addUrl, addTitle,lang) {
  if(document.all && !window.opera) {
    window.external.AddFavorite(addUrl, addTitle);
    return false;
  }
  else if(window.opera && window.print) {
    linkObj.title=addTitle;
    return true;
  }
  else if((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function')) {
    if (lang=='cs') {
      if(window.confirm('P\u0159idat oblíbenou stránku jako nový panel?')) {
        window.sidebar.addPanel(addTitle, addUrl, '');
        return false;
      }
    } else if (lang=='en') {
      if(window.confirm('Add to the browser\'s favorites?')) {
        window.sidebar.addPanel(addTitle, addUrl, '');
        return false;
      }
    }
    else if (lang=='sk') {
      if(window.confirm('Prida\u0165 do ob\u013eúbených položiek prehliadača?')) {
        window.sidebar.addPanel(addTitle, addUrl, '');
        return false;
      }
    }
    else if (lang=='de') {
      if(window.confirm('Zu Favoriten hinzufügen des Browsers?')) {
        window.sidebar.addPanel(addTitle, addUrl, '');
        return false;
      }
    }
  }
  if (lang=='cs') {
    window.alert('Po potvrzení stiskn\u011bte CTRL-D,\nstránka bude přidána k vašim oblíbeným odkazům.');
  } else if (lang=='en') {
    window.alert('For confirmation press CTRL+D,\n the page will be added to your favorites.');
  }
  else if (lang=='sk') {
    window.alert('Pre potvrdenie stla\u010dte kombináciu klávesov CTRL + D, stránka bude pridaná do ob\u013eúbených');
  }
  else if (lang=='de') {
    window.alert('Zur Bestätigung drücken Sie STRG + D, wird die Seite zu Ihren Favoriten hinzugefügt werden');
  }
  return false;
}


//prihlaseni zakaznika
function loginCustomer() {
  document.getElementById("login_form").submit();
}


//prihlaseni pri zmacknuti Enteru
function submitViaEnter(evt) {
  evt = (evt) ? evt : event;
  var target = (evt.target) ? evt.target : evt.srcElement;
  var form = target.form;
  var charCode = (evt.charCode) ? evt.charCode :
  ((evt.which) ? evt.which : evt.keyCode);
  if (charCode == 13) {
    form.submit();
    return false;
  }
  return true;
}


//klikatelne logo
function goToIndex() {
  window.location.href = "http://" + location.hostname + "/index.jsp";
}


//By Dynamic Drive: http://www.dynamicdrive.com/style/
var menuids=["suckertree1"]; //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus() {
  for (var i=0; i<menuids.length; i++) {
    var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul");
    for (var t=0; t<ultags.length; t++) {
      ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle";
      ultags[t].parentNode.onmouseover=function() {
        this.getElementsByTagName("ul")[0].style.display="block";
      };
      ultags[t].parentNode.onmouseout=function() {
        this.getElementsByTagName("ul")[0].style.display="none";
      };
    }
  }
}

if (window.addEventListener)
  window.addEventListener("load", buildsubmenus, false);
else if (window.attachEvent)
  window.attachEvent("onload", buildsubmenus);


//ikony ostatnich shopu
function onImageA() {
  document.getElementById("ico_sportobchod").src = "/images/sportobchoda.jpg";
}
function offImageA() {
  document.getElementById("ico_sportobchod").src = "/images/sportobchodn.jpg";
}
function onImageB() {
  document.getElementById("ico_unihocshop").src = "/images/unihocshopa.jpg";
}
function offImageB() {
  document.getElementById("ico_unihocshop").src = "/images/unihocshopn.jpg";
}
function onImageC() {
  document.getElementById("ico_eflorbal").src = "/images/eflorbala.jpg";
}
function offImageC() {
  document.getElementById("ico_eflorbal").src = "/images/eflorbaln.jpg";
}
function onImageD() {
  document.getElementById("ico_kopacky").src = "/images/kopackya.jpg";
}
function offImageD() {
  document.getElementById("ico_kopacky").src = "/images/kopackyn.jpg";
}
function onImageE() {
  document.getElementById("ico_brusle").src = "/images/bruslea.jpg";
}
function offImageE() {
  document.getElementById("ico_brusle").src = "/images/bruslen.jpg";
}
function onImageFF() {
  document.getElementById("ico_salova").src = "/images/sala.jpg";
}
function offImageFF() {
  document.getElementById("ico_salova").src = "/images/saln.jpg";
}


//vlajky
function onImageF(RootPath) {
  var imagePath = "styly/images_design/cza.jpg";
  document.getElementById("ico_czk").src = RootPath.concat(imagePath);
}
function offImageF(RootPath) {
  var imagePath = "styly/images_design/czn.jpg";
  document.getElementById("ico_czk").src = RootPath.concat(imagePath);
}
function onImageG(RootPath) {
  var imagePath = "styly/images_design/sva.jpg";
  document.getElementById("ico_svk").src = RootPath.concat(imagePath);
}
function offImageG(RootPath) {
  var imagePath = "styly/images_design/svn.jpg";
  document.getElementById("ico_svk").src = RootPath.concat(imagePath);
}
function onImageH(RootPath) {
  var imagePath = "styly/images_design/ena.jpg";
  document.getElementById("ico_eng").src = RootPath.concat(imagePath);
}
function offImageH(RootPath) {
  var imagePath = "styly/images_design/enn.jpg";
  document.getElementById("ico_eng").src = RootPath.concat(imagePath);
}
function onImageI(RootPath) {
  var imagePath = "styly/images_design/dea.jpg";
  document.getElementById("ico_den").src = RootPath.concat(imagePath);
}
function offImageI(RootPath) {
  var imagePath = "styly/images_design/den.jpg";
  document.getElementById("ico_den").src = RootPath.concat(imagePath);
}
function onImageJ(RootPath) {
  var imagePath = "styly/images_design/eua.jpg";
  document.getElementById("ico_eu").src = RootPath.concat(imagePath);
}
function offImageJ(RootPath) {
  var imagePath = "styly/images_design/eun.jpg";
  document.getElementById("ico_eu").src = RootPath.concat(imagePath);
}
//meny
function onImageK(RootPath) {
  var imagePath = "styly/images_design/kca.jpg";
  document.getElementById("ico_kc").src = RootPath.concat(imagePath);
}
function offImageK(RootPath) {
  var imagePath = "styly/images_design/kcn.jpg";
  document.getElementById("ico_kc").src = RootPath.concat(imagePath);
}
function onImageL(RootPath) {
  var imagePath = "styly/images_design/euroa.jpg";
  document.getElementById("ico_euro").src = RootPath.concat(imagePath);
}
function offImageL(RootPath) {
  var imagePath = "styly/images_design/euron.jpg";
  document.getElementById("ico_euro").src = RootPath.concat(imagePath);
}
