﻿POP=Class.create();
POP.prototype={
    initialize:function(){
        this.div = document.createElement("div");
        this.iframe = document.createElement("iframe");
        this.node = document.createElement("div");
        this.content = document.createElement("div");
        this.div.onclick = this.close.bind(this, this.div);
        this.init_element();
    },
    
    set_position:function(width,height){this.node.style.width=width+"px";this.node.style.height=height+"px";var de=document.documentElement;var w=self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;var h=self.innerHeight||(de&&de.clientHeight)||document.body.clientHeight;if (window.innerHeight && window.scrollMaxY){yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){yScroll=document.body.scrollHeight;}else{yScroll= document.body.offsetHeight;}var pagesize=this.getPageSize();var arrayPageScroll=this.getPageScrollTop();this.node.style.left=((w-width)/2)+"px";this.node.style.top = (arrayPageScroll[1]+((pagesize[1]-height)/2))+"px";},getPageSize:function(){var de=document.documentElement;var w=self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;var h=self.innerHeight||(de&&de.clientHeight)||document.body.clientHeight;arrayPageSize=new Array(w,h);return arrayPageSize;},getPageScrollTop:function(){var yScrolltop;if (self.pageYOffset){yScrolltop=self.pageYOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScrolltop=document.documentElement.scrollTop;}else if(document.body){yScrolltop=document.body.scrollTop;}arrayPageScroll=new Array('',yScrolltop);return arrayPageScroll;},
    
    init_element:function(){
        this.div.setAttribute(IE?"className":"class","LB_overlay");
        this.iframe.setAttribute(IE?"className":"class","LB_overlay");
        this.node.setAttribute(IE?"className":"class","Nall_screen");
        this.content.setAttribute(IE?"className":"class","Call_screen");
        this.node.appendChild(this.content);
    },
        
    add:function(width,height){
        var div = this.div, iframe=this.iframe;
        div.style.height=iframe.style.height=Math.max(document.documentElement.scrollHeight,document.documentElement.offsetHeight)+"px";
        div.style.width=iframe.style.width=this.getPageSize()[0];
        //div.className="LB_overlay";
        //iframe.className= "LB_overlay";
        document.body.appendChild(iframe);
        document.body.appendChild(div);
        document.body.appendChild(this.node);
        this.set_position(width,height);
    },
    
    close:function(){var div=this.div,iframe=this.iframe;document.getElementsByTagName("html")[0].style.overflow=IE?"":"auto";document.body.removeChild(iframe);document.body.removeChild(div);document.body.removeChild(this.node);}
};

var pop_box_con = function(title,con,w,h) {
    var box = '<table border="0" cellspacing="0" cellpadding="0"><tr><td width="6" height="6" style="height:6px; width:6px; line-height:0; font-size:0px;"><IMG SRC="/images/pop_box_01.gif" WIDTH=6 HEIGHT=6 ALT=""></td><td style="height:6px; line-height:0; font-size:0px; border-top:#F9973C solid 1px;background-color:#FFEFD6;">&nbsp;</td><td width="6" height="6" style="height:6px; width:6px; line-height:0; font-size:0px;"><IMG SRC="/images/pop_box_02.gif" WIDTH=6 HEIGHT=6 ALT=""></td></tr><tr><td background="/images/pop_box_07.gif" style="width:6px; line-height:0; font-size:0px; height:25px;"></td><td valign="top" style="margin-right:3px; background-color:#FFEFD6; height:25px;"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td style="padding-left:3px; font-weight:bold;">'+ title +'</td><td>&nbsp;</td><td width="50" align="center"><input type="button" id="close_pop" class="close_pop" value="[关闭]" /></td></tr></table></td><td background="/images/pop_box_03.gif" style="width:6px; line-height:0; font-size:0px; height:25px;"></td></tr><tr><td background="/images/pop_box_07.gif" style="width:6px; line-height:0; font-size:0px;">&nbsp;</td><td valign="top" style="margin-right:3px; width:'+ (w-12) +'px; height:'+ (h-43) +'px; background-color:#FFEFD6;">';
        box += con;
        box += '</td><td background="/images/pop_box_03.gif" style="width:6px; line-height:0; font-size:6px;">&nbsp;</td></tr><tr style="height:6px; line-height:0; font-size:6px;"><td width="6" height="6" style="height:6px; line-height:0; font-size:6px;"><IMG SRC="/images/pop_box_06.gif" WIDTH=6 HEIGHT=6 ALT=""></td><td background="/images/pop_box_05.gif">&nbsp;</td><td width="6" height="6" style="height:6px; line-height:0; font-size:6px;"><IMG SRC="/images/pop_box_04.gif" WIDTH=6 HEIGHT=6 ALT=""></td></tr></table>';
        
        return box;
}