<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>Dvbbs PHP2.0++ Setup Wizard</title>
<style type="text/css">
/***全局定义***/
*{ margin:0; padding:0;}
body { margin:0px; margin-left:auto; margin-right:auto; font-size:12px; color:#012737; }
div { margin-left:auto; margin-right:auto;}
form { margin:0px; padding:0px;}
img{ margin:0px; padding:0px;  vertical-align: middle; font-size:12px;border:none;}
.input{margin:0px; padding:0px;  vertical-align: middle; font-size:12px;border:1px solid #acd6ed; height:18px; line-height:18px; color:#666666;}
a { color:#CC3300; text-decoration:none; }
a:hover { color:#CC3300; text-decoration:underline; }
.red { color:#ff3300; font-family:Arial,sans-serif; font-size:11px;}

#main{ width:500px; height:342px; margin-top:200px; }
#tit{ width:100%; height:34px; line-height:34px; font-size:14px; color:#ffffff; background:url("images/tit_bg.gif");}
#tit_name { text-indent:20px; float:left;}
#close { float:right; margin-top:6px; margin-right:10px;}
#mainbox { clear:both;width:498px; height:342px; border:1px #D7EAF0 solid; border-top:none;}
#box_left { width:145px; height:340px; background:url("images/left_bg.gif"); border:1px solid #ffffff; border-right:none; float:left; }
#box_right { width:351px; height:340px; background:url("images/bg.gif"); border:1px solid #ffffff; border-left:none; float:left; text-align:center;}
#text_01{ width:90%; height:180px; line-height:180%;  margin:20px 0 0 0; text-align:left;overflow-x:hidden; overflow-y:auto; background:#FFFFFF; text-indent:10px}
#text_02 { width:90%; height:30px;  line-height:180%; margin:20px 0 10px 0; background:#e5f0f6; border:1px solid #ffffff; text-align:left;}
.button{border:1px solid #BFCDDC;background:#f1f3ff; height:22px;}
.tit1{
text-align:left;
background-color:#B0C3F1;
background-image : url("../images/bg4.gif");
background-repeat: repeat-y;
color:#fff;
font-size: 12px;
line-height: 25px;
height: 25px;
margin-top:8px;
border:#ccc 1px solid;
margin:0 auto;
padding-left:3px;
}
table{
width:100%;
}
td{
line-height:18px;
}
input,select , textarea , option {
font-family : tahoma, verdana, 宋体, fantasy;
font-size : 12px;
line-height : 15px; 
color : #000000;
} 
.forumrow{
background-color:#EEF7FD;
height: 24px;
text-align : left;
padding-left:5px;
}

#ProgressBar {font:12px Verdana, Arial, Helvetica, sans-serif;border:1px solid #5B94DF;text-align: left;height:28px;}
#Pointer {border:1px solid  #FFFFFF;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#DDE9F9, endColorstr=#81ACE7;margin-left: 0px;height:28px;}
#Lable {position:absolute;width:100%;text-align: center;height:28px;}
</style>
<script language="javascript">
var g_encode="gbk";
function execAndShow(sussess,retmsg){
   if(sussess){
       var ojbshow=document.getElementById("text_01");
	   if(false!==(arrRet=parseServerResult(retmsg))){
	       if(arrRet["js"]!=="")eval(arrRet["js"]);
		   if(arrRet["errno"]===0){
			   ojbshow.innerHTML=arrRet["msg"];
			   ojbshow.scrollTop=ojbshow.scrollHeight; 
			   updateProgressBar();
			}else{
				//服务器端执行命令错误
				doOnError(arrRet["errno"],arrRet["msg"]);
				cmdIp--;
			}
	   }else{
	   	   alert("|------------------"+lang["data_format_err"]+"--------------------|\r\n"+retmsg);
		   //返回值格式错误
	   }
   }else{
	   //连接错误
	   alert(lang["ajax_err_0"]+"\n"+lang["ajax_err_1"]+":"+retmsg[2]);
	  
   }
   enabledbtn();
}

doOnError=function(errno,errmsg){
	switch(errno){
		case 0:
		break;
		
		case 1:
		break;
		
		case 2:
		break;
		
		case 4:
		break;
		
		case 8:
		break;
		
		default:
		break;
	}
}
function parseServerResult(s){
	arrRet=s.split("@@@");
	arr2=Array(3);
	if(arrRet.length!==5)return false;
	arr2["errno"]=parseInt(arrRet[1]);
	arr2["msg"]=arrRet[2];
	arr2["js"]=arrRet[3];
	return arr2;
}
</script>
<script language="javascript">
var servercmd=function(command,params,execurl,callbackfunc,encode,async){
	var raiseError=function(msg){
		if(msg)alert(msg);
	}
	var _command=command;
	if(params){
		var _params=params;
	}else{
		var _params='';
	}

	if(execurl){
		var _execurl=execurl;
	}else{
		return false;
	}

	if(typeof(callbackfunc)!=="function"){
		return false;
	}else{
		_callbackfunc=callbackfunc;
	}

	if(encode){
		var _encode=encode;
	}else{
		_encode="gbk";
	}
	if(async!==false){
		_async=true;
	}else{
		_async=false;
	}

	var getajax=function(){
		try{
			ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(e){
			try{
				ajax = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				try{
					ajax = new XMLHttpRequest();
				}catch(e){
					ajax = null;
				}
			}
		}
		return ajax;
	}
     
	evalVariables=function(s){
		if(s==="") return s;
		re=/\{(.+?)\}/gm;
	    try{
		   return s.replace(re,function($1){if($1){return eval($1)}else{return ""}});
		}catch(e){
		   return s
		}
    }
	
	this.execute=function(){
		var ajax=getajax();
		if(!ajax)return false;
		url=(-1!==(pos=_execurl.indexOf("?"))&&_execurl!=="?")?_execurl.substr(0,pos):_execurl;
		if(url!=="?")url+="?";
		url+="command="+_command;
		if(url.substr(url.length-1,1)!=="&"&&_params.substr(0,1)!=="&")url+="&";
		url+=_params;
		if(url.substr(url.length-1,1)!=="&")url+="&";
		url+="charset="+_encode;
		url=evalVariables(url);
		if(_async){
			try{
		       ajax.onreadystatechange = function(){
				   if(ajax.readyState == 4){
					   if(ajax.status==200){
						   _callbackfunc(true,ajax.responseText);
					   }else{
						   _callbackfunc(false,[1,"",url]);
					   }
				   }
			   };
	        }catch(e){
		      return false;
	       }
		}
		ajax.open("GET", url, _async);
		(g_encode=="")&&(g_encode=encode);
		ajax.setRequestHeader("Content-Type", "text/xml;charset="+g_encode);
		
	    ajax.setRequestHeader("If-Modified-Since","0");
	    ajax.send(null);
		
		if(!_async){
			 _callbackfunc(true,ajax.responseText);
		}
	
	}
	
	return this;
}
</script>
<script language="javascript">
function formToQueryString(theForm){
var QueryString="";
var i=0;
   for(i=0;i<theForm.elements.length;i++){
   QueryString=QueryString+theForm.elements[i].name+"=";
   QueryString=QueryString+theForm.elements[i].value+"&";
   }
   return QueryString;
}
</script>
<script language="javascript">
var lang=Array();
	lang["ajax_err_0"]="网络错误，请检查网络连接并确认浏览器支持Ajax";
	lang["ajax_err_1"]="不能访问";
    lang["msg_0"]="关闭安装窗口？";
    lang["data_format_err"]="数据错误！";
</script>
<script language="javascript">
//第一个要执行的命令
var cmd_queue=Array();
var cmdIp=0;
var steps=12;
cmd_queue[0]=new servercmd("0","","exec_cmd.php",execAndShow,"gbk",true);
cmd_queue[1]=new servercmd(1,"language={document.getElementById('language').value}","exec_cmd.php",execAndShow,"gbk",true);
cmd_queue[2]=new servercmd(2,"language={document.getElementById('language').value}","exec_cmd.php",execAndShow,"gbk",true);
cmd_queue[3]=new servercmd(3,"{formToQueryString(document.getElementById('frmsetup'))}","exec_cmd.php",execAndShow,"gbk",true);
cmd_queue[4]=new servercmd(4,"{formToQueryString(document.getElementById('frmsetup'))}","exec_cmd.php",execAndShow,"gbk",true);
cmd_queue[5]=new servercmd(5,"{formToQueryString(document.getElementById('frmsetup'))}","exec_cmd.php",execAndShow,"gbk",true);
cmd_queue[6]=new servercmd(6,"{formToQueryString(document.getElementById('frmsetup'))}","exec_cmd.php",execAndShow,"gbk",true);
cmd_queue[7]=new servercmd(7,"","exec_cmd.php",execAndShow,"gbk",true);
cmd_queue[8]=new servercmd(8,"","exec_cmd.php",execAndShow,"gbk",true);
cmd_queue[9]=new servercmd(9,"{formToQueryString(document.getElementById('frmsetup'))}","exec_cmd.php",execAndShow,"gbk",true);
cmd_queue[10]=new servercmd(10,"{formToQueryString(document.getElementById('frmsetup'))}","exec_cmd.php",execAndShow,"gbk",true);
cmd_queue[11]=new servercmd(11,"","exec_cmd.php",execAndShow,"gbk",true);


function execCmdNext(sender){
     if(sender!==null&&typeof(sender)==="object")sender.disabled=true;
     enabledbtn(true);
   if(curcmd=cmd_queue[cmdIp]){
      curcmd.execute();
	  cmdIp++;
	  return true;
   }else{
      return false;
   }
}

function execCmdBack(sender){
  if(typeof(sender)==="object")sender.disabled=true;
  sender.disabled=true;
  enabledbtn(true);
  if(curcmd=cmd_queue[cmdIp-2]){
      curcmd.execute();
	  cmdIp--;
	  return true;
   }else{
      return false;
   }
}

function enabledbtn(opt){
   cmdcount=cmd_queue.length;
   document.getElementById('btnNext').disabled=(cmdcount-1===cmdIp||opt===true);
   document.getElementById('btnBack').disabled=(cmdIp<=1||opt===true); 
   return true;
}

function updateProgressBar() {
	p = parseInt((cmdIp+1)/steps*100);
	if(p>100)p=100;
	p=p+"%";
	document.getElementById("Pointer").style.width = p;
	document.getElementById("Lable").innerHTML = p;
}

function window_onload(){
	execCmdNext(null);
};
</script>
</head>
<body onload="window_onload()">
<div id="main">
  <div id="tit"><span id="tit_name">Dvbbs PHP2.0++ Setup Wizard</span><span id="close"><input type="image" src="images/close.gif" onclick="cancelInstall()" alt="" border="0" style="height: auto; border: none;" /></span></div>
  <div id="mainbox">
     <div id="box_left"></div>
	 <div id="box_right">
	    <div id="text_01">
	   </div>
	    <div id="text_02">
		<div id="ProgressBar">
			<div id="Lable">0%</div>
			<div id="Pointer" style="width:0%"></div>
		</div>
		</div>
	   <h1><input type="button" name="btnBack" id="btnBack" class="button" value="Back" onclick="execCmdBack(this)" disabled=true>
<input type="button" name="btnNext"  id="btnNext" class="button" value="Next"  onclick="execCmdNext(this)">
</h1>
	 </div>
  </div>

</div>
</body>
</html>
