﻿$(function() {
    displayLoginMsg();
    tanchucheng();
});

function getCookie(name) {

    function trimString(s) {
        return s.replace(/(^[\s]+)|([\s]+$)/g, "");
    }
    var cookieValue = null;
    if (document.cookie && document.cookie != '') {
        var cookies = document.cookie.split(';');
        for (var i = 0; i < cookies.length; i++) {
            var cookie = trimString(cookies[i]);
            if (cookie.substring(0, name.length + 1) == (name + '=')) {
                try {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                } catch (e) {
                    cookieValue = cookie.substring(name.length + 1);
                } break;
            }
        }
    } return cookieValue;
}


function displayLoginMsg() {

    var username = getCookie('CurrentUserUserName');
    var UserGroupId = getCookie('CurrentUserGroupId');
    var html = '';


    if (username != null && UserGroupId != null) {


        html = '您好&nbsp;' + username + '&nbsp;[<a href=\"/logout.aspx\">退出</a>]|';

        switch (UserGroupId) {
            case '0':
                html += '<a href=\"/user/\">我的房讯网</a>';

                break;
            case '1':
                html += '<a href=\"/Brokers/\">我的房讯网</a>';

                break;
            case '2':
                html += '<a href=\"/shop/\">我的房讯网</a>';

                break;



        }
        html += '|<a href=\"/help/\">帮助中心</a>';


    } else {
        html = '<a href=\"/login.htm\">登录</a>|<a href=\"/reg.htm\">注册</a>|<a href=\"/login.htm\">我的房讯网</a>|<a href=\"/help/\">帮助中心</a>';
    }

    var obj = document.getElementById('userLoginMsg');
    if (obj != null) {
        obj.innerHTML = html;
    }
}




function startRequest(type, id) {

    $.post('/ajax/rengQi.ashx', { type: type, id: id }, function(data) {

        $("#renqi").html(data);

    })
}


function stateChangeIE(_frame) {
    if (_frame.readyState == "interactive")//state: loading ,interactive,   complete
    {
        var loader = document.getElementById("load");
        loader.innerHTML = "";
        loader.style.display = "none";
        _frame.style.visibility = "visible";
    }
}

function stateChangeFirefox(_frame) {
    var loader = document.getElementById("load");
    loader.innerHTML = "";
    loader.style.display = "none";
    _frame.style.visibility = "visible";
}

function tanchucheng() {

    $('#mapBody').css({ width: $('body').width(), height: $('body').height() });
    $('#mapMain').css({ left: Math.floor(($('body').width() - 750) / 2) });
    $('#mapBut').click(function() {
    
        var sele = document.getElementsByTagName("select");
        for (j = 0; j < sele.length; ++j) {
            sele[j].style.display = "none";
        }

        $('#mapBody').css({ display: 'block' });
        $('#mapMain').css({ display: 'block' });

    });
    
    $('#mapMainTopBg .right').click(function() {

        var sele = document.getElementsByTagName("select");
        for (j = 0; j < sele.length; ++j) {
            sele[j].style.display = "";
        }

        $('#mapBody').css({ display: 'none' });
        $('#mapMain').css({ display: 'none' });

    });
}


