/*   paste in your code and press Beautify button   */
var ContactLayer = Class.create();
ContactLayer.prototype = Object.extend(new Layer, {
    initialize: function (d, b, e) {
        this.layerIdstring = "main-block-iframe";
        this.node = d;
        this.navTo = false;
        this.iframehref = (location.host == 'stage.siemens.com') ? '/cc/corp/contact/en/business.htm' : this.getTriggerUrl(b.href);
        this.iframeidstring = "iframe-contact-id";
        this.iframeisloaded = false;
        this.iframeheight = 50;
        var c = document.createElement("iframe");
        c.setAttribute("id", this.iframeidstring);
        c.setAttribute("name", this.iframeidstring);
        c.setAttribute("src", "about:blank");
        c.setAttribute("height", this.iframeheight + "px");
        c.setAttribute("width", "100%");
        c.setAttribute("frameBorder", "0");
        c.setAttribute("border", "0");
        c.setAttribute("marginwidth", "0");
        c.setAttribute("marginheight", "0");
        c.setAttribute("scrolling", "no");
        c.setAttribute("bgColor", "#e7e8eb");
        c.setAttribute("unload", "hideIt();");
        this.initSuper(d, b);
        var a = Helper.getCloseButton(this.node);
        if (!a) {
            alert("Implementation Error: no close button found")
        }
        a.observe("click", function () {
            this.close()
        }.bindAsEventListener(this));
        b.href = "javascript:void(0);";
        $(this.layerIdstring).appendChild(c);
        if (this.navTo) {
            this.toggle();
        }
    },
    getUrl: function (a) {
        var c = ((typeof(url) == "undefined") || (url.length == 0)) ? window.location.href : url;
        loU = c.split("?");
        if (loU.length > 1) {
            var d = loU[1].split("&");
            for (var b = 0; b < d.length; b++) {
                var e = d[b].split("=");
                if (e[0] == a) {
                    if (e.length > 1) {
                        return e[1];
                    }
                }
            }
        } else {
            return null;
        }
    },
    setTriggerUrl: function (a) {
        this.iframehref = a;
        this.iframeisloaded = false
    },
    getTriggerUrl: function (a) {
        var b = this.getUrl("contact");
        if (b != null) {
            this.navTo = true;
            return "/contact" + b;
        } else {
            return a;
        }
    },
    beforeClose: function () {
        HeaderAnimation.unregisterLayer();
        if(Info.browser.isIEpre7) {
            $$('select').each( function(elm) { elm.show(); } );
        }
        return true;
    },
    afterClose: function (a) {
        if (!Layer.toggle) {
            HeaderAnimation.augment();
        }
    },
    beforeOpen: function () {
        HeaderAnimation.registerLayer(this);
        if (!this.iframeisloaded) {
            this.iframeisloaded = false;
            this.addPreloader();
        }
        return true
    },
    afterOpen: function () {
        if (!this.iframeisloaded) {
            this.setIFrameLocation();
        }
        HeaderAnimation.diminish();
    },
    hide: function () {
        this.node.removeClassName("active-layer");
        this.trigger.up().removeClassName("active");
    },
    show: function () {
        this.node.addClassName("active-layer");
        this.trigger.up().addClassName("active");
        this.trigger.addClassName("clicked");
        this.trigger.observe("mouseout", function (a) {
            var b = Event.findElement(a, "a");
            b.removeClassName("clicked");
            b.stopObserving("mouseout");
        })
    },
    setOffset: function (a) {
        this.node.style.top = a + "px";
    },
    setIFrameLocation: function () {
        Event.observe($(this.iframeidstring), "load", function (a) {
            this.rechunkIFrame(a);
        }.bindAsEventListener(this));
        $(this.iframeidstring).src = this.iframehref;
    },
    showIFrame: function () {
        this.removePreloader();
    },
    hideIFrame: function () {
        this.addPreloader()
    },
    addPreloader: function () {
        if (!$("lightbox-preloader")) {
            new Insertion.Before($(this.iframeidstring), "<div id='lightbox-preloader'>&nbsp;</div>")
        }
        $(this.iframeidstring).style.visibility = "hidden";
    },
    removePreloader: function () {
        if ($("lightbox-preloader")) {
            $("lightbox-preloader").remove()
        }
        $(this.iframeidstring).style.visibility = "visible";
    },
    rechunkIFrame: function (c) {
        var a = (window.event) ? event : c;
        var d = (a.currentTarget) ? a.currentTarget : a.srcElement;
        if (d) {
            if (d.contentWindow) {
                var b = d.contentWindow.document.getElementById("toolbar-layer-contact").offsetHeight;
                d.contentWindow.document.onUnload = function () {
                    alert("unloading")
                };
                d.height = b;
                this.iframeheight = b
            } else { if (d.contentDocument) {
                    var b = d.contentDocument.document.getElementById("toolbar-layer-contact").offsetHeight;
                    d.height = b;
                    this.iframeheight = b;
                } else {
                    return
                }
            }
            this.iframeisloaded = true;
        }
        if(Info.browser.isIEpre7) {
            $$('select').each( function(elm) { elm.hide(); } );
        }
    }
});

var TRIGGER_IFRAME_CONTACT_REL_REGEX = /^trigger-(contact)$/;
function init_contact_trigger_Layers() {
    if ($("content-zone")) {
        var a = $$('a[rel="trigger-contact"]');
        a.each(function (b) {
            b = $(b);
            if (b) {
                b.observe("click", function (d) {
                    var c = IFRAME_CONTACT_LAYER.contact;
                    c.setTriggerUrl(b.href);
                    c.toggle();
                    Event.stop(d)
                }.bindAsEventListener(this));
            }
        }.bind(this))
    }
}
function showContactIFrame() {
    var a = IFRAME_CONTACT_LAYER.contact;
    a.showIFrame();
}
function hideContactIFrame() {
    var a = IFRAME_CONTACT_LAYER.contact;
    a.hideIFrame();
};