﻿/*
**********************************************************************************
Copyright (c)Net Projekt 2010 - Razvoj informacijskih sustava i tehnologije
Trinajstici 97, HR - 51215 Kastav
+385 98 1638 500
**********************************************************************************
*/

function loadPopup(strURL) {

    var $scrollingDiv = window.top.$("#ViNGAdmin");

    var strHTML = "<table width='100%' id='ViNGAdmin_header'><tr><td class='v3head'>";
    strHTML += "<span class='v3headVing'>ViNG<span class='v3'>3</span>Admin</span>";
    strHTML += "</td><td align='right'>";
    strHTML += "<a href='javascript:top.disablePopup();'>";
    strHTML += "<img src='../Admin/img/close.gif' style='border: 0px none;' /></a></td></tr></table>";

    //        $("#ViNGAdminBG").css({
    //            "opacity": "0.5"
    //        });
    //        $("#ViNGAdminBG").fadeIn("slow");

    var windowHeight = window.top.document.documentElement.clientHeight;

    $scrollingDiv.fadeIn("fast");

    $scrollingDiv.css({ "height": windowHeight - 40 + "px" });
    $scrollingDiv.html(strHTML + "<iframe frameborder='no' style='border: 0px none;' src='" + strURL + "' height='" +
        (windowHeight - 100 + "px") +
        "' width='850'></iframe>");

    centerPopup();

    var popupHeight = $scrollingDiv.height();

    $(window.top).scroll(function () {
        $scrollingDiv
				.stop()
				.animate({ "top": windowHeight / 2 - popupHeight / 2 + $(window).scrollTop() + "px" }, "slow");
    });

    //$("#ViNGAdmin").corner();

}


function disablePopup() {
    window.top.$("#ViNGAdminBG").fadeOut("fast");
    window.top.$("#ViNGAdmin").fadeOut("fast");
}

function centerPopup() {
    var windowWidth = window.top.document.documentElement.clientWidth;
    var windowHeight = window.top.document.documentElement.clientHeight;
    var popupHeight = window.top.$("#ViNGAdmin").height();
    var popupWidth = window.top.$("#ViNGAdmin").width();
    window.top.$("#ViNGAdmin").css({
        "position": "absolute",
        "top": windowHeight / 2 - popupHeight / 2 + $(window).scrollTop(),
        "left": windowWidth / 2 - popupWidth / 2
    });
    //only need force for IE6

    window.top.$("#ViNGAdminBG").css({
        "top": $(window).scrollTop(),
        "height": windowHeight
    });

}

function refreshPage() {
    if (top.document.getElementById("if_adminFrame")) {
        top.$('#if_adminFrame').get(0).contentWindow.location.reload(true);
    }
    else {
        parent.location.reload(true);
    }
}

/*******************************************/

$(document).ready(function () {
});

/*******************************************/

$("#ViNGAdminClose").click(function () {
    disablePopup();
});

$("#ViNGAdminBG").click(function () {
    disablePopup();
});

$(document).keypress(function (e) {
    if (e.keyCode == 27) {
        disablePopup();
    }
});

$("#ViNGAdmin").keypress(function (e) {
    if (e.keyCode == 27) {
        disablePopup();
    }
});

/******** IFRAME Pipeline ***********/

function setDimensions(h) {
    h = parseInt(h);
    var iframe = document.getElementById('if_mainframe');

    var nAdd = 30;
    var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
    if (is_chrome)
        nAdd = 130;
    iframe.style.height = h + nAdd + "px";
}

/******** IFRAME Pipeline ***********/
