function submit_all( actiontype , mark , id)
{ 
    var arr = new Array();
    var select_num = 0;
    var ids = '';
    if( id > 0)
    {
        ids = id;
        select_num = 1;
    }
    else
    {
        $(".table").find("input:checked[name=rows_id]").each(function(i) {
            arr[i] = $(this).val();
            select_num ++;
        });
        arr = unique(arr);
        ids = arr.join(",");
    }
    
    if(ids) 
    {
        if(actiontype == "multi_delete_house") 
        {
            if( mark == 1 )
            {
                document.action_form.actiontype.value = actiontype;
                document.action_form.actionid.value = ids;
                document.action_form.submit();
            }
            else
            {
                if( select_num > 0 )
                {
                    confirm2( "确定要删除选定的"+select_num+"条记录吗？", actiontype , ids);
                }
                else
                {
                    confirm2( "确定要删除选定的记录吗？", actiontype , ids );
                }
            }
        }

        if(actiontype == "multdel") 
        {
            if ( mark == 1 ) 
            {
                document.search_form.actiontype.value = actiontype;
                document.search_form.actionid.value = ids;
                document.search_form.submit();
            }
            else
            {
                confirm2( "确定要删除选定的记录吗？" , actiontype)
            }
        }

        if(actiontype == "appointment") 
        {   
            document.reserve_form.action = 'http://nj.zsb.house365.com/reserve/project_house_set/';
            document.reserve_form.actionid.value = ids;
            document.reserve_form.submit();
        }

        if(actiontype == "uppublish") {
            if (mark==1) 
            {
                document.getElementById('publishbtn').disabled=true;
                document.action_form.actiontype.value=actiontype;
                document.action_form.actionid.value=ids;
                document.action_form.submit();
            }
            else
            {
                confirm2("确定要再发布选定的记录吗？",actiontype);
            }
        }

        if(actiontype == "refresh") {

            if (mark==1) 
            {
                document.action_form.actiontype.value = actiontype;
                document.action_form.actionid.value = ids;
                document.action_form.submit();
            }
            else
            {   
                if( select_num > 0 )
                {
                    confirm2( "确定要刷新选定的"+select_num+"条记录吗？", actiontype , ids);
                }
                else
                {
                    confirm2( "确定要刷新选定的记录吗？", actiontype , ids );
                }
            }
        }
        
        if( actiontype == "invalid_house") 
        {   
            if (mark == 1) 
            {
                document.action_form.actiontype.value = actiontype;
                document.action_form.actionid.value = ids;
                document.action_form.submit();
            }
            else
            {   
                if( select_num > 0 )
                {
                    confirm2( "您确定要对选定的"+select_num+"条房源纪录执行失效操作吗？", actiontype , ids);
                }
                else
                {
                    confirm2( "您确定要对选定的房源纪录执行失效操作吗？", actiontype , ids );
                }
            }
        }

        if(actiontype == "qx_reserve")
        {
            if (mark==1) 
            {   
                document.reserve_form.action = 'http://nj.zsb.house365.com/reserve/project_house_cancel/';
                document.reserve_form.actionid.value=ids;
                document.reserve_form.submit();
            }
            else
            {
                confirm2("确定要把选定的记录取消预约吗？",actiontype)
            }
        }

        if(actiontype == "movesell") 
        {
            window.open("move.php?tbl=sell&ids="+ids,'','width=400,height=100,scrollbars=no');
        }

	if(actiontype == "moverent") 
        {
            window.open("move.php?tbl=rent&ids="+ids,'','width=400,height=100,scrollbars=no');
	}

        if(actiontype == "reserve") 
        {
            if(document.getElementById('reserve_id').value == '')
            {
                $("#dialog_tip").html("请先选择预约方案");
                openWin('dialogts');
                return false;
            }
            
            if (mark == 1) 
            {
                document.getElementById('reservebtn').disabled=true;
                document.action_form.actiontype.value=actiontype;
                document.action_form.actionid.value=ids;
                var t = document.getElementById("reserve_id"); 
                document.action_form.pid.value=t.options[t.selectedIndex].value;							
                document.action_form.submit();
            }
            else
            {
                confirm2("确定要预约选定的记录吗？")
            }
        }
    } 
    else 
    {
        $("#dialog_tip").html("请先选定信息！");
        openWin('dialogts');
    }
    
    return false;
}

/*去掉数组重复项----------------*/
function unique(data)
{ 
    data = data || []; 
    var a = {}; 
    len = data.length;

    for ( var i = 0; i < len ; i++ )
    { 
        var v = data[i]; 
        if (typeof(a[v]) == 'undefined')
        { 
            a[v] = 1; 
        } 
    }
    
    data.length = 0; 
    for (var i in a)
    { 
        data[data.length] = i; 
    }
    
    return data; 
} 

function clickdel2(id,mark)
{  
    if (mark) 
    {
        document.action_form.actiontype.value="del";
        document.action_form.actionid.value=id;
        document.action_form.submit();
    }
    else
    {
      confirm4("确定要删除该记录吗？",id);
    }
    
    return false;
}


function upcreate2(id,mark)
{
    if (mark==1) 
    {
        document.action_form.actiontype.value="upcreate";
        document.action_form.actionid.value=id;
        document.action_form.submit();
    }
    else
    {
        confirm3("确定要再发布该记录吗？",id);
    }

    return false;
}

function confirm2(tips , act , ids)
{
    $("#dialogSaveDiv2").html(tips);

    $('#dialog_url2').bind('click', function () {
        openWin('docation_loading');
        submit_all( act , 1 , ids);
    });

    openWin("dialogtc2");
}

function confirm3(tips,id)
{
    $("#dialogSaveDiv2").html(tips);
    $('#dialog_url2').bind('click', function () {
        upcreate2(id,1);
    });

    openWin("dialogtc2");
}

function confirm4(tips,id)
{
    $("#dialogSaveDiv2").html(tips);
    $('#dialog_url2').bind('click', function () {
        clickdel2(id,1);
    });
    openWin("dialogtc2");
}
    
function invalid_one_house( id , pg )
{
    $("#dialog_id").val(id);
    $("#dialogSaveDiv").html("确定要把该记录变为失效吗？");
    $("#dialog_url").attr("href","/model/multdo.php?actiontype=change_esta&tbl=sell&actionid="+id+"&pg="+pg);
    openWin("dialogtc");
}