﻿var ok = false;
var message = "";

function showError(obj) {
    message = "<img align='absmiddle' src='/image/icon_err.png' />&nbsp;&nbsp;" + message;
    $(obj).html(message);
    $(obj).removeClass("ok");
    $(obj).addClass("error");
}

function showOK(message, obj) {
    $(obj).html(message);
    $(obj).removeClass("error");
    $(obj).addClass("ok");
}
function createNav(strElementID) {
    $("#" + strElementID).wrap("<span></span>");
}

function goSearch()
{
    var strKeyWord = $("#inputSecSearch").val();
    if (strKeyWord == "输入房源特征，地点或小区名字..."){
        strKeyWord = "";
    }
    var strPath = $("#txtKeyWord").val();
    setCookieAction("keyword", strKeyWord, strPath);
}

function goToPage(strEval, strPath)
{
    location.href = strEval + strPath + ".html";
}

function isTrueHouse(strUntiID, strClassify)
{

    if (!confirm("本次操作可能触犯经纪人利益，后果不堪设想，确定执行吗？")) {
        return false;
    }


    $.ajax({
        type: "get",
        dataType: "html",
        url: '/Service/MixVlidate.html',
        cache: false,
        data: "strUntiID=" + escape(strUntiID) + "&strClassify=" + strClassify,
        success: function(result) {
            if (result !== "False") {
                alert("举报成功");
            }
        }
    });
}

function goArea(key, strUnitID)
{
    setCookieAction(key, strUnitID, $("#txtRoot").val());
}



function setCookieAction(cookiename, cookievalue, strAction)
{
    var Days = 1;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
    document.cookie = cookiename + "=" +escape(cookievalue) + ";expires=" + exp.toGMTString() + "; path=" + "/";
    location.href = strAction;
}

function loadMap()
{

    if (GBrowserIsCompatible())
    {
        var strLat = $("#txtLat").val();
        var strLng = $("#txtLng").val();
        var map = new GMap2(document.getElementById("map_canvas"));
        var point = new GLatLng(strLat, strLng)
        map.setCenter(point, 14);
        map.addOverlay(new GMarker(point));
    }
}

function profileEmailValidate(required, email, obj)
 {
     if (!required) 
     {
         return;
     }
     if (email.length == 0) 
     {
         ok = false;
         message = "必须填写Email。";
         showError(obj);
         return;
     }
     var self = this;
     var emailRegex = /^\w+([-+.]\w+)*@\w+([-.]\\w+)*\.\w+([-.]\w+)*$/;
     if (!emailRegex.test(email)) {
         ok = false;
         message = "请输入正确的Email地址";
         showError(obj);
         return;
     }

     message = "<img align='absmiddle' src='/image/icon_acc.png' />";
     showOK(message, obj);
}

function emailValidate(required, email, obj) {
    if (!required) 
    {
        return;
    }
    if (email.length == 0) {
        ok = false;
        message = "必须填写Email。";
        showError(obj);
        return;
    }
    var self = this;
    var emailRegex = /^\w+([-+.]\w+)*@\w+([-.]\\w+)*\.\w+([-.]\w+)*$/;
    if (!emailRegex.test(email)) {
        ok = false;
        message = "请输入正确的Email地址";
        showError(obj);
        return;
    }


    $.ajax({
        type: "get",
        dataType: "html",
        url: '/Regsiter.html',
        cache: false,
        data: "strMixPara=" + escape(email) + "&EventType=CheckEmail",


        success: function(result) {
            if (result == "False") {
                message = "您所输入的Email已经被注册！";
                showError(obj);
                return;
            }
            message = "<img align='absmiddle' src='/image/icon_acc.png' />";

            showOK(message, obj);
        },
        error: function() 
        {
            message = "system error!";
            showError(obj);
        }
    });
    
    message = "<img align='absmiddle' src='/image/icon_acc.png' />";
    showOK(message, obj);
}

function storeNameValidate(evalPara, obj) 
{
    if (evalPara.length < 4 || evalPara.length > 100)
     {
         message = "请填写真实的中介名称";
         showError(obj);
         return;
     }


     $.ajax({
         type: "get",
         dataType: "html",
         url: '/UserCenter/NewStore.html',
         cache: false,
         data: "strMixPara=" + escape(evalPara) + "&EventType=CheckStoreName",


         success: function(result) 
         {
             if (result == "False") 
             {
                 message = "您所输入的中介名称已存在！";
                 showError(obj);
                 return;
             }
             message = "<img align='absmiddle' src='/image/icon_acc.png' />";

             showOK(message, obj);
         },
         error: function() {
             message = "system error!";
             showError(obj);
         }
     });
}



function loginNameValidate(loginName, obj) 
{
    if (loginName.length < 4 || loginName.length > 100) {
        emailValidate
        showError(obj);
        return;
    }

    $.ajax({
        type: "get",
        dataType: "html",
        url: '/Regsiter.html',
        cache: false,
        data: "strMixPara=" + escape(loginName) + "&EventType=CheckUserName",


        success: function(result) {
            if (result == "False") {
                message = "您所输入的用户名已经被注册！";

                showError(obj);
                return;
            }
            message = "<img align='absmiddle' src='/image/icon_acc.png' />";

            showOK(message, obj);
        },
        error: function() {
            message = "system error!";
            showError(obj);
        }
    });

}

function passwordValidate(string, obj) {

    if (string.length < 4 || string.length > 100)
     {
         message = "请填写4位以上的长度密码";
        showError(obj);
        return;
    }

    showOK("<img align='absmiddle' src='/image/icon_acc.png' />", obj);
}

function reasonValidate() {
    var strEval = $("#txtReason").val();
    var obj = $("#txtReasonMsg");
    if (strEval.length < 3 || strEval.length > 100)
     {
        message = " 请填写拒绝理由";
        showError(obj);
        return;
    }

    showOK("<img align='absmiddle' src='/image/icon_acc.png' />", obj);
}

function AddExternal()
{

    var strUrl=$("#txtUrl").val();
    var strTitle = $("#txtTitle").val();
    var ctrl = (navigator.userAgent.toLowerCase()).indexOf('mac') != -1 ? 'Command/Cmd' : 'CTRL';
    if (document.all) 
    {
        window.external.addFavorite(strUrl, strTitle);
    } else if
    (window.sidebar) 
    {
        window.sidebar.addPanel(strTitle, strUrl, "");
    }
    else 
    {
        alert('您可以尝试通过快捷键' + ctrl + ' + D 加入到收藏夹~');
    }
}



function reasonCheck() 
{
    if ($("#txtReasonMsg").attr("class").indexOf("ok") == -1) {
        reasonValidate($("#txtReason").val(), $("#txtReasonMsg"));
    }
    if ($(".ok").size() == 1)
    {
        $("#hfReason").val($("#txtReason").val());
        return true;
    }
    return false;
}

function integralValidate(strEval, obj) 
{
    if (strEval.length < 1 || strEval.length > 100) 
    {
        message = " 请填写赠送积分数量";
        showError(obj);
        return;
    }

    if (isNaN(strEval)) 
    {
        message = " 请填写数字";
        showError(obj);
        return;
    }

    if (eval($("#lblIntegral").html()) < eval(strEval))
    {
        message = "赠送积分数量不能大于户账总积分";
        showError(obj);
        return;
    }

    showOK("<img align='absmiddle' src='/image/icon_acc.png' />", obj);
}


function otherNameValidate(loginName, obj)
 {
    if (loginName.length < 4 || loginName.length > 100) {
        message = "请填写4位以上的长度用户名";
        showError(obj);
        return;
    }

    var currentName=$("#lblLoginName").html();
    if (currentName == loginName)
    {
        message = "不能对自己赠送积分";
        showError(obj);
        return;
    }

    $.ajax({
        type: "get",
        dataType: "html",
        url: '/Regsiter.html',
        cache: false,
        data: "strMixPara=" + escape(loginName) + "&EventType=CheckUserName",


        success: function(result) {
        if (result == "True") {
                message = "用户名不存在！";

                showError(obj);
                return;
            }
            message = "<img align='absmiddle' src='/image/icon_acc.png' />";

            showOK(message, obj);
        },
        error: function() {
            message = "system error!";
            showError(obj);
        }
    });

}


function checkIntegralForm() 
{
    if ($("#txtIntegralMsg").attr("class").indexOf("ok") == -1) {
        integralValidate($("#txtIntegral").val(), $("#txtIntegralMsg"));
    }
    if ($("#txtOtherNameMsg").attr("class").indexOf("ok") == -1) {
        otherNameValidate($("#txtOtherName").val(), $("#txtOtherNameMsg"));
    }
    if ($(".ok").size() == 2)
     {
        return true;
    }
    return false;
}

function principalValidate(strEval, obj) 
{
    if (strEval.length < 2 || strEval.length > 100) {
        message = " 填写店长姓名";
        showError(obj);
        return;
    }

    showOK("<img align='absmiddle' src='/image/icon_acc.png' />", obj);
}

function personNameValidate(strEval, obj) {
    if (strEval.length < 2 || strEval.length > 100) {
        message = " 请填写真实姓名";
        showError(obj);
        return;
    }

    showOK("<img align='absmiddle' src='/image/icon_acc.png' />", obj);
}
function shopNameValidate(strEval, obj) {
    if (strEval.length < 2 || strEval.length > 100) {
        message = " 请填写店铺名称";
        showError(obj);
        return;
    }

    showOK("<img align='absmiddle' src='/image/icon_acc.png' />", obj);
}
function newsTitle(strEval, obj)
{
    if (strEval.length <1 || strEval.length > 100)
    {
        message = " 请填写新闻标题";
        showError(obj);
        return;
    }

    showOK("<img align='absmiddle' src='/image/icon_acc.png' />", obj);
}

function topicTitle(strEval, obj)
{
    if (strEval.length < 1 || strEval.length > 100) {
        message = " 请填写主题";
        showError(obj);
        return;
    }

    showOK("<img align='absmiddle' src='/image/icon_acc.png' />", obj);
}

function IdentityCardNumberValidate(ic, obj) {
    //身份证正则表达式(15位) 
    var isIDCard1 = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;
    //身份证正则表达式(18位) 
    var isIDCard2 = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$/;

    if (isIDCard1.test(ic) || isIDCard2.test(ic)) {
        showOK("<img align='absmiddle' src='/image/icon_acc.png' />", obj);
        return;
    }
    message = "请填写正确的身份证号码";
    showError(obj);
    return;
}

function companyValidate(selectValue)
{
    var obj = $("#dlStoreListMsg");
    if (selectValue == "0" || selectValue == undefined) {
        message = "请选择正确的中介门店信息";
        showError(obj);
        return;
    }
    showOK("<img align='absmiddle' src='../image/icon_acc.png' />", obj);
}

function storeAddressValidate(strEval, obj) 
{
    if (strEval.length < 5 || strEval.length > 100) {
        message = " 请填写真实的中介地址";
        showError(obj);
        return;
    }

    showOK("<img align='absmiddle' src='/image/icon_acc.png' />", obj);
}

function contactValidate(strEval, obj)
 {
     if (strEval.length < 5 || eval.length > 100)
     {

        message = "请填写真实的联系电话";
        showError(obj);
        return;
    }

    var pattern = /^\s*(\S+(\s+\S+)*)\s*$/;

    if (!pattern.exec(strEval))
     {
         message = "请填写有效的联系电话";
         showError(obj);
         return;
    }

    message = "<img align='absmiddle' src='/image/icon_acc.png' />";

    showOK(message, obj);
}

function areaValidate(strEval)
{
    var obj = $("#dlAreaListMsg");
    if (strEval.length < 15 || eval.length > 100)
     {
         
        message = "请选择中介所在区域";
        showError(obj);
        return;
    }

    message = "<img align='absmiddle' src='/image/icon_acc.png' />";

    showOK(message, obj);
}

function dropListValidate(strEval) 
{
    var obj = $("#dlNewsLogListMsg");
    if (strEval.length < 15 || eval.length > 100) {

        message = "请选择新闻分类";
        showError(obj);
        return;
    }

    message = "<img align='absmiddle' src='/image/icon_acc.png' />";

    showOK(message, obj);
}


function dropForumValidate(strEval)
{
    var obj = $("#dlForumListMsg");
    if (strEval.length < 15 || eval.length > 100) {

        message = "请选择主题分类";
        showError(obj);
        return;
    }

    message = "<img align='absmiddle' src='/image/icon_acc.png' />";

    showOK(message, obj);
}

function checkNewsForm()
{

    if ($("#txtNewsTitleMsg").attr("class").indexOf("ok") == -1) {
        storeNameValidate($("#txtNewsTitle").val(), $("#txtNewsTitleMsg"));
    }

    if ($("#dlNewsLogList").attr("class").indexOf("ok") == -1) 
    {
        dropListValidate($("#dlNewsLogList").val());
    }

    if ($(".ok").size() == 2) {
        return true;
    }
    return false;

}

function checkTopicForm()
{

    if ($("#txtTopicTitleMsg").attr("class").indexOf("ok") == -1) {
        topicTitle($("#txtTopicTitle").val(), $("#txtTopicTitleMsg"));
    }

    if ($("#dlForumList").attr("class").indexOf("ok") == -1) {
        dropForumValidate($("#dlForumList").val());
    }

    if ($(".ok").size() == 2) {
        return true;
    }
    return false;

}

function passwordConfirm(psw1, psw2, obj) 
{
    if (psw1 != psw2) {
        message = "密码不一致";
        showError(obj);
        return;
    }
    showOK("<img align='absmiddle' src='../image/icon_acc.png' />", obj);
}

function  checkProfileForm()
{
    if ($("#txtPersonNameMsg").attr("class").indexOf("ok") == -1)
     {
        personNameValidate($("#txtPersonName").val(), $("#txtPersonNameMsg"));
     }
    if ($("#txtIDNumMsg").attr("class").indexOf("ok") == -1)
       {
             IdentityCardNumberValidate($("#txtIDNum").val(), $("#txtIDNumMsg"));
        }
    if ($("#txtContactMsg").attr("class").indexOf("ok") == -1)
             {
                 contactValidate($("#txtContact").val(), $("#txtContactMsg"));
             }

    if ($("#dlStoreListMsg").attr("class").indexOf("ok") == -1) 
        {
            companyValidate($("#dlStoreList").val());
       }

       if ($("#txtEmailMsg").attr("class").indexOf("ok") == -1) {
           profileEmailValidate(true, $("#txtEmail").val(), $("#txtEmailMsg"));
       }

    if ($(".ok").size() == 5) {
        return true;
    }
    return false;
}

function checkStoreForm()
{

    if ($("#txtStoreNameMsg").attr("class").indexOf("ok") == -1) {
        storeNameValidate($("#txtStoreName").val(), $("#txtStoreNameMsg"));
    } 

    if ($("#txtPrincipalNameMsg").attr("class").indexOf("ok") == -1) {
        principalValidate($("#txtPrincipalName").val(), $("#txtPrincipalNameMsg"));
    }


    if ($("#txtStoreAddressMsg").attr("class").indexOf("ok") == -1) {
        storeAddressValidate($("#txtStoreAddress").val(), $("#txtStoreAddressMsg"));
    }

    if ($("#txtContactMsg").attr("class").indexOf("ok") == -1)
     {
         contactValidate($("#txtContact").val(), $("#txtContactMsg"));
    }

    if ($("#dlAreaList").attr("class").indexOf("ok") == -1) {
        areaValidate($("#dlAreaList").val());
    }

    if ($(".ok").size() == 5) {
        return true;
    }
    return false;

}

function checkEditStoreForm()
{

    if ($("#txtPrincipalNameMsg").attr("class").indexOf("ok") == -1) 
    {
        principalValidate($("#txtPrincipalName").val(), $("#txtPrincipalNameMsg"));
    }

    if ($("#txtContactMsg").attr("class").indexOf("ok") == -1) 
    {
        contactValidate($("#txtContact").val(), $("#txtContactMsg"));
    }

    if ($("#txtStoreAddressMsg").attr("class").indexOf("ok") == -1)
     {
        storeAddressValidate($("#txtStoreAddress").val(), $("#txtStoreAddressMsg"));
    }


    if ($("#dlAreaList").attr("class").indexOf("ok") == -1)
     {
        areaValidate($("#dlAreaList").val());
    }

    if ($(".ok").size() == 4)
    {
        return true;
    }
    return false;

}

function CheckForm() 
{
    if ($("#txtLoginNameMsg").attr("class").indexOf("ok") == -1) 
    {
        loginNameValidate($("#txtLoginName").val(), $("#txtLoginNameMsg"));
    }

    if ($("#txtEmailMsg").attr("class").indexOf("ok") == -1)
     {
        emailValidate(true, $("#txtEmail").val(), $("#txtEmailMsg"));
    }
    passwordValidate($("#txtPassword").val(), $("#txtPasswordMsg"));

    if ($("#txtPasswordMsg").attr("class").indexOf("ok") != -1)
     {
        passwordConfirm($("#txtPassword").val(), $("#txtPasswordConfirm").val(), $("#txtPasswordConfirmMsg"));
    }

    if ($(".ok").size() == 4)
     {
        return true;
    }
    return false;
}


function checkPasswordForm() 
{
    passwordValidate($("#txtPassword").val(), $("#txtPasswordMsg"));

    if ($("#txtPasswordMsg").attr("class").indexOf("ok") != -1) {
        passwordConfirm($("#txtPassword").val(), $("#txtPasswordConfirm").val(), $("#txtPasswordConfirmMsg"));
    }

    if ($(".ok").size() == 2) {
        return true;
    }
    return false;
}


function ajaxFileUpload(divBox, fileControl, photoTypeName, needTitle, max, strUploadPath) 
{

     if ($(divBox).data("max") > max) 
    {
        alert("最多只能上传" + max + "张图片");
        return false;
    }

    var total = 0;
    if ($(divBox).data("max") != undefined)
     {
        total = $(divBox).data("max");
    }
    else 
    {
        total = 1;
    }
    $(divBox).data("max", total + 1);

    var uploadCommodel = $(divBox);
    uploadCommodel.find(".msgPanel").ajaxStart(function()
     {
    }).ajaxComplete(function() {
    });

    $.ajaxFileUpload
			({
                url: "/Service/ImageUploadMixHandler.html?strUploadPath=" + escape(strUploadPath),
                type: "get",
			    secureuri: false,
			    fileElementId: fileControl,
			    dataType: 'json',
			    success: function(data, status)
			     {
			         if (typeof (data.states) != 'undefined')
			         {
			            if (data.states == "false") {
			                showMsg(uploadCommodel, data.msg);
			            }
			            else {
			                showMsg(uploadCommodel, data.msg);
			                showPicDiv(uploadCommodel, data, photoTypeName, needTitle, divBox, max);
			            }
			        }
			    },
			    error: function(data, status, e) {
			        alert(e);
			    }
			})
    return false;
}
function showMsg(uploadCommodel, msg) 
{
    uploadCommodel.find(".msgPanel").html(msg);
}


function showPicDiv(uploadCommodel, data, photoTypeName, needTitle, divBox, max) {
    var has = parseInt($(uploadCommodel).data("max")) - 1;
    var i = has % 4;

    if (i == 1 && has > 4) {
        var height = parseInt($(uploadCommodel).parent().prev().css("height"));
        $(uploadCommodel).parent().prev().css("height", (height + i * 130) + "px");
        $(uploadCommodel).parent().css("height", (height + i * 130) + "px");
    }

    var picDivID = photoTypeName + "_" + Math.ceil(Math.random() * 1000);
    var picDiv = '<div id="' + picDivID + '" class="housepicone">'
    	                + '<div class="housepic">'
    	                + '<img height="75" width="100" src="' + data.minPhotoUrl + '" alt="" />'
                        + '<div class="deletepic1">'
    	                + '<a onclick="deletePicDiv(\'' + picDivID + '\',\'' + divBox + '\');" href="javascript:void(0)">删除</a>'
    	                + '</div>'
    	                + '<input type="hidden" value="' + data.minPhotoUrl + '" name="' + photoTypeName + '_Min" />'
    	                + '<input type="hidden" value="' + data.maxPhotoUrl + '" name="' + photoTypeName + '_Max" />'
    	                + '</div>';
    if (needTitle) {
        picDiv = picDiv + '<div class="housepicw1"><textarea name="' + photoTypeName + '_Title">照片描述最多16个中文字</textarea><span style="color: rgb(102, 102, 102);">描述：(选填)</span><br /></div></div>';
    }
    else {
        picDiv = picDiv + '<div style="display:none;" class="housepicw1"><textarea name="' + photoTypeName + '_Title">测试隐藏内容获取</textarea><span style="color: rgb(102, 102, 102);">描述：(选填)</span><br /></div></div>';
    }

    uploadCommodel.find(".defaultPicPanel").hide();
    uploadCommodel.find(".commodelPanel").append(picDiv);
}



function deletePicDiv(picDivID, divBox) {
    $("#" + picDivID).parent().parent().find(".msgPanel").html("");
    $("#" + picDivID).remove();


    var has = parseInt($(divBox).data("max")) - 1;
    var i = has % 4;
    if (i == 1 && has > 3) {
        var height = parseInt($(divBox).parent().prev().css("height"));
        $(divBox).parent().prev().css("height", (height - 130) + "px");
        $(divBox).parent().css("height", (height - 130) + "px");
    }

    var total = $(divBox).data("max") - 1;
    if (total == 1) {
        $(divBox + " .defaultPicPanel").show();
    }
    $(divBox).data("max", total);
}



function requestBlock(strAreaID)
{
    $("#txtAreaID").val(strAreaID);
    $("form:first").submit();
}

function fixBlockID(strBlockID) {
    $("#txtBlockID").val(strBlockID);
    $("form:first").submit();
}
function fixPrice(strFrom, strEnd, strPriceID) {
    $("#txtPriceFrom").val(strFrom);
    $("#txtPriceEnd").val(strEnd);
    $("#txtPriceID").val(strPriceID);
    $("form:first").submit();
}

function fixAcr(strFrom, strEnd, strAcrID) {
    $("#txtAcrFrom").val(strFrom);
    $("#txtAcrEnd").val(strEnd);
    $("#txtAcrID").val(strAcrID);
    $("form:first").submit();
}

function fixRomm(strRoomID, strRoomNum) {
    $("#txtRoomID").val(strRoomID);
    $("#txtRoomNum").val(strRoomNum);
    $("form:first").submit();
}

function fixHouseType(strHouseTypeID) {
    $("#txtHouseTypeID").val(strHouseTypeID);
    $("form:first").submit();
}

function fixSearchText()
{
    $("#txtSearchText").val($("#txtSearch").val());
    $("form:first").submit();
}

function fixPuDate(strEval) {
    $("#txtPubDays").val(strEval);
    $("form:first").submit();


}

function fixSecState()
{
    var count = $("#dlDays option").length;
    for (var i = 0; i < count; i++)
    {
        if ($("#dlDays").get(0).options[i].value == $("#txtPubDays").val()) {
            $("#dlDays").get(0).options[i].selected = true;
            break;
        }
    }

    var AgeCount = $("#ddlAge option").length;
    for (var i = 0; i < AgeCount; i++) {
        if ($("#ddlAge").get(0).options[i].value == $("#txtAgeData").val()) {
            $("#ddlAge").get(0).options[i].selected = true;
            break;
        }
    }

    var OrderByCount = $("#dllOrderBy option").length;
    for (var i = 0; i < OrderByCount; i++) 
    {
        if ($("#dllOrderBy").get(0).options[i].value == $("#txtOrderBy").val()) {
            $("#dllOrderBy").get(0).options[i].selected = true;
            break;
        }
    }

    var strTypeID = $("#txtSourceType").val();
    var elementID = "#" + strTypeID;
    var html = "<span></span>";
    if (strTypeID == "0")
    {
        $(elementID).wrap(html);
    }
    if (strTypeID == "1")
    {
        $(elementID).wrap(html);
    }
    if (strTypeID == "2") {
        $(elementID).wrap(html);
    }
    if (strTypeID == "3") {
        $(elementID).wrap(html);
    }

}

function fixOrderBy(strEval)
{
    $("#txtOrderBy").val(strEval);
    $("form:first").submit();
}

function fixSourceType(strEval) 
{
    $("#txtSourceType").val(strEval);
    $("form:first").submit();
}


function fixAge(strEval)
{
    var strFrom = strEval.substring(0, strEval.lastIndexOf(","));
    var strEnd = strEval.substring(strEval.lastIndexOf(",") + 1);
    
    $("#txtAgeFrom").val(strFrom);
    $("#txtAgeEnd").val(strEnd);
    $("#txtAgeData").val(strEval);
    $("form:first").submit();
}
function fixCommunity()
{
    $("#txtSearchText").val($("#txtCommunityName").val());
    $("form:first").submit();
}
function fixArea(strEval) {
    $("#txtAreaID").val(strEval);
    $("form:first").submit();
}
function fixSecHouse() 
{
    $("#txtSearchText").val($("#txtSecHouse").val());
    $("form:first").submit();
}

function fixSubID(strSubID) {
    $("#txtSubID").val(strSubID);
    $("form:first").submit();
}

function fixStation(strStationID) {
    $("#txtStationID").val(strStationID);
    $("form:first").submit();
}

function setCookie(cookiename, cookievalue)
{
    var Days = 1;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
    document.cookie = cookiename + "=" + encodeURI(cookievalue) + ";expires=" + exp.toGMTString() + "; path=" + "/";
}

function goRentSub(cookiename, cookievalue) {

    var Days = 1;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
    document.cookie = cookiename + "=" + encodeURI(cookievalue) + ";expires=" + exp.toGMTString() + "; path=" + "/";
    location.href = "/SubLine/Rent.html";
}
function doSubmit() {
    if ($("#txtLoginUserName").val().length > 0 && $("#txtLoginPassword").val().length > 0) {
        return true;
    }
    return false;
}

function TabShow(strTab) {
    if (strTab == "strNewHouse") {

        $("#strSecHouse").removeClass("searchbuttonactive01");
        $("#strSecHouse").addClass("searchbuttonactive02");

        $("#strRentHouse").removeClass("searchbuttonactive01");
        $("#strRentHouse").addClass("searchbuttonactive03");

        $("#strNewHouse").removeClass("searchbuttonactive04");
        $("#strNewHouse").addClass("searchbuttonactive01");
    }

    if (strTab == "strSecHouse") {
        $("#strRentHouse").removeClass("searchbuttonactive01");
        $("#strRentHouse").addClass("searchbuttonactive03");

        $("#strNewHouse").removeClass("searchbuttonactive01");
        $("#strNewHouse").addClass("searchbuttonactive04");

        $("#strSecHouse").removeClass("searchbuttonactive02");
        $("#strSecHouse").addClass("searchbuttonactive01");

        $("#strCondition").attr({ href: "/Sale/" });

        $("#txtKeyWord").val("/Sale/");
        $("#txtRoot").val("/Sale/");
    }
    if (strTab == "strRentHouse") {

        $("#strSecHouse").removeClass("searchbuttonactive01");
        $("#strSecHouse").addClass("searchbuttonactive02");

        $("#strNewHouse").removeClass("searchbuttonactive01");
        $("#strNewHouse").addClass("searchbuttonactive04");

        $("#strRentHouse").removeClass("searchbuttonactive03");
        $("#strRentHouse").addClass("searchbuttonactive01");

        $("#strCondition").attr({ href: "/Rent/" });

        $("#txtKeyWord").val("/Rent/");
        $("#txtRoot").val("/Rent/");
    }
}


