﻿function fixPNG(myImage) {
    var arVersion = navigator.appVersion.split("MSIE");
    var version = parseFloat(arVersion[1]);
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
        var imgID = (myImage.id) ? "id='" + myImage.id + "' " : "";
        var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : "";
        var imgTitle = (myImage.title) ? "title='" + myImage.title + "' " : "title='" + myImage.alt + "' ";
        var imgStyle = "display:inline-block;" + myImage.style.cssText;
        var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + myImage.width + "px; height:" + myImage.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>";
        myImage.outerHTML = strNewHTML;
    }
}
//弹出自编短信投注框

function showSmsBg(SN) {
    //动态加上

    var tl = "手机投票";
    var t2 = "91" + SN;
    var temphtml = "<div id='dialog' style='width:400px; BORDER: #e2c4a7 1px solid; height:auto;;position:absolute;'>" +
  "<div style='background-color:#fbf5ef; height:30px; line-height:30px; text-indent:10px; font-size:14px;BORDER-bottom: #e2c4a7 1px solid; width:100%;'>" +
    "<div style='float:left;'><strong>" + tl + "</strong></div>" +
    "<div style='float:right; height:21px; width:31px; margin-bottom:4px; margin-top:5px; margin-right:5px;'><img src='images/close2.gif' onmouseout='javascript:this.src=\"images/close2.gif\"' onmouseover='javascript:this.src=\"images/close1.gif\"' onclick='closeBg();' title='关闭'/></div>" +
  "</div>" +
  "<div style='height: auto;background-color:#ffffff;'>" +
    "<table width='100%' height='100%' border='0' align='center' cellpadding='0' cellspacing='10'>" +
      "<tr>" +
        "<td align='left' valign='middle' style='line-height:20px;'>编辑短信：</td>" +
      "</tr>" +
      "<tr>" +
        "<td align='center' valign='middle' style='line-height:20px;'><textarea cols='45' rows='2' readonly='readonly'>" + t2 + "</textarea></td>" +
      "</tr>" +
      "<tr>" +
        "<th style='line-height:20px; background:url(/images/email_open_image.gif) no-repeat 100px 1px; color:#FF7F00; font-size:14px;'>发送至<span class='STYLE3'>10628882</span></th>" +
      "</tr>" +
      "<tr>" +
        "<td align='left' valign='middle' style='line-height:20px;'>注：编辑短信时，91后面跟选手编号，不用+,如 91001 </td>" +
      "</tr>" +
    "</table>" +
  "</div>" +
"</div>" +
 "<div id='fullbg'></div>";


    jQuery("body").append(temphtml);

    var bH = jQuery("body").height();
    var bW = jQuery("body").width() + 16;
    var objWH = getObjWh("dialog");
    jQuery("#fullbg").css({ width: bW, height: bH, display: "block" });
    var tbT = objWH.split("|")[0] + "px";
    var tbL = objWH.split("|")[1] + "px";
    jQuery("#dialog").css({ top: tbT, left: tbL, display: "block" });
    jQuery(window).scroll(function () { resetBg() });
    jQuery(window).resize(function () { resetBg() });
}


function showSongSmsBg(SN) {
    //动态加上

    var tl = "手机投票";
    var t2 = "91" + SN;
    var temphtml = "<div id='dialog' style='width:400px; BORDER: #e2c4a7 1px solid; height:auto;;position:absolute;'>" +
  "<div style='background-color:#fbf5ef; height:30px; line-height:30px; text-indent:10px; font-size:14px;BORDER-bottom: #e2c4a7 1px solid; width:100%;'>" +
    "<div style='float:left;'><strong>" + tl + "</strong></div>" +
    "<div style='float:right; height:21px; width:31px; margin-bottom:4px; margin-top:5px; margin-right:5px;'><img src='images/close2.gif' onmouseout='javascript:this.src=\"images/close2.gif\"' onmouseover='javascript:this.src=\"images/close1.gif\"' onclick='closeBg();' title='关闭'/></div>" +
  "</div>" +
  "<div style='height: auto;background-color:#ffffff;'>" +
    "<table width='100%' height='100%' border='0' align='center' cellpadding='0' cellspacing='10'>" +
      "<tr>" +
        "<td align='left' valign='middle' style='line-height:20px;'>编辑短信：</td>" +
      "</tr>" +
      "<tr>" +
        "<td align='center' valign='middle' style='line-height:20px;'><textarea cols='45' rows='2' readonly='readonly'>" + t2 + "</textarea></td>" +
      "</tr>" +
      "<tr>" +
        "<th style='line-height:20px; background:url(/images/email_open_image.gif) no-repeat 100px 1px; color:#FF7F00; font-size:14px;'>发送至<span class='STYLE3'>10628882</span></th>" +
      "</tr>" +
      "<tr>" +
        "<td align='left' valign='middle' style='line-height:20px;'>注：编辑短信时，91后面跟歌曲编号，不用+,如 91B011 </td>" +
      "</tr>" +
    "</table>" +
  "</div>" +
"</div>" +
 "<div id='fullbg'></div>";


    jQuery("body").append(temphtml);

    var bH = jQuery("body").height();
    var bW = jQuery("body").width() + 16;
    var objWH = getObjWh("dialog");
    jQuery("#fullbg").css({ width: bW, height: bH, display: "block" });
    var tbT = objWH.split("|")[0] + "px";
    var tbL = objWH.split("|")[1] + "px";
    jQuery("#dialog").css({ top: tbT, left: tbL, display: "block" });
    jQuery(window).scroll(function () { resetBg() });
    jQuery(window).resize(function () { resetBg() });
}


//关闭灰色JS遮罩层和操作窗口
function closeBg() {
    //window.location.reload();
    jQuery("#fullbg").remove();
    jQuery("#dialog").remove();
}
function closeBgFlush() {
    window.location.reload();
    //jQuery("#fullbg").remove();
    //jQuery("#dialog").remove();
}

function getObjWh(obj) {
    var st = document.documentElement.scrollTop; //滚动条距顶部的距离
    var sl = document.documentElement.scrollLeft; //滚动条距左边的距离
    var ch = document.documentElement.clientHeight; //屏幕的高度
    var cw = document.documentElement.clientWidth; //屏幕的宽度

    //alert(st +"\n"+ sl +"\n"+ ch +"\n"+ cw);

    var objH = $("#" + obj).height(); //浮动对象的高度
    var objW = $("#" + obj).width(); //浮动对象的宽度
    var objT = Number(st) + (Number(ch) - Number(objH)) / 2;
    var objL = Number(sl) + (Number(cw) - Number(objW)) / 2;
    return objT + "|" + objL;
}
function resetBg() {
    var fullbg = $("#fullbg").css("display");
    if (fullbg == "block") {
        var bH2 = $("body").height();
        var bW2 = $("body").width() + 16;
        $("#fullbg").css({ width: bW2, height: bH2 });
        var objV = getObjWh("dialog");
        var tbT = objV.split("|")[0] + "px";
        var tbL = objV.split("|")[1] + "px";
        $("#dialog").css({ top: tbT, left: tbL });
    }
}


