﻿var SuccessIco="<img src='../images/accept.gif' />";
var ErrorIco="<img src='../images/exclamation.gif' />";
var LoadingIco="<img src='../images/loading.gif' />";

function IframeResize(targObj)
{
 var targWin = targObj.parent.document.all[targObj.name];
 if(targWin != null) {
  var HeightValue = targObj.document.body.scrollHeight;
  if(HeightValue <500){HeightValue =500};
  if (targWin.style.pixelHeight < HeightValue) {
  targWin.style.pixelHeight = HeightValue;
  }
 }
}

function DrawImage(ImgD, iwidth, iheight) {
    var flag = false;
    var image = new Image();
    image.src = ImgD.src;
    if (image.width > 0 && image.height > 0) {
        flag = true;
        if (image.width / image.height >= iwidth / iheight) {
            if (image.width > iwidth) {
                ImgD.width = iwidth;
                ImgD.height = (image.height * iwidth) / image.width;
            }
            else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
        else {
            if (image.height > iheight) {
                ImgD.height = iheight;
                ImgD.width = (image.width * iheight) / image.height;
            }
            else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
    }
} 

function popwin(strTitle,urlstr, nWidth, nHeight,fnAction) {
   if (nWidth < 10 || nWidth > 1000)
      nWidth = 300;
   if (nHeight < 10 || nHeight > 1000)
      nHeight = 300;

  //popClose();
//  $("#dlgCon").attr("width", nWidth.toString());
//   $("#dlgCon").attr("height", nHeight.toString());
//   $('#dlgCon').attr("src", urlstr);
//  $("#dlgDiv").dialog("enable");
$("#dlgShow").html("<div id='dlgDiv' style='padding:0'><div id='dlgCon' style='padding:0'><iframe id='dlgCon' scrolling='auto' src='" + urlstr + "' frameborder='0' width='" + nWidth.toString() + "' height='" + nHeight.toString() + "'></iframe></div><input id='hdPopState' name='hdPopState' type='hidden' value='0' /><input id='hdPopVal' name='hdPopVal' type='hidden' value='' /></div>");
  //$("#dlgCon").html("<iframe id='dlgCon' scrolling='auto' src='" + urlstr + "' frameborder='0' width='" + nWidth.toString() + "' height='" + nHeight.toString() + "'></iframe>");
  if (fnAction)
       $('#dlgDiv').dialog({ modal: true, title: strTitle, bgiframe: true, resizable: false, height: nHeight, width: nWidth, overlay: { opacity: 0.5, background: 'black' }, close: fnAction });
   else
       $('#dlgDiv').dialog({ modal: true, title: strTitle, bgiframe: true, resizable: false, height: nHeight, width: nWidth, overlay: { opacity: 0.5, background: 'black'} });
}
function emuClick(objT)
{
   if ( $.browser.msie )
       objT.click();          
   else  
   {  
      var   evt   =   document.createEvent("MouseEvents");  
      evt.initEvent("click",true,true);  
      objT.dispatchEvent(evt);  
   }   
}

function popClose() {
//    $('#dlgCon').html("");
    $("#dlgDiv").dialog("destroy").remove();
    //$("#dlgShow").html("<div id='dlgDiv' style='padding:0'><div id='dlgCon' style='padding:0'></div><input id='hdPopState' name='hdPopState' type='hidden' value='0' /><input id='hdPopVal' name='hdPopVal' type='hidden' value='' /></div>");
//    $('#dlgDiv').html("");
//    $('#dlgDiv').html("<div id='dlgCon' style='padding:0'></div><input id='hdPopState' name='hdPopState' type='hidden' value='0' /><input id='hdPopVal' name='hdPopVal' type='hidden' value='' />");
    //$("#dlgDiv").dialog("close");
}

function CreateDatePick(CtrlId)
{
  $('#'+CtrlId).datepicker({  
      dateFormat: 'yy-mm-dd',
 yearRange: '2009:2012',
  clearText:'清除',
  closeText:'关闭',
  prevText:'前一月',
 nextText:'后一月',
  currentText:' ',
 monthNames:['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
  });  
}

function AddRowsHove(TabId,HoveClass) {
   $("#" + TabId + " tr[class!='Header']").hover(
  function() {
      $(this).addClass(HoveClass);
  },
  function() {
      $(this).removeClass(HoveClass);
  }
); 
}

function AjaxDo(param,CallBack)
{
   $.getJSON("../inc/AjaxAgent.ashx",param,CallBack);
}

function AjaxDoPost(param,CallBack)
{
   $.post("../inc/AjaxAgent.ashx",param,CallBack);
}

function OnlyNumber()
{
if ( !(((window.event.keyCode >= 48) && (window.event.keyCode <= 57)) || (window.event.keyCode == 13) || (window.event.keyCode == 46)|| (window.event.keyCode == 45)))
{
window.event.keyCode = 0 ;
}
}

function fixPNG(myImage) {
    var arVersion = navigator.appVersion.split("MSIE");
    var version = parseFloat(arVersion[1]);
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
        var imgName = myImage.src.toUpperCase();
        if (imgName.indexOf(".PNG") > 0) {
            var width = myImage.width;
            var height = myImage.height;
            var sizingMethod = (myImage.className.toLowerCase().indexOf("scale") >= 0) ? "scale" : "image";
            myImage.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + myImage.src.replace('%23', '%2523').replace("'", "%27") + "', sizingMethod='" + sizingMethod + "')";
            myImage.src = "../images/blank.gif";
            myImage.width = width;
            myImage.height = height;
        }
    }
}

function StringBuilder() {
    this.__string__ = new Array();
}
StringBuilder.prototype.append = function(str) {
    this.__string__.push(str);
}
StringBuilder.prototype.toString = function() {
    return this.__string__.join("");
}
