var popIframeLayer = $Class({
    $init:function()
    {
        
    },
    _createIframe : function()
    {
        this.container = $("<div>");
        this.elIframe = $("<iframe>");
        this.elIframe.setAttribute("scrolling", "no");
        this.elIframe.setAttribute("frameborder", "0", "0");
        this.elIframe.setAttribute("width", "100px");
        this.container.appendChild(this.elIframe);
        
        this.container.style.position = "absolute";
        this.container.style.left = "-9999px";
        this.container.style.display = "none";
        document.body.appendChild(this.container);
    },
    _removeIframe : function()
    {
        document.body.removeChild(this.container);
    },
    show : function(url)
    {
        this._createIframe();
        var iframe = this.elIframe;
        this.container.style.display = "block";
        
        if(iframe.attachEvent)
		    iframe.attachEvent('onload', $Fn(this.resizeIframe, this).bind());
		else
		    if(iframe.addEventListener)
                iframe.addEventListener('load', $Fn(this.resizeIframe, this).bind(), false);
        //var subUrl = url.substring(url.indexOf('?go='));
        //subUrl = subUrl.substring(4);
        //subUrl += document.location.href + "popupLogin";
        //url = url.substring(0, url.indexOf('?go='));
        //url += "?go=" + encodeURIComponent(subUrl);
        //alert(url);
        iframe.setAttribute("src", url);
    },
    hide : function()
    {
        SPS.layer.hide(true);
        this._removeIframe();
    },
    resizeIframe: function()
	{
	    var iframe = this.elIframe;
	    iframe.setAttribute("height", "100px");
	    var bHeight = iframe.contentWindow.document.body.scrollHeight;
	    var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
	    var bWidth = iframe.contentWindow.document.body.scrollWidth;
        var dWidth = iframe.contentWindow.document.documentElement.scrollWidth;
        
	    var height = Math.max(bHeight, dHeight);
	    var width = Math.max(bWidth, dWidth);

        iframe.setAttribute("height", height);
        iframe.setAttribute("width", width);
        
        this.container.style.width = width + "px";
        this.container.style.height = height + "px";

//        this.container.style.position = "";
//        this.container.style.left = "";
        SPS.layer.show(this.container, true);
        
    }
});
window.popLayer = new popIframeLayer();