﻿function show_dialog(url,width,height){
    
    var wt=(document.documentElement.clientHeight-height)/2;   
    var wl=(document.body.clientWidth-width)/2;   
   
    
    
    
    var wh = document.documentElement.scrollTop;
    
    //alert(wh);
    
	var body_width=document.body.clientWidth+'px';	
	var body_height=document.documentElement.clientHeight+'px';
	
	//alert(body_width);
	
	
	var bg_obj = createDiv("show_bg","#D5D5D5","0px","0px","absolute",body_width,body_height,"999");
	bg_obj.style.top = '0px';
	bg_obj.style.left = '0px';
	bg_obj.style.filter='alpha(opacity=60)';
	document.body.appendChild(bg_obj);
	
	
	
	dvs = createDiv("show_dialog","#ffffff","0px","0px","absolute","0px","0px","10000");
	dvs.style.top=wt+wh+'px';	
	dvs.style.left = wl+'px';
	dvs.style.border="2px solid #3366bb";
	
	dvs.style.width = width+10;
	dvs.style.height = height+50;
	
	dvs.style.textAlign="center";
	
	
	document.body.appendChild(dvs);
	
	//dvs.innerHTML='<div style="float:left;width:'+(width-55)+'px;overflow:hidden;height:20px;text-align:left;font-weight:bold;padding-top:8px;background-color:#27C1FC"></div>'
	
	//+'<div style="float:left;width:15px;height:20px;padding-top:8px;background-color:#27C1FC"><img src="/App_Themes/Default/images/dialog_close.gif" style="cursor:hand" onclick="close_dialog()"></div>'
	
	//+'<div style="float:left;width:40px;height:20px;overflow:hidden;text-align:left;font-weight:bold;padding-top:8px;background-color:#27C1FC"><span style="cursor:hand;color:#FFFFFF" onclick="close_dialog()"> 关闭 </span></div>'
	
	//+'<iframe  marginheight="0"  marginwidth="0"  frameborder="0"  scrolling="no"  width="'+(width-20)+'"  height="'+(height-30)+'" src="'+url+'"></iframe>';
	
	
	
	dvs.innerHTML='<div style="background-color:#3366bb;width:'+width+'px;padding:10px 5px 5px 5px;height:20px;"><div style="float:left;color:#FFFFFF;overflow:hidden;text-align:left;font-weight:bold;></div>'
	
	+'<div style="float:right;><img src="/App_Themes/Default/images/dialog_close.gif" style="cursor:hand" onclick="close_dialog()"></div>'
	
	+'<div style="float:right;overflow:hidden;text-align:left;font-weight:bold;"><a href="javascript:void(0);" onclick="close_dialog()" style="color:#ffffff;text-decoration:none;"> 关闭 </a></div></div>'
		
	+'<div style="background-color:#ffffff;width:'+width+'px;padding:5px;"><iframe  marginheight="0"  marginwidth="0"  frameborder="0"  scrolling="no"  width="'+(width)+'px"  height="'+(height)+'px" src="'+url+'"></iframe></div>';
	
}

function show_messageinfo(title,content,width,height)
{
   if(document.getElementById('show_bg')!=null)
   {
         return;
   }
   var wt=(document.documentElement.clientHeight-height)/2;
   var wl=(document.body.clientWidth-width)/2;
   
   var wh=document.documentElement.scrollTop;
   alert(wh);
}


function show_dialoginfo(title,content,width,height){
    
    
    
    if(document.getElementById("show_bg")!=null)
    {
        return;
    }
    
    var wt=(document.documentElement.clientHeight-height)/2;   
    var wl=(document.body.clientWidth-width)/2;   
   
    
    
    
    var wh = document.documentElement.scrollTop;
    
    //alert(wh);
    
	var body_width=document.body.clientWidth+'px';	
	var body_height=document.documentElement.clientHeight+wh+'px';
	
	//alert(body_height);
	
	
	var bg_obj = createDiv("show_bg","#D5D5D5","0px","0px","absolute",body_width,body_height,"999");
	bg_obj.style.filter='alpha(opacity=20)';
	bg_obj.style.top = '0px';
	bg_obj.style.left = '0px';
	document.body.appendChild(bg_obj);
	
	
	
	
	
	dvs = createDiv("show_dialog","#ffffff","0px","0px","absolute","0px","0px","10000");
	dvs.style.top=wt+wh+'px';	
	dvs.style.left = wl+'px';
	dvs.style.border="2px solid #0071de";
	
	dvs.style.width = width+10;
	dvs.style.height = height;
	
	dvs.style.textAlign="center";
		
	document.body.appendChild(dvs);
	
	dvs.focus();
	
	//alert(width);
	
	dvs.innerHTML='<div style="background-color:#3366bb;width:'+width+'px;padding:10px 5px 5px 5px;height:20px;"><div style="float:left;color:#FFFFFF;overflow:hidden;text-align:left;font-weight:bold;">'+title+'</div>'
	
	+'<div style="float:right;><img src="/App_Themes/Default/images/dialog_close.gif" style="cursor:hand" onclick="close_dialog()"></div>'
	
	+'<div style="float:right;overflow:hidden;text-align:left;font-weight:bold;><a href="javascript:void(0);" onclick="close_dialog()" style="cursor:hand;color:#ffffff;text-decoration:none;"> 关闭 </a></div></div>'
	
	+'<div style="clear:both;background-color:#ffffff;width:'+width+'px;overflow:hidden;text-align:left;padding:5px; border:0px solid #000000;color:#333;height:'+(height-80)+'px">'+content+'</div>'
	
	+'<div style="background-color:#ffffff;width:'+width+'px;padding:5px;"><input type="button" value="确定" onclick="close_dialog();" style="border:1px solid #cccccc;background-color:#ffffff;width:80px;"></div>';
	
}


function reset(){
	window.location=window.location;
}

function close_dialog(){

    try
    {
        var bg_obj=document.getElementById("show_bg");
	    var dvs = document.getElementById("show_dialog");
	    document.body.removeChild(bg_obj);
	    document.body.removeChild(dvs);
	    setTimeout(CurrentFocus,5);
    }
    catch(e)
    {

    }
	
}

function CurrentFocus()
{
    try
    {
        if(CurrentObject!=null&&CurrentObject.style.Dispaly!="none")
            CurrentObject.focus();
    }
    catch(e)
    {

    }
}

function createDiv(dvid,bgcolor,lft,tp,pos,wdth,hgt,zindex){
	var newdv = document.createElement("div");
	if(dvid!=""){
		newdv.id = dvid;
	}
	if(bgcolor!=""){
		newdv.style.backgroundColor=bgcolor;
	}
	if(lft!=""){
		newdv.style.left = lft;
	}
	if(tp!=""){
		newdv.style.top = tp;
	}
	if(pos!=""){
		newdv.style.position = pos;
	}
	if(wdth!=""){
		newdv.style.width = wdth;
	}
	if(hgt!=""){
		newdv.style.height = hgt;
	}
	if(zindex!=""){
		newdv.style.zIndex = zindex;
	}
	return newdv;
}
document.onkeydown = EnterKeyClose;
function EnterKeyClose()
{
    
    if(event.keyCode==13)
    {
       close_dialog();
    }
}