var ie = document.all?1:0;
function CheckAll1()
{
    for (var i=0;i<document.listmail.elements.length;i++) {
        var e = document.listmail.elements[i];
        var tag = 'TR_'+(i-3);

        if (e.name != "allbox1") {
            e.checked = document.listmail.allbox1.checked;
            if (e.name != "allbox"){
                //on_check(tag,e);
            }
            customerBox('customerTr['+i+']',document.listmail.elements[i]);
        }
    }
}
function show_msg(msg)
{
	try {
		var d_tips = fromID('tips');
		var d_msg = fromID('msg');
		d_msg.innerHTML=msg;
		d_tips.style.display = "";
		del_class(d_tips, "hide");
	} catch(e) {
		alert(msg); 
	}
}

function CheckAll()
{
	for (var i=0;i<document.listmail.elements.length;i++)
    {
        var e = document.listmail.elements[i];
        var tag = 'TR_'+(i-3);
        if (e.name != "allbox")
        {
            e.checked = document.listmail.allbox.checked;
            if (e.name != "allbox1") {
                //on_check(tag,e);
            }
        }
        customerBox('customerTr['+i+']',document.listmail.elements[i]);

    }
}


function on_check(tid,CB)
{

    var E = document.getElementById(tid);
    if(E != null){
        if (CB.checked) 
			add_class(E, "selectbg");
        else
			del_class(E, "selectbg");
    }
}

function checkSelect(){
    for (var i=0;i<document.listmail.elements.length;i++)
    {
        var e = document.listmail.elements[i]
            if(e.type.toUpperCase() == "CHECKBOX" && e.checked){
                return statusFlag = 1;
                break;
            }
    }
}
function move(dst)
{
    var act = "移动";
    if ('垃圾箱' == dst) { /* 垃圾箱 */
        act = "删除";
    } 
    if (1 != checkSelect()) {
        show_msg('请选择要'+act+'的邮件');
        return; 
    }
    document.listmail.dest.value = dst;
    document.listmail.submit(); 
}
function DoSubmit(action,myObj)
{
    var isChecked = checkSelect();
    if(action == 'move')
    {
        if(isChecked != 1){
            show_msg("您没有选择要移动的邮件，请选择后再操作！");
            myObj.options[0].selected = true;
            return false;
        }else{
            document.listmail.dest.value=document.movemail.select_target.value;
            document.listmail.submit();
        }
    } else if (action == 'move1')
    {
        if(isChecked != 1){
            show_msg("您没有选择要移动的邮件，请选择后再操作！");
            myObj.options[0].selected = true;
            return false;
        }else{
            document.listmail.dest.value=document.listmail.select_target1.value;
            document.listmail.submit();
        }
    } else if(action == 'del')
    {
        if(isChecked != 1){
            show_msg("您没有选择要删除的邮件，请选择后再操作！");
            return false;
        }else{
            document.listmail.dest.value="垃圾箱";
            document.listmail.submit();
        }
    }
}

function showsearch()
{
    var s = document.getElementById("search");
    if (s.style.display == "none") {
        s.style.display = "block";
    } else {
        s.style.display = "none";
    }
}

function changePage(folder, page_select)
{
    window.location.href="listmail.php?folder="+folder+"&search=no&action=page&page="+page_select.value;
}

function customerBox(id,thisBox)
{
    var E = document.getElementById(id);

    if(E != null){
        if (thisBox.checked)
			add_class(E, "selected");
        else
			del_class(E, "selected"); 
    }

}
