//调用说明 title 窗口标题,furl 框架调用时连接的页面地址,w 窗口宽度,h 窗口高度,btxt 底部说明,t特殊接口
//参数 b 等于0 确定关闭,等于1 确定刷新,等于2取消关闭,等于3确定刷新取消关闭.等于4 提交框架内的ifform表单,其它非整数数字以链接处理

//框架调用 
function ShowIframe(title, furl, w, h, btxt, b){
Artstr(title,'<iframe name=popiframe id=popiframe onload=loadbar("'+btxt+'"); src='+furl+' frameborder="0" width='+w+' height='+h+' scrolling="no"></iframe>',w+4,h+28,'<img src=inc/img/loading.gif align=absmiddle> Loading...',b);
}
function ShowAlert(title, msg, w, h, b){
Artstr(title,'<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><img src=inc/img/tt.gif align=absmiddle>&nbsp;&nbsp;<font color=red><b>'+msg+'</b></font></tr></td></table>',w+4,h+28,'',b);	
}
function ShowAlert2(title, msg, w, h, b){
Artstr(title,'<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><font color=red><b>'+msg+'</b></font></tr></td></table>',w+4,h+28,'',b);	
}
function loadbar(au){
var au;
document.getElementById("btBox").innerHTML=au;
}

function Artstr(title, msg, w, h, btxt, b){

	var s=document.getElementsByTagName("select"); //--------------把所有select标签捉住
	for(var j=0;j<s.length;j++){s[j].style.display="none";} //--------------设为不显示，再进行下面操作
	var titleheight = "28"; // 提示窗口标题高度 
	var bordercolor = "#709CD2"; // 提示窗口的边框颜色 
	var titlecolor = "#FFFFFF"; // 提示窗口的标题颜色 
	var titlebgcolor = "#666699"; // 提示窗口的标题背景色
	var bgcolor = "#FFFFFF"; // 提示内容的背景色
	var path="inc/img/"; //图片所在路径色
	
	var iWidth = document.documentElement.clientWidth; 
	var kHeight = document.documentElement.clientHeight;
	var mHeight = document.documentElement.scrollTop;
	var iHeight = mHeight+kHeight;
	var bgObj = document.createElement("div"); 
	bgObj.id="bgBox";
	bgObj.style.cssText = "position:absolute;background-color:#cccccc;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=50);opacity:0.3;z-index:998;";
	document.body.appendChild(bgObj); 
	
	var msgObj=document.createElement("div");
	msgObj.id="msgBox";
	msgObj.style.cssText = "position:absolute;font:12px '宋体';top:"+(mHeight+(kHeight-h)/2-100)+"px;left:"+(iWidth-w)/2+"px;width:"+w+"px;height:"+h+"px;text-align:center;border:0px solid "+bordercolor+";border-top-style: none;background-color:"+bgcolor+";padding:0px;z-index:999;";
	document.body.appendChild(msgObj);
	
	var table = document.createElement("table");
	msgObj.appendChild(table);
	table.style.cssText = "margin:0px;border:0px;padding:0px;";

	table.cellSpacing = 0;

	
	var tr = table.insertRow(-1);
	
		var lefttit = tr.insertCell(-1);
	lefttit.style.cssText = "padding-left:1px;width:4px;BACKGROUND: url("+path+"theme.gif);background-position:0 0px;background-repeat:no-repeat;background-color:" + titlebgcolor;
	lefttit.innerHTML = "";
	
	var titleBar = tr.insertCell(-1);
	titleBar.style.cssText = "width:"+(w-20)+"px;height:28px;BACKGROUND: url("+path+"theme.gif);background-position:0 -68px;background-repeat:x;text-align:left;padding:0px;margin:0px;font:bold 12px '宋体';color:"+titlecolor+";border:0px solid " + bordercolor + ";cursor:move;background-color:" + titlebgcolor;
	titleBar.style.paddingLeft = "6px";
	titleBar.innerHTML = title;
	var moveX = 0;
	var moveY = 0;
	var moveTop = 0;
	var moveLeft = 0;
	var moveable = false;
	var docMouseMoveEvent = document.onmousemove;
	var docMouseUpEvent = document.onmouseup;
	titleBar.onmousedown = function() {
		var evt = getEvent();
		moveable = true; 
		moveX = evt.clientX;
		moveY = evt.clientY;
		moveTop = parseInt(msgObj.style.top);
		moveLeft = parseInt(msgObj.style.left);
		
		document.onmousemove = function() {
			if (moveable) {
				var evt = getEvent();
				var x = moveLeft + evt.clientX - moveX;
				var y = moveTop + evt.clientY - moveY;
				if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) {
					msgObj.style.left = x + "px";
					msgObj.style.top = y + "px";
				}
			}	
		};
		document.onmouseup = function () { 
			if (moveable) { 
				document.onmousemove = docMouseMoveEvent;
				document.onmouseup = docMouseUpEvent;
				moveable = false; 
				moveX = 0;
				moveY = 0;
				moveTop = 0;
				moveLeft = 0;
			} 
		};
	}
	
	var closeBtn = tr.insertCell(-1);
	closeBtn.style.cssText = "cursor:pointer; padding:0px;padding-right:6px;BACKGROUND: url("+path+"theme.gif) no-repeat right top;background-position:0 -34px;background-color:" + titlebgcolor;
	closeBtn.innerHTML = "<span><img src="+path+"dialogclose.gif title='关闭'></span>";
	closeBtn.onclick = closes;
	function closes(){ 
	for(var j=0;j<s.length;j++){s[j].style.display="";} //--------------再给select显出来
		document.body.removeChild(bgObj); 
		document.body.removeChild(msgObj); 

	} 
	var msgBox = table.insertRow(-1).insertCell(-1);
	msgBox.style.cssText = "font:9pt '宋体';border:1px solid "+bordercolor+";border-top-style: none;border-bottom-style: none;height:"+(h-28)+"px;";
	msgBox.colSpan  = 3;
	msgBox.innerHTML = msg;
	
	var buttonTB = document.createElement('TABLE');
	buttonTB.style.cssText = "font:9pt '宋体';margin:0px;height:32px;border:1px solid "+bordercolor+";border-top-style: none;position:absolute;top:"+h+"px;left:0px;width:"+w+"px;text-align:right;BACKGROUND: url("+path+"btbg.gif);background-color:" + titlebgcolor;
	buttonTB.cellSpacing = 0;
var bttr = buttonTB.insertRow(-1);	
	
var btBar =bttr.insertCell(-1);
    btBar.id="btBox";
	btBar.style.cssText = "font:9pt '宋体';width:"+w+"px;text-align:left;padding:0px;margin:0px;color:"+bordercolor+";border:0px solid " + bordercolor + ";"
	btBar.style.paddingLeft = "6px";
	btBar.innerHTML = btxt;

if (b==0) {

var btBtn = bttr.insertCell(-1);
	btBtn.style.cssText = "cursor:pointer; padding:0px;padding-right:10px;"
	btBtn.innerHTML = "<span><img src="+path+"yes.gif title='确定'></span>";
	btBtn.onclick = closes;	
}

if (b==1||b==3) {

var btBtn1 = bttr.insertCell(-1);
	btBtn1.style.cssText = "cursor:pointer; padding:0px;padding-right:10px;"
	btBtn1.innerHTML = "<span><img src="+path+"yes.gif title='确定' onclick ='location.reload()'></span>";	
}

if (b==4) {

var btBtn4 = bttr.insertCell(-1);
	btBtn4.style.cssText = "cursor:pointer; padding:0px;padding-right:10px;"
	btBtn4.innerHTML = "<span><img src="+path+"yes.gif title='确定' onclick =ifform();></span>";
	//btBtn4.onclick="document.frames['popiframe'].form1.aa.value='000';"
}

if (b>1){		
var btBtn2 = bttr.insertCell(-1);
	btBtn2.style.cssText = "cursor:pointer; padding:0px;padding-right:10px;"
	btBtn2.innerHTML = "<span><img src="+path+"none.gif title='取消'></span>";
	btBtn2.onclick = closes;
}

var re = /^[0-9]+.?[0-9]*$/;   //如果b是非数字以链接处理  
     if (!re.test(b))
    {		
var btBtn5 = bttr.insertCell(-1);
	btBtn5.style.cssText = "cursor:pointer; padding:0px;padding-right:10px;"
	btBtn5.innerHTML = "<span><img src="+path+"yes.gif title='确定' onclick =location.href='"+b+"'></span>";
var btBtn6 = bttr.insertCell(-1);
	btBtn6.style.cssText = "cursor:pointer; padding:0px;padding-right:10px;"
	btBtn6.innerHTML = "<span><img src="+path+"none.gif title='取消'></span>";
	btBtn6.onclick = closes;	
	}

	msgObj.appendChild(buttonTB);
	
    // 获得事件Event对象，用于兼容IE和FireFox
    function getEvent() {
	    return window.event || arguments.callee.caller.arguments[0];
    }
	

}
//外部关闭调用
function closes2(){
          var s=document.getElementsByTagName("select");	
	      for(var j=0;j<s.length;j++){s[j].style.display="";} //select显出来

		  if (window.document.readyState){//IE
          msgBox.removeNode(true); 
		  bgBox.removeNode(true);		  
		  }else{//火狐
          document.getElementById("msgBox").style.display="none"; //火狐浏览器中关闭
          document.getElementById("bgBox").style.display="none";			  
		  }
}
function ifform(){
	var ss;
	ss=frames['popiframe'].document.getElementById("ifform");
	if(ss){
		frames['popiframe'].document.forms['ifform'].submit();
	}else{
        location.reload();
    }
} 


