﻿
/**
* Declare Variable With C# Boolean 
*/
var True = true, False = false;

var OfficeRootURL = "http://www.xiezilou.com/";

var arrWeiboWordsFilters = new Array("房友", "91office", "51offcie", "房租", "出租", "求组", "乐居", "操盘", "艳遇", "平方米", "元", "风险保证金", "看盘", "减仓", "平仓", "待涨个股", "基金", "股票");

/**
*static base url
*/
var StaticBaseUrl = 'http://res0.xzlres.com';

/**
*上传接口地址
*/
var UpLoadURL = 'http://upload.xzlres.com';
//var UpLoadURL = 'http://localhost:7000';

/**
*上传枚举类型,相册:0，楼书/特色/模板:1,资源文件:2,水印图3,专题4
**/
var UpLoadType = {
    Album: 0,
    File: 1,
    Resource: 2,
    WaterMarkPhoto: 3,
    Topic: 4
};

/**
* 微博评论内容里，是否存在微博过滤关键字
* @param {String} content
*/
function existWeiBoKeyWords(content) {
    for (var i in arrWeiboWordsFilters) {
        if (content.indexOf(arrWeiboWordsFilters[i]) > -1) {
            return true;
        }
    }
    return false;
}

/**
* Init AutoComplete Control
* @param {String} elemID
* @param {String} url
* @param {Function} onSelect
* @param {JSONObject} params
*/
function InitAutoComplete(elemID, url, onSelect, params) {
    if ($('#' + elemID)[0] != null) {
        return $('#' + elemID).autocomplete({
            deferRequestBy: 500,
            params: params,
            delimiter: true,
            serviceUrl: url,
            noCache: true,
            onSelect: onSelect
        });
    }
};


/**
* Init Selector Control
* @param {String} elemID
* @param {JSONObject} JSONArray
* @param {Function} onSelected
* @param {String} defValue
* @param {Bool} isMulti
* @return {Object}
*/
function InitSelector(elemID, JSONArray, onSelected, defValue, columnNum, isMulti, colWidth, tbxWidth) {
    var showMode = isMulti ? 'multi' : 'single';
    if ($('#' + elemID)[0] != null) {
        columnNum = (columnNum == null && JSONArray.length < 6) ? 1 : columnNum;
        return new Selector({
            containerId: '#' + elemID,
            items: JSONArray,
            defVal: defValue || '',
            showMode: showMode,
            colNum: columnNum,
            colWidth: colWidth || 90,
            tbxWidth: tbxWidth || 90,
            onSelected: onSelected
        });
    }
    else {
        return null;
    }
}

/**
* Get Selector Control JSONArray DataSource
* @param {Array} array
* @param {String} defTxt
* @param {String} defVal
* @return {JSONArray}
*/
function GetSelectorJSONArray(array, defTxt, defVal) {
    if (defTxt == null) {
        defTxt = "请选择";
    }
    if (defVal == null) {
        defVal = "";
    }
    var JSONArray = [];

    if (array != null) {
        for (i in array) {
            JSONArray.push({ txt: array[i], val: i });
        }
    }
    var exist = false;
    $.each(JSONArray, function (i) {
        if (this.txt == defTxt && this.val == defVal) {
            exist = true;
        }
    });
    if (!exist) {
        JSONArray.unshift({ txt: defTxt, val: defVal });
    }
    return JSONArray;
}


/**
* 显示调试信息（浏览器FireFox/IE，显示至控制台）
* @param {Object|String} info 
*/
var Log = function (info) {
    var isObject = (typeof info == "object");
    if (typeof console != "undefined" && typeof console.info != "undefined") {
        console.info("Global Debug: " + (isObject ? "%o" : "%s"), info);
    }
    else {
        window.alert((isObject ? "ERROR! " : "") + info);
    }
};


/**
* 设置cookies
* @param {String} key 
* @param {String} value 
*/
var setCookie = function (key, value) {
    var argv = setCookie.arguments;
    var argc = setCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    if (expires != null) {
        var LargeExpDate = new Date();
        LargeExpDate.setTime(LargeExpDate.getTime() + (expires * 1000 * 3600 * 24));
    }
    document.cookie = key + "=" + escape(value) + ((expires == null) ? "" : ("; expires=" + LargeExpDate.toGMTString()));
};


/**
* 获取Cookie对应值
* @param {String} key
* @return {String}
*/
var getCookie = function (key) {
    var arr = document.cookie.match(new RegExp("(^| )" + key + "=([^;]*)(;|$)"));
    if (arr != null) {
        return unescape(arr[2]);
    } else {
        return null;
    }
};

/**
* 处理IE6下默认不缓存背景图片
*/
(function () {
    var ua = window.navigator.userAgent.toLowerCase();
    var isOpera = ua.indexOf("opera") > -1;
    var isIE = !isOpera && ua.indexOf("msie") > -1;
    var isIE7 = !isOpera && ua.indexOf("msie 7") > -1;

    if (isIE && !isIE7) {
        try {
            document.execCommand("BackgroundImageCache", false, true);
        }
        catch (e) {
        }
    }
})();


/**
* Serialize Form Elements To JSON
*/
$.fn.serializeObject = function () {
    var o = {};
    var a = this.serializeArray();
    $.each(a, function () {
        if (o[this.name]) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name] += (',' + ($.trim(this.value) || ''));     // CheckBox Value Split with ','
            //o[this.name].push($.trim(this.value) || '');
        } else {
            o[this.name] = $.trim(this.value) || '';
        }
    });
    return o;
};


//搜索框提示
function InitTipsInput() {
    var blurColor = "#999";
    var focusColor = "#333";
    $(".SearchInput").each(function () {

        $(this).css({ "color": blurColor }).focus(function () {
            if ($(this).val() != $(this).attr('title')) {
                $(this).css({ "color": focusColor })
            }
            else {
                $(this).val("").css({ "color": blurColor })
            }
        }).blur(function () {
            if ($(this).val() == "" || $(this).val() == $(this).attr('title')) { $(this).val($(this).attr('title')).css({ "color": blurColor }) }
            else {
                $(this).css({ "color": focusColor })
            }
        }).keydown(function () { $(this).css({ "color": focusColor }) })
        $(this).blur();
    })
}

//打印方法
function Print() {
    window.print();
}

//设置公共头部Tab选中样式
function setHeaderTab(index) {
    var dom = $('#divHeaderTab ul').find('li').eq(index);
    if ($(dom)[0] != null) {
        $(dom).attr("id", "Current");
    }
}

//分享到微博
function gotoTSina(object, focusPhoto) {
    var title = document.title;
    var pic = encodeURI(focusPhoto);
    $(object).attr('href', 'http://v.t.sina.com.cn/share/share.php?url='
        + encodeURIComponent(window.location)
        + '&title=' + encodeURIComponent('@写字楼网官博 '+title)
        + '&pic=' + pic
        );
    return true;
}

//分享到人人网
function gotoRenren(object, focusPhoto) {
    var title = document.title;
    var pic = encodeURI(focusPhoto);
    $(object).attr('href', 'http://share.renren.com/share/buttonshare.do?title='
        + encodeURIComponent(title)
        + '&link=' + encodeURIComponent(location.href)
        + '&content=' + encodeURIComponent(title));
    return true;
}

//分享到豆瓣网
function gotoDouban(object, focusPhoto) {
    var title = document.title;
    $(object).attr('href', 'http://www.douban.com/recommend/?title='
        + encodeURIComponent(title)
        + '&link=' + encodeURIComponent(location.href)
        + '&content=' + encodeURIComponent(title));
    return true;
}

//分享到开心网
function gotoKaixin001(object, focusPhoto) {
    var title = document.title;
    var pic = encodeURI(focusPhoto);
    $(object).attr('href', 'http://www.kaixin001.com/repaste/share.php?rtitle='
        + encodeURIComponent(title)
        + '&rurl=' + encodeURIComponent(location.href)
        + '&rcontent=' + encodeURIComponent(title)
        );
    return true;
}

//分享到腾讯微博
function gotoQqZone(object, focusPhoto) {
    var title = encodeURI(document.title);
    var appkey = encodeURI("appkey");
    var pic = encodeURI(focusPhoto);
    var site = '';
    var u = 'http://v.t.qq.com/share/share.php?title=' + title
            + '&url=' + encodeURIComponent(document.location)
            + '&appkey=' + appkey + '&site='
            + site + '&pic=' + pic;
    $(object).attr('href', u);

    return true;
}

/*** 只针对单一指定cookie做设置的操作 cookie中值的形式:'{strJsonArr:[{1:aa,2:bb,3:cc},{1:dd,2:ee,3:rr}]}',
***  需要有属性为"id",如下面的historyJson.strJsonArr[i].id;
* 参数1:cookie的主键
* 参数2:cookie的值(JOSN对象)
* 参数3:cookie的过期时间
* 参数4:存放Json数组的最大长度
***/
function setHistoryCookie(key, strJson, expires, jsonArrMaxLength) {
    var readHistory = getCookie(key);
    //记录第一次进入的数据
    if (readHistory == null) {
        value = '{"strJsonArr":[' + JSON.stringify(strJson) + ']}';
        if (expires > 0) {//为0时不设定过期时间，浏览器关闭时cookie自动消失
            var LargeExpDate = new Date();
            LargeExpDate.setTime(LargeExpDate.getTime() + (expires * 1000 * 3600 * 24));
        }
        document.cookie = key + "=" + escape(value) + ((expires == 0) ? "" : ("; expires=" + LargeExpDate.toGMTString()));
        return;
    }
    var historyJson = JSON.parse(readHistory);

    jsonArrMaxLength = jsonArrMaxLength || 7;
    //查询cookie中是否有重复的值,有重复的去除掉里面重复的，添加新的内容
    //如果有多于7项，则删除数组中最后一位，然后将最新的放入最前面
    if (historyJson.strJsonArr.length < jsonArrMaxLength) {
        for (var i = 0; i < historyJson.strJsonArr.length; i++) {
            if (historyJson.strJsonArr[i].id == strJson.id) {
                historyJson.strJsonArr.splice(i, 1);
            }
        }
    }
    else {
        var isRepeat = false;
        for (var i = 0; i < historyJson.strJsonArr.length; i++) {
            if (historyJson.strJsonArr[i].id == strJson.id) {
                historyJson.strJsonArr.splice(i, 1);
                isRepeat = true;
            }
        }
        if (!isRepeat)
            historyJson.strJsonArr.shift();
    }
    historyJson.strJsonArr.push(strJson);
    document.cookie = key + "=" + escape(JSON.stringify(historyJson));
}

function showListLoading() {
    if ($("#divListLoading")[0] != null) {
        $("#divListLoading").show();
    }
}

function hideListLoading() {
    if ($("#divListLoading")[0] != null) {
        $("#divListLoading").hide();
    }
}

function getArgs(strUrl) {
    var args = [];
    var iPos = strUrl.indexOf("?");
    if (iPos > -1) {
        var query = strUrl.substring(iPos + 1); //获取查询串
        var pairs = query.split("&"); //在&处断开   
        for (var i = 0; i < pairs.length; i++) {
            var pos = pairs[i].indexOf('='); //查找name=value   
            if (pos == -1) continue; //如果没有找到就跳过   
            var argname = pairs[i].substring(0, pos); //提取name
            var value = pairs[i].substring(pos + 1); //提取value
            args.push({ key: argname, val: value });
        }
    }
    return args; //返回对象
}

//日期格式方法扩增
Date.prototype.format = function (format) {
    var o =
    {
        "M+": this.getMonth() + 1, //month
        "d+": this.getDate(),    //day
        "h+": this.getHours(),   //hour
        "m+": this.getMinutes(), //minute
        "s+": this.getSeconds(), //second
        "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
        "S": this.getMilliseconds() //millisecond
    }
    if (/(y+)/.test(format))
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
    return format;
}

/*操作结果提示
*msg:提示语
*secends:悬停秒数
*/
function showtipBoxMsg(msg, showTime) {

    var tipDiv = '<div class="Tip" id="tipbox" style="display:none; z-index:2000;">' + '<span id="tipboxMsg">' + msg + '</span>' + '</div>';
    if ($('#tipbox')[0] == undefined) {
        $("body").append(tipDiv);
    }

    msg = msg || "操作成功!";
    showTime = showTime || 2000;
    $("#tipboxMsg").html(msg);
    $("#tipbox").fadeIn("slow");
    setTimeout(function () {
        $("#tipbox").fadeOut("slow");
    }, showTime);

}



/**自助PK Start**/
var selfSelPKInputIndexArray = [];

//初始化suggest
function initSelfSelPKInput(buildingtype) {
    selfSelPKInputIndexArray = [];

    for (var i = 1; i <= 3; i++) {
        selfSelPKInputIndexArray[i] = InitAutoComplete('sleBuilding' + i, '/Service/GetCNNameForSuggest', function (value, data) {
            if (arguments[2] != null) {
                var me = arguments[2];
                $(me).val(value);
                $(me).removeClass('ErrorBox').addClass('FocusBox');
                var meID = $(me).attr('id');
                $('#' + meID + 'ID').val(data);
            }
        }, { buildingType: buildingtype });
    }
    if (selfSelPKInputIndexArray[1] != null && selfSelPKInputIndexArray[1] != undefined) {
        selfSelPKInputIndexArray[1].suggestions.push($('#sleBuilding1').val());
        selfSelPKInputIndexArray[1].data.push($('#sleBuilding1ID').val());
    }
}

//200毫秒之后验证
function checkSelBuilding(index) {
    setTimeout(function () { realCheckSelBuilding(index) }, 200);
}
//判断所填写的物业名是否有对应的id
function realCheckSelBuilding(index) {
    var domName = 'sleBuilding' + index;
    var domIDName = domName + 'ID';
    if ($('#' + domName).val() != '') {
        var txt = $('#' + domName).val();
        var id = 0;
        for (var j = 0; j < selfSelPKInputIndexArray[index].suggestions.length; j++) {
            var s = selfSelPKInputIndexArray[index].suggestions[j];
            if (txt == s) {
                id = selfSelPKInputIndexArray[index].data[j];
            }
        }
        if (id == 0) {
            $('#' + domIDName).val('');
            $('#' + domName).removeClass('FocusBox').addClass('ErrorBox');
            showtipBoxMsg('暂无' + $('#' + domName).val() + '信息，请修改！', 2000);
        }
        else {
            $('#' + domName).removeClass('ErrorBox').addClass('FocusBox');
            $('#' + domIDName).val(id);
        }
    }
    else {
        $('#' + domName).removeClass('ErrorBox').removeClass('FocusBox');
        $('#' + domIDName).val('');
    }
}

//跳转到相应pk页
function selfSelPK(buildingtype) {
    var selIDS = '';

    if ($('#divSelSelPK').find('.ErrorBox').size() > 0) {
        showtipBoxMsg('暂无' + $('#divSelSelPK').find('.ErrorBox').eq(0).val() + '信息，请修改！', 2500);
        $('#divSelSelPK').find('.ErrorBox').eq(0).focus();
        return false;
    }

    for (var i = 1; i <= 3; i++) {
        var id = $('#sleBuilding' + i + 'ID').val();
        if (id != '') {
            selIDS += id + ',';
        }
    }

    if (selIDS != '') {
        selIDS = selIDS.substring(0, selIDS.length - 1);
    }
    if (selIDS.indexOf(',') < 0) {
        var buildingTypeName = buildingtype == 2 ? '服务式办公' : (buildingtype == 3 ? '创意园区' : '写字楼');
        alert('请至少选择两个' + buildingTypeName + '进行PK!');
    }
    else {
        var pkurl = buildingtype == 2 ? '/ServicedOffice/pk/' : (buildingtype == 3 ? '/CreativePark/pk/' : '/Office/pk/');
        window.open(pkurl + selIDS);
    }
}
/**自助PK END**/

/**
* Register jQuery Validate Method
*/
function RegisterValidatorMethod() {
    if ($.validator != null) {
        $.validator.addMethod('UserName', function (value, element) {
            return this.optional(element) || /^[\u0391-\uFFE5\w]+$/.test(value);
        }, 'invalid username format');

        $.validator.addMethod('AllNumbers', function (value, element) {
            return this.optional(element) || !(/^\d+$|^(-?\d+)(\.\d+)?$/.test(value));
        }, 'companyname can not be all numbers');

        $.validator.addMethod('BizPhoneNumber', function (value, element) {
            value = value.replace(/，/ig, ',');
            return this.optional(element) || (/^\d{7,8}$|^(\d{7,8}\,\d{7,8})+$/.test(value));
        }, 'phone number error');

        $.validator.addMethod('isMobile', function (value, element) {
            var length = value.length;
            return this.optional(element) || (length == 11 && /(^1[358][0-9]{9}$)/.test(value));
        }, 'invalid mobilephone number');

        $.validator.addMethod('isWorkPhone', function (value, element) {
            var tel = /(^(\d{2,4}[-_－—]?)?\d{3,8}([-_－—]?\d{3,8})?([-#\*]?\d{1,7})?$)|(^0?1[35] \d{9}$)/;
            return this.optional(element) || (tel.test(value));
        }, 'invalid workphone number');

        $.validator.addMethod('IntegerNumber', function (value, element) {
            return this.optional(element) || /(^[0-9]+$)/.test(value);
        }, 'invalid integer number');

        $.validator.addMethod('IntegerComma', function (value, element) {
            return this.optional(element) || (/^\d+$|^(\d+\,\d*)+$/.test(value));
        }, 'RoomArea error');

        $.validator.addMethod('HHMMTimeFormat', function (value, element) {
            return this.optional(element) || (/^([0-9]|0\d{1}|1\d{1}|2[0-3]):([0-5]\d{1})$/.test(value));
        }, 'hh:mm time format error');

        $.validator.addMethod("isDecimalTwo", function (value, element) {
            var decimal = /^-?\d+(\.\d{1,2})?$/;
            return this.optional(element) || (decimal.test(value));
        }, '小数位数不能超过2位');
    }
}

/***评论功能***/
//根据描点加载微博或评论tab页
function loadWeiboOrCommentByHash() {
    var urlHash = window.location.hash;
    if (urlHash.indexOf('Weibo') > 0) {
        if ($('#tabWeibo')[0] != null) {
            $('#tabWeibo').trigger('click');
        }
    } else if (urlHash.indexOf('Comment') > 0) {
        if ($('#tabComment')[0] != null) {
            $('#tabComment').trigger('click');
        }
    }
}
//获取评论
function getWebComment(count, updateTargetId, loadingElementId) {
    var buildingType = $('#buildingType').val();
    var buildingID = $('#buildingID').val();

    var rqdata = "BuildingType=" + buildingType;
    rqdata += "&BuildingID=" + buildingID;
    rqdata += "&Count=" + count;

    $('#' + loadingElementId).show();
    $.ajax({
        type: 'POST',
        url: '/Service/GetComment',
        data: rqdata,
        success: function (res) {
            $('#' + loadingElementId).hide();
            if (res != null) {
                $('#' + updateTargetId).html(res);
            }
        }
    });
}

//获取分页评论
function getPageWebComment(buildingType, buildingID) { 
   
    var rqUrl = '/Service/GetPageComment?PropertyType=' + buildingType + '&PropertyID=' + buildingID;

    $.ajax({
        type: 'POST',
        url: rqUrl,
        success: function (res) {
            $('#divListLoading').hide();
            if (res != null) {
                $('#ulCommentList').html(res);
            }
        },
        error: function () {
            Log(arguments[1]);
        }
    });
}

//设置评论者心情
function setMood(index) {
    $('#EmoList a:[class="curr"]').removeClass();
    $('#EmoList a:eq(' + (index - 1) + ')').addClass('curr');
    $('#commenterMood').val('face_' + index + '.jpg');
}

//将用户评论写入数据库
function submitComment() {
    var content = $.trim($('#xzlComment').val());
    if (content.length < 2) {
        alert('请至少输入2个字符');
        return false;
    }
    if (content.length > 1000) {
        alert('评论不能超过1000个字符');
        return false;
    }
    var mood = $('#commenterMood').val();
    var buildingType = $('#buildingType').val();
    var buildingID = $('#buildingID').val();

    var rqdata = "BuildingType=" + buildingType;
    rqdata += "&BuildingID=" + buildingID;
    rqdata += "&Content=" + encodeURIComponent(content);
    rqdata += "&Mood=" + mood;

    var submitUrl = "/Service/AddComment";

    $.ajax(
        {
            type: "post",
            url: submitUrl,
            data: rqdata,
            error: function (error) {
                showtipBoxMsg(error, 10);
            },
            success: function (res) {
                if (res.IsSuccess) {
                    var faceImgBaseUrl = $('#faceImgBaseUrl').val();
                    var elemHtml = '<li><dl><dt><img src="' + faceImgBaseUrl + mood + '" title=""></dt>'
                    + '<dd>' + content + '<br/><span style="color: #999; font-size: 12px;">写字楼网友 发表于3秒前'
                    + '</span></dd></dl></li><li class="dotline"></li>';
                    if ($('#ulCommentList li').size() < 2) {
                        $('#ulCommentList').html(elemHtml);
                    } else {
                        $('#ulCommentList').prepend(elemHtml);
                    }
                    $('#xzlComment').val('');
                } else {
                    showtipBoxMsg('评论失败，请重试或联系管理员！', 2000);
                }
            }
        }
    );
}

//异步载入打分页面
function loadScorePanle() {
    var buildingType = $('#buildingType').val();
    var buildingID = $('#buildingID').val();

    var rqdata = "BuildingType=" + buildingType;
    rqdata += "&BuildingID=" + buildingID;

    $.ajax({
        type: 'POST',
        url: '/Service/GetScorePanle',
        data: rqdata,
        success: function (res) {
            $('#loadingScorePanle').hide();
            if (res != null) {
                $('#divScorePanle').append(res);
            }
        },
        error: function () {
            Log(arguments[1]);
        }
    });
}

/**
* Show Loading
*/
function Loading(show) {
    if (show == null) { show = true; }
    var $Loading = $('#divLoading');
    if ($Loading[0] != null) {
        if (show) $Loading.fadeIn();
        else $Loading.fadeOut();
    }
    ServerProcessing = show ? true : false;
}

//------------------------------------------------------新版写字楼

//搜索下拉框
function SelectTab(id, wrapID) {
    id = id || "select_list";
    wrapID = wrapID || "select_wrap";
    $('#' + id).hide(); //初始ul隐藏
    $('#' + wrapID).hover(function () { //鼠标移动函数
        $('#' + id).fadeIn();
        $(this).parent().hover(
        function () {
        },
        function () {
            $(this).parent().find('#' + id).hide();
        });
    },
function () {
});
    $('#' + id + ' li a').click(function () {
        $('#' + wrapID).html($(this).html());
        $('#' + id).hide();
        var txtDesc = "输入" + $(this).html() + "名称或地址关键字";
        $("#txtSearchKey").attr("title", txtDesc).val(txtDesc);
        InitTipsInput();
    });
}

//搜索
function SearchNews() {
    var newskey = document.getElementById("txtSearchKey").value;
    if (newskey == '' || newskey == '请输入搜索条件') return;
    var url = 'http://search.dichan.com/search.aspx?q=' + escape(newskey) + '&channel=3';
    window.open(url);
}

//初始化写字楼自动提示
function InitSearchSuggest() {
    //var buildType = $('#BuildingType').val();
    //关联楼盘
    InitAutoComplete('txtSearchKey', '/Service/GetCNNameForSuggest', function (value, data) {
        $('#txtSearchKey').val(value);
        searchOffice();
    }, { buildingType: function () {
        return parseInt($('#txtBuildingType').val());
    }
    });
}

//搜索写字楼
function searchOffice() {
    var buildingType = $("#txtBuildingType").val();
    var keywords = $("#txtSearchKey").val()
    var newUrl = "";
    if (keywords != "" && keywords.search(/名称或地址关键字/) < 0) {
        switch (buildingType) {
            case "1":
                newUrl = "/Office/List/?keyword=" + encodeURIComponent(keywords);
                break;
            case "2":
                newUrl = "/ServicedOffice/List/?keyword=" + encodeURIComponent(keywords);
                break;
            case "3":
                newUrl = "/CreativePark/List/?keyword=" + encodeURIComponent(keywords);
                break;
            default:
                newUrl = "/Office/List/?keyword=" + encodeURIComponent(keywords);
                break;

        }
    } else {
        //window.location.href = "/Office/List";
        switch (buildingType) {
            case "1":
                newUrl = "/Office/List";
                break;
            case "2":
                newUrl = "/ServicedOffice/List";
                break;
            case "3":
                newUrl = "/CreativePark/List";
                break;
            default:
                newUrl = "/Office/List";
                break;

        }
    }
    window.open(newUrl);
}
//设置建筑类型
function setBuildingType(type) {
    $('#txtBuildingType').val(type);
    //InitSearchSuggest();
}

//选中的导航栏目
function SelectNav(selectId, className) {
    selectId = selectId - 1 || 0;
    var topNav = $("#topNav li");
    for (var i = 0; i < topNav.length; i++) {
        if (selectId == i)
            topNav.eq(i).attr("class", className);
        else
            topNav.eq(i).removeAttr("class");
    }
}

function initHeader() {
    SelectTab();
    InitTipsInput();
    InitSearchSuggest();

}

/**
* 得到字符串长度（汉字长度为2）
* @param {String} str 
* @return {Int}
*/
var GetStringLen = function (str) {
    return str.replace(/[^\x00-\xff]/g, '**').length;
}

function selSearchMenu(url) {
    $("#urlSearchMenu a").each(function () {
        $(this).removeClass("cur");
    });
    $("#urlSearchMenu a").each(function () {
        if ($(this).attr("href") == url) {
            $(this).addClass("cur");
        }
    });
}

