﻿window.__sheild = null;
window.__dialogFrame = null;
window.__newImage = null;
window.__imageBackground = null;

var stop_scroll = false;

function scrolltop() {
    if (stop_scroll == true) {
        scroll(0, 0);
    }
}

function showForm(elementId) {

    raiseSheild();

    var element = document.getElementById(elementId);
    if (element != null) {
        element.style.display = "block";
        element.style.position = "absolute";
        element.style.top = "100px";
        element.style.left = ((document.body.clientWidth - element.scrollWidth) / 2) + "px";
        element.style.zIndex = "10000";
    }
}
function hideForm(elementId) {
    var element = document.getElementById(elementId);
    if (element != null) {
        element.style.display = "none";
    }

    lowerSheild();
}
function EnlargeImage(anImage, width, height) {
    var imageUrl = anImage.src.split("?");
    //alert(imageUrl[0]);
    raiseSheild();

    if (window.__newImage == null) {
        window.__newImage = document.createElement("img");
        window.__imageBackground = document.createElement("div");
        window.__imageBackground.className = "enlargedImage";
        window.__imageBackground.style.position = "absolute";
        //        window.__newImage.width = "500px";
        //        window.__newImage.height = "500px";
        //window.__newImage.style.top = "0px";
        window.__imageBackground.style.top = "100px";
        window.__imageBackground.style.left = ((document.body.clientWidth - width) / 2) + "px";
        window.__imageBackground.onclick = function() { CloseEnlargedImage(); return false; }
        window.__newImage.onclick = function() { CloseEnlargedImage(); return false; }
        window.__imageBackground.appendChild(window.__newImage);
        document.body.appendChild(window.__imageBackground);
    }
    window.__newImage.src = imageUrl[0] + "?width=" + width;  //+ "&height=" + height;
//    while (window.__newImage.attributes["complete"] != "complete") {
//        window.__newImage.style.display = "none"
//    }
    window.__newImage.style.display = "block";
    window.__imageBackground.style.display = "block";

    //stop_scroll = true;
}
function CloseEnlargedImage() {
    if (window.__newImage != null) {
        window.__imageBackground.style.display = "none";
    }
    lowerSheild();

    //stop_scroll = false;
}
function showDialog(dialogUrl, width, height, value, text) {
    raiseSheild();

    if (window.__dialogFrame == null) {
        window.__dialogFrame = document.createElement("iframe");
        window.__dialogFrame.className = "dialogFrame";
        window.__dialogFrame.style.position = "absolute";
        window.__dialogFrame.width = width;
        window.__dialogFrame.height = height;
        window.__dialogFrame.style.top = "100px";
        window.__dialogFrame.style.left = ((document.body.clientWidth - window.__dialogFrame.width) / 2) + "px";

        document.body.appendChild(window.__dialogFrame);
    }
    window.__dialogFrame.src = dialogUrl;
    window.__dialogFrame.style.display = "block";
}
function closeDialog() {
    if (window.__dialogFrame != null) {
        window.__dialogFrame.style.display = "none";
    }
    lowerSheild();
}
function raiseSheild() {
    if (window.__sheild == null) {
        window.__sheild = document.createElement("div");
        window.__sheild.Id = "sheild";
        window.__sheild.className = "sheild";
        window.__sheild.style.filter = "alpha(opacity=75)"
        window.__sheild.style.opacity = ".75";
        window.__sheild.style.mozOpacity = ".75";
        window.__sheild.onclick = function() { CloseEnlargedImage(); return false; }

        document.body.appendChild(window.__sheild);
    }
    window.__sheild.style.display = "block";
}
function lowerSheild() {
    if (window.__sheild != null) {
        window.__sheild.style.display = "none";
    }
}
function Navigate(url) {
    location.href = url;
}
