var pattern=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
var __=function(message)
{
	return i18n_arr[message] ? i18n_arr[message] : message;
}
var i18n_arr = new Array();
//sendMail.js
i18n_arr["MailSizeLimitMessage"]="Every file must be less than {singleAttachmentsizeLimit} MB, and whole less than {mailsizeLimit} MB.";
i18n_arr["OneFileOverSizeMessage"]="\"<b>{fileName}</b>\" file size is larger then {singleAttachmentsizeLimit} MB.";
i18n_arr["TotalFilesOverSizeMessage"]="Attachments exceed {mailsizeLimit} MB.";
i18n_arr["1"]="Jan";
i18n_arr["2"]="Feb";
i18n_arr["3"]="Mar";
i18n_arr["4"]="Apr";
i18n_arr["5"]="May";
i18n_arr["6"]="Jun";
i18n_arr["7"]="Jul";
i18n_arr["8"]="Aug";
i18n_arr["9"]="Sep";
i18n_arr["10"]="Oct";
i18n_arr["11"]="Nov";
i18n_arr["12"]="Dec";
/////////////////////////////////////////////////错误dialog引用的国际化信息///////////////////////////////////////////////////////////
var lang="en_US";
var LangPack={
"zh_CN":{"buttontextYes":"是","buttontextNo":"否","buttontextOK":"确定","buttontextCancel":"取消","dlgTitleMessage":"提示","errAttachmentExists":"该附件已存在！","errNotSelectMail":"请选中要操作的邮件"}
,"zh_TW":{"buttontextYes":"是","buttontextNo":"否","buttontextOK":"确定","buttontextCancel":"取消","dlgTitleMessage":"提示","errAttachmentExists":"该附件已存在！","errNotSelectMail":"请选中要操作的邮件"}
,"en_US":{"buttontextYes":"Yes","buttontextNo":"No","buttontextOK":"OK","buttontextCancel":"Cancel","dlgTitleMessage":"Message","errAttachmentExists":"Attachment already exists.","errNotSelectMail":"Please select one mail at least."}
}
var code_arr = {
	"1000000":"System Error.",
	"1000001":"Illegal Operation.",
	"1000002":"Session expired, please login.",
	"1000003":"Unknown error code.",
	"1000004":"Mail decode failed.",
	"1010101":"Password error.",
	"1010102":"Username or password error.",
	"1020101":"Save to sent box failed.",
	"1020102":"Save to draft box failed.",
	"1030101":"Receive mail failed(Remote server error).",
	"1030102":"Delete external account folder failed(referenced by filter rules).",
	"1040101":"Import/Export contact into CSV format error.",
	"1040102":"Import/Export contact into XLS format error.",
	"1040103":"Contact with same email exists.",
	"1040104":"This contact group already exists.",
	"1050101":"Delete Archive folder failed(referenced by filter rules).",
	"1060101":"Delete Custom folder failed(referenced by filter rules).",
	"1070101":"Please check the White-List unique constraint.",
	"1070102":"White-List database error.",
	"1070103":"Delete filter rule  failed.",
	"1080101":"Filename duplicated.",
	"1080102":"Insufficient Net-Disk space.",
	"1090102":"Duplicated External account name.",
	"1080101":"Network Disk Duplicate file.",
	"1060102":"Custom e-mail folder database error.",
	"1060103":"Custom e-mail folder Juna.",
	"5010101":"White list already exists in this account.",
	"1010104":"This account already exists in the blacklist.",
	"5010103":"This account already exists in the blacklist.",
	"1010105":"This signature already exists.",
	"1000005":"Operating frequency is too high."
}
function code_nifo(code){
	return code_arr[code]||"";
}
var tipDialog={
  initOK:false
  ,$:function(id){ return document.getElementById(id); }
  ,init:function(){
	var $=this.$;
	if(!$("tipDialog")){
		var strDlgHTML='\
			<div id="tipDialog" class="tipDialog" style="display:none;">\
				<div class="t-left"></div>\
				<div class="t-center">\
					<div class="title"><span id="tipDialog-title"></span><a href="#"><span id="tipDialog-closeX" class="closeX"></span></a></div>\
					<div class="content" id="tipDialog-content">&nbsp;</div>\
					<div class="line"></div>\
					<div class="buttons"><input type="button" id="tipDialog-btnOK" class="btn-2" value="OK"/><input type="button" id="tipDialog-btnCancel" class="btn-2" value="Cancel"/></div>\
				</div>\
				<div class="t-right"></div>\
			</div>\
			';
		document.body.insertAdjacentHTML("afterBegin",strDlgHTML);
	}
	if(!$("pageMask")){
		document.body.insertAdjacentHTML("afterBegin",'<div id="pageMask" style="display:none;"></div>');
	}

	$("tipDialog-closeX").onclick=this.hide;
	$("tipDialog-closeX").onmouseover=function (){
		this.className='closeX closeX-hover';
	}
	$("tipDialog-closeX").onmouseout=function (){
		this.className='closeX';
	}
	$("tipDialog-btnOK").className = $("tipDialog-btnCancel").className = "btn-2 btn-2-en";
	this.initOK=true;
  }
  ,show:function(content){
	var $=this.$;
	if(!this.initOK){this.init()}
	this.showMask(1);
	if(typeof content != "object"){
		var content={'content':content}
	}
	if(typeof content.buttons != "object"){
		content.buttons={"OK":1}
	}
	if(!content.title) content.title = "Message";
	$("tipDialog-btnCancel").style.display=content.buttons.Cancel?'':'none';
	$("tipDialog-btnOK").onclick=function(){tipDialog.hide();if(content.OK){content.OK()}};
	$("tipDialog-btnCancel").onclick=function(){tipDialog.hide();if(content.Cancel){content.Cancel()}};

	$("tipDialog-title").innerHTML=content.title;
	$("tipDialog-content").innerHTML=content.content;
	var dE=document.documentElement;
	$("tipDialog").style.top=(dE.scrollTop+(dE.clientHeight-$("tipDialog").offsetHeight)/2)+"px";
	$("tipDialog").style.left=(dE.scrollLeft+(dE.clientWidth-$("tipDialog").offsetWidth)/2)+"px";
	$("tipDialog").style.display='';
	//置焦点到默认按钮
	var btn = content.defaultButton;
	if(!btn && content.buttons.OK)btn="OK";
	if(!btn && content.buttons.Cancel)btn="Cancel";
	try{if(btn)$("tipDialog-btn"+btn).focus();}catch(jserr){}
  }
  ,alert:function(content){
	this.show(content);
  }
  ,confirm:function(content){
	if(typeof content != "object"){
		var content={'content':content}
	}
	content.buttons = {"OK":1,"Cancel":1}
	this.show(content);
  }
  ,hide:function(){
	//this.$("tipDialog").style.display='none';
  	document.getElementById("tipDialog").style.display="none";
	tipDialog.showMask(0);
  }
  ,showMask:function(bShow){
	var $=this.$;
	//$("pageMask").style.height=Math.max(document.documentElement.offsetHeight-4,document.documentElement.scrollHeight-4)+'px';
    //$("pageMask").style.width=Math.max(document.documentElement.offsetWidth,document.documentElement.scrollWidth)+'px';
	$("pageMask").style.display=bShow?'':'none';
  }
}
var tipDialogBricase={
	initOK:false
  ,$:function(id){ return document.getElementById(id); }
  ,init:function(){
    var $=this.$;
    if(!$("pageMask")){
        document.body.insertAdjacentHTML("afterBegin",'<div id="pageMask" style="display:none;"></div>');
    }
    if($("tipDialog-closeX")){
    $("tipDialog-closeX").onclick=this.hide;
    $("tipDialog-closeX").onmouseover=function (){
        this.className='closeX closeX-hover';
    }
    $("tipDialog-closeX").onmouseout=function (){
        this.className='closeX';
    }
    }
    this.initOK=true;
  }
  ,show:function(dialogId){
    var $=this.$;
    if(!this.initOK){this.init()}
    tipDialogBricase.showMask(1);
    var dE=document.documentElement;
    $(dialogId).style.top=(dE.scrollTop+(dE.clientHeight-$(dialogId).offsetHeight)/2)+"px";
    $(dialogId).style.left=(dE.scrollLeft+(dE.clientWidth-$(dialogId).offsetWidth)/2)+"px";
    $(dialogId).style.display='';
  }
  ,hide:function(dialogId){
    document.getElementById(dialogId).style.display='none';
    tipDialogBricase.showMask(0);
  }
  ,showMask:function(bShow){
    var $=this.$;
    //$("pageMask").style.height=Math.max(document.documentElement.offsetHeight,document.documentElement.scrollHeight)+'px';
    //$("pageMask").style.width=Math.max(document.documentElement.offsetWidth,document.documentElement.scrollWidth)+'px';
    $("pageMask").style.display=bShow?'':'none';
  }
}
var tipDialogLayer={
  initOK:false
  ,$:function(id){ return document.getElementById(id); }
  ,init:function(){
    var $=this.$;
    if(!$("pageMask")){
        document.body.insertAdjacentHTML("afterBegin",'<div id="pageMask" style="display:none;"></div>');
    }
    if($("tipDialog-closeX")){
    $("tipDialog-closeX").onclick=this.hide;
    $("tipDialog-closeX").onmouseover=function (){
        this.className='closeX closeX-hover';
    }
    $("tipDialog-closeX").onmouseout=function (){
        this.className='closeX';
    }
    }
    this.initOK=true;
  }
  ,show:function(dialogId){
    var $=this.$;
    if(!this.initOK){this.init()}
    this.showMask(1);
    var dE=document.documentElement;
    $(dialogId).style.top=(dE.scrollTop+(dE.clientHeight-$(dialogId).offsetHeight)/2)+"px";
    $(dialogId).style.left=(dE.scrollLeft+(dE.clientWidth-$(dialogId).offsetWidth)/2)+"px";
    $(dialogId).style.display='';
  }
  ,hide:function(dialogId){
    document.getElementById(dialogId).style.display='none';
    tipDialog.showMask(0);
  }
  ,showMask:function(bShow){
    var $=this.$;
    //$("pageMask").style.height=Math.max(document.documentElement.offsetHeight,document.documentElement.scrollHeight)+'px';
    //$("pageMask").style.width=Math.max(document.documentElement.offsetWidth,document.documentElement.scrollWidth)+'px';
    $("pageMask").style.display=bShow?'':'none';
  }
}
if(window!=top['main']){
	if(top['main'] && top['main'].tipDialog){
		tipDialog = top['main'].tipDialog;
	}if(top['main'] && top['main'].tipDialogLayer){
		tipDialogLayer = top['main'].tipDialogLayer;
	}
}
function confirmClearMailBox(boxName,boxLabel){
	var msg,href,folderId;
	switch (boxName){
		case "Trash":
			msg='Are you sure to empty the Deleted folder?';
			href='mail/TrashMailList.jsp';
			folderId="4";
			break;
		case "Spam":
			msg='Are you sure to empty the Junk folder?';
			href='mail/SpamMailList.jsp';
			folderId="5";
			break;
		default: 
			return false;
	}
	tipDialog.confirm({'content':__(msg), 'OK':function(){clearMailByFolder(folderId,href,boxLabel)}});
}