/**  
 * @author Van  
 * @constructor mailServer
 * @description this script is for "pages/security/company.jsp"
 * @date 2010-9-15
 * @since version 1.0 
 */  
$package('itsm.config.mailServer')

itsm.config.mailServer.mailServer = function() {
	
	return {
		
		findServiceMail:function(){
			
			var url = 'mailServer!findServereMail.action';
			$.post(url,function(res){
				
				$('#smtp_serverAddress').val(res.smtpServerAddress);
				$('#smtp_serverPort').val(res.smtpServerPort);
				$('#pop3_serverAddress').val(res.pop3ServerAddress);
				$('#pop3_serverPort').val(res.pop3ServerPort);
				$('#userName').val(res.userName);
				$('#password').val(res.password);
				if(res.emailServerId!=null){
					
					$('#emailServerId').val(res.emailServerId);
				}
			});
		},

		saveOrUpdateMailServer:function(){
			
			
			if($('#MailServerForm').form('validate')){
				var _params = $('#MailServerDiv form').serialize();
			
				var url = 'mailServer!saveOrUpdateEmailServer.action';

				//显示进程
				startProcess();
				 $.post(url,_params, function(){
						//隐藏进程
						endProcess();
					 	msgShow(i18n['saveSuccess'],'show');
					 	findServiceMail();
				});
			}
			
		},
		init:function(){
			
			itsm.config.mailServer.mailServer.findServiceMail();
			
			
			$('#company_mailserver_save').click(itsm.config.mailServer.mailServer.saveOrUpdateMailServer);
			
		}
		
	};

}();


//载入
$(document).ready(itsm.config.mailServer.mailServer.init);
	