﻿// script pro globalni funkce pri generovani stranky

function OnGlobalImgZoom(TarObject, IMGsrc, IMGorig) {
    document.getElementById("VarGlobalImgZoom").value = IMGorig;
    document.getElementById(TarObject).src = IMGsrc;
}


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) {
    
    var ZoomImg = document.getElementById("VarGlobalImgZoom").value;
    if (ZoomImg != "")
        ImgFile = ZoomImg;
    OnGlobalImgShow(ID, ImgFile, ImgWidth, ImgHeight, ImgColor, ImgBorder, shadowColor, shadowDistanc);
}

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 OnGlobalImgShow(ID, ImgFile, ImgWidth, ImgHeight, ImgColor, ImgBorder, shadowColor, shadowDistanc) {
    // spravny vypocet pozice stredu obrazovky i vzhledem k posubu dokumentu
    var screenHeight = BrowseHeight();
    var ImgTop = (screenHeight / 2) - (ImgHeight / 2) + document.body.scrollTop;
    var screenWidth = BrowseWidth();
    var ImgLeft = (screenWidth / 2) - (ImgWidth / 2) + document.body.scrollLeft;
    // spravny vypocet pozice stredu obrazovky i vzhledem k posubu dokumentu

    // stin
    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;
    OnGlobalImgWindowShadow.id = "IMGshadow";
    window.document.body.appendChild(OnGlobalImgWindowShadow);
    // stin


    // obrazek
    OnGlobalImgWindow.style.position = "absolute";
    OnGlobalImgWindow.style.top = ImgTop;
    OnGlobalImgWindow.style.left = ImgLeft;
    OnGlobalImgWindow.style.width = ImgWidth;
    OnGlobalImgWindow.style.height = ImgHeight;
    OnGlobalImgWindow.style.border = "1px solid gray";//  ImgBorder;
    OnGlobalImgWindow.style.cursor = "pointer";
    OnGlobalImgWindow.id = "IMGelement";
    OnGlobalImgWindow.src = "/core/imgresampler.aspx?f=" + ImgFile + "&w=" + ImgWidth + "&h=" + ImgHeight + "&c=" + ImgColor;
    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
    OnGlobalImgWindowIconClose.style.position = "absolute";
    OnGlobalImgWindowIconClose.style.top = ImgTop - 10;
    OnGlobalImgWindowIconClose.style.left = ImgLeft + ImgWidth - 10;
    OnGlobalImgWindowIconClose.style.width = 20;
    OnGlobalImgWindowIconClose.style.height = 20;
    OnGlobalImgWindowIconClose.style.cursor = "pointer";
    OnGlobalImgWindowIconClose.id = "IMGiconclose";
    OnGlobalImgWindowIconClose.src = "/icons/sada001/remove.ico";
    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";
    document.getElementById("IMGelement").style.display = "none";
    document.getElementById("IMGshadow").style.display = "none";
    document.getElementById("IMGiconclose").style.display = "none";
}
function OnGlobalImgWindowShow() {

    //    event.srcElement.style.display = "none";
    document.getElementById("IMGelement").style.display = "";
    document.getElementById("IMGshadow").style.display = "";
    document.getElementById("IMGiconclose").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      ////////