/*
	*2009/1/4 增加prototype版检查功能！
*/
if (DEPLOY_MODE=='undefined'){//调适模式和部署模式怎么区分 
	var DEPLOY_MODE=true
}

var mbDocument= {
	Version: '1.0.0.1',
	REQUIRED_PROTOTYPE: '1.6.0',
	AllowDownCount:5,
	load: function() {
		function convertVersionString(versionString){
		  var r = versionString.split('.');
		  return parseInt(r[0])*100000 + parseInt(r[1])*1000 + parseInt(r[2]);
		}
	 
		if((typeof Prototype=='undefined') || (typeof Element == 'undefined') ||  (typeof Element.Methods=='undefined') ||  (convertVersionString(Prototype.Version) < convertVersionString(mbDocument.REQUIRED_PROTOTYPE)))
		   throw("mbDocument requires the Prototype JavaScript framework >= " + mbDocument.REQUIRED_PROTOTYPE);
		
	},
	tip:function(obj,str){
		infoobj=obj.up(0).select("SPAN.info")[0];
		if (obj.tagName=='INPUT') obj.activate();
		if (infoobj){
			if (str!=''){
				infoobj.update(str);
				infoobj.className='info';
				infoobj.addClassName('warning');
			}else{
				infoobj.update('OK');
				infoobj.className='info';
                infoobj.addClassName('Success');
			}
		}
	},
	fixPng:function() { 
		var arVersion = navigator.appVersion.split("MSIE") 
		var version = parseFloat(arVersion[1]) 

		if ((version >= 5.5 && version < 7.0) && (document.body.filters)) { 
			var png = /\.png$/i;
			var imgs = document.getElementsByTagName('img');
			for(var i = 0, l = imgs.length; i < l; i++) {
				if(png.test(imgs.item(i).src)) {
					imgs.item(i).style.width = imgs.item(i).offsetWidth;
					imgs.item(i).style.height = imgs.item(i).offsetHeight;
					imgs.item(i).style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + imgs.item(i).src + '\',sizingMethod=\'image\')';
					imgs.item(i).src = 'empty.gif';
				}
			}
		}

	},
	/**
	*tabSwitch(标头对象集，内容对象集，当前对象，对象CSS名称集['on','off'])
	*/
	tabSwitch:function(ttlObject,cntObject,selTab,classNames){
		//alert(selTab)
		if(Object.isUndefined(classNames)){
			classNames=['tabon','taboff','OldMagic']
		}
		selIndex=ttlObject.indexOf(selTab);
		if (selIndex==-1){
			return;
		}
		ttlObject.each(function(tab){
			//alert(ttlObject[selIndex],tab.index)
			tab.className=(ttlObject[selIndex]==tab)?classNames[0]:classNames[1];
			
		})
		cntObject.each(function(main){
			main.className=(cntObject[selIndex]==main)?'ullistOn':'ullistOff';
		})
		

		$('OldMagicSet').className = classNames[2];
	}
	,
	parseString:function(PString,div1,div2){
		if (PString=='' || PString.replace(/\s/g,'')==''){
			return new Array();
		}
		if(Object.isUndefined(div1)) div1='\n';
		if(Object.isUndefined(div2)) div2='|';
		var items=PString.split(div1);
		var result=new Array();
		for (i=0;i<items.length;i++){
			if (items[i].replace(/\s/g,'').length>1){
				result[result.length]=items[i].split(div2)	
			}
		}
		return result;
	}
	,
	//id|softname|softico|softdescription|advices|status|isMicrosoft
	addItems:function(PString,index){
		if(Object.isUndefined(index)) index='0';
		var items = this.parseString(PString);
		$(index+'_Item_Length').innerHTML=items.length;
		
		var myTemplate = new Template(
			'<li id="'+index+'_item_#{0}" class="bgChange Status_#{5} MS_#{6}">'
			+'<div class="start_name2">'
			+'    <div class="softico fl"><img src="#{2}" width="32" height="32" /></div>'
			+'    <div class="kq fl">'
			+'      <div class="kq1">'
			+'				<div class="fl start_name3">#{1}</div>'
			+'				<div class="soft_beta fl">#{4} </div>'
			+'				<div class="soft_beta2 fl" id="'+index+'_status_Item_#{0}" style="display:none;"></div>'
			+'				<div class="starting fl" id="'+index+'_btn_Item_#{0}"></div>'
			+'				<div class="path" id="'+index+'_path_Item_#{0}"></div>'
/*			+'	<div style="clear:both"></div>'*/
			+'      </div>'
			+'      <div class="kq2"><a href="jvascript:;" title="#{3}" style="color:#c0c0c0">#{3}</a></div>'
			+'    </div>'
			+'  </div>'
			+'</li>'			
		);

		var html="";
		var count=0;
		items.each(function(conv){
			count++;
			html+=myTemplate.evaluate(conv);
		})
		$(index+'_WinStartItem').innerHTML=html;
		var StartedApplication=0;
		items.each(function(conv){
			if (parseInt(conv[6])===1 && index==1){
				if (!$(index+'_lstMS_Item').checked) $(index+'_item_'+conv[0]).hide();
			}			
			if (parseInt(conv[5])===0){
				$(index+'_btn_Item_'+conv[0]).innerHTML='<a href="ExecCmd=openItem;ID='+conv[0]+'"><img src="JPG/start" class="btn" /></a>'
				//$(index+'_status_Item_'+conv[0]).innerHTML="已禁止";
				if (!$(index+'_lstRootStart').checked && parseInt(conv[6])===0) $(index+'_item_'+conv[0]).hide();
			}else{
				$(index+'_btn_Item_'+conv[0]).innerHTML='<a href="ExecCmd=closeItem;ID='+conv[0]+'"><img src="JPG/ban" class="btn" /></a>'	
				//$(index+'_status_Item_'+conv[0]).innerHTML="已启动";
				if (parseInt(conv[6])===0) StartedApplication++;
				$(index+'_path_Item_'+conv[0]).innerHTML='<a href="ExecCmd=openPath;ID='+conv[0]+'">位置</a>';
			}
			
			
		})
		$(index+'_Item_StartedLength').innerHTML=StartedApplication;
		this.btnStatus();
		this.bindLiMouse();
	},
	
	//id|osname|language|checked(1 is checked)|GUID|checked
	addItemsOs:function(PString,index){
		index='2';
		var items = this.parseString(PString);
		$(index+'_Item_Length').innerHTML=items.length;

		var myTemplate = new Template(			
			'<li id="'+index+'_item_#{0}" class="bgChange Status_#{3}">' 
			+'	  <div class="mr">'
			//+'		 <form id="form1" name="form1" method="post" action="">'
			+'		   <label>'
			+'			  <input type="radio" name="os" id="os_#{0}" value="#{4}" #{5}/>'
			+'			  <input type="hidden" name="osOrder_#{0}" id="osOrder_#{0}" value=#{0} />'
			+'		  </label>'
			//+'	   </form>'
			+'	  </div>'
			+'	  <div class="xtmc">#{1}</div>'
			+'	  <div class="yy">#{2}</div>'
			+'</li>		'
		);

		var html="";
		var count=0;
		items.each(function(conv){
			count++;
			html+=myTemplate.evaluate(conv);
		})
		$(index+'_WinStartItem').innerHTML=html;
			
		this.bindLiMouse();
		
		$(index+'_span1').innerHTML='<a href="javascript:onClick=mbDocument.move(\'up\',' + items.length + ');"><img height="29" width="80"  src="JPG/up"  class="btn" ></a>';
		$(index+'_span2').innerHTML='<a href="javascript:onClick=mbDocument.move(\'down\',' + items.length + ');"><img height="29" width="80"  src="JPG/down"  class="btn"></a>';
		$(index+'_span3').innerHTML='<a href="javascript:onClick=mbDocument.dataSubimit(' + items.length + ');"><img src="JPG/swmr" width="80" height="29" class="btn"/></a></a>';
		this.btnStatus();
		
	},
	showCurrentSystem:function(os,index,seconds){
		$(index+'_Item_StartedLength').innerHTML=os;
		$('TimeOut').value=seconds;
	},
	bindLiMouse:function(){
		$A($$('li.bgChange')).each(function(li){
			li.onmouseover=function(){
				li.setStyle({'backgroundColor':'#EEF5FF'});
			}
			li.onmouseout=function(){
				li.setStyle({'backgroundColor':'#fff'})
			}
			
		})
	}
	,
	chg_ItemStatus:function(id,status,index){
		if(Object.isUndefined(index)) index='0';
		if (parseInt(status)===0){
			$(index+'_btn_Item_'+id).innerHTML='<a href="ExecCmd=openItem;ID='+id+'"><img src="start" class="btn" /></a>'
			//$(index+'_status_Item_'+id).innerHTML="已禁止";

			$(index+'_item_'+id).removeClassName('Status_0');
			$(index+'_item_'+id).removeClassName('Status_1');
			$(index+'_item_'+id).addClassName('Status_0');
			$(index+'_path_Item_'+id).innerHTML="";
		}else{
			$(index+'_btn_Item_'+id).innerHTML='<a href="ExecCmd=closeItem;ID='+id+'"><img src="JPG/ban" class="btn" /></a>'	
			//$(index+'_status_Item_'+id).innerHTML="已启动";
			$(index+'_path_Item_'+id).innerHTML="位置";
			$(index+'_item_'+id).removeClassName('Status_0');
			$(index+'_item_'+id).removeClassName('Status_1');
			$(index+'_item_'+id).addClassName('Status_1');
		}
		this.btnStatus();
	},
	EmptyItems:function(index){
		if(Object.isUndefined(index)) index=0;
		$(index+'_Item_Length').innerHTML=0;
		$(index+'_WinStartItem').innerHTML='';
	}
	,
	listAllRootStart:function(isList,index){
		if(Object.isUndefined(index)) index='0';
		var StartedApplication=0;
		$A($$('UL#'+index+'_WinStartItem li')).each(function(li){
			if (isList && li.hasClassName('Status_0') && !li.hasClassName('MS_1'))	{
				li.show();	
			}else if(li.hasClassName('Status_0') && !li.hasClassName('MS_1')){
				li.hide();	
			}
			if (li.style.display!='none' && li.hasClassName('Status_1') && li.hasClassName('MS_0')){
				StartedApplication++;
			}
		})
		$(index+'_Item_StartedLength').innerHTML=StartedApplication;
	}
	,
	listAllMicrosoftSvervice:function(isList){
		var StartedApplication=0;
		$A($$('UL#1_WinStartItem li')).each(function(li){
			if (isList && li.hasClassName('MS_1'))	{
				li.show();	
			}else if(li.hasClassName('MS_1')){
				li.hide();	
			}
			//if (li.style.display!='none'  && li.hasClassName('Status_1')){
		//		StartedApplication++;
		//	}
		})
		$(index+'_Item_StartedLength').innerHTML=StartedApplication;

	}
	,
	btnStatus:function(){
		$A($$('img.btn')).each(function(img){
			
			//alert("img.src=" + img.src);
			var perName=img.src.substr(img.src.length-3,3);
			var sourceName=img.src.replace('_1.'+perName,'.'+perName).replace('_2.'+perName,'.'+perName)
			//alert("sourceName=" +sourceName);
			img.onmouseover=function(){
				img.src=sourceName.replace('.'+perName,'_1.'+perName);
			}
			img.onmouseout=function(){
				img.src=sourceName
			}
			img.onclick=function(){
				img.src=sourceName.replace('.'+perName,'_2.'+perName);
				img.src=sourceName.replace('.'+perName,'_1.'+perName);
			}
			//alert("img.src2=" + img.src);
		});
	
	},
	move:function(type,count){
		
        for(var i=1;i<=count;i++){			
			$id='os_' + i;
			if($($id).checked){
				var id_checked=i;
			}			
		}
		
		var order = $F('osOrder_' + id_checked);
		var idContent = $('2_item_' + order).innerHTML;
		if (type == 'up') {
		
			if (order != 1) {
			
				var idAgo = order - 1;
				var conentAgo = $('2_item_' + idAgo).innerHTML;
				
				var idContent_change = idContent.replace('value=' + order, 'value=' + idAgo);
				$('2_item_' + idAgo).innerHTML = idContent_change;
				
				var conentAgo_change = conentAgo.replace('value=' + idAgo, 'value=' + order);
				$('2_item_' + order).innerHTML = conentAgo_change;
				
			}
			
		}
		else 
			if (type == 'down') {
				if (order != count) {
				
					var idAfter;
					if (order == 1) {
						idAfter = 2;
					}
					else 
						if (order == 2) {
							idAfter = 3;
						}
						else 
							if (order == 4) {
								idAfter = 5;
							}
							else 
								if (order == 5) {
									idAfter = 6;
								}
								else 
									if (order == 6) {
										idAfter = 7;
									}
									else {
										idAfter = order + 1;
									}
					var conentAfter = $('2_item_' + idAfter).innerHTML;
					
					var idContent_change = idContent.replace('value=' + order, 'value=' + idAfter);
					$('2_item_' + idAfter).innerHTML = idContent_change;
					
					var conentAfter_change = conentAfter.replace('value=' + idAfter, 'value=' + order);
					$('2_item_' + order).innerHTML = conentAfter_change;
					
				}
			}
		
		$('os_' + id_checked).checked = true;
		

		this.btnStatus();

	},
	dataSubimit: function(count){
		
		
		if($('TimeOut').value==""){
			$('TimeOut').value="0";
		}
		

        for(var i=1;i<=count;i++){			
			$id='os_' + i;
			if($($id).checked){
				var id_checked=i;
			}
		}
		//得到排序
		var Osorder = new Array();
		for (var i = 1; i <= count; i++) {
			Osorder[$F('osOrder_' + i)] = $('os_' + i).value;
		}
		var OsorderList = "";
		for (var i = 1; i <= count; i++) {
			if (i != count) {
				OsorderList += Osorder[i] + '|';
			}
			else {
				OsorderList += Osorder[i];
			}
			
		}
		var hrefInfo = 'ExecCmd=SetApply;DefaultOS=' + $F('os_' + id_checked) + ';OSOrder=' + OsorderList + ';TimeOut=' + $('TimeOut').value;
		$('os_' + id_checked).checked = true;
		this.btnStatus();
		
		window.navigate(hrefInfo);
		
	},
	//输入法快捷方式 隐藏或显示
	IMEshortcut: function(type){
		if(type==0){
			$('IMEshortcut').hide();
			this.setValue2Page(5,$F('IMEString'));
		}else if(type==1){
			$('IMEshortcut').show();
			//this.setValue2Page(5,$F('IMEString'));
		}else if(type==2){
			$('IMEshortcut').hide();
			this.setIMESelected();
		}
	},
	itemOpen: function(item){
		//alert(item);
        var GetsonItem=item+'_description';
		if($(GetsonItem).className=="tab_on"){
			
			$(GetsonItem).className="tab_off";
			$(item).className="textclose";
		}else{
			$(GetsonItem).className="tab_on";
			$(item).className="textopen";
		}
	},
	//添加表单值
	//1,SystemSetOption1=1|param1=3@3@3|SystemSetOption2=0|SystemSetOption3=1| ...
	//2,win7Score=4.7|CPUScore=4.7|memScore=4.7|graphicScore=4.7|gameGraphicScore=4.7|diskScore=4.7
	//3,IEVersion=8.0|IETitle=aaa|IEDefaultOpenPage=http://www.haokan123.com|IEDefaultDownloadUrl=d:\download|IEDefaultSearchEngine=百度|ForbidIEDownloadFile=0
	//4,lnkFlag=1,2,3|param=图标索引|forbidCreateLnkText=1|desktopIconTransparent=1|clearInvalidIcon=1
	//5,defaultIME=aa|IMEOrder=aa;bb|switchIMEHotKey=左ALT+左SHIFT|NowIMESwitchEnglishHotKey=aaa|FullHalfWidthHotKey=aaa
	//6,closeCDRom=1|brownseHere=0|CamouflageFolder=0|openWithNotepad=0|encryptFile=0|Defragging=0|copy2Folder=0|rebootComputer=0|openNowDirWithDos=0|shutDownComputer=0|move2Folder=0|clearRecycleBin=0
	//7,win8_metro=1|win8_LockInterface=0|win8_metroBannedUninstall=0|win8_control=0;win8_control_param=0000000|win8_createShortcut=0|win8_addAdminOwnership=0|win8_shortcutMenu=0;win8_shortcutMenu_param=0000000000000
	setValue2Page: function(moudle,params){
		var changeparams=new Array();
		var paramsArr=params.split('|');
		for(var i=0;i<paramsArr.length;i++){
			var getParams=paramsArr[i].split('=');
			changeparams[getParams[0]]=getParams[1];
			//alert(getParams[0]+'->'+getParams[1]);
		}
		//alert(params);
		if(moudle==1){
			
		  if(changeparams['SystemSetOption1']==1){
		  	$('SystemSetOption1').checked=true;			
			var params_1=changeparams['param1'].split('@');
			$('param1_1').value=params_1[0];
			$('param1_2').value=params_1[1];
			$('param1_3').value=params_1[2];
		  }else if(changeparams['SystemSetOption1']==0){
		  	$('SystemSetOption1').checked=false;
		  	$('param1_1').value='';
				$('param1_2').value='';
				$('param1_3').value='';
		  }
		  for(var j=2;j<=32;j++){
		  	if(changeparams['SystemSetOption'+j]==1){
			  $('SystemSetOption'+j).checked=true;
			}else{
			  $('SystemSetOption'+j).checked=false;
			}
		  }
		}else if(moudle==2){
			
			var keyArray=new Array('win7Score','CPUScore','memScore','graphicScore','gameGraphicScore','diskScore');
			for(var i=0;i<keyArray.length;i++){
				
			 	$(keyArray[i]).value=changeparams[keyArray[i]];
	
			}

			//$('win7zs').innerHTML="&nbsp;"+changeparams['win7Score'];
			
			
		}else if(moudle==3){
			
			var keyArray=new Array('IEVersion','IETitle','IEDefaultOpenPage','IEDefaultDownloadUrl','IEDefaultSearchEngine','ForbidIEDownloadFile');
			for(var i=0;i<keyArray.length-1;i++){
				//alert(keyArray[i]);
				if(i!=3){//浏览按钮不可写入
			 	$(keyArray[i]).value=changeparams[keyArray[i]];
	            }
			}
			var keyArray_5=keyArray.length-1;
		  	if(changeparams[keyArray[keyArray_5]]==1){
			  $(keyArray[keyArray_5]).checked=true;
			}
			var getIETitle=this.len(changeparams['IETitle']);
			$('IEDefaultTitle').innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+getIETitle;
			
		}else if(moudle==4){
			
			var keyArray=new Array('lnkFlag','forbidCreateLnkText','desktopIconTransparent','clearInvalidIcon');

            $('lnkFlag_' +changeparams[keyArray[0]]).checked=true;	
            if(changeparams[keyArray[0]]==2){
            	$('viewPic').disabled=false;
            }
			for(var i=1;i<keyArray.length;i++){			
				if (changeparams[keyArray[i]] == 1) {
					$(keyArray[i]).checked=true;
				}
			}
			
		}else if(moudle==5){
			
			var keyArray=new Array('defaultIME','IMEOrder','switchIMEHotKey','NowIMESwitchEnglishHotKey','Jump2NowIMEHotKey');
			//defaultIME
			var IME=new Array();
			IME=changeparams['IMEOrder'].split(';');
			var IMEString_default="";
			var IMEString_Order="";
			for(var j=0;j<IME.length;j++){
				
				if(IME[j]==changeparams['defaultIME']){
					IMEString_default+='<option value="'+IME[j]+'" selected="selected">'+IME[j]+'</option>';
				}else{
					IMEString_default+='<option value="'+IME[j]+'">'+IME[j]+'</option>';
				}
				
			}
      $('defaultIME1').innerHTML="xxx";
			$('defaultIME1').innerHTML='<select name="defaultIME" id="defaultIME">'+IMEString_default+'</select>';
			
			//IMEOrder
			for(var j=0;j<IME.length;j++){
				if(IME[j]==changeparams['defaultIME']){
					IMEString_Order+='<option value="'+IME[j]+'"  selected="selected">'+IME[j]+'</option>';
				}else{
					IMEString_Order+='<option value="'+IME[j]+'" >'+IME[j]+'</option>';
				}
				
			}
     
			$('IMEOrder1').innerHTML='<select name="IMEOrder" id="IMEOrder" size=6 >'+IMEString_Order+'</select>';
			
			//switchIMEHotKey 不同输入法轮换切换
			var switchIMEHotKey1Array =new Array('未分配','Ctrl','左Alt');
			var switchIMEHotKey2Array =new Array('&nbsp;','Shift');
			var switchIMEHotKey=changeparams['switchIMEHotKey']; //得到的switchIMEHotKey 值
			//alert(switchIMEHotKey);
			if(switchIMEHotKey.indexOf('+')==-1){ switchIMEHotKey=switchIMEHotKey+'+&nbsp;'}
			//alert(switchIMEHotKey);
			var SIHArray=new Array();
			SIHArray=switchIMEHotKey.split('+');
			//选中第一个值
			var SIH1=this.array_search(SIHArray[0],switchIMEHotKey1Array);			
			$('switchIMEHotKey1').selectedIndex=SIH1;

			//选中第二个值
			var SIH2=this.array_search(SIHArray[1],switchIMEHotKey2Array);
			//alert('SIHArray[1]=' + SIHArray[1]);
			$('switchIMEHotKey2').selectedIndex=SIH2;
			
			
			//NowIMESwitchEnglishHotKey
			var NowIMESwitchEnglishHotKey1Array =new Array('Ctrl','Ctrl+Shift','左Alt+Shift');
			var NowIMESwitchEnglishHotKey2Array =new Array('Space','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
			var NowIMESwitchEnglishHotKey=changeparams['NowIMESwitchEnglishHotKey']; //得到的NowIMESwitchEnglishHotKey 值
			var NIMSArray=new Array();
			NIMSArray=NowIMESwitchEnglishHotKey.split('+');
			if (NIMSArray.length == 3) {//如果有三个值，证明有3个加号
				NIMSArray[0] = NIMSArray[0] +'+'+ NIMSArray[1];
				NIMSArray[1] = NIMSArray[2];
			}
			//选中第一个值
			var NIMS1=this.array_search(NIMSArray[0],NowIMESwitchEnglishHotKey1Array);			
			$('NowIMESwitchEnglishHotKey1').selectedIndex=NIMS1;

			//选中第二个值
			var NIMS2=this.array_search(NIMSArray[1],NowIMESwitchEnglishHotKey2Array);
			$('NowIMESwitchEnglishHotKey2').selectedIndex=NIMS2;
			
			
			//FullHalfWidthHotKey
			var FullHalfWidthHotKey1Array =new Array('Ctrl','Ctrl+Shift','左Alt+Shift');
			var FullHalfWidthHotKey2Array =new Array('Space','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
			var FullHalfWidthHotKey=changeparams['FullHalfWidthHotKey']; //得到的FullHalfWidthHotKey 值
			var FHWHArray=new Array();
			FHWHArray=FullHalfWidthHotKey.split('+');
			if (FHWHArray.length == 3) {//如果有三个值，证明有3个加号
				FHWHArray[0] = FHWHArray[0] +'+'+ FHWHArray[1];
				FHWHArray[1] = FHWHArray[2];
			}
			//选中第一个值
			var FHWH1=this.array_search(FHWHArray[0],FullHalfWidthHotKey1Array);			
			$('FullHalfWidthHotKey1').selectedIndex=FHWH1;

			//选中第二个值
			var FHWH2=this.array_search(FHWHArray[1],FullHalfWidthHotKey2Array);
			$('FullHalfWidthHotKey2').selectedIndex=FHWH2;
			

            $('IMEString').value=params;
		}else if(moudle==6){
			
			var keyArray=new Array('closeCDRom','brownseHere','CamouflageFolder','openWithNotepad','encryptFile','Defragging','copy2Folder','rebootComputer','openNowDirWithDos','shutDownComputer','move2Folder','clearRecycleBin');
			for(var i=0;i<keyArray.length;i++){
				
			 if(changeparams[keyArray[i]]==1){
			 	$(keyArray[i]).checked=true;
			 }
				
			}
			
		}else if(moudle==7){
			var win8_controls=changeparams['win8_control_param']; 
			if(parseInt(win8_controls)>0){ changeparams['win8_control_cb']=1;}else{ changeparams['win8_control_cb']=0;}
			for(var i=0;i<win8_controls.length;i++){
				var j=i+1;
				var getKey='win8_control'+j;
				changeparams[getKey]=win8_controls.substr(i,1);
				//alert(getKey+'='+changeparams[getKey]);
			}
			
			var win8_shortcutMenus=changeparams['win8_shortcutMenu_param'];
			if(parseInt(win8_shortcutMenus)>0){ changeparams['win8_scm_cb']=1; }else{ changeparams['win8_scm_cb']=0; }
			for(var i=0;i<win8_shortcutMenus.length;i++){
				var j=i+1;
				var getKey='win8_shortcutMenu'+j;
				changeparams[getKey]=win8_shortcutMenus.substr(i,1);
				//alert(getKey+'='+changeparams[getKey]);
			}
			
			var keyArray=new Array('win8_metro','win8_LockInterface','win8_metroBannedUninstall','win8_control1','win8_control2','win8_control3','win8_control4','win8_control5','win8_control6','win8_control7','win8_createShortcut','win8_addAdminOwnership','win8_shortcutMenu1','win8_shortcutMenu2','win8_shortcutMenu3','win8_shortcutMenu4','win8_shortcutMenu5','win8_shortcutMenu6','win8_shortcutMenu7','win8_shortcutMenu8','win8_shortcutMenu9','win8_shortcutMenu10','win8_shortcutMenu11','win8_shortcutMenu12','win8_shortcutMenu13','win8_scm_cb','win8_control_cb');
			for(var i=0;i<keyArray.length;i++){
			 if(changeparams[keyArray[i]]==1){
			 	$(keyArray[i]).checked=true;
			 }else{
			 	$(keyArray[i]).checked=false;
			 }
			}
			
		}
	},
	//页面中点“应用”按钮时调用
	//添加表单值
	//1,SystemSetOption1=1|param1=3@3@3|SystemSetOption2=0|SystemSetOption3=1| ...
	//2,win7Score=4.7|CPUScore=4.7|memScore=4.7|graphicScore=4.7|gameGraphicScore=4.7|diskScore=4.7
	//3,IEVersion=8.0|IETitle=aaa|IEDefaultOpenPage=http://www.haokan123.com|IEDefaultDownloadUrl=d:\download|IEDefaultSearchEngine=百度|ForbidIEDownloadFile=0
	//4,lnkFlag=1,2,3|param=图标索引|forbidCreateLnkText=1|desktopIconTransparent=1|clearInvalidIcon=1
	//5,defaultIME=aa|IMEOrder=aa;bb|switchIMEHotKey=左ALT+左SHIFT|NowIMESwitchEnglishHotKey=aaa|FullHalfWidthHotKey=aaa
	//6,closeCDRom=1|brownseHere=0|CamouflageFolder=0|openWithNotepad=0|encryptFile=0|Defragging=0|copy2Folder=0|rebootComputer=0|openNowDirWithDos=0|shutDownComputer=0|move2Folder=0|clearRecycleBin=0
	//7,win8_metro=1|win8_LockInterface=0|win8_metroBannedUninstall=0|win8_control=0|win8_control_param=0000000|win8_createShortcut=0|win8_addAdminOwnership=0|win8_shortcutMenu=0|win8_shortcutMenu_param=0000000000000
	 getValueFromPage: function(){
		var moudle;
		
		var tabSwitch0=$('Tab_Content_0').className;
		var tabSwitch1=$('Tab_Content_1').className;
		var tabSwitch2=$('Tab_Content_2').className;
		if(tabSwitch0=='ullistOn'){	//第一页面		
           moudle='1';
		   moudle+="||";
		   
		  //模块1
		  if($('SystemSetOption1').checked==true){ var SystemSetOption1='SystemSetOption1=1|param1='+$F('param1_1')+'@'+$F('param1_2')+'@'+$F('param1_3'); }else{  var SystemSetOption1='SystemSetOption1=0';}
		  moudle+=SystemSetOption1+'|';
		  for(var moudle1=2;moudle1<=32;moudle1++){
		  	 var param1='SystemSetOption'+moudle1;
		  	 if($('SystemSetOption'+moudle1).checked==true){ var param1=param1+'=1'; }else{  var param1=param1+'=0';}

			 	if (moudle1 == 32) {
					moudle += param1 ;
				}else{
					moudle += param1 + '|';
				}
		  }
		 
		  
		}else if(tabSwitch1=='ullistOn'){//第二页面
		   if ($('win7').style.display != "none"){
		  	 moudle='2|3|4|5';
		   } else {
		  	 moudle='3|4|5';
		   }
		   moudle+="||";
		   
		   
	      //模块2
		  //var win7Score='win7Score='+$F('win7Score');
		  if ($('win7').style.display != "none"){
			  var keyArray=new Array('win7Score','CPUScore','memScore','graphicScore','gameGraphicScore','diskScore');
				for(var i=0;i<keyArray.length;i++){
						var param2=keyArray[i];
						var param2=param2+'='+$F(param2);
			            moudle+=param2+'|';
				}
			  moudle+="|";
			}      
	
	      //模块3
		  var keyArray=new Array('IEVersion','IETitle','IEDefaultOpenPage','IEDefaultDownloadUrl','IEDefaultSearchEngine','ForbidIEDownloadFile');
			for(var i=0;i<keyArray.length;i++){
					var param3=keyArray[i];
					var param3=param3+'='+$F(param3);
		            moudle+=param3+'|';
			}
		  moudle+="|";
		  
		  
		  //模块4
		  var keyArray=new Array('lnkFlag','forbidCreateLnkText','desktopIconTransparent','clearInvalidIcon');
		  var IconIndex=$F('IconIndex');
		  for(var j=1;j<=3;j++){ 
		    var lnkFlag='lnkFlag_'+j;
		    if(j==2){
		      if($(lnkFlag).checked==true){ moudle+='lnkFlag='+j+'|param=' + IconIndex +'|'; }
		    }else{
		    	if($(lnkFlag).checked==true){ moudle+='lnkFlag='+j+'|'; }
		    }
		  }		
		  for(var i=1;i<keyArray.length;i++){
		  	 var param4=keyArray[i];
		  	 if($(param4).checked==true){ var param4=param4+'=1'; }else{  var param4=param4+'=0';}
			 moudle+=param4+'|';		  
		  }
		  moudle+="|";
		  
		  //模块5
		  var keyArray=new Array('defaultIME','IMEOrder','switchIMEHotKey','NowIMESwitchEnglishHotKey','FullHalfWidthHotKey');
		  for(var i=0;i<keyArray.length;i++){
				var param5=keyArray[i];
				//alert(param5);
				if(param5=='defaultIME'){
				  var param5Text=$(param5).options[($(param5).selectedIndex)].text;
				  param5=param5+'='+param5Text; 
				}else if(param5=='IMEOrder'){
					 // var defaultIME=$('defaultIME').options[($('defaultIME').selectedIndex)].text;
					//  alert('defaultIME='+defaultIME);
					//var IMEOrderLength=$('defaultIME').length;
					//alert('IMEOrderLength=' + IMEOrderLength);
					var IMEOrder="";
					for(var k=0;k<$('IMEOrder').length;k++){
	
						if (k == $('IMEOrder').length - 1) {
							IMEOrder += $('IMEOrder').options[k].text ;
						}
						else {
							IMEOrder += $('IMEOrder').options[k].text + ';' ;
						}
	
					}
					param5='IMEOrder='+IMEOrder;
				 
				}else{
				  var param5Text1=$(param5+'1').options[($(param5+'1').selectedIndex)].text;
				  var param5Text2=$(param5+'2').options[($(param5+'2').selectedIndex)].text;
				  if (param5Text1 == '未分配') {
				  	param5 = param5 + '=' + param5Text1 ;
				  }
				  else {
				  	param5 = param5 + '=' + param5Text1 + '+'+ param5Text2;
				  }
				}
	      //moudle+=param5+'|';
				if (keyArray[i] == 'FullHalfWidthHotKey') {
					moudle += param5 ;
				}else{
					moudle += param5 + '|';
				}
		  }
	     // moudle+="|";
		  
		  /*
	      //模块6
		  var keyArray=new Array('closeCDRom','brownseHere','CamouflageFolder','openWithNotepad','encryptFile','Defragging','copy2Folder','rebootComputer','openNowDirWithDos','shutDownComputer','move2Folder','clearRecycleBin');
		  for(var i=0;i<keyArray.length;i++){
				var param6=keyArray[i];
				if($(param6).checked==true){ var param6=param6+'=1'; }else{  var param6=param6+'=0';}
				if (keyArray[i] == 'clearRecycleBin') {
					moudle += param6 ;
				}else{
					moudle += param6 + '|';
				}
		  }
		  */
		}else if(tabSwitch2=='ullistOn'){	//第一页面		
       moudle='7';
		   moudle+="|";

		  //模块1
			  //var keyArray=new Array('win8_metro','win8_LockInterface','win8_metroBannedUninstall','win8_control1','win8_control2','win8_control3','win8_control4','win8_control5','win8_control6','win8_control7','win8_createShortcut','win8_addAdminOwnership','win8_shortcutMenu1','win8_shortcutMenu2','win8_shortcutMenu3','win8_shortcutMenu4','win8_shortcutMenu5','win8_shortcutMenu6','win8_shortcutMenu7','win8_shortcutMenu8','win8_shortcutMenu9','win8_shortcutMenu10','win8_shortcutMenu11','win8_shortcutMenu12','win8_shortcutMenu13');
		   var keyArray=new Array('win8_metro','win8_LockInterface','win8_metroBannedUninstall');           
		}
		moudle+=this.getMoudle(keyArray,'|');
		
		var keyArray=new Array('win8_control1','win8_control2','win8_control3','win8_control4','win8_control5','win8_control6','win8_control7');
		var win8_controls=this.getMoudle(keyArray,'');
		var getwin8_controls="";
		if(parseInt(win8_controls)>0){ var getwin8_controls='|win8_control=1';}else{ var getwin8_controls='|win8_control=0';}
		moudle+=getwin8_controls+'|win8_control_param='+win8_controls;
		
		var keyArray=new Array('win8_createShortcut','win8_addAdminOwnership');
		moudle+='|='+this.getMoudle(keyArray,'|');
		
		var keyArray=new Array('win8_shortcutMenu1','win8_shortcutMenu2','win8_shortcutMenu3','win8_shortcutMenu4','win8_shortcutMenu5','win8_shortcutMenu6','win8_shortcutMenu7','win8_shortcutMenu8','win8_shortcutMenu9','win8_shortcutMenu10','win8_shortcutMenu11','win8_shortcutMenu12','win8_shortcutMenu13');
		var win8_shortcutMenus=this.getMoudle(keyArray,'');
		var getwin8_shortcutMenus="";
		if(parseInt(win8_shortcutMenus)>0){ var getwin8_shortcutMenus='|win8_shortcutMenu=1';}else{ var getwin8_shortcutMenus='|win8_shortcutMenu=0';}
		moudle+=getwin8_shortcutMenus+'|win8_shortcutMenu_param='+this.getMoudle(keyArray,'');
		
	  //alert(moudle);
	  return moudle;
	  
	},
	getMoudle: function(keyArray,sign){//win8个性设置得到参数
		    var moudle='';
				for(var i=0;i<keyArray.length;i++){
					  var param="";
						var param6=keyArray[i];
						if($F(param6)){
							param=$F(param6);
						}else{
							param=0;
						}
						
						if(sign=='|'){
							var param6='|'+param6+'='+param;
						}else{
							var param6=param;
						}
			      moudle+=param6;
				}
				return moudle;
	},
	moveup: function(){
		var selIndex=$('IMEOrder').selectedIndex;
		if(selIndex!=0){
			var selValue=$('IMEOrder').options[selIndex].value;
			var selText=$('IMEOrder').options[selIndex].text;
			$('IMEOrder').options[selIndex].value=$('IMEOrder').options[selIndex-1].value;
			$('IMEOrder').options[selIndex].text =$('IMEOrder').options[selIndex-1].text;
			$('IMEOrder').options[selIndex-1].value=selValue;
			$('IMEOrder').options[selIndex-1].text =selText;
			$('IMEOrder').selectedIndex=selIndex-1;
		}
	},
	
	movedown: function(){
		var selIndex=$('IMEOrder').selectedIndex;
		var optionLength=$('IMEOrder').options.length-1;
		if(selIndex!=optionLength){
			var selValue=$('IMEOrder').options[selIndex].value;
			var selText=$('IMEOrder').options[selIndex].text;
			$('IMEOrder').options[selIndex].value=$('IMEOrder').options[selIndex+1].value;
			$('IMEOrder').options[selIndex].text =$('IMEOrder').options[selIndex+1].text;
			$('IMEOrder').options[selIndex+1].value=selValue;
			$('IMEOrder').options[selIndex+1].text =selText;
			$('IMEOrder').selectedIndex=selIndex+1;
		}
	},
	//根据键值取数组键名
	array_search: function(value,array){
		
	  for(var i=0;i<array.length;i++){
	  	if(array[i]==value){
			return i;
		}		
	  }
	},
	GetIconIndex: function(){
		window.navigate('ExecCmd=GetIconIndex');
		//alert('更改成功！');
	},
	setIconIndex: function(IconIndex){
		$('IconIndex').value=IconIndex;
	},
	win7individuation: function(type){
		if(type=='0'){
			$('win7').hide();
			$('win7').style.display = "none";
		}else if(type=='1'){
			$('win7').show();
			$('win7').style.display = "block";
		}		
	},
	getIEDefaultDownloadUrl: function(){
		window.navigate('ExecCmd=getIEDefaultDownloadUrl');
	},
	setIEDefaultDownloadUrl: function(text1){
		$('IEDefaultDownloadUrl').value=text1;
	},
	//输入法/快捷方式/确定
	setIMESelected: function(){
	  //模块5
	  var moudle;
	  var keyArray=new Array('defaultIME','IMEOrder','switchIMEHotKey','NowIMESwitchEnglishHotKey','FullHalfWidthHotKey');
	  for(var i=0;i<keyArray.length;i++){
			var param5=keyArray[i];
			//alert(param5);
			if(param5=='defaultIME'){
			  var param5Text=$(param5).options[($(param5).selectedIndex)].text;
			  param5=param5+'='+param5Text; 
			}else if(param5=='IMEOrder'){
				 // var defaultIME=$('defaultIME').options[($('defaultIME').selectedIndex)].text;
				//  alert('defaultIME='+defaultIME);
				//var IMEOrderLength=$('defaultIME').length;
				//alert('IMEOrderLength=' + IMEOrderLength);
				var IMEOrder="";
				for(var k=0;k<$('IMEOrder').length;k++){

					if (k == $('IMEOrder').length - 1) {
						IMEOrder += $('IMEOrder').options[k].text ;
					}
					else {
						IMEOrder += $('IMEOrder').options[k].text + ';' ;
					}

				}
				param5='IMEOrder='+IMEOrder;
			 
			}else{
			  var param5Text1=$(param5+'1').options[($(param5+'1').selectedIndex)].text;
			  var param5Text2=$(param5+'2').options[($(param5+'2').selectedIndex)].text;
			  if (param5Text1 == '未分配') {
			  	param5 = param5 + '=' + param5Text1 ;
			  }
			  else {
			  	param5 = param5 + '=' + param5Text1 + '+Shift';
			  }
			}
      //moudle+=param5+'|';
			if (keyArray[i] == 'FullHalfWidthHotKey') {
				moudle += param5 ;
			}else{
				moudle += param5 + '|';
			}
	  }
	  
	  $('IMEString').value=moudle;
	  
	},
	len: function(s) { 	
		if(s.length>=4){
		kk=s.substr(0,4)+ '...';
		}else{
		kk=s;
		}
		return kk;
	} ,
	OpenOldMagicSet: function(){
		window.navigate('ExecCmd=OpenOldMagicSet');
	},
	checkall: function(module, num){
		if (module == 1) {
			if (num == 0) {
				for (var j = 1; j <= 8; j++) {
					$('SystemSetOption' + j).checked = true;
				}
			}
			else 
				if (num == 1) {
					for (var j = 1; j <= 8; j++) {
						$('SystemSetOption' + j).checked = !$('SystemSetOption' + j).checked;
					}
				}
			
			$('system0').className="textopen";
			$('system0_description').className='tab_on';			
		}
		else 
			if (module == 2) {
				if (num == 0) {
					for (var j = 9; j <= 32; j++) {

						if($('SystemSetOption' + j).disabled==true){
							 continue;
						}
						$('SystemSetOption' + j).checked = true;
					}
				}
				else 
					if (num == 1) {
						for (var j = 9; j <= 32; j++) {
							if($('SystemSetOption' + j).disabled==true){
								 continue;
							}
							$('SystemSetOption' + j).checked = !$('SystemSetOption' + j).checked;
						}
					}
			}	
			$('system').className="textopen";		
			$('system_description').className='tab_on';
		
	},
	check_all: function(option){
      var optionValue=$F($(option));
      var inputs=document.getElementsByName(option+'s');
			if (optionValue == 0) {
				for (var j = 0; j < inputs.length; j++) {
					inputs[j].checked = true;
				}
				$(option).value=1;
			}
			else{
					for (var j = 0; j < inputs.length; j++) {
						inputs[j].checked = false;
					}
					$(option).value=0;
			}
	},
	 check_one: function(option){//二级选项判断一级选项
      var optionValue=$F($(option));
      var inputs=document.getElementsByName(option+'s');
      var cnt=0;
			for (var j = 0; j < inputs.length; j++) {
					if(inputs[j].checked == true){
						 cnt++;
					}
			}
			
			if(cnt>0){
				  $(option).checked=true;
				  $(option).value=1;
			}else{
				  $(option).checked=false;
				  $(option).value=0;
			}
	},
	commend: function(){//推荐
		var tabSwitch0=$('Tab_Content_0').className;
		var tabSwitch1=$('Tab_Content_1').className;
		var tabSwitch2=$('Tab_Content_2').className;
		if(tabSwitch0=='ullistOn'){			
			this.setValue2Page(1,'SystemSetOption1=1|param1=3@3@3|SystemSetOption2=1|SystemSetOption3=1|SystemSetOption4=1|SystemSetOption5=0|SystemSetOption6=1|SystemSetOption7=1|SystemSetOption8=0|SystemSetOption9=1|SystemSetOption10=1|SystemSetOption11=1|SystemSetOption12=1|SystemSetOption13=0|SystemSetOption14=0|SystemSetOption15=0|SystemSetOption16=1|SystemSetOption17=1|SystemSetOption18=0|SystemSetOption19=0|SystemSetOption20=0|SystemSetOption21=0|SystemSetOption22=0|SystemSetOption23=1|SystemSetOption24=1|SystemSetOption25=1|SystemSetOption26=0|SystemSetOption27=0|SystemSetOption28=0|SystemSetOption29=0|SystemSetOption30=0|SystemSetOption31=1|SystemSetOption32=1');
			var commendArray1= new Array('ForbidIEDownloadFile','lnkFlag_3','forbidCreateLnkText','desktopIconTransparent');
			for(var i=0;i<=commendArray1.length-1;i++){
				$(commendArray1[i]).checked=true;
			}
			
		}else if(tabSwitch1=='ullistOn'){
			var commendArray2= new Array('lnkFlag_1','lnkFlag_2','clearInvalidIcon');
			for(var j=0;j<=commendArray2.length-1;j++){
				$(commendArray2[j]).checked=false;
			}
			$('switchIMEHotKey1').selectedIndex=1;
			$('switchIMEHotKey2').selectedIndex=1;		
		}else if(tabSwitch2=='ullistOn'){
			this.setValue2Page(7,'win8_metro=1|win8_LockInterface=1|win8_metroBannedUninstall=0|win8_control=1|win8_control_param=0111111|win8_createShortcut=1|win8_addAdminOwnership=1|win8_shortcutMenu=1|win8_shortcutMenu_param=1110111101111');
		}

	},
	setSystemOptionCheckValue: function(strings, checkValue){//strings=a1,a2,a3
		 var strArray=new Array();
		 strArray=strings.split(',');
		 if (checkValue==0) {
			 for(var k=0;k<strArray.length;k++){
			 	 $('SystemSetOption'+strArray[k]).disabled=true;		 	 
	     }
	     $('IMERestart').hide();
	   } else if (checkValue==1) {
	   	for(var k=0;k<strArray.length;k++){
			 	 $('SystemSetOption'+strArray[k]).disabled=false;		 	 
	     }
	     $('IMERestart').show();
	   }		 	
	 },
	 setLnkPic: function(param){
	 	 if(param==0){
	 	    $('viewPic').disabled=true;
	 	 }else if(param==1){
	 		  $('viewPic').disabled=false;
	 	 }
	},
		selectdControl: function(){//选未分配是第二个选项是空格，其他是 '+Shift'
			  var param5Text1=$('switchIMEHotKey1').options[($('switchIMEHotKey1').selectedIndex)].text;
			  if (param5Text1 == '未分配') {
			  	$('switchIMEHotKey2').selectedIndex=0;
			  }
			  else {
			  	$('switchIMEHotKey2').selectedIndex=1;
			  }
			  $('switchIMEHotKey2').disabled=true;
		
	},
	 win8Set:function(){//win8设置
	 		 	$('win8Set').innerHTML="<span title='当前非win8系统不可用' class='fontGray'>win8个性设置</span>";
	 }
}
mbDocument.load();
//document.oncontextmenu=new Function("event.returnValue=false;");
//document.onselectstart=new Function("event.returnValue=false;");
