function second_menus_display(top_menu)
{
    var second_menus = "second_menus_" + top_menu.id;
    document.getElementById(second_menus).style.display="block";
}

function second_menus_hidden(top_menu)
{
    var second_menus = "second_menus_" + top_menu.id;
    document.getElementById(second_menus).style.display="none";
}

function status_submit(act)
{
    var url = "index.php?act=status";
    
    var value = document.getElementById("cid").value;
    if (value.length != 0 && value!=0)
        url += "&cid=" + value;

    var value = document.getElementById("proid").value;
    if (value.length != 0)
        url += "&proid=" + value;
    
    value = document.getElementById("username").value;
    if (value.length != 0)
        url += "&username=" + value;

    value = document.getElementById("judgestatus").value;
    url += "&judgestatus=" + value;
    act.action = url;
    location.href = url;
    return false;
}

function search(act)
{
    var url = "index.php?act=search";
    var value = document.getElementById("keyword").value;
    if (value.length != 0 && value!="ProId or keywords")
        url += "&keyword=" + value;
    else
        return false;
    
    act.action = url;
    location.href = url;
    return false;
}

function register_submit()
{
    location.href = "index.php?act=register";
}

function add_to(pid, cid)
{
    var pro_id = prompt("请输入练习中的Problem Id:");
    if (confirm("确定要将比赛的"+pid+"加为练习中的"+pro_id+"?"))
    {
        var url = "index.php?act=problem&type=addto&cid="+cid+"&id="+pid+"&new_id="+pro_id;

        location.href = url;
    }
}

function delete_contest(id)
{
	var returned = window.confirm('Are you sure to delete the contest？');
	if (returned)
	{
        location.href = "index.php?act=conman&type=delete&id=" + id;
	}
}

function problem_more()
{
    var father = document.getElementById("problem_add");
    var pmax = document.getElementById("pmax");
    var max = parseInt(pmax.value) + 1;
    pmax.value = max;
    var p = document.createElement("p");
	p.innerHTML =
            "ProblemId:<input name=\"proid_"+max+"\" value=\""+(1000+max)+"\"/> \
            <span>ProblemDescId:<input name=\"pdid_"+max+"\" /></span>";
	father.appendChild(p);
}


