﻿// script pro globalni funkce pri generovani stranky

function OnGlobalImgZoom(TarObject, IMGsrc, IMGorig) {
    document.getElementById("VarGlobalImgZoom").value = IMGorig;
    document.getElementById(TarObject).src = IMGsrc;
}

var bIE = navigator.appName == "Microsoft Internet Explorer";
var bOnGlobalImgWindowDark = true;
var bOnGlobalImgWindowShadow = true;
var bOnGlobalImgWindow = true;
var bOnGlobalImgWindowIconClose = true;


var OnGlobalImgWindowDark = window.document.createElement("DIV");
var OnGlobalImgWindowShadow = window.document.createElement("DIV");
var OnGlobalImgWindow = window.document.createElement("IMG");
var OnGlobalImgWindowIconClose = window.document.createElement("IMG");

function OnGlobalImgClick(ID, ImgFile, ImgWidth, ImgHeight, ImgColor, ImgBorder, shadowColor, shadowDistanc, IcoClose, IconSize, hideC, hideV, hideDark) {
    //var ikona = "/icons/sada001/remove.ico";
    var ZoomImg = document.getElementById("VarGlobalImgZoom").value;
    if (ZoomImg != "")
        ImgFile = ZoomImg;


    if (shadowDistanc == 0) bOnGlobalImgWindowShadow = false;
    if (hideDark == null) hideDark = false;
    bOnGlobalImgWindowDark = hideDark;

    OnGlobalImgShow(ID, ImgFile, ImgWidth, ImgHeight, ImgColor, ImgBorder, shadowColor, shadowDistanc, IcoClose, IconSize, hideC, hideV, hideDark);
}

function BrowseWidth() {
    if (window.innerWidth) return window.innerWidth;
    else if (document.documentElement && document.documentElement.clientWidth)
        return document.documentElement.clientWidth;
    else if (document.body && document.body.clientWidth)
        return document.body.clientWidth;
    else return null;
}
function BrowseHeight() {
    if (window.innerHeight) return window.innerHeight;
    else if (document.documentElement && document.documentElement.clientHeight)
        return document.documentElement.clientHeight;
    else if (document.body && document.body.clientHeight)
        return document.body.clientHeight;
    else return null;
}

function OnGlobalImgShowWindow(ImgFile, hideC, hideV, ImgWidth, ImgHeight) {
    var writesignature_checked = '&hideV=true';
    if (hideV != "true")
    { writesignature_checked = ''; }
    var writecopyright_checked = '&hideC=true';
    if (hideC != "true")
    { writecopyright_checked = ''; }
    ImgColor = "";
    var fileUrl = "/core/imgresampler.aspx?f=" + ImgFile + "&w=" + ImgWidth + "&h=" + ImgHeight + "&c=" + ImgColor + writesignature_checked + writecopyright_checked;
    window.open(fileUrl, "obrazek", "left=20,top=20,width=" + ImgWidth + ",height=" + ImgHeight + ",toolbar=0,resizable=1");
}

function OnGlobalImgBuild(TargetElementID, ID, ImgFile, ImgWidth, ImgHeight, ImgColor, ImgTitle, ImgAlt, hideC, hideV) {
    var targetelement = document.getElementById(TargetElementID);
    var writesignature_checked = '&hideV=true';
    if (hideV != "true")
    { writesignature_checked = ''; }
    var writecopyright_checked = '&hideC=true';
    if (hideC != "true")
    { writecopyright_checked = ''; }

    targetelement.id = ID;
    targetelement.src = "/core/imgresampler.aspx?f=" + ImgFile + "&w=" + ImgWidth + "&h=" + ImgHeight + "&c=" + ImgColor + writesignature_checked + writecopyright_checked;
    targetelement.style.width = ImgWidth;
    targetelement.style.height = ImgHeight;
}

function OnGlobalImgShow(ID, ImgFile, ImgWidth, ImgHeight, ImgColor, ImgBorder, shadowColor, shadowDistanc, IcoClose, IconSize, hideC, hideV, hideDark ) {
    if (shadowDistanc == 0) bOnGlobalImgWindowShadow = false;
    if (hideDark == null) hideDark = false;
    bOnGlobalImgWindowDark = hideDark;

    // velikost pracovni plochy prohlizece
    var screenHeight = BrowseHeight();
    var screenWidth = BrowseWidth();
    // velikost pracovni plochy prohlizece

    // prepocet velikosti zvetseniny v pomeru proti pracovni plose prohlizece
    if (ImgWidth > screenWidth) {
        var newWidth = (screenWidth / 100) * 80;
        var pomer = (newWidth / ImgWidth) * 100;

        ImgWidth = Math.round(newWidth);
        ImgHeight = Math.round((ImgHeight / 100) * pomer);
    }

    if (ImgHeight > screenHeight) {
        var newHeight = (screenHeight / 100) * 80;
        var pomer = (newHeight / ImgHeight) * 100;

        ImgHeight = Math.round(newHeight);
        ImgWidth = Math.round((ImgWidth / 100) * pomer);
    }
    // prepocet velikosti zvetseniny v pomeru proti pracovni plose prohlizece

    // spravny vypocet pozice stredu obrazovky i vzhledem k posubu dokumentu
    var ImgTop = (screenHeight / 2) - (ImgHeight / 2) + document.body.scrollTop;
    var ImgLeft = (screenWidth / 2) - (ImgWidth / 2) + document.body.scrollLeft;
    // spravny vypocet pozice stredu obrazovky i vzhledem k posubu dokumentu

    // stmivacka
    if (bOnGlobalImgWindowDark) {
        OnGlobalImgWindowDark.style.position = "absolute";
        OnGlobalImgWindowDark.style.top = 0;
        OnGlobalImgWindowDark.style.left = 0;
        OnGlobalImgWindowDark.style.width = document.body.scrollWidth;
        OnGlobalImgWindowDark.style.height = document.body.scrollHeight;
        OnGlobalImgWindowDark.style.backgroundColor = "Black";
        if (bIE)
            OnGlobalImgWindowDark.style.filter = "Alpha(opacity=70)";
        else
            OnGlobalImgWindowDark.style.opacity = "0.7";
        if (window.addEventListener) {
            OnGlobalImgWindowDark.addEventListener('click', OnGlobalImgWindowHide, false);
        } else { // IE
            OnGlobalImgWindowDark.attachEvent("onclick", OnGlobalImgWindowHide);
        }

        OnGlobalImgWindowDark.id = "IMGdark";
        window.document.body.appendChild(OnGlobalImgWindowDark);
    }
    // stmivacka

    // stin
    if (bOnGlobalImgWindowShadow) {
        OnGlobalImgWindowShadow.style.position = "absolute";
        OnGlobalImgWindowShadow.style.top = (ImgTop + shadowDistanc);
        OnGlobalImgWindowShadow.style.left = (ImgLeft + shadowDistanc);
        OnGlobalImgWindowShadow.style.width = ImgWidth;
        OnGlobalImgWindowShadow.style.height = ImgHeight;
        OnGlobalImgWindowShadow.style.backgroundColor = shadowColor;
        if (bIE)
            OnGlobalImgWindowShadow.style.filter = "Alpha(opacity=70)";
        else
            OnGlobalImgWindowShadow.style.opacity = "0.7";
        OnGlobalImgWindowShadow.id = "IMGshadow";
        window.document.body.appendChild(OnGlobalImgWindowShadow);
    }
    // stin


    // obrazek
    if (bOnGlobalImgWindow) {
        OnGlobalImgWindow.style.position = "absolute";
        OnGlobalImgWindow.style.top = ImgTop;
        OnGlobalImgWindow.style.left = ImgLeft;
        OnGlobalImgWindow.style.width = ImgWidth;
        OnGlobalImgWindow.style.height = ImgHeight;
        OnGlobalImgWindow.style.border = ImgBorder;
        OnGlobalImgWindow.style.cursor = "pointer";
        OnGlobalImgWindow.id = "IMGelement";
        var writesignature_checked = '&hideV=true';
        if (hideV != "true")
        { writesignature_checked = ''; }
        var writecopyright_checked = '&hideC=true';
        if (hideC != "true")
        { writecopyright_checked = ''; }
        OnGlobalImgWindow.src = "/core/imgresampler.aspx?f=" + ImgFile + "&w=" + ImgWidth + "&h=" + ImgHeight + "&c=" + ImgColor + writesignature_checked + writecopyright_checked;
        if (window.addEventListener) {
            OnGlobalImgWindow.addEventListener('click', OnGlobalImgWindowHide, false);
        } else { // IE
            OnGlobalImgWindow.attachEvent("onclick", OnGlobalImgWindowHide);
        }
        OnGlobalImgWindow.title = "Zavřít";
        window.document.body.appendChild(OnGlobalImgWindow);
    }
    // obrazek

    //ikona Zavrit
    if (IcoClose != "") {
        if (bOnGlobalImgWindowIconClose != "") {
            if (IconSize == "")
                IconSize = 32;
            OnGlobalImgWindowIconClose.style.position = "absolute";
            OnGlobalImgWindowIconClose.style.top = ImgTop - (IconSize / 2);
            OnGlobalImgWindowIconClose.style.left = ImgLeft + ImgWidth - (IconSize / 2);
            OnGlobalImgWindowIconClose.style.width = IconSize;
            OnGlobalImgWindowIconClose.style.height = IconSize;
            OnGlobalImgWindowIconClose.style.cursor = "pointer";
            OnGlobalImgWindowIconClose.id = "IMGiconclose";
            OnGlobalImgWindowIconClose.src = IcoClose;
            if (window.addEventListener) {
                OnGlobalImgWindowIconClose.addEventListener('click', OnGlobalImgWindowHide, false);
            } else { // IE
                OnGlobalImgWindowIconClose.attachEvent("onclick", OnGlobalImgWindowHide);
            }
            OnGlobalImgWindowIconClose.title = "Zavřít";
            window.document.body.appendChild(OnGlobalImgWindowIconClose);
        }
    }
    /**/
    //ikona Zavrit



    OnGlobalImgWindowShow();   
}

function OnGlobalImgWindowHide() {

    //    event.srcElement.style.display = "none";
    if (bOnGlobalImgWindow)
        document.getElementById("IMGelement").style.display = "none";

    if (bOnGlobalImgWindowShadow)
        document.getElementById("IMGshadow").style.display = "none";

    if(bOnGlobalImgWindowDark)
        document.getElementById("IMGdark").style.display = "none";

    var ikonaclose = document.getElementById("IMGiconclose");
    if (ikonaclose != null)
        ikonaclose.style.display = "none";
}
function OnGlobalImgWindowShow() {

    //    event.srcElement.style.display = "none";
    if (bOnGlobalImgWindow)
        document.getElementById("IMGelement").style.display = "";

    if (bOnGlobalImgWindowShadow)
        document.getElementById("IMGshadow").style.display = "";
    
    if (bOnGlobalImgWindowDark)
        document.getElementById("IMGdark").style.display = "";

    var ikonaclose = document.getElementById("IMGiconclose");
    if(ikonaclose != null)
        ikonaclose.style.display = "";
}


//////////   odstraneni ramecku u flash      ////////
/*
var objects = document.getElementsByTagName("embed");
function eolas(i)
{
    objects[i].outerHTML = objects[i].outerHTML;
}
for (var i=0; i<objects.length; i++)
    window.setTimeout("eolas(" + i + ")", 1);
*/   
//////////   odstraneni ramecku u flash      ////////

//////////   nacteni sponzorskeho banneru      ////////
//var MainFloatBanner = null;
//var obsah = "<img src='http://localhost/UserFiles/FelixNETcenik/balicek_jistota.jpg' border='0'>";
//ShowFloatBanner(obsah,17000,"MainFloatBanner");


//////////   nacteni sponzorskeho banneru      ////////
