﻿function fixDomain() {
    try { if (window.top.document.domain != 'www.fwxgx.com' && window.top.location.href.indexOf('fwxgx.com') > 0) document.domain = "fwxgx.com"; } catch (e) { void (0); }
}
function getCurrentDay(){
        var date = new Date();
        return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
    }
function replacechn(url) {
    var chn = /[\u4E00-\u9Fa5]/;
    if (chn.test(url)) {
        return url = encodeURI(url);
    }
    return url;
}

function getDomain() {
    var hp = window.location.hostname.split('.');
    var domain = window.location.hostname;
    if (hp.length > 1) domain = hp[hp.length - 2] + "." + hp[hp.length - 1];
    return domain;
}
fixDomain();

if (typeof ($) == 'undefined') $ = null;

//分页控件校验页索引的函数
function doCheck(el, maxIndex) {
    var r = new RegExp('^\\s*(-?\\d+)\\s*$');
    if (r.test(el.value)) {
        var value = parseInt(RegExp.$1);
        if (value < 1 || value > maxIndex) {
            alert('页数超出范围！');
            el.select();
            el.focus();
            return false;
        }
        return true;
    }
    alert('页索引无效！');
    el.select();
    el.focus();
    return false;
}


//点击列表框表头上的CheckBox选择所有列表的CheckBox
//element : 表格的ID
//value 表头CheckBox的值
function checkedAllCheckbox(element, value) {
    for (i = 0; i < element.all.length; i++) {
        var obj = element.all(i);
        if (obj.type == 'checkbox' && obj.isDisabled == false) {
            obj.checked = value;
        }
    }
}

// 列表中的checkbox状态改变的时候，设置全部选中的checkbox的状态
function setSelectAllState(element, selectAll) {
    var result = true;
    for (i = 0; i < element.all.length; i++) {
        var obj = element.all(i);
        if (obj.type == 'checkbox' && obj.isDisabled == false) {
            result &= obj.checked;
            if (result == false)
                break;
        }
    }
    selectAll.checked = result;
}

function AppendVerifyKey2Url(url) {
    return url + (url.indexOf("?") < 0 ? "?" : "&") + "1=1";
}



function inputNumber() {
    if (!((window.event.keyCode >= 48) && (window.event.keyCode <= 57))) return false;
}

//根据对象ID字符串，返回对象。
function $G(elementName) {
    return document.getElementById(elementName);
}

//根据对象的name字符串返回，对象集合
function $N(elementName) {
    return document.getElementsByName(elementName);
}

//根据标记名称返回对象集合。
function $T(elementName) {
    return document.getElementsByTagName(elementName);
}


function GetCookie(sName) {
    // cookies are separated by semicolons
    var aCookie = document.cookie.split("; ");
    for (var i = 0; i < aCookie.length; i++) {
        // a name/value pair (a crumb) is separated by an equal sign
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0])
            return unescape(aCrumb[1]);
    }
    // a cookie with the requested name does not exist
    return null;
}

function SetCookie(name, value, expires)//两个参数，一个是cookie的名子，一个是值,expires是要保存的天数
{
    if (typeof (expires) == "undefined") expires = ""
    if (expires != "") {
        var exp = new Date();
        exp.setTime(exp.getTime() + expires * 24 * 60 * 60 * 1000);
    }
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}


//获取页面中，单选框列表选中的值
function $getCheckedRadio(elementName) {
    var radios = $N(elementName);
    var values = "";
    for (var i = 0; i < radios.length; i++) {
        if (radios[i].checked) {
            values = radios[i].value;
            break;
        }
    }
    return values;
}

//更改一个对象的隐藏显示状态
function $showHideObject(obj) {
    if (obj.style.display == "none")
        obj.style.display = "";
    else
        obj.style.display = "none";
}


// ******************************************************* end

/*
添加一个函数到onload事件中        参数methodName表示函数名称，字符串类型的。    */
function $addLoadEventHandler(methodName) {
    $addElementEventHandler(window, "onload", methodName);
}

/*
添加一个方法到到一个对象的一个的一个事件中
element 要设置的对象  
eventName 事件名称， 字符串类型的。        methodName表示函数名称，字符串类型的。    */
function $addElementEventHandler(element, eventName, methodName) {
    if (document.all) {
        element.attachEvent(eventName, new Function(methodName));
    }
    else {
        if (eventName.substring(0, 2) == "on") eventName = eventName.substring(2);
        element.addEventListener(eventName, new Function(methodName), true);
    }
}

/******************下面的方法是为了防止表单重复提交****************************/

//修改当前页面所有表单的提交事件
function $setFormCheckSubmited() {
    return;
    if ($ && $('form').validate) return;
    var frms = document.forms;
    for (var i = 0; i < document.forms.length; i++) {
        if (typeof (frms[i].submited) == 'undefined' && frms[i].getAttribute('CheckSubmited') != 'false')//防止重复加载自定义的提交事件
        {
            frms[i].baseSubmit = frms[i].submit;
            frms[i].submited = false;
            frms[i].submit = new Function("$submitForm(this)");
            $addElementEventHandler(frms[i], "onsubmit", "return $submitForm(document.forms[" + i + "])");
        }
    }
}

//提交一个表单，如果当前表单已经提交，那么就不会继续提交该表单
function $submitForm(frm) {
    if (frm.submited) return false;
    frm.submited = true;
    frm.baseSubmit();
    return false; //防止onsubmit事件继续提交表单
}
/*****************************end*************************************************/

//表单操作对象，对表单对象进行的一些操作封装在这个类里面
function FormOperation(formObject) {
    this.operatorForm = formObject
    FormOperation.prototype.checkAll = function(checkState) {
        var e = this.operatorForm.getElementsByTagName('input');
        for (var i = 0; i < e.length; i++) {
            if (e[i].type == "checkbox") e[i].checked = checkState;
        }
    }

    FormOperation.prototype.hasChecked = function() {
        var e = this.operatorForm.elements;
        for (var i = 0; i < e.length; i++) {
            if (e[i].type == "checkbox" && e[i].checked && e[i].value != "on" && e[i].value.length > 0) { return true; }
        }
        return false;
    }

    FormOperation.prototype.submit = function() {
        this.operatorForm.submit();
    }
}

//表格操作对象，对表格进行的一些操作封装在这个类里面
function TableOperation(tableObject) {
    //计算某列的值的总和
    TableOperation.prototype.sumCol = function(colIndex) {
        var count = 0;
        for (var i = 0; i < tableObject.rows.length - 1; i++) {
            if (tableObject.rows[i].cells[colIndex])
                count += isNaN(parseInt(tableObject.rows[i].cells[colIndex].innerText)) ? 0 : parseInt(tableObject.rows[i].cells[colIndex].innerText);
        }
        return count;
    }

    //计算某列的值的总和
    TableOperation.prototype.avg = function(colIndex) {
        var count = 0.00;
        var n = 0.00;
        var j = 0;
        for (var i = 0; i < tableObject.rows.length - 1; i++) {

            if (tableObject.rows[i].cells[colIndex]) {
                n = isNaN(parseInt(tableObject.rows[i].cells[colIndex].innerText)) ? 0.00 : parseInt(tableObject.rows[i].cells[colIndex].innerText * 100) / 100;
                if (n > 0) {
                    j++;
                    count += n;
                }
            }
        }
        return parseInt(count / j * 100 / 100);
    }

    //计算某行总和
    TableOperation.prototype.sumRow = function(rowIndex) {
        var count = 0;
        var r = tableObject.rows[rowIndex];
        for (var i = 0; i < r.cells.length - 1; i++) {
            if (r.cells[i])
                count += isNaN(parseInt(r.cells[i].innerText)) ? 0 : parseInt(r.cells[i].innerText);
        }
        return count;
    }

    TableOperation.prototype.formatAsTab = function(currentPic, backGroundPic, width, height) {
        tds = tableObject.getElementsByTagName("td");
        for (var i = 0; i < tds.length; i++) {
            if (tds[i].innerText == "" || tds[i].getAttribute("IsTab") != "true")
                continue;

            if (tds[i].getAttribute("TabStyle") == "selected" || tds[i].getAttribute("Selected") == "true") {
                tds[i].background = currentPic;
                tds[i].style.color = "#0000aa";
                tds[i].style.fontWeight = 'bold';
                tds[i].style.cursor = "hand";
            }
            else {
                tds[i].background = backGroundPic;
                tds[i].style.cursor = "hand";
                $addElementEventHandler(tds[i], "onmouseover", "if(event.srcElement.tagName=='TD') event.srcElement.background = '" + currentPic + "'");
                $addElementEventHandler(tds[i], "onmouseout", "if(event.srcElement.tagName=='TD') event.srcElement.background = '" + backGroundPic + "'");
            }
        }
    }

    TableOperation.prototype.formatAsSimpleTab = function(currentColor, backGroundColor, width, height) {
        tds = tableObject.getElementsByTagName("td");
        for (var i = 0; i < tds.length; i++) {
            if (tds[i].innerText == "" || tds[i].getAttribute("IsTab") != "true")
                continue;
            tds[i].style.cursor = "hand";
            tds[i].style.padding = "6px";
            tds[i].style.fontSize = "10pt";
            tds[i].style.border = "1px solid #cccccc";

            tds[i].style.borderBottomWidth = "0px"; //去掉下面的边框

            if (i != tds.length - 1)
                tds[i].style.borderRightWidth = "0px"; //如果不是最后一个，去掉右边边框

            if (tds[i].getAttribute("TabStyle") == "selected" || tds[i].getAttribute("Selected") == "true") {
                tds[i].style.background = currentColor;
                tds[i].style.fontWeight = "bold";
            }
            else {
                tds[i].style.background = backGroundColor;
                $addElementEventHandler(tds[i], "onmouseover", "if(event.srcElement.tagName=='TD') event.srcElement.style.background = '" + currentColor + "'");
                $addElementEventHandler(tds[i], "onmouseout", "if(event.srcElement.tagName=='TD') event.srcElement.style.background = '" + backGroundColor + "'");
            }
        }
    }

}

//下拉列表框操作对象
function SelectOperater(obj) {
    //如果没有选项，是否显示该select
    this.showEmpty = true;
    //待操作的select对象
    this.selectObject = obj;
    //添加列表项
    this.add = function(text, value, index) {
        var op = new Option(text, value);
        if (index == undefined)
            this.selectObject.options.add(op, this.selectObject.options.length);
        else
            this.selectObject.options.add(op, index); //.add在Firefox中无效，改用options.add
    }
    //删除列表项
    this.removeOption = function(optionIndex) {
        if (optionIndex == undefined) {
            for (var i = this.selectObject.length - 1; i > -1; i--) {
                if (this.selectObject.options[i].selected)
                    this.selectObject.remove(i);
            }
        }
        else {
            this.selectObject.remove(optionIndex);
        }
    }
    //把另一个select对象中选中的项添加到自身
    this.addFromSelect = function(obj) {
        for (var i = 0; i < obj.options.length; i++) {
            if (obj.options[i].selected) {
                this.selectObject.options.add(new Option(obj.options[i].text, obj.options[i].value), this.getIndex(obj.options[i].value));
            }
        }
    }

    //获取某个值在列表中的位置，按照value值的大小，从小到大排序
    this.getIndex = function(id) {
        for (var i = 0; i < this.selectObject.options.length; i++) {
            if (parseInt(this.selectObject.options[i].value) > id) break;
        }
        return i;
    }

    //清空列表项
    this.clear = function() {
        for (var i = this.selectObject.length - 1; i > -1; i--) {
            this.selectObject.remove(i);
        }
    }

    //根据一个二维数组初始化一个list
    this.init = function(list, selectedValue) {

        this.clear();
        for (var i = 0; i < list.length; i++) {
            this.add(list[i][1], list[i][0]);
        }
        this.add("--请选择--", "-1", 0);

        if (i > 0) {
            this.setValue(selectedValue ? selectedValue : -1);
            this.selectObject.style.display = "";
        }
        else {
            if (!this.showEmpty) this.selectObject.style.display = "none";
        }

    }

    this.setValue = function(value) { this.selectObject.value = value; }

}


//pang，关键字集合用逗号分开，对象集合使用getElementsByTagName获取的
//把一个对象集合中的内容按照一个关键字集合格式化
function formatKeyWords(keyWords, objs) {
    var keyWordsList = keyWords.split(',');

    for (var j = 0; j < objs.length; j++) {
        for (var i = 0; i < keyWordsList.length; i++) {
            var r = new RegExp(keyWordsList[i], "g");
            objs[j].innerHTML = objs[j].innerHTML.replace(r, '<font color=red>' + keyWordsList[i] + '</font>');
        }
    }
}

//显示指定数量的星星
function showStars(num) {
    for (var i = 0; i < num; i++) {
        document.write('<img src=/image/star.gif />');
    }
}

//退出登录
function signout() {
    if (top)
        top.location.href = '/signout.oxml?__ReturnUrl=' + escape(top.location.href);
    else
        top.location.href = '/signout.oxml';
}

//进入登录页面
function signin() {

    if (top)
        top.location.href = '/GIM_O_User_Login.exml?__ReturnUrl=' + escape(top.location.href);
    else
        top.location.href = '/GIM_O_User_Login.exml';
}

//根据html页面名称，返回exml页面地址
function getExmlUrl(htmlName) {
    switch (htmlName) {
        case "question.htm":
            return "Web_002_A01_000V.exml";
            break;

        case "im.htm":
            return "WEB_006_000_000.exml";
            break;

        case "soft.htm":
            return "Web_004_000_000.exml";
            break;

        case "classroom.htm":
            return "Web_003_000_000.exml";
            break;

        case "inform.htm":
            return "Web_005_000_000.exml";
            break;
    }
}

function formatAjaxParams(form) {
    var str = "";
    var objs = form.elements;
    for (var i = 0; i < objs.length; i++) {
        str += "&" + objs[i].name + "=" + objs.value;
    }
    if (str.length > 0) return str.substring(1);
    return str;

}


function iframeAutoFit(minHeight) {
    try {
        if (window != parent) {
            var a = parent.document.getElementsByTagName("IFRAME");
            for (var i = 0; i < a.length; i++) //author:meizz
            {
                if (a[i].contentWindow == window) {
                    var h1 = 0, h2 = 0;
                    a[i].parentNode.style.height = a[i].offsetHeight + "px";
                    a[i].style.height = "10px";
                    if (document.documentElement && document.documentElement.scrollHeight) {
                        h1 = document.documentElement.scrollHeight;
                    }
                    if (document.body) h2 = document.body.scrollHeight;

                    var h = Math.max(h1, h2);
                    if (document.all) { h += 4; }
                    if (window.opera) { h += 1; }
                    if (h <= 4) {
                        setTimeout("iframeAutoFit();", 500);
                        break;
                    }
                    if (minHeight && h < minHeight) h = minHeight;
                    a[i].style.height = a[i].parentNode.style.height = h + "px";
                }
            }
        }
    }
    catch (ex) { }
}

function $setSelectDefaultValue() {
    try {
        $("select[defaultValue]").each(function() {
            $(this).val($(this).attr("defaultValue"));
        });
    }
    catch (ex) { }
}

function showNickTools(userId) {
    $G('NickToolsFrame').src = 'Web_000_C01_008.axml?__UserID=' + userId;
    var x = document.body.scrollLeft + event.clientX;
    var y = document.body.scrollTop + event.clientY;
    $G('divNickTools').style.top = y - 10;
    $G('divNickTools').style.left = x;
    $G('divNickTools').style.display = '';
}

function hideNickTools() {
    $G('divNickTools').style.display = "none";
}

var notLoginMsg = '您还没有登录，请登录后进行该操作！';
var notHasDog = '您未验证加密锁，没有权限下载，请您到个人中心进行验证！';
var canNotDeleteIsAccepted = '最佳答案不能进行删除操作！';
var userIsLock = '你的帐户已经被封杀，系统不允许你登录！';
var ipIsLock = '您所在的IP已经被封杀，如果您是我们的用户请和我们联系！';
var notHavePurview = '权限不够，不能进行该操作！';
var notEnoughPoint = '没有足够的积分，不能进行该操作！';
var shareDataMaxSize = 15 * 1024;

//调用防止表单重复提交代码
if ($)
    $($setFormCheckSubmited);
else
    $addLoadEventHandler("$setFormCheckSubmited()");

//调用设置select对象默认值代码
if ($)
    $($setSelectDefaultValue);
else
    $addLoadEventHandler("$setSelectDefaultValue()");


//lib++2008-07-25{
function loadJsCssFile(filename, filetype) {
    if (filetype == "js") { //如果是.js文件
        var fileref = document.createElement('script');
        fileref.setAttribute("type", "text/javascript");
        fileref.setAttribute("src", filename);
    }
    else if (filetype == "css") { //如果是.css文件
        var fileref = document.createElement("link");
        fileref.setAttribute("rel", "stylesheet");
        fileref.setAttribute("type", "text/css");
        fileref.setAttribute("href", filename);
    }
    if (typeof fileref != "undefined")
        document.getElementsByTagName("head")[0].appendChild(fileref);
}
function loadJsFile(filename) {
    var fileref = document.createElement('script');
    fileref.setAttribute("type", "text/javascript");
    fileref.setAttribute("src", filename);
    if (typeof fileref != "undefined")
        document.getElementsByTagName("head")[0].appendChild(fileref);
}
function loadCssFile(filename) {
    var fileref = document.createElement("link");
    fileref.setAttribute("rel", "stylesheet");
    fileref.setAttribute("type", "text/css");
    fileref.setAttribute("href", filename);
    if (typeof fileref != "undefined")
        document.getElementsByTagName("head")[0].appendChild(fileref);
}

function loadPlugInFile(name) {
    loadCssFile("/css/" + name + ".css");
    loadJsFile("/script/" + name + ".js");
}

//}

//pang++ 提示登陆信息的地方，换成显示登陆框
//{
if (!alertBase) var alertBase = window.alert;
window.alert = function(messageStr) {
    if (messageStr == notLoginMsg) {
        showLoginBox();
        return;
    }
    alertBase(messageStr);
}

function showLoginBoxAsUrl(loginUrl) {
    c_domain = getDomain();
    if (c_domain.indexOf('.') > 0) document.domain = c_domain;
    showLoginBox(null, null, loginUrl);
}
function showLoginBox(messageStr, param, loginUrl, top, left) {



    //如果左侧有登陆框，就不再显示，只是定位到登陆框
    /*if ($('#loginFrame').length > 0) {
    $('#loginFrame').contents().find('#__UserName').focus();
    if (typeof messageStr != 'undefined' && messageStr) alertBase(notLoginMsg);
    return;
    }

    if ($('#formLogin').length > 0) {
    $('#__UserName').focus();
    alertBase(notLoginMsg);
    return;
    }*/

    //默认返回当前页面
    if (typeof param == 'undefined' || !param) {
        param = window.top.location.href
    }
    jinghaoposition = param.indexOf('#');
    if (jinghaoposition > 0)
        param = param.substr(0, jinghaoposition);


    //显示消息
    if (typeof messageStr != 'undefined' && messageStr) alertBase(messageStr);

    var loginBox = $G('loginBox');

    //创建loginbox
    if (!loginBox) {
        loginBox = document.createElement("div");
        document.body.appendChild(loginBox);
        var url = '/gim_h_login.axml';

        if (loginUrl && loginUrl.length > 0) {
            url = loginUrl;
        }
        else {
            if (window.top.location.href.indexOf('service.fwxgx.cn') == -1) {
                urlpart = window.top.location.href.split('/');
                url = urlpart[0] + "//www." + urlpart[2].split('.')[1] + "." + urlpart[2].split('.')[2] + url;
            }
            else {
                url = "http://service.fwxgx.cn" + url;
            }
        }
        loginBox.innerHTML = "<div class=easydrag id=loginBox style='width:240px;' ><div class=easydrag_content><span style=color:red></span><iframe name=loginBoxFrame width=230 height=150px frameborder=0 src=" + url + "?__ReturnUrl=" + param + " scrolling=no style=overflow:hidden;></iframe></div></div>";
        $("#loginBox iframe")[0].src = url + "?__ReturnUrl=" + escape(param);
        seteasydrag('loginBox', '用户登陆');
    }
    //$("#loginBox iframe")[0].src = url + "?__ReturnUrl=" + escape(param);
    showeasydrag('loginBox', top, left);
    $('#loginBox iframe')[0].contentWindow.focus();
    //显示loginbox，这里用了延迟显示，使前面的相关组件能够加载完成
    //setTimeout("showeasydrag('loginBox');", 1000);

}

function showLoginBoxWithPos(top, left) {
    showLoginBox(false, false, false, top, left)
}
function notLogin() {
    alert(notLoginMsg);
}
//}
//获取URL中某个参数
function getUrlParam(o) {
    var url = decodeURI(window.location.toString());
    var tmp;
    if (url && url.indexOf("?")) {
        var arr = url.split("?");
        var parms = arr[1];
        if (parms && parms.indexOf("&")) {
            var parmList = parms.split("&");
            jQuery.each(parmList, function(key, val) {
                if (val && val.indexOf("=")) {
                    var parmarr = val.split("=");
                    if (o) {
                        if (typeof (o) == "string" && o == parmarr[0]) {
                            tmp = parmarr[1] == null ? '' : parmarr[1];
                        }
                    }
                    else {
                        tmp = parms;
                    }
                }
            });
        }
    }
    return tmp;
}
//替换URL中某个参数
function replaceUrlParam(url, name, value) {
    if (new RegExp("[\?]", "gi").exec(url) == null)
        return url + "?" + name + "=" + value;

    var rg1 = new RegExp(name + "=[^&]*", "gi");
    var rg2 = new RegExp("[&]{2,}", "gi");
    var result, returl = url;

    while ((result = rg1.exec(url)) != null) {
        returl = returl.replace(result, "");
    }
    while ((result = rg2.exec(url)) != null) {
        returl = returl.replace(result, "");
    }
    return (returl + "&" + name + "=" + value);
}
function bg1a(bgA) { bgA.className = 'butBox onBut'; }
function bg1b(bgA) { bgA.className = 'butBox'; }
function goNotLoginPage(url) {
    location.href = url + "?__ReturnUrl=" + top.location.href;
}

//获取首页登陆框信息
function getLoginedUserInfo() {
    if (gUserID && gUserID.length > 0 && gUserID > 0) {
        try {
            $('#LoginedUserInfo').hide();
            $(function() {
                $.ajax({
                    //url: "/GIM_O_User_AjaxInfo.axml",
                    url: "/u/u",
                    cache: true,
					data: {"_ts":getCurrentDay()},
                    success: function(txt) {
                        $('#LoginedUserInfo').html(txt);
                        $('#LoginedUserInfo').show();
                        initUserBar();
                    }
                });
            })
        }
        catch (ex) { }
    }
    else {
        $.ajax({ url: "/loginbox.html", cache: true,
            success: function(txt) {
                $('#LoginedUserInfo').html(txt).show();
            }
        });
    }
}

function initUserBar() {
    if (gUserID && gUserID.length > 0 && gUserID > 0 && $('#topuserinfo').length > 0) {
        if ($('#usernick').length > 0) {
            $('#userbar_nick').html($('#usernick').html());
            $('#userbar_level').text($('#userlevel').text());
            $('#userbar_msg').text($('#usermsg').text());
            $('#topuserinfo').show();
            $('#topuserinfo_notlogin').hide();
            return;
        }

        if ($('#formLogin').length == 0) {
            $.ajax({
                //url: "/AjaxForUserBar.axml",
                url: "/u/u/bar",
                cache: true,
				data: {"_ts":getCurrentDay()},
                success: function(txt) {
                    $('#topuserinfo').html(txt);
                    $('#topuserinfo').show();
                    $('#topuserinfo_notlogin').hide();
                }
            });
        }
    }
    else {
        $('#topuserinfo').hide();
        $('#topuserinfo_notlogin').show();
    }
}


function gotoCJZS() {
    if (!gUserID || gUserID < 0) {
        alert(notLoginMsg);
        return false;
    }

    if (location.href.indexOf('grandsoft.cn') > -1) {
        window.location.href = 'http://gam.grandsoft.cn:8080/devel';
        return;
    }

    if (location.href.indexOf('fwxgx.com') > -1)
        window.location.href = 'http://gam.fwxgx.com/gam';
    else
        window.location.href = 'http://gam.grandsoft.com.cn/gam';
}
function gtrim(txt) {
    if (txt == undefined) return "";
    return txt.replace(/(^\s*)|(\s*$)/g, "");
}
function isblank(txt) {
    return gtrim(txt) == "";
}
gUserID = GetCookie("UserID");
function notlogin() {
    return !((gUserID != null) && (gUserID > 0));
}
function islogin(){
	return ((gUserID != null) && (gUserID > 0));
}
var entityType = { "add": 0, "modify": 1, "remove": 2 };

try {
    $(function() {
        $("textarea").each(function() {
            if (gtrim(this.value) == "") {
                $(this).val("");
            }
        });
        initUserBar();
    });
}
catch (e) {

}

//global variable, this will store the highest height value  
var maxHeight = 0;

function setHeight(col) {
    col = $(col);
    col.each(function() {
        if ($(this).height() > maxHeight) {
            maxHeight = $(this).height(); ;
        }
    });
    col.height(maxHeight);
}

function showmyapp(obj) {
    var pos = getposition(obj);
    $('#userbar_myapplist').css('top', pos.y + $(obj).height()-1);
    $('#userbar_myapplist').css('left', pos.x);
    $('#userbar_myapplist').show();
}

function hidemyapp(obj) {
    $('#userbar_myapplist').hide();
}
function getposition(obj) {
    var p = new Object();
    p.x = 0;
    p.y = 0;

    if (!obj) return p;

    while (obj && obj.tagName.toUpperCase() != "BODY" && obj.tagName.toUpperCase() != "HTML") {
        p.x += obj.offsetLeft;

        p.y += obj.offsetTop;

        obj = obj.offsetParent;
    }

    return p;
}

var Head = {
    _homeUrl: 'http://www.fwxgx.com',
    homepage: function(objIn) {//设为首页
        try {
            objIn.style.behavior = 'url(#default#homepage)';
            objIn.setHomePage(this._homeUrl);
        }
        catch (e) { alert("您现在使用的浏览器无法自动设为首页，请手动设置！"); }
    },
    addFavorite: function() {//添加为收藏
        var url = this._homeUrl;
        var title = "广联达服务新干线";
        if (window.sidebar) window.sidebar.addPanel(title, url, "");
        else if (document.all) window.external.AddFavorite(url, title);
        else if (window.opera && window.print) return true;
    }
};

function inputTipText() {
    $("input[class*=grayTips]") //所有样式名中含有grayTips的input
          .each(function() {
              var oldVal = $(this).val();   //默认的提示性文本
              $(this)
             .css({ "color": "#888" }) //灰色
             .focus(function() {
                 if ($(this).val() != oldVal) { $(this).css({ "color": "#000" }) } else { $(this).val("").css({ "color": "#888" }) }
             })
             .blur(function() {
                 if ($(this).val() == "") { $(this).val(oldVal).css({ "color": "#888" }) }
             })
             .keydown(function() { $(this).css({ "color": "#000" }) })

          })
}
try {
    $(function() {
        inputTipText(); //直接调用就OK了
    })
}
catch (e) { }
