﻿/// <reference path="jquery-vsdoc.js" />
var baseroot;

$(document).ready(function()
{
    MyPng();
});
function MyPng()
{
    $("img.mypng").each(function()
    {
        if ($.browser.msie && $.browser.version >= 5.5 && $.browser.version <= 6.0)
        {
            $(this)[0].runtimeStyle.backgroundImage = "none";
            $(this)[0].runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + $(this).attr("src") + "', sizingMethod='image')"
            $(this).attr("src", baseroot + "/images/pub/spacer.gif");            
        }
    });
}


function myleftback()
{
    $("#leftmenu").hide();
    $("#leftmenumin").show();
}
function myleftpop()
{
    $("#leftmenu").show();
    $("#leftmenumin").hide();
}
function OnBlur(event)
{
    $("#" + event.data.id + "hint")[0].className = "";
    var args = { id: event.data.id };
    eval(event.data.fn + "(args);");
}
function OnFocus(event)
{
    if ($.trim($("#" + event.data.id + "hint").html()) != ""
	    && $.trim($("#" + event.data.id + "hint").html()) != "&nbsp; &nbsp; &nbsp;")
    {
        if ($("#" + event.data.id + "hint")[0].className != "hinterror")
        {
            $("#" + event.data.id + "hint")[0].className = "hint";
        }
    }
}
function RemoveClass(event)
{
    $("#" + event.id + "hint")[0].className = "";
}
function HintError(event, msg)
{
    RemoveClass(event);
    $("#" + event.id + "hint").addClass("hinterror");
    $("#" + event.id + "hint").html(msg);
}
function HintRight(event, msg)
{
    RemoveClass(event);
    if (msg == "")
    {
        msg = "&nbsp; &nbsp; &nbsp; ";
    }

    $("#" + event.id + "hint").addClass("hintright");
    $("#" + event.id + "hint").html(msg);
}
function HindEmpty(event, msg)
{
    RemoveClass(event);
    $("#" + event.id + "hint").html(msg);
}
function FormValidation(groupid, centerclass)
{
    $("#" + groupid).find("." + centerclass).each(function()
    {
        $(this).find("input").each(function()
        {
            if ($(this)[0].getAttributeNode("eval"))
            {
                var span = $("#" + $(this)[0].id + "hint");

                if (span.lenght != 0)
                {
                    $(this).bind("focus", { id: $(this).attr("id") }, OnFocus)
                    $(this).bind("blur", { id: $(this).attr("id"), fn: $(this)[0].getAttributeNode("eval").value }, OnBlur)
                }
            }
        });
        $(this).find("select").each(function()
        {
            if ($(this)[0].getAttributeNode("eval"))
            {
                var span = $("#" + $(this)[0].id + "hint");

                if (span.lenght != 0)
                {
                    $(this).bind("focus", { id: $(this).attr("id") }, OnFocus)
                    $(this).bind("blur", { id: $(this).attr("id"), fn: $(this)[0].getAttributeNode("eval").value }, OnBlur)
                }
            }
        });
    });
}
function asclen(str)
{
    var num = 0;
    for (i = 0; i < str.length; i++)
    {
        if (str.charCodeAt(i) <= 255)
        {
            num++;
        }
        else
        {
            num += 2;
        }
    }
    return num;
}
var inputdialog;
var inputdialogok;
function showinputdlg(title, msg, txt, onok)
{
    inputdialog = $("<div><div class='intputdlgmsg'>" + msg
    + "</div><div class='inputdlgtext'><input id='txtinputdlg' value='" + txt
    + "'></div><div class='inputdlgbtns'><input type='button' class='pubbutton1' value='确 定' onclick='oninputdlgok();'/> &nbsp; &nbsp; &nbsp; &nbsp;<input type='button' class='pubbutton1' value='取 消' onclick='oninputdlgcancel();'/></div></div>");

    inputdialog.dialog(
    {
        title: title,
        width: 410,
        height: 158,
        modal: true,
        overlay: { opacity: 0.5, background: "black" },
        dialogClass: "inputdlg"
    });
    inputdialogok = onok;
}
function oninputdlgok()
{
    var txt = $("#txtinputdlg", inputdialog).val();
    if ($.trim(txt) == "")
    {
        $("#txtinputdlg", inputdialog).focus();
        alert("请输入内容");
        return;
    }
    $(inputdialog).dialog("destroy").remove();

    if (inputdialogok)
    {
        eval(inputdialogok + "(\"" + txt + "\")");
    }
    inputdialogok = null;
}
function oninputdlgcancel()
{
    $(inputdialog).dialog("destroy").remove();
    inputdialogok = null;
}
function showinputdlg1(title, msg, txt, onok, img)
{
    inputdialog = $("<div><table border='0' width='100%'><tr><td align='center' valign='top'><br/><div class='userimgbg'><img src='" + img
    + "'/></div></td><td><div class='intputdlgmsg1'>" + msg
    + "</div><textarea id='txtinputdlg'>" + txt
    + "</textarea></td></tr></table><div class='inputdlgbtns'><input type='button' class='pubbutton1' value='确 定' onclick='oninputdlgok();'/> &nbsp; &nbsp; &nbsp; &nbsp;<input type='button' class='pubbutton1' value='取 消' onclick='oninputdlgcancel();'/></div></div>");

    inputdialog.dialog(
    {
        title: title,
        width: 410,
        height: 236,
        modal: true,
        overlay: { opacity: 0.5, background: "black" },
        dialogClass: "inputdlg1"
    });
    inputdialogok = onok;
}
function showmsgdlg(title, msg, img)
{
    inputdialog = $("<div><table border='0' width='100%'><tr><td align='center' valign='top' width='120'><br/><div class='userimgbg'><img src='" + img
    + "'/></div></td><td><div class='msgdlgmsg'>" + msg
    + "</div><div class='inputdlgbtns'><input type='button' class='pubbutton1' value='关 闭' onclick='oninputdlgcancel();'/></div></td></tr></table></div>");

    inputdialog.dialog(
    {
        title: title,
        width: 410,
        height: 158,
        modal: true,
        overlay: { opacity: 0.5, background: "black" },
        dialogClass: "msgdlg"
    });
}
function OnDisableTextKeyDown(eventTag)
{
    var event = eventTag || window.event;

    if (window.event)
    {
        event.returnValue = false;
    }
    else
    {
        event.preventDefault();
    }
}