﻿/* javascriptová korekce prohlížečů při načítání stránky - verze pro jquery */
korekceProhlizecu();
function korekceProhlizecu() {
    /* pro operu verze < 10 skryjeme vodorovny scrollbar trikem */
    if ($.browser.opera) {
        var version = $.browser.version.substr(0,2);
        if ((version == "7.") || (version == "8.") || (version == "9.")) {
            $("html").css("overflow-x", "auto");
            $("html").css("overflow-y", "auto");
            $("html").css("height", "101%");
        }
    }
};

/* Pro fce kde do url jde docID */
function showImg(url,width,height)
{
    width += 50;
    height+= 50;

    if(height + 50 > screen.height)
        height = screen.height - 200;
    if(width + 50 > screen.width)
        width = screen.width - 100;
        
    x = (screen.width  -  width) / 2;
    y = (screen.height - height) / 2;

    // zjistime bazovou adresu portalu (vetsinou adresa domeny)
    var baseElements = document.getElementsByTagName("base");
    var base;
    if (baseElements.length > 0) {
        base = baseElements[0].href;
    }
    else {
        base = "";
    }
    
    var ImgUrl=base+"imgDetail.aspx?docID="+url;

    //var a = window.open(ImgUrl,"imgDialog","toolbar=yes,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,left="+x+",top="+y+",resizable=yes,width="+(width)+",height="+(height));
    // staticke width height - uprava pro automaticky resize
    var a = window.open(ImgUrl,"imgDialog","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,left="+x+",top="+y+",resizable=yes,width=50,height=50");      
};
/* rozmery width,height jiz neni nutne predavat */
/*function showImg(url)
{
    width  = 50;
    height = 50;
    
    if(height + 50 > screen.height)
        height = screen.height - 200;

    if(width + 50 > screen.width)
        width = screen.width - 100;
        
    x = (screen.width  -  width) / 2;
    y = (screen.height - height) / 2;
    
    var ImgUrl="./imgDetail.aspx?docID="+url;

    var a = window.open(ImgUrl,"imgDialog","toolbar=yes,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,left="+x+",top="+y+",resizable=yes,width=50,height=50");
}
*/


/* pro fce kde url je definovano externe */
function showImg2(url,width,height)
{
    width  += 50;
    height += 50;
    
    if(height + 50 > screen.height)
        height = screen.height - 200;

    if(width + 50 > screen.width)
        width = screen.width - 100;
        
    x = (screen.width  -  width) / 2;
    y = (screen.height - height) / 2;

    //var a = window.open(ImgUrl,"imgDialog","toolbar=yes,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,left="+x+",top="+y+",resizable=yes,width="+(width)+",height="+(height));
    // staticke width height - uprava pro automaticky resize
    window.open(url,"imgDialog","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,left="+x+",top="+y+",resizable=yes,width=20,height=20");
};

/* Provadi automaticky window resize dle rozmeru img v imgDetail po nacteni stranky */

/*function remanipulator(width, height)
{
   if (height + 50 > screen.height)
        height= screen.height - 200;
   if (width + 50 > screen.width)
         width = screen.width - 100;

        posX = (screen.width  -  width) / 2;
        posY = (screen.height - height) / 2;

          window.resizeTo(width,height+70);
          window.moveTo(posX,posY);
          window.resizeTo(width,height+70);
}*/

/* ************************************** */



/*----- ZJISTENI DRUHU PROHLIZECE -----*/
function browser() {
  var userAgent = navigator.userAgent.toLowerCase();
  if(userAgent.indexOf("msie") != -1){
    return "ie";
  }
  else if(userAgent.indexOf("firefox") != -1){
    return "firefox";
  }
  else if(userAgent.indexOf("opera") != -1){
    return "opera";
  }
  else return "other";
};

/*----- DODATECNA ZMENA OKNA OBRAZKU (imgDetail.xsl) -----*/
function remanipulator(width, height)
{
    if(height + 50 > screen.height)
        height= screen.height - 200;
    if(width + 50 > screen.width)
        width = screen.width - 100;

    posX = (screen.width  -  width) / 2;
    posY = (screen.height - height) / 2;

    // pozor: Nejdriv premistit a potom teprve zvetsovat (aby bylo na obrazovce dost mista)
    window.moveTo(posX,posY);

    /* zmena velikosti okna podle prohlizecu */
    if(browser()=="ie"){
        window.resizeTo(width-42,height-35);
    }
    else if(browser()=="firefox"){
        window.resizeTo(width-40,height+0);
    }
    else if(browser()=="opera"){
        window.resizeTo(width-40,height+0);
    }
    else {
        window.resizeTo(width,height);
    }
};
