﻿//防止IFRAME加载
if(top.location != self.location){
	top.location.href = 'http://ent.khews.com';
};

Ext.namespace("Main");
Ext.BLANK_IMAGE_URL = 'ext/resources/images/default/s.gif';//设定Ext占位图片路径

//未登陆处理
Main.Part1 = function(){
	
	//定义公共函数
	return {
		/**
		 * 初始方法
		 */
		init : function(){
			 document.title = Main.lang.Ews;
			 if(WebService.Loading){
		     	 this.loadHtml();
		     	 this.progressFlag = true;//停止显示进度条标记
		     }else{
		     	this.init.defer(50,this);
		     };
		},
			
		
		/**
		 * 加载加载页面内容
		 */
		loadHtml : function(){
			Ext.Ajax.request({
				url:'default/Default01.html',
				scope:this,
				callback:this.setForm,
				disableCaching:false
			});
			
			Ext.getDom('copyright').innerHTML = Main.lang.Copyright;
		},
		
		
		/**
		 * 设定表单
		 */
		setForm : function(options , success , response){
			var tpl = new Ext.XTemplate(response.responseText);
			tpl.overwrite(Ext.getDom('wrapper'), Main.lang);
			
			Ext.get('login_container').select('ul',true).elements[0].addClass(Main.currLang);
			
			var Ecom_User_ID = new Ext.form.TextField({
				 id:'Ecom_User_ID',
				 allowBlank:false,
				 blankText:Main.lang.Ecom_User_ID_label, 
				 emptyText:Main.lang.Ecom_User_ID_label,
				 applyTo:'Ecom_User_ID',
//				 vtype:'alphanum'
				 enableKeyEvents:true
			});
			
			var Ecom_User_Password = new Ext.form.TextField({
				 id:'Ecom_User_Password',
				 applyTo:'Ecom_User_Password',
				 blankText : Main.lang.Ecom_User_Password_label,
				 allowBlank : false,
				 inputType:'password',
				 enableKeyEvents:true
			});
			
			var Ecom_SchemaVersion = new Ext.form.TextField({
				 id:'Ecom_SchemaVersion',
				 allowBlank:false,
				 blankText:Main.lang.Ecom_SchemaVersion_error, 
				 applyTo:'Ecom_SchemaVersion',
				 vtype:'alphanum',
				 enableKeyEvents:true
			});
			
			new Ext.form.TextField({
				id:'forgetAccount',
				allowBlank:false,
				blankText:Main.lang.Ecom_User_ID_label,
				emptyText:Main.lang.Ecom_User_ID_label,
				applyTo:'forgetAccount',
				vtype:'alphanum'
			});
			
			new Ext.form.TextField({
				id:'foretEmail',
				allowBlank:false,
				blankText:Main.lang.ForgetEmail,
				emptyText:Main.lang.ForgetEmail,
				applyTo:'foretEmail',
				vtype:'email'
			});
			
			Ecom_User_ID.on('focus' , function(){
				if( Ecom_User_ID.validate() ){
					var html = Main.lang.Ecom_User_ID_label;	
				}else{
					var html = Main.lang.Ecom_User_ID_error;
				};
				
				var obj = Ext.get('Ecom_User_ID').next('p');
				obj.query('strong')[0].innerHTML = html;
				obj.setDisplayed(true);
				Ext.get('errorMsg_wd').setDisplayed(false);
				this.unDispForgetPass();
			},this);
			
			Ecom_User_ID.on('blur' , function(){
				Ext.get('Ecom_User_ID').next('p').setDisplayed(false);
			});
			
			Ecom_User_ID.on('keypress',this.keyenter,this);
			
			Ecom_User_Password.on('focus' , function(){
				var obj = Ext.get('Ecom_User_Password').next('p');
				obj.query('strong')[0].innerHTML = Main.lang.Ecom_User_Password_label;
				obj.setDisplayed(true);
				Ext.get('errorMsg_wd').setDisplayed(false);
				this.unDispForgetPass();
			},this);
			
			Ecom_User_Password.on('blur' , function(){
				Ext.get('Ecom_User_Password').next('p').setDisplayed(false);
			});
			
			Ecom_User_Password.on('keypress',this.keyenter,this);
			
			Ecom_SchemaVersion.on('focus' , function(){
				var obj = Ext.get('Ecom_SchemaVersion').next('p');
				obj.query('strong')[0].innerHTML = Main.lang.Ecom_SchemaVersion_label;
				obj.setDisplayed(true);
				Ext.get('errorMsg_wd').setDisplayed(false);
				this.unDispForgetPass();
			},this);
			
			Ecom_SchemaVersion.on('blur' , function(){
				Ext.get('Ecom_SchemaVersion').next('p').setDisplayed(false);
			});
			
			Ecom_SchemaVersion.on('keypress',this.keyenter,this);
			
			Ecom_SchemaVersion.on('keyup',function(el,event){
				el.setValue(el.getValue().toUpperCase());
			});
			
			Ext.get('loginSubmit').on('click',this.switchVersion,this,{stopEvent:true,ver:'2.0'});
			
			Ext.get('errorMsg_btn').on('click', function(){
				Ext.get('errorMsg_wd').setDisplayed(false);
			});
			
			//绑定刷新验证码
			Ext.get('CheckCode').on('click' , this.refreshCode , null , {stopEvent:true});
			Ext.get('RefreshCode').on('click' , this.refreshCode , null , {stopEvent:true});
			
			//绑定忘记密码
			Ext.get('LoastPass').on('click' , this.dispForgetPass , this , {stopEvent:true});
			Ext.get('ForgetPassword').on('click' , this.dispForgetPass , this , {stopEvent:true});			
			Ext.get('forget_close').on('click' , this.unDispForgetPass);
			Ext.get('forget_btn').on('click' , this.sendEmail , this);
			
			var langLi = Ext.get('login_container').select('ul>li',true).elements;
			langLi[0].on('click',this.changeLang,this,{stopEvent:true,lang:'zh-cn'});
			langLi[1].on('click',this.changeLang,this,{stopEvent:true,lang:'zh-tw'});
			
			Ext.get('SwitchVersion').on('mouseover',this.switchVersionTips);
			Ext.get('SwitchVersion').on('mouseout',this.switchVersionTips);
			Ext.get('SwitchVersion').on('click',this.switchVersion,this,{stopEvent:true,ver:'1.0'});
			
			Main.setCookie("EWS.Ver",'2.0');//写入Cookie 当前登入版本
		},
		
		/**
		 * 切换版本入口提示隐藏/显示
		 */
		switchVersionTips : function(){
			Ext.get('SwitchVersion_Tips').toggle();
		},
		
		/**
		 * 切换版本入口
		 * @param {Object} event
		 * @param {Object} target
		 * @param {Object} option
		 */
		switchVersion : function(event , target , option){
			Main.setCookie("EWS.Ver",option.ver);//写入Cookie 当前登入版本
			this.submitFn();
		},
		
		/**
		 * 切换语言
		 * @param {object} event
		 * @param {object} target
		 * @param {object} option
		 */
		changeLang : function(event , target , option){
			window.location = 'default.cfm?lang='+option.lang;
		},
		
		/**
		 * 按键：回车提交表单
		 * @param {object} el
		 * @param {object} event
		 */
		keyenter : function(el,event){
			//按键：回车 响应表单提交
			if(event.getKey() == 13){
				this.submitFn();
			};
		},
		
		
		/**
		 * 刷新验证码
		 */
		refreshCode : function(){
			Ext.getDom('EWS_VeryCode').src = 'http://'+Main.lang.EWSServer+'/EWS_VeryCode.cfm?'+new Date();
			this.blur();
		},
		
		
		/**
		 * 显示忘记密码表单
		 */
		dispForgetPass : function(){
			Ext.get('recoverPass').setDisplayed(true);
			Ext.get('errorMsg_wd').setDisplayed(false);
		},
		
		
		/**
		 * 隐藏忘记密码表单
		 */
		unDispForgetPass : function(){
			Ext.get('recoverPass').setDisplayed(false);
			Ext.get('recoverPass').query('legend>span')[0].innerHTML = Main.lang.GetPassword;
		},
		
		
		/**
		 * 表交提交
		 */
		submitFn : function(){
			var isValid = false;
			var errorMsg_wd = Ext.get('errorMsg_wd');
			var li = errorMsg_wd.query('li');
			
			this.unDispForgetPass();			
			
			if( !Ext.getCmp('Ecom_User_ID').validate() ){
				isValid = true;
				li[0].style.display = '';
			}else{
				li[0].style.display = 'none';
			};
			
			if( !Ext.getCmp('Ecom_User_Password').validate() ){
				isValid = true;
				li[1].firstChild.innerHTML = Main.lang.Ecom_User_Password_label;
				li[1].style.display = '';
			}else{
				li[1].style.display = 'none';
			};
			
			if( !Ext.getCmp('Ecom_SchemaVersion').validate() ){
				isValid = true;
				li[2].firstChild.innerHTML = Main.lang.Ecom_SchemaVersion_label;
				li[2].style.display = '';
			}else{
				li[2].style.display = 'none';
			};
			
			errorMsg_wd.setDisplayed(isValid);
			
			if(!isValid){
				Ext.get('login_container').setDisplayed(false);
				Ext.get('loginbg').setDisplayed(true);
				this.progressBar();
				this.url = Main.lang.EWSServer;
				this.postInfo();
			};
		},
		
		
		/**
		 * 提交表单数据
		 */
		postInfo : function(){
			WebService.Request({
			    gateWay:"http://"+this.url+"/flashservices/gateway",
				service:"KeFuOnline.ServerLogin_ews",
				method:"Login",
				arguments:[ Ext.getDom("Ecom_User_ID").value , Ext.getDom("Ecom_User_Password").value , Ext.getDom("Ecom_SchemaVersion").value ],
				scope:this,
				onResult:function(id , result){
					this.showMessage(result);
				}
				,onFault: Main.WS_onFault
			});
		},
		
		
		/**
		 * 表交提交响应
		 * @param {Object} result
		 */
		showMessage : function(result){
			var val = parseInt(result["val"],10);
			var errorMsg_wd = Ext.get('errorMsg_wd');
			var li = errorMsg_wd.query('li');
			this.progressFlag = false;//停止显示进度条标记

			Ext.each(li , function(item){
				item.style.display = 'none';
			});
			
			if(val != 0){
				Ext.get('login_container').setDisplayed(true);
				Ext.get('loginbg').setDisplayed(false);
				this.progressFlag = false;//停止进度条处理
			};
			switch (val) {
				case 0://登入成功
					Main.setCookie("EWS",this.url);//写入Cookie
					Main.setCookie("EWS_TRYINFO", Ext.util.JSON. encode(result.TryInfo) );//写入Cookie
					Main.setCookie("accounts", Ext.getDom("Ecom_User_ID").value );//帐号写入Cookie
					//资料管理系统Cookie记录
					WebService.Request({
						gateWay:'http://'+this.url+'/ResourceManager/Gateway.aspx',
						service : "RMDao.CompanySvrInfo",
						method : "SaveCIDCookie_UpLoad",
						arguments : [{eid:Ext.getDom("Ecom_User_ID").value,password:Ext.getDom("Ecom_User_Password").value}],
						scope : this,
						onResult :function(id,data){
						}
					});
					
					//注销，释放内存
					Ext.destroy(
						Ext.getCmp('Ecom_User_ID'),
						Ext.getCmp('Ecom_User_Password'),
						Ext.getCmp('Ecom_SchemaVersion'),
						Ext.get('loginSubmit'),
						Ext.get('errorMsg_btn'),
						Ext.get('CheckCode'),
						Ext.get('RefreshCode'),
						Ext.get('LoastPass'),
						Ext.get('ForgetPassword'),
						Ext.get('forget_close'),
						Ext.get('forget_btn')
					);
					
					Main.TryInfo = result.TryInfo;//记录试用帐号信息
					Main.Part2.init();
					break;
				
				case 1://帐号与密码不正确
					li[0].firstChild.innerHTML = Main.lang.AccountError;
				    li[0].style.display = '';
				    errorMsg_wd.setDisplayed(true);
					break;
					
				case 2://验证码不正确
				    li[2].firstChild.innerHTML = Main.lang.VeryCodeError;
				    li[2].style.display = '';
				    errorMsg_wd.setDisplayed(true);
					break;
					
				case 3://帐号不可使用
			        li[0].firstChild.innerHTML = Main.lang.AccountStop;
				    li[0].style.display = '';
				    errorMsg_wd.setDisplayed(true);
					break;
					
				case 4://重复登入
				    li[0].firstChild.innerHTML = Main.lang.HasLogin;
				    li[0].style.display = '';
				    errorMsg_wd.setDisplayed(true);
					break;
					
				case 5://试用用户过期
					this.trayaccountsOut(result);
					break;
					
				case 999://正式用户过期
					this.accountsOut();
					break;
			};
		},
		
		
		 /**
		  * 等待进度条
		  */
		 progressBar : function(){
		 	//判断：停止显示进度条标记
		 	if(!this.progressFlag){
		 		return;
		 	};
		 	
		 	var obj = Ext.get('loginbg').query('div')[0];

		 	switch(obj.style.width){
		 		case '0%':
		 			obj.style.width = '10%';
		 			break;
		 	    case '100%' :
			 		obj.style.width = '10%';
			 		break;
			 	case '10%' :
			 		obj.style.width = '20%';
			 		break;
		 		case '20%' :
			 		obj.style.width = '30%';
			 		break;
		 		case '30%' :
			 		obj.style.width = '40%';
			 		break;
			 	case '40%' :
			 		obj.style.width = '50%';
			 		break;
			 	case '50%' :
			 		obj.style.width = '60%';
			 		break;
			 	case '60%' :
			 		obj.style.width = '70%';
			 		break;
		 		case '70%' :
			 		obj.style.width = '80%';
			 		break;
			 	case '80%' :
			 		obj.style.width = '90%';
			 		break; 
			 	case '90%' :
			 		obj.style.width = '100%';
			 		break;
		 	};
	
		 	this.progressBar.defer(300,this);
		 },
		 
		 /**
		  * 发送忘记密码邮件
		  */
		 sendEmail : function(){
			if( !Ext.getCmp('forgetAccount').validate() ){
				Ext.get('recoverPass').query('legend>span')[0].innerHTML = Main.lang.Ecom_User_ID_error;
				return;
			};
			
			if( !Ext.getCmp('foretEmail').validate() ){
				Ext.get('recoverPass').query('legend>span')[0].innerHTML = Main.lang.ForgetEmailError;
				return;
			};

			WebService.Request({
				gateWay:"http://"+Main.lang.EWSServer+"/flashservices/gateway",
				service:"KeFuOnline.ServerLogin_ews",
				method:"Forget",
				arguments:[Ext.getDom('forgetAccount').value , Ext.getDom('foretEmail').value , Main.currLang],
				scope:this,
				onResult:function(id , result){						 
					 if(result==1){
					    Ext.get('recoverPass').query('legend>span')[0].innerHTML = Main.lang.ForgetSuccess;
					 }else{
					 	Ext.get('recoverPass').query('legend>span')[0].innerHTML = Main.lang.ForgetEmailFaild;
					 };
				},
				onFault: Main.WS_onFault
		   });

		}
		
		//正式用户帐号过期
		,accountsOut : function(){
			window.location.href = 'accountExpired/index.html';
		}
		
		//试用户帐号过期
		,trayaccountsOut : function(result){
			Ext.Ajax.request({
				url: 'default/default05.html',
				scope: this,
				callback: function(options, success, response){
					var time = result.CDate||new Date();
					var CID = result.TryInfo.CID||'';
					//计算资料保存时间
					if (typeof(time) == 'object') {						
						time.setTime(time.getTime()+30*24*60*60*1000);
//						time = time.getFullYear()+"-"+(time.getMonth()+1)+"-"+time.getDate();
					}
					
					var accounts = Ext.get('Ecom_User_ID').getValue();
//					Main.lang.TryInfo['3'] = time ;
					Main.lang.TryInfo['31'] = time.getFullYear() ;
					Main.lang.TryInfo['32'] = time.getMonth()+1 ;
					Main.lang.TryInfo['33'] = time.getDate() ;					
					Main.lang.TryInfo['7'] = accounts;
					
					var tpl = new Ext.XTemplate(response.responseText);
					var body = Ext.getBody();
					var div = body.createChild([{
						tag: 'div',
						cls: 'coverbg'
					},{
						tag:'div'
						,cls:'EWS_experience EWS_experience1'
						,html: tpl.applyTemplate(Main.lang.TryInfo)
					}]);
					
					div.select('a',true).elements[0].on('click',function(e,target,options){
						window.open("http://ent.khews.com/ews_createTestAccount/GotoPay.aspx?CID="+CID);
					},div,{stopEvent:true});
				},
				disableCaching: false
			});
		}
	}
}();


/*
 * 写入Cookie
 * @param {string} name
 * @param
 */
Main.setCookie = function(name , value){
	document.cookie=name+"="+value+"; path=/";
};


/*
 * 读取Cookie
 * @param {string} name
 */
Main.getCookie = function(name){
var search = name + "=";
  
	if (document.cookie.length > 0) {
		var offset = document.cookie.indexOf(search);
		
		if (offset != -1) {
		    offset += search.length;
		     
		     var end = document.cookie.indexOf(";", offset);
		     
		     if (end == -1){ 
		        end = document.cookie.length;
		     };
		     
		     return unescape(document.cookie.substring(offset, end));
		};
	};
};


/**
 * 删除名称为name的Cookie  
 * @param {String} name
 */
Main.delCookie = function(name){
    var date = new Date();
    date.setTime(date.getTime() - 10000);//为了删除指定名称的cookie，可以将其过期时间设定为一个过去的时间
    document.cookie = name + "=a; expires=" + date.toGMTString();
};


Main.WS_onFault = function(){
	alert("通信失败！");
};


//已登陆处理
Main.Part2 = function(){
	return {
		/**
		 * 初始方法
		 */
		init : function(){
			if(WebService.Loading){
		     	 this.loadInfo();
		     }else{
		     	this.init.defer(50,this);
		    };
		},
		
		/**
		 * 加载企业资料
		 */
		loadInfo : function(){
			WebService.Request({
				gateWay : "http://" + Main.getCookie('EWS') + "/flashservices/gateway",
				service : "WebSite.PublicFunction",
				method  : "GetCompanyInfo",
				scope   : this,
				onResult: function(id, result) {
					this.loadHtml(result);
				},
				onFault : Main.WS_onFault
			});
		},
		
		/**
		 * 加载页面内容
		 * @param {String} CInfo 企业资料
		 */
		loadHtml : function(CInfo){
			if (Main.getCookie("EWS.Ver") == '1.0') {
				var htmlUrl = 'default/Default03.html';//旧版本处理
			}else{
				var htmlUrl = '/default/Default02.html';//新版本处理
			};
					

			Ext.Ajax.request({
				url:htmlUrl,
				scope:this,
				  callback:function(options , success , response){
						this.setFormByNewVer(response.responseText , CInfo);
				},
				disableCaching:false
			});
		},
		
		/**
		 * 设定表单(新版处理)
		 * @param {String} responseText
		 * @param {Object} CInfo
		 */
		setFormByNewVer : function(responseText , CInfo){
			Main.Part1.progressFlag = false;//停止进度条处理
			Ext.get('wrapper').update('');//清空
			
			var tpl = new Ext.XTemplate(responseText);
			tpl.overwrite(Ext.getDom('wrapper'), Main.lang);
			
			Ext.query('div[class=successMain]>h2')[0].innerHTML = CInfo["CName"];
			Main.setCookie('CID',CInfo["CID"]);
			if(Main.TryInfo == undefined){
				Main.TryInfo = Ext.util.JSON.decode(Main.getCookie("EWS_TRYINFO"));
			}

			var ews_istry = parseInt(Main.TryInfo.IsTry, 10);
			
			//显示试用帐号信息
			if (ews_istry == 1) {
				Ext.Ajax.request({
					url: 'default/default04.html',
					scope: this,
					callback: function(options, success, response){
						//读取cookies,读取内容包括：
						var time = Main.TryInfo.CDate;
						if(typeof(time) == 'string'){
							time = Main.TryInfo.CDate.split('T')[0];
						}else{
							var year = time.getFullYear().toString();
							var m = time.getMonth() + 1;
							var month = (m < 10) ? '0' + m : m;
							var d = time.getDate();
							var day = (d < 10) ? '0' + d : d;
							time = year+"-"+month+"-"+day;
						}
						Main.lang.TryInfo['5'] = window.location.href.indexOf('ent1')>0?"http://ent1.khews.com/":"http://ent.khews.com/";
						Main.lang.TryInfo['3'] = time ;
						Main.lang.TryInfo['9'] = Main.TryInfo.PAS;
						
						var EID = Main.TryInfo.EID;
						Main.lang.TryInfo['7'] = EID;
						
						var tpl = new Ext.XTemplate(response.responseText);
						var body = Ext.get('wrapper');
//						var body = Ext.getBody();
						var div = body.createChild({
							tag: 'div',
							cls: 'EWS_experience',
							html: tpl.applyTemplate(Main.lang.TryInfo)
						});
						
						div.select('a',true).elements[0].on('click',function(e,target,options){
							window.location.href="http://ent.khews.com/ews_createTestAccount/GotoPay.aspx?CID="+Main.getCookie("CID");
							//this.remove();
						},div,{stopEvent:true});
					},
					disableCaching: false
				});
			}
			
			//此帐号为EWS标准建站版，隐藏与建站无关功能
			if (ews_istry == 3) {
					//在线考勤
					Ext.get('title3').setDisplayed(false);
					
					//物品管理
					Ext.get('title4').setDisplayed(false);
					
					//立体广告
					Ext.get('title6').setDisplayed(false);
					
					//易度
					Ext.get('title7').setDisplayed(false);
					
					//支付系统
					if(Ext.get('title12')){
						Ext.get('title12').setDisplayed(false);
					}
			}

			//绑定移入效果
			Ext.each( Ext.select('div[class=menu] li h3' , true).elements , function(item){
				item.on('mouseover', this.liOver , this , {stopEvent:true , id: item.dom.parentNode.id});
			},this);
			
			//绑定产品手册
			Ext.each( Ext.select('div[class=menu] li a:nth-child(2)' , true).elements , function(item){
				item.on('click',this.DownHelp,this,{stopEvent:true});
			} ,this);
			
			new Ext.form.TextField({
				 id:'CompanyPass',
				 applyTo:'CompanyPass',
				 allowBlank : false,
				 inputType:'password'
			});
			
			//绑定帮助
			Ext.select('ul[class=serviceList]>li>a[class=help]',true).elements[0].on('click',this.DownHelp,this,{stopEvent:true});
			
			if (Main.getCookie("EWS.Ver") == '1.0') {
			//旧版本处理
				//打开建站
				Ext.get('title0').select('a:first-child' , true).elements[0].on('click',this.oldWebSite,this,{stopEvent:true});
				
			}else{
			//新版本处理

				//打开建站
				Ext.get('title1').select('a:first-child' , true).elements[0].on('click',this.service1,this,{stopEvent:true});
				
				//打开网站监测
				Ext.get('title2').select('a:first-child' , true).elements[0].on('click',this.service2,this,{stopEvent:true});
				
				//打开线上考勤
				if(Ext.get('title3')){
					Ext.get('title3').select('a:first-child' , true).elements[0].on('click',this.service3,this,{stopEvent:true});
				}
				
				//打开物品管理
				if(Ext.get('title4')){
					Ext.get('title4').select('a:first-child' , true).elements[0].on('click',this.service4,this,{stopEvent:true});
				};
				
				//打开商品发布
				Ext.get('title5').select('a:first-child' , true).elements[0].on('click',this.service5,this,{stopEvent:true});
				
				//打开海报系统
				if(Ext.get('title6')){
					Ext.get('title6').select('a:first-child' , true).elements[0].on('click',this.service6,this,{stopEvent:true});
				};
				
				//打开ED.易度在线
				if(Ext.get('title7')){
					Ext.get('title7').select('a:first-child' , true).elements[0].on('click',this.service7,this,{stopEvent:true});
				};
				
				//打开商务管理
				if(Ext.get('title8')){
					Ext.get('title8').select('a:first-child' , true).elements[0].on('click',this.service8,this,{stopEvent:true});
				}
				//打开信息发布
				Ext.get('title9').select('a:first-child' , true).elements[0].on('click',this.service9,this,{stopEvent:true});
				
				//打开会员管理
				Ext.get('title10').select('a:first-child', true).elements[0].on('click', this.service10, this, {
					stopEvent: true
				});
				
				//打开资源管理
				Ext.get('title11').select('a:first-child', true).elements[0].on('click', this.service11, this, {
					stopEvent: true
				});
				
				//支付系统
				if(Ext.get('title12')){
					Ext.get('title12').select('a:first-child', true).elements[0].on('click', this.service12, this, {
						stopEvent: true
					});
				};
				
				
				
 Ext.getDom('copyright').innerHTML = Main.lang.Copyright;
			};
			
			
			//显示企业资料密码输入框
			Ext.select('ul[class=serviceList]>li:nth-child(1)>a',true).elements[0].on('click',this.setDisplayCompany,this,{stopEvent:true,disp:true});
			
			//隐藏企业资料密码输入框
			Ext.select('fieldset[class=enterprise_wd]>button',true).elements[0].on('click',this.setDisplayCompany,this,{stopEvent:true,disp:false});
			
			//验证企业密匙
			Ext.select('fieldset[class=enterprise_wd]>button',true).elements[1].on('click',this.CompanyPassInput,this);
			
			//取消修改企业资料
			Ext.select('fieldset[class=material_wd]>button',true).elements[0].on('click',function(){
				Ext.select('fieldset[class=material_wd]',true).elements[0].setDisplayed(false);
			});
			
			//提交修改企业资料
			Ext.select('fieldset[class=material_wd]>button',true).elements[1].on('click',this.editCompanyInfo,this);
			
			//隐藏修改企业资料提示框
			Ext.select('div[class=msgTips_wd]>button',true).elements[0].on('click',function(){
				Ext.select('div[class=msgTips_wd]',true).elements[0].setDisplayed(false);
			});
			
			//忘记企业密匙
			Ext.select('fieldset[class=enterprise_wd]>p>a',true).elements[0].on('click',this.forgetPW,this,{stopEvent:true});
			
			//显示个人资料输入框
			Ext.select('ul[class=serviceList]>li:nth-child(2)>a',true).elements[0].on('click',this.setDisplayPersonal,this,{stopEvent:true,disp:true});
			
			//隐藏个人资料输入框
			Ext.select('fieldset[class=individual_wd]>button',true).elements[0].on('click',this.setDisplayPersonal,this,{stopEvent:true,disp:false});
			
			//提交个人资料
			Ext.select('fieldset[class=individual_wd]>button',true).elements[1].on('click',this.editPersonalInfo,this);
			
			//注销
			Ext.select('ul[class=serviceList]>li:nth-child(5)>a',true).elements[0].on('click',this.logout,this,{stopEvent:true});			
		},
		
		
		/**
		 * 下载帮助手册
		 */
		DownHelp : function(){
			window.open('/DownloadSource/ews_'+Main.currLang+'.rar');
		},
		
		
		/**
		 *  表单li Over事件
		 * @param {object} evt event
		 * @param {object} taret event target
		 * @param {object} option
		 */
		liOver : function(evt , target , option){			
			clearTimeout(this.overID);//清除执行效果
			
			this.overID = (function(){
				var MenuDiv = Ext.getDom('MenuDiv');
				var li = MenuDiv.getElementsByTagName('li');
				var isCurrent = false;//默认当前li不是操作对象
				
				Ext.each( li , function(item){
					if(item.id == option.id && item.className == 'status'){
						isCurrent = true;//当前li是操作对象
						return false;
					};
					
					if(item.className == 'status'){
						var o = Ext.get(item);
						o.removeClass('status');
						o.select('h3',true).elements[0].setDisplayed(true);
						o.select('p',true).elements[0].setDisplayed(false);
						o.select('div',true).elements[0].setDisplayed(false);
					};
				});
				
				//判断若当前li不是操作对象，则执行下面操作
				if(!isCurrent){
					var obj = Ext.get(option.id);
					obj.dom.className = 'status';
					obj.select('h3',true).elements[0].setDisplayed(false);
					obj.select('p',true).elements[0].setDisplayed(true);
					
					var div = obj.select('div',true).elements[0];
					div.setVisibilityMode(Ext.Element.DISPLAY);
					div.setVisible(true,{duration:.5,easing:'easeNone'});
				};
			}).defer(100,this);
		},
		
		
		/**
		 * 打开建站
		 */
		service1 : function(){
			var w = window.screen.width;
			var h = window.screen.height;
			var website = window.open('http://'+Main.getCookie('EWS')+'/website/index.cfm?lang='+Main.currLang, 'website', 'width=' + w + ',height=' + h + ',scrollbars=yes,top=0,left=0');
			website.focus();
		},
		
		
		/**
		 * 打开网站监测
		 */
		service2 : function(){
			var w = window.screen.width;
			var h = window.screen.height;
			var Monitor = window.open('http://'+Main.getCookie('EWS')+'/JumpMonitor.cfm?lang='+Main.currLang, 'Monitor', 'width=' + w + ',height=' + h + ',scrollbars=yes,top=0,left=0');
			Monitor.focus();
		},
		
		/**
		 * 打开线上考勤
		 */
		service3: function(){
			var w = window.screen.width;
			var h = window.screen.height;
			var website = window.open('http://'+Main.getCookie('EWS')+'/JumpKaoQin.cfm?lang='+Main.currLang, 'kaoqin', 'width=' + w + ',height=' + h + ',scrollbars=yes,top=0,left=0');
			website.focus();
		},
		
		
		/**
		 * 打开物品管理
		 */
		service4: function(){
			var w = window.screen.width;
			var h = window.screen.height;
			var Goods = window.open('http://'+Main.getCookie('EWS')+'/JumpGoods.cfm?lang='+Main.currLang, 'Goods', 'width=' + w + ',height=' + h + ',scrollbars=yes,top=0,left=0');
			Goods.focus();
		},
		
		
		/**
		 * 打开商品发布
		 */
		service5: function(){
			var w = window.screen.width;
			var h = window.screen.height;
			var Order = window.open('http://'+Main.getCookie('EWS')+'/JumpOrder.cfm?lang='+Main.currLang, 'Order', 'width=' + w + ',height=' + h + ',scrollbars=yes,top=0,left=0');
			Order.focus();
		},
		
		
		/**
		 * 打开海报系统
		 */
		service6: function(){
			var w = window.screen.width;
			var h = window.screen.height;
			var Poster = window.open('http://'+Main.getCookie('EWS')+'/Poster/index.cfm?lang='+Main.currLang, 'Poster', 'width=' + w + ',height=' + h + ',scrollbars=yes,top=0,left=0');
			Poster.focus();
		},
		
		/**
		 * 打开ED.易度在线
		 */
		service7: function(){
			var w = window.screen.width;
			var h = window.screen.height;
			var EveryDo = window.open('http://'+Main.getCookie('EWS')+'/CooperApp/EDOProj.cfm', 'EveryDo', 'width=' + w + ',height=' + h + ',scrollbars=yes,top=0,left=0');
			EveryDo.focus();
		},
		
		/**
		 * 打开商务管理
		 */
		service8: function(){
			var w = window.screen.width;
			var h = window.screen.height;
			var sap = window.open('http://'+Main.getCookie('EWS')+'/sap/index.html?lang='+Main.currLang, 'sap', 'width=' + w + ',height=' + h+',top=0,left=0' );
			sap.focus();
		},
		
		/**
		 * 打开信息发布
		 */
		service9: function(){
			var w = window.screen.width;
			var h = window.screen.height;
			var info = window.open('http://'+Main.getCookie('EWS')+'/InfoSys/index.cfm?lang='+Main.currLang, 'info', 'width=' + w + ',height=' + h+',top=0,left=0' );
			info.focus();
		},
		
		/**
		 * 打开会员管理
		 */
		service10: function(){
			var w = window.screen.width;
			var h = window.screen.height;
			var Member = window.open('http://'+Main.getCookie('EWS')+'/JumpMember.cfm?lang='+Main.currLang, 'Member', 'width=' + w + ',height=' + h+',scrollbars=yes,top=0,left=0' );
			Member.focus();
		},
		
		/**
		 * 打开资源管理
		 */
		service11: function(){
			var w = window.screen.width;
			var h = window.screen.height;
			var ResourceManager = window.open('http://'+Main.getCookie('EWS')+'/JumpRM.cfm?lang='+Main.currLang, 'ResourceManager', 'width=' + w + ',height=' + h);
			ResourceManager.focus();
		},
		
		/**
		 * 支付系统
		 */
		service12: function(){
			var w = window.screen.width;
			var h = window.screen.height;
			var PaymentSystem = window.open('http://'+Main.getCookie('EWS')+'/JumpPay.cfm?lang='+Main.currLang, 'PaymentSystem', 'width=' + w + ',height=' + h);
			PaymentSystem.focus();
		},
		
		/**
		 * 旧版建站系统
		 */
		oldWebSite : function(){
			var w = window.screen.width;
			var h = window.screen.height;
			var website = window.open('http://'+Main.getCookie('EWS')+'/CHS/Main.cfm?lang='+Main.currLang, 'website', 'width=' + w + ',height=' + h );
			website.focus();
		},
		
		/**
		 *  显示/隐藏 企业资料密码输入框
		 * @param {object} evt event
		 * @param {object} taret event target
		 * @param {object} option
		 */
		setDisplayCompany : function(evt , target , option){
			Ext.select('fieldset[class=enterprise_wd]',true).elements[0].setDisplayed(option.disp);
			
			if(option.disp){
				this.setDisplayPersonal(null,null,{disp:false});
			};
			
			if(target){
				target.blur();
			};
		},
		
		/**
		 *  显示/隐藏 个人设置输入框
		 * @param {object} evt event
		 * @param {object} taret event target
		 * @param {object} option
		 */
		setDisplayPersonal : function(evt , target , option){
			if(!option.disp){
				Ext.getDom('PersonalPass1').value = '';
				Ext.getDom('PersonalPass2').value = '';
				Ext.getDom('PersonalPass3').value = '';
			};
			
			if(option.disp){
				this.setDisplayCompany(null,null,{disp:false});
			};
			
			Ext.select('fieldset[class=individual_wd]',true).elements[0].setDisplayed(option.disp);
			
			if(target){
				target.blur();
			};
		},
		
		/**
		 * 企业资料密码输入框处理
		 */
		CompanyPassInput : function(){
			var obj = Ext.select('fieldset[class=enterprise_wd]>p',true).elements[1];
			obj.setDisplayed(true);
			
			if ( !Ext.getCmp('CompanyPass').validate() ){
				obj.update('<span>'+Main.lang.CompanyPassEmpty+'</span>');
				return;
			};
			
			WebService.Request({
				gateWay:"http://"+Main.getCookie('EWS')+"/flashservices/gateway",
				service : "DefaultFun",
				method : "check",
				scope : this,
				arguments : [ Ext.getDom('CompanyPass').value ],
				onResult : function(id, result) {					
					if (result) {
						this.key = Ext.getDom('CompanyPass').value;
						Ext.getDom('CompanyPass').value = '';
						obj.update('<span>'+Main.lang.CompanyPassSuccess+'</span>');
						this.loadCompanyInfo();
					} else {
						obj.update('<span>'+Main.lang.CompanyPassError+'</span>');
					}
				},
				onFault : Main.WS_onFault
			});
		},
		
		/**
		 * 读取企业资料
		 */
		loadCompanyInfo : function() {
			WebService.Request({
				gateWay:"http://"+Main.getCookie('EWS')+"/flashservices/gateway",
				service : "DefaultFun",
				method : "load",
				scope : this,
				arguments : [this.key],
				onResult : function(id, result) {
					if( result == false){
						obj.update('<span>'+Main.lang.CompanyPassError+'</span>');
						return;
					};
					
					Ext.select('fieldset[class=enterprise_wd]',true).elements[0].setDisplayed(false);
					Ext.select('fieldset[class=enterprise_wd]>p',true).elements[1].setDisplayed(false);
					Ext.select('fieldset[class=material_wd]',true).elements[0].setDisplayed(true);
					
					Ext.getDom('CName').value = result.CName;
					Ext.getDom('CWebsite').value = result.CWebsite;
					Ext.getDom('CEmail').value = result.CEmail;
				},
				onFault : Main.WS_onFault
			});
		},
		
		/**
		 * 修改企业资料
		 */
		editCompanyInfo : function() {
			var obj = Ext.select('fieldset[class=material_wd]>p>strong',true).elements[0];
			
			if( Ext.getDom('CPass1').value != Ext.getDom('CPass2').value){
				var obj = Ext.select('fieldset[class=material_wd]>p>strong',true).elements[0];
				obj.update(Main.lang.CPassError);
				obj.setDisplayed(true);
				return;
			};
			
			obj.update('');
			obj.setDisplayed(false);
						
			WebService.Request({
				gateWay:"http://"+Main.getCookie('EWS')+"/flashservices/gateway",
				service : "DefaultFun",
				method : "edit",
				scope : this,
				arguments : [ Ext.getDom('CName').value , Ext.getDom('CWebsite').value , Ext.getDom('CPass1').value , Ext.getDom('CEmail').value , this.key],
				onResult : function(id, result) {
					if (result) {
						Ext.query('div[class=successMain]>h2')[0].innerHTML = Ext.getDom('CName').value;
						Ext.getDom('CName').value = '';
						Ext.getDom('CWebsite').value = '';
						Ext.getDom('CEmail').value = '';
						Ext.select('fieldset[class=material_wd]',true).elements[0].setDisplayed(false);
						Ext.select('div[class=msgTips_wd]',true).elements[0].setDisplayed(true);
					}
				},
				onFault : Main.WS_onFault
			});
		},
		
		
		/**
		 * 忘记企业密匙
		 */
		forgetPW : function(){
			Ext.select('fieldset[class=enterprise_wd]',true).elements[0].setDisplayed(false);
			Ext.select('fieldset[class=enterprise_wd]>p',true).elements[1].setDisplayed(false);
			Ext.select('fieldset[class=material_wd]',true).elements[0].setDisplayed(false);
			var obj = Ext.select('div[class=msgTips_wd]',true).elements[0];
			Ext.select('div[class=msgTips_wd]>p>strong',true).elements[0].update(Main.lang.CPassForget);
			Ext.select('div[class=msgTips_wd]',true).elements[0].setDisplayed(true);
			
			WebService.Request({
				gateWay:"http://"+Main.getCookie('EWS')+"/flashservices/gateway",
				service : "DefaultFun",
				method : "forget",
				scope : this,
				arguments : [Main.currLang],
				onResult : function(id, result) {},
				onFault : Main.WS_onFault
			});
		},
		
		/**
		 * 修改个人资料
		 */
		editPersonalInfo : function(){
			var Pass1 = Ext.getDom('PersonalPass1').value;
			var Pass2 = Ext.getDom('PersonalPass2').value;
			var Pass3 = Ext.getDom('PersonalPass3').value;
			
			if(Pass1 == ''){
				Ext.select('fieldset[class=individual_wd]>p>strong',true).elements[0].update(Main.lang.PersonalPassError1);
				Ext.select('fieldset[class=individual_wd]>p',true).elements[0].setDisplayed(true);
				return;
			};

			if(Pass2 == ''){
				Ext.select('fieldset[class=individual_wd]>p>strong',true).elements[0].update(Main.lang.PersonalPassError2);
				Ext.select('fieldset[class=individual_wd]>p',true).elements[0].setDisplayed(true);
				return;		
			};
			
			if(Pass2 !== Pass3){
				Ext.select('fieldset[class=individual_wd]>p>strong',true).elements[0].update(Main.lang.PersonalPassError3);
				Ext.select('fieldset[class=individual_wd]>p',true).elements[0].setDisplayed(true);
				return;
			};
			
			Ext.select('fieldset[class=individual_wd]>p',true).elements[0].setDisplayed(false);
			
			WebService.Request({
				gateWay:"http://"+Main.getCookie('EWS')+"/flashservices/gateway",
				service : "DefaultFun",
				method : "ModifyPersonalInfo",
				scope : this,
				arguments : [Pass1 , Pass2],
				onResult : function(id, result) {
					if(result){
						Ext.select('fieldset[class=individual_wd]>p>strong',true).elements[0].update(Main.lang.PersonalSettingSuccess);
						Ext.select('fieldset[class=individual_wd]>p',true).elements[0].setDisplayed(true);
						(function(){
							this.setDisplayPersonal(null,null,{disp:false});
						}).defer(1000,this);
					}else{
						Ext.select('fieldset[class=individual_wd]>p>strong',true).elements[0].update(Main.lang.PersonalError1);
						Ext.select('fieldset[class=individual_wd]>p',true).elements[0].setDisplayed(true);
					};
				},
				onFault : Main.WS_onFault
			});
		},
		
		logout : function(){
			WebService.Request({
				gateWay:"http://"+Main.getCookie('EWS')+"/flashservices/gateway",
				service : "DefaultFun",
				method : "logout",
				onResult : function(id, result) {
					Main.delCookie ("EWS");
					window.location='default.cfm';
				},
				onFault : Main.WS_onFault
			});
		}
	};
}();
