﻿function UserCheck()
{
    if($('#txtuname').val()=="")
    {
        alert('请输入用户名');
        return ;
    }
    if($('#txtpwd').val()=="")
    {
        alert('请输入密码!');
        return ;
    }
    AjaxRequest.Post('btOK',function(content)
    {
        if (content['Url'] == '0') 
        {
            alert(content['Tip']);
        }
        else
        {
            var returnUrl = location.href;
            returnUrl = StringHelper.Clear(returnUrl, '#')
            GoUrl(returnUrl);
        }
    });
}

function searchDate(type)
{    
    var typeid=$('#slcsearchtype').val();
    
    var userType=$('#slcsearchusertype').val();
    
    var areaID=$('#slcsearcharea').val();
    
    var useID=$('#slcsearchuse').val();
    
    var tingID=$('#slcsearchting').val();
    var timeID=$('#slcsearchtime').val();
    
    var price1=$('#txtprice1').val();
    var price2=$('#txtprice2').val();
    var pricetype=$('#slcsearchpricetype').val();
    var keys=$('#txtkeys').val();
    var str="n="+typeid;
    
    if(userType <2)
    {
        str+="&u="+userType;
    }
    if(areaID >0)
    {
        str+="&a="+areaID;
    }
    if(useID >0)
    {
        str+="&us="+useID;
    }
    if(tingID >0)
    {
        str+="&t="+tingID;
    }
    if(timeID >0)
    {
        str+="&m="+timeID;
    }
    if(price1!=0)
    {
        if(price2<price1)
        {
            alert('价格2不能小于价格1');
            return ;
        }
        if(price1 ==price2)
        {
            str+="&p1="+price1+"&pt="+pricetype;
        }
        else
        {
            str+="&p1="+price1+"&p2="+price2+"&pt="+pricetype;
        }
    };
    if(keys!="请输入关键字")
    {
        str+="&k="+keys
    }
    if (type == 0) 
    {
        GoUrl('SearchInfos.aspx?' + str);
    }
    else 
    {
        GoUrl('Searchs.aspx?' + str);
    }
}

function checkslc(slc,id)
{
    select = document.getElementById(slc);    
    for(var i=0;i<select.length;i++)   
    {  
        if(select.options[i].value == id)
        {
            select[i].selected=true;
        }
    }  
}

function upImg(id)
{
    Dialog.Show('上传图片', '600', '350', 'UpImg.aspx?ID='+id);
}


function choose(div,flag)
{
    var cbx=document.getElementById(div).getElementsByTagName('input');
    for (var i =0;i<cbx.length;i++)
    {
        cbx[i].checked=flag;
    }
}

function getids(div)
{
    var ids ="";
    var cbx=document.getElementById(div).getElementsByTagName('input');
    for (var i =0;i<cbx.length;i++)
    {
        if(cbx[i].checked)
        {
            ids += cbx[i].value+",";
        }
    }
    if(ids !="")
    {
        ids =ids.substring(0,ids.length-1);
    }
    return ids;
}

function dltdata(div)
{
    var ids = getids(div);
    if(ids=="")
    {
        alert("请选择要删除的项!");
        return ;
    }
    else
    {
        $('#txtid').val(ids);
        Submit('btOK');
    }
}

function zhiding(div,type)
{
    var ids = getids(div);
    if(ids=="")
    {
        alert("请选择要置顶的项!");
        return ;
    }
    else
    {
        $('#txtid').val(ids);
        if(type==1)
        {
            Submit('btZhiDing');
        }
        else
        {   
            Submit('btUnZhiDing');
        }
    }
}
