function Preview(MessageID){
	var WinURL="mrweb.cgi?action=preview&SessionID="+document.container.SessionID.value+"&id="+MessageID;
	Check(MessageID);  
	var aWin=window.open(WinURL,'detail');
}

function Check(MessageID)
{
  document.container.CurID.value=MessageID;

  for(var i=0;i<document.ListOption.elements.length;i++) {
    var e=document.ListOption.elements[i];
    if(e.name=='IDCheck'&&e.value==MessageID) {e.checked=true;} 
		else {e.checked=false;}
  }
	
}

function Compose(action){
	var aWin;
	var WinURL="mrweb.cgi?action="+action+"&SessionID="+document.container.SessionID.value+"&id="+document.container.CurID.value;
	aWin=window.open(WinURL,'compose', 'width=700,height=480,resizable=0,scrollbars=auto')
}	

function Operate(action){
	var i=document.ListOption.newmailbox.selectedIndex;
	
	if(document.ListOption.newmailbox.options[i].text=="---请选择操作的文件夹---") {
		alert("请选择操作的文件夹！");
	}else{
	        document.ListOption.action.value=action;
		document.ListOption.submit();
	}
}

function Delete()
{
 var i,ck=0;
 
 if(document.ListOption.IDCheck.checked == 1) 
  ck=1;
 else
 for(i=0;i<document.ListOption.IDCheck.length;i++)
 {
  if(document.ListOption.IDCheck[i].checked) 
  {
   ck=1; 
   break;
  }
 }
 if(ck==0) 
 {
  alert ("您还没有选择要删除的邮件!");
 }	
 else
 {
  document.ListOption.action.value="delete";
  document.ListOption.submit();
 } 
}

function ShowPage(PageNo)
{
	var winURL="mrweb.cgi?action=maillist&SessionID="+document.container.SessionID.value;
	    winURL=winURL+"&PageNo="+PageNo;
	    winURL+="&mailbox="+document.container.mailbox.value;
	var aWin=window.open(winURL,'_self');
}

function SelectAll()
{
 var i;
 
 if(document.ListOption.IDCheck.length)
 {
  for(i=0;i<document.ListOption.IDCheck.length;i++)
  {
   document.ListOption.IDCheck[i].checked=document.ListOption.AllCheck.checked;
  }
 }
 else
  document.ListOption.IDCheck.checked=document.ListOption.AllCheck.checked;
  document.ListOption.AllCheck1.checked=document.ListOption.AllCheck.checked;
}

function SelectAll1()
{
 var i;
 
 if(document.ListOption.IDCheck.length)
 {
  for(i=0;i<document.ListOption.IDCheck.length;i++)
  {
   document.ListOption.IDCheck[i].checked=document.ListOption.AllCheck1.checked;
  }
 }
 else
  document.ListOption.IDCheck.checked=document.ListOption.AllCheck1.checked;
  document.ListOption.AllCheck.checked=document.ListOption.AllCheck1.checked;
}

function SetOrder(OrderType)
{
	var winURL="mrweb.cgi?action=order&SessionID="+document.container.SessionID.value+"&OrderType="+OrderType;
	    winURL+="&mailbox="+document.container.mailbox.value;
 
 
 var aWin=window.open(winURL,'_self');
}