$(document).ready(function()
{

    $(".module-toolbar-item").hover(
  function()
  {
      $(this).addClass("module-toolbar-item-over");
  },
  function()
  {
      $(this).removeClass("module-toolbar-item-over");
  }
  );

    setClientLang();
    fixPng();
});

function setClientLang()
{
    doLang("span");
    doLang("option");
    doLang("button");
}

function doLang(element, isValue, isTitleValue)
{
    var strLang = "";
    $(element).each(function()
    {
        if ($(this).attr("tlang") != null)
        {
            strLang = tLang[$(this).attr("tlang")];
            if (isValue)
            {
                $(this).val(strLang);
            }
            else if (isTitleValue)
            {
                $(this).attr("title", strLang);
            }
            else
            {
                $(this).html(strLang);
            }
        }
    });
}

//是ie6中的png图片透明
function fixPng()
{
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])
    if ((version >= 5.5 && version < 7.0) && (document.body.filters))
    {
        for (var i = 0; i < document.images.length; i++)
        {
            var img = document.images[i];
            var imgName = img.src.toUpperCase();
            if (imgName.indexOf(".PNG") > 0)
            {
                var width = img.width;
                var height = img.height;
                var sizingMethod = (img.className.toLowerCase().indexOf("scale") >= 0) ? "scale" : "image";
                img.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src.replace('%23', '%2523').replace("'", "%27") + "', sizingMethod='" + sizingMethod + "')";
                img.src = "../images/null.gif";
                img.width = width;
                img.height = height;
            }
        }
    }
}
  

//打开模块操作页面，如模块设置、编辑等
function GotoNewPage(url)
{
    location.href = url;
}

function GotoNewPage(url, target)
{
    if (target == "_blank")
    {
        window.open(url);
    }
    else
    {
        location.href = url;
    }
}

//选择回车按钮，针对Submit按钮
function EnterKey(event, ButtonId)
{
    e = event ? event : (window.event ? window.event : null);
    if (e.keyCode == 13)
    {
        document.getElementById(ButtonId).focus();
    }

}

//选择回车按钮，针对Button按钮
function submitKeyClick(event, button)
{
    e = event ? event : (window.event ? window.event : null);
    if (e.keyCode == 13)
    {
        event.cancelBubble = true;
        event.returnValue = false;
        button.click();
    }
}

//等比例缩放图片
function DrawImage(ImgD, FitWidth, FitHeight)
{
    var image = new Image();
    image.src = ImgD.src;
    if (image.width > 0 && image.height > 0)
    {
        if (image.width / image.height >= FitWidth / FitHeight)
        {
            if (image.width > FitWidth)
            {
                ImgD.width = FitWidth;
                ImgD.height = (image.height * FitWidth) / image.width;
            } else
            {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        } else
        {
            if (image.height > FitHeight)
            {
                ImgD.height = FitHeight;
                ImgD.width = (image.width * FitHeight) / image.height;
            } else
            {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
    }
}