

function showDBox(url){ 
    if(document.getElementById('down_popup_div')){
        return ;
    }

    var div_obj = document.createElement("div");
    var background_div = document.createElement("div");
    var ifr = document.createElement("iframe");

    // 绑定esc取消对话框
    document.onkeydown = function(e){
        if (document.all) {
            key_code = event.keyCode;
        } else {
            key_code = e.keyCode;
        }
        if (key_code==27) {
            cancelPopup();
            return ;
        }		
    }
    
    // 设置对话框的风格
	//getScrollTop()
    background_div.id = 'down_popup_background'; 
	// 这里需要
	background_div.onclick=cancelPopup;
    div_obj.id = 'down_popup_div';
    ifr.id = 'ifr_showTip';
    
    // 不透明处理
    

    var argv   = arguments;
	var argc   = arguments.length;  

    //var ifr = "<iframe src=\"\" id=\"ifr_showTip\" style=\"width:400px;height:300px;border:0px;\" frameborder=no></iframe>"
    div_obj.appendChild(ifr);
    ifr.style.width="400px";
    ifr.style.height="350px";
    ifr.style.border="0px solid #000";
    ifr.frameBorder=0;
    document.body.appendChild(background_div); 
    document.body.appendChild(div_obj);
    rebuild();
    ifr.src=url;
    //$("ifr_showTip").src = url 
}


function showD1Box(url){ 
    if(document.getElementById('down_popup_div')){
        return ;
    }

    var div_obj = document.createElement("div");
    var background_div = document.createElement("div");
    var ifr = document.createElement("iframe");

    // 绑定esc取消对话框
    document.onkeydown = function(e){
        if (document.all) {
            key_code = event.keyCode;
        } else {
            key_code = e.keyCode;
        }
        if (key_code==27) {
            cancelPopup();
            return ;
        }		
    }
    
    // 设置对话框的风格
	//getScrollTop()
    background_div.id = 'down_popup_background'; 
	// 这里需要
	background_div.onclick=cancelPopup;
    div_obj.id = 'down_popup_div';
    ifr.id = 'ifr_showTip';
    
    // 不透明处理
    

    var argv   = arguments;
	var argc   = arguments.length;  

    //var ifr = "<iframe src=\"\" id=\"ifr_showTip\" style=\"width:400px;height:300px;border:0px;\" frameborder=no></iframe>"
    div_obj.appendChild(ifr);
    ifr.style.width="400px";
    ifr.style.height="230px";
    ifr.style.border="0px solid #000";
    ifr.frameBorder=0;
    document.body.appendChild(background_div); 
    document.body.appendChild(div_obj);
    rebuild();
    ifr.src=url;
    //$("ifr_showTip").src = url 
}

function showBox(url,width,height){ 
    if(document.getElementById('down_popup_div')){
        return ;
    }

    var div_obj = document.createElement("div");
    var background_div = document.createElement("div");
    var ifr = document.createElement("iframe");

    // 绑定esc取消对话框
    document.onkeydown = function(e){
        if (document.all) {
            key_code = event.keyCode;
        } else {
            key_code = e.keyCode;
        }
        if (key_code==27) {
            cancelPopup();
            return ;
        }		
    }
    
    // 设置对话框的风格
	//getScrollTop()
    background_div.id = 'down_popup_background'; 
	// 这里需要
	background_div.onclick=cancelPopup;
    div_obj.id = 'down_popup_div';
    ifr.id = 'ifr_showTip';
    
    // 不透明处理
    

    var argv   = arguments;
	var argc   = arguments.length;  

    //var ifr = "<iframe src=\"\" id=\"ifr_showTip\" style=\"width:400px;height:300px;border:0px;\" frameborder=no></iframe>"
    div_obj.appendChild(ifr);
    ifr.style.width=width + "px";
    ifr.style.height=height + "px";
    ifr.style.border="0px solid #000";
    ifr.frameBorder=0;
    document.body.appendChild(background_div); 
    document.body.appendChild(div_obj);
    rebuild();
    div_obj.style.top ='100px'; 
    ifr.src=url;
    //$("ifr_showTip").src = url 
}


function getWindowLength(type,debug) {
    type=(typeof type=='undefined')?'error':type;
    type=type.toLowerCase();
    var w='width';
    var h='height';
    if (w.indexOf(type)===0) {
        type='Width';
    } else if (h.indexOf(type)===0) {
        type='Height';
    } else {
        alert('wrong parameter'+type);
    }
    var attrs=['offset'+type,'scroll'+type,'client'+type,'inner'+type];
    var db=document.body;
    var de=document.documentElement;
    var r=0;
    var tmp_r=0;
    var a='';
    for (var i=0;i<attrs.length;i++) {
        a=attrs[i];
        tmp_r=db[a]>de[a]?db[a]:de[a];
        if (debug) {
            alert(a+':'+tmp_r);
        }
        if (typeof tmp_r == 'undefined' || tmp_r<r)  continue;
        c_attr=a;
        r=tmp_r;
    }
    if (debug) {
        alert(c_attr+':'+r);
    }
    return r;
}


function cancelPopup(){  
	if((document.getElementById('down_popup_background')!=null)&&(document.getElementById('down_popup_div')!=null))
	{
    document.body.removeChild(document.getElementById('down_popup_background'));  
    document.body.removeChild(document.getElementById('down_popup_div'));  
    }
}
function sGetScrollTop()
{
    if (document.documentElement.scrollTop!=0) { 
        return document.documentElement.scrollTop;
    }
    return document.body.scrollTop;
}
function rebuild()
{
	if((document.getElementById('down_popup_background')!=null)&&(document.getElementById('down_popup_div')!=null))
	{  
	
    var background_div = document.getElementById('down_popup_background');
    background_div.style.position = 'absolute';
    background_div.style.left  = 0;
    background_div.style.top = '0px';
    background_div.style.background = '#333';
    background_div.style.height = getWindowLength('h')-4+'px';
    background_div.style.width = '100%';//getWindowLength('w')-20+'px';
    background_div.style.filter  = 'alpha(opacity=90)';
    background_div.style.opacity = .95;
    background_div.style.MozOpacity  = .95;
    background_div.style.zIndex = '0';
	background_div.style.textAlign='left';
	
	var div_obj = document.getElementById('down_popup_div');
    
    // 不透明处理
    div_obj.style.position = 'absolute';
	div_obj.style.background = '#FFF';
    div_obj.style.left   = getWindowLength('w')/2 -200+'px';	
    div_obj.style.width  = '400px';
    div_obj.style.color = 'black';
	div_obj.style.padding='0';
    div_obj.style.top = sGetScrollTop()+(window.screen.availHeight*1/4)+'px';
    div_obj.style.zIndex = '2';
    div_obj.style.float = 'left'; 

	}
}

window.onresize=function () {
    rebuild();
} 