﻿var myWidth = "";
var myHeight = "";
var pageScrollPositionX = 0;
var pageScrollPositionY = 0;
var ScrollingInterval = null;
var MrTransparentBackground_Object = new Object();
MrTransparentBackground_Object.displayCornerImages = true;
MrTransparentBackground_Object.showCloseButton = false;
function setWindowSize() {

    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }

}


function getScrollXY_Background() {
    var scrOfX = 0, scrOfY = 0;
    if (typeof (window.pageYOffset) == 'number') {
        //Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }
    pageScrollPositionX = scrOfX;
    pageScrollPositionY = scrOfY;

    var newdivElement = document.getElementById("divMrTransparentBackground");
    if (newdivElement) {
        newdivElement.style.top = pageScrollPositionY;
        newdivElement.style.left = pageScrollPositionX;
    }

}

window.onresize = function () {
    if (document.getElementById("divMrTransparentBackground")) {
        var divMrTransparentBackground = document.getElementById("divMrTransparentBackground");
        setWindowSize();
        divMrTransparentBackground.style.width = myWidth + "px";
        divMrTransparentBackground.style.height = myHeight + "px";
    }

}




function DisplayMrTransparentBackground(zIndexParam) {
    if (document.getElementById("divMrTransparentBackground")) {
        document.getElementById("divMrTransparentBackground").style.display = "";
    }
    else {
        setWindowSize();
        var newdiv = document.createElement("div");
        newdiv.id = "divMrTransparentBackground";
        newdiv.style.width = myWidth + "px";
        newdiv.style.height = myHeight + "px";
        newdiv.style.top = "0px";
        newdiv.style.left = "0px";
        newdiv.style.paddingLeft = "0px";
        newdiv.style.paddingTop = "0px";
        newdiv.style.zIndex = zIndexParam;
        newdiv.style.backgroundColor = "#000000";
        newdiv.style.opacity = "0.63";
        newdiv.style.filter = "alpha(opacity=63)";
        if (navigator.userAgent.toString().toLowerCase().search("msie 7") != -1 ||
            navigator.userAgent.toString().toLowerCase().search("msie 8") != -1) {
            newdiv.style.position = "absolute";
            //newdiv.style.position = "fixed";
        }
        else {
            newdiv.style.position = "fixed";
        }
        newdiv.style.top = "0px";
        newdiv.style.left = "0px";
        newdiv.style.zIndex = zIndexParam;
        document.body.appendChild(newdiv);
    }
    ScrollingInterval = setInterval("getScrollXY_Background()", 100);
    document.getElementById("divMrTransparentBackground").style.display = "";
}

function GetCloseButtonHTML(panelId) {
    var closeButtonHtmlParam = "<div panelid=" + "'" + panelId + "'" + " " + "style='text-align: right; padding: 5px; background-color: white'" + "><img panelid=" + "'" + panelId + "'" + "src=" + "'" + "/js/facebox/closelabel.gif" + "'" + " " + "onclick='closeMrTransparentContent(this)'" + " " + "style='cursor: pointer'" + " /></div>";
    return closeButtonHtmlParam;
}

function closeMrTransparentContent(elementParam) {
    var panelid = elementParam.getAttribute("panelid");
    HideMrTransparentContent(panelid);
}

//function showMainMovie2() {

//    var winWp = 630

//    if (parseInt(navigator.appVersion) > 3) {
//        if (navigator.appName == "Netscape") {
//            winWp = window.innerWidth;

//        }
//        if (navigator.appName.indexOf("Microsoft") != -1) {
//            winWp = document.documentElement.clientWidth;

//        }
//    }

//    // <check note nxcvasdsdj232> if the bottom image visible then height should be  460px, otherwise without bottom image 375px
//    var windowtoopen = "/members/panels/display_my_account2.aspx";
//    var contentHTML = "<div style='text-align:right; padding: 5px 5px 0px; background-color:white'><img style='cursor: pointer;' onclick='display_my_account2_close();' src='/js/facebox/closelabel.gif' title='close' id='mr_6f131841_63fe_4747_8e5f_0c410554c162'></div>";
//    contentHTML += '<iframe id="ManageGifts_GroupList_panel" src="' + windowtoopen + '" frameborder="0"  scrolling="vertical" style="height:375px; width:518px; background-color: white;"></iframe>';
//    var zIndexParam = 500;
//    var elementWidth = "520";
//    var topParam = "110";
//    var panelId = "display_my_account2_panel";
//    DisplayMrTransparentContent(contentHTML, zIndexParam, elementWidth, topParam, panelId);



//    var leftPosition = ((window.screen.width) - parseInt(elementWidth)) / 2;

//    window.parent.document.getElementById('display_my_account2_panel').style.left = leftPosition + "px";
//}

//function display_my_account2_close() {
//    HideMrTransparentContent("display_my_account2_panel");
//}

function DisplayMrTransparentContent(contentHTML, zIndexParam, elementWidth, topParam, panelId) {
    // show transparent background here
    DisplayMrTransparentBackground(zIndexParam - 10);
    var mrcontentholder = document.getElementById(panelId);
    if (mrcontentholder) {
        mrcontentholder.style.display = "";
    }
    else {
        mrcontentholder = document.createElement("div");
        mrcontentholder.id = panelId;
        if (navigator.userAgent.toString().toLowerCase().search("msie 7") != -1 ||
            navigator.userAgent.toString().toLowerCase().search("msie 8") != -1) {
            mrcontentholder.style.position = "absolute";
        }
        else {
            mrcontentholder.style.position = "fixed";
        }
        mrcontentholder.style.zIndex = zIndexParam;

        document.body.appendChild(mrcontentholder);
    }
    // if close button property is True then show it
    if (MrTransparentBackground_Object.showCloseButton) {
        mrcontentholder.innerHTML = GetCloseButtonHTML(panelId);
    }
    else {
        mrcontentholder.innerHTML = "";
    }
    mrcontentholder.innerHTML += contentHTML;
    // set panel position here
    if (mrcontentholder.style.position == "absolute") {
        mrcontentholder.style.top = parseInt(MrRegistryObject.GetPageYOffset()) + parseInt(topParam) + "px";
    }
    // fixed
    else {
        mrcontentholder.style.top = topParam + "px";
    }

    mrcontentholder.style.left = (myWidth - elementWidth) / 2 + "px";

    // append rounded corner here
    AppendRoundedCornerWithId(document.getElementById(panelId), panelId);

    // check custom attributes
    if (MrTransparentBackground_Object.displayCornerImages == false) {
        var displayTransparent = document.getElementById(panelId);
        // td corners
        document.getElementById("mr_de31ef95_1c31_42b5_8b97_1dcc4275f2e5").style.backgroundColor = "";
        document.getElementById("mr_05171666_cf88_441f_bdc6_f3203754e9d3").style.backgroundColor = "";
        document.getElementById("mr_de90a3f9_61ae_4dcc_94af_552a70ab1025").style.backgroundColor = "";
        document.getElementById("mr_82b9465d_9673_49ff_91a2_640cfbcde433").style.backgroundColor = "";
        var allCornerImages = displayTransparent.getElementsByTagName("img");
        for (var i = 0; i < allCornerImages.length; i++) {

            if (allCornerImages[i].src.toLowerCase().indexOf("corner") > 0) {
                allCornerImages[i].style.visibility = "hidden";
            }
        }
    }
}


function HideMrTransparentContent(panelId) {
    HideMrTransparentBackground();
    document.getElementById(panelId).style.display = "none";
}

function HideMrTransparentBackground() {
    clearInterval(ScrollingInterval);
    document.getElementById("divMrTransparentBackground").style.display = "none";
}


function AppendRoundedCorner(OuterElement) {
    var roundedCornerHtml = "<table id='tableRoundedCorner' style='width:1%' cellpadding='0' cellspacing='0'><tr id='mr_3a658f53_39a0_4cb3_8a4a_7e60035fb6d2'><td style='width:1%' id='mr_34ee5368_ec1d_43e6_85a2_9a8c1f5a42b9'><img alt='' src='http://images.myregistry.com/Images/MyRegistry/transparentpanel/Corner.gif' style='height:10px' id='mr_e1c79d37_a6e8_4391_8b42_2ce527a523d3'></td><td style='width:98%; background-color:#A6A6A6' id='mr_de31ef95_1c31_42b5_8b97_1dcc4275f2e5'></td><td style='width:1%' id='mr_c9a874dd_26e3_4ce8_ae5f_79a5942ee432'><img alt='' src='http://images.myregistry.com/Images/MyRegistry/transparentpanel/corner2.gif' style='height:10px' id='mr_36563a1b_83bc_4ba7_9f47_be193611fdc7'></td></tr><tr id='mr_5295d699_4079_45be_b5e1_b60fbd8bedc4'><td style='background-color:#A6A6A6' id='mr_82b9465d_9673_49ff_91a2_640cfbcde433'></td><td id='tdContent'>" + OuterElement.innerHTML + "</td><td style='background-color:#A6A6A6' id='mr_05171666_cf88_441f_bdc6_f3203754e9d3'></td></tr><tr id='mr_1b1d0f06_a251_4321_abb5_77fd59300c51'><td id='mr_dce4164d_1a76_4c31_914e_4ba7787675ff'><img alt='' src='http://images.myregistry.com/Images/MyRegistry/transparentpanel/corner4.gif' style='height:10px' id='mr_5480eaa5_3a8e_48e9_8a58_8dac25b66743'></td><td style='background-color:#A6A6A6' id='mr_de90a3f9_61ae_4dcc_94af_552a70ab1025'></td><td id='mr_7aaa5901_692d_457a_b606_fa56c7efa9cd'><img alt='' src='http://images.myregistry.com/Images/MyRegistry/transparentpanel/corner3.gif' style='height:10px' id='mr_90991292_cf88_47fc_9add_0046e40cd83b'></td></tr></table>";
    OuterElement.innerHTML = roundedCornerHtml;
}

function AppendRoundedCornerWithId(OuterElement, panelId) {
    var roundedCornerHtml = "<table id='RoundedCorner_" + panelId + "' style='width:1%' cellpadding='0' cellspacing='0'><tr id='mr_3a658f53_39a0_4cb3_8a4a_7e60035fb6d2'><td style='width:1%' id='mr_34ee5368_ec1d_43e6_85a2_9a8c1f5a42b9'><img alt='' src='http://images.myregistry.com/Images/MyRegistry/transparentpanel/Corner.gif' style='height:10px' id='mr_e1c79d37_a6e8_4391_8b42_2ce527a523d3'></td><td style='width:98%; background-color:#A6A6A6' id='mr_de31ef95_1c31_42b5_8b97_1dcc4275f2e5'></td><td style='width:1%' id='mr_c9a874dd_26e3_4ce8_ae5f_79a5942ee432'><img alt='' src='http://images.myregistry.com/Images/MyRegistry/transparentpanel/corner2.gif' style='height:10px' id='mr_36563a1b_83bc_4ba7_9f47_be193611fdc7'></td></tr><tr id='mr_5295d699_4079_45be_b5e1_b60fbd8bedc4'><td style='background-color:#A6A6A6' id='mr_82b9465d_9673_49ff_91a2_640cfbcde433'></td><td id='tdContent'>" + OuterElement.innerHTML + "</td><td style='background-color:#A6A6A6' id='mr_05171666_cf88_441f_bdc6_f3203754e9d3'></td></tr><tr id='mr_1b1d0f06_a251_4321_abb5_77fd59300c51'><td id='mr_dce4164d_1a76_4c31_914e_4ba7787675ff'><img alt='' src='http://images.myregistry.com/Images/MyRegistry/transparentpanel/corner4.gif' style='height:10px' id='mr_5480eaa5_3a8e_48e9_8a58_8dac25b66743'></td><td style='background-color:#A6A6A6' id='mr_de90a3f9_61ae_4dcc_94af_552a70ab1025'></td><td id='mr_7aaa5901_692d_457a_b606_fa56c7efa9cd'><img alt='' src='http://images.myregistry.com/Images/MyRegistry/transparentpanel/corner3.gif' style='height:10px' id='mr_90991292_cf88_47fc_9add_0046e40cd83b'></td></tr></table>";
    OuterElement.innerHTML = roundedCornerHtml;
}

function findPos(obj) {
    var objectParam = obj;
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
    }
    var elementParam = objectParam;
    elementParam.left = curleft;
    elementParam.top = curtop;
    return elementParam;
}
