﻿var NewWin = null;
function OpenBar(path,title,height,width,left,top,resizable,scrollbars)
{
   var arg = "height="+height+",width="+width+",left="+left+",top="+top+",resizable="+resizable+",scrollbars="+scrollbars+",status=no,toolbar=no,menubar=no,location=no";
   NewWin = window.open(path,title,arg);
   NewWin.focus();
}
function DrawImage(imgObject,iwidth,iheight)
{
  var image=new Image();
  image.src=imgObject.src;
  var FitWidth = iwidth;
  var FitHeight = iheight;
  imgObject.style.marginTop = 0 +'px';
  imgObject.style.marginBottom = 0 +'px';
  if(image.width>0 && image.height>0)
  {
    if(image.width/image.height >= FitWidth/FitHeight)
    {
     if(image.width>FitWidth)
     {
      imgObject.width=FitWidth;
      imgObject.height=(image.height*FitWidth)/image.width;
     }
     else
     {
      imgObject.width=image.width;
      imgObject.height=image.height;
     }
    }
    else
    {
     if(image.height>FitHeight)
     {
      imgObject.height=FitHeight;
      imgObject.width=(image.width*FitHeight)/image.height;
     }
     else
     {
      imgObject.width=image.width;
      imgObject.height=image.height;
     }
   }
   if(imgObject.height < FitHeight)
   {
      var mInt =  Math.round((FitHeight-imgObject.height)/2) +'px';
      imgObject.style.marginTop = mInt;
      imgObject.style.marginBottom = mInt;
   }
  }    
}
function getId(aID)
{
  return (document.getElementById) ? document.getElementById(aID): document.all[aID];
}
function stopEvent(evt)
{
   if (evt.preventdefault)
   {
     evt.preventdefault();
     evt.stopPropagation();
   }
   else
   {
      evt.cancelBubble = true;
      evt.returnValue = false;
   }
}
function isempty(strtext)
{
   var testText = strtext;
   var testLength = testText.length;
   for(i = 0;i < testLength; i++)
   {
     var testEmpty = testText.substring(i,i+1);
     if(testEmpty != " ")
     {
       return false;
     }
   }
  return true;
}
 function getOs() 
{ 
   var OsObject = ""; 
   if(navigator.userAgent.indexOf("MSIE")>0) { 
        return "MSIE"; 
   } 
   if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){ 
        return "Firefox"; 
   } 
   if(isSafari=navigator.userAgent.indexOf("Safari")>0) { 
        return "Safari"; 
   }  
   if(isCamino=navigator.userAgent.indexOf("Camino")>0){ 
        return "Camino"; 
   } 
   if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){ 
        return "Gecko"; 
   } 
} 
function dozoom(objcontrol,fontsize)
{
    var cs = 1;
    if(isNaN(fontsize)){
	   cs = parseFloat(getId(objcontrol).style.fontSize);
	  if(fontsize == "+"){
          cs += 0.1;
       }
       else if(fontsize == "-"){
          cs -= 0.1;
       }
	}
    else{
       cs = fontsize;
    }
	cs = Math.round(cs*10)/10;
    if(cs > 0.6 && cs < 1.8){
        getId(objcontrol).style.fontSize=cs+'em';
    }
    else{
       alert("字号调整超出范围 !");
    }
}
var isIe=getOs(); 
function high(which)
{ 
     theobject=which;
     highlighting=setInterval("highlightit(theobject)",60);
} 
function low(obj)
{ 
    clearInterval(highlighting);
    if(isIe=="MSIE")
      obj.filters.alpha.opacity=100;
    else
      obj.style.opacity=1;
} 
function highlightit(cur)
{ 
    if(isIe=="MSIE")
    {
       if (cur.filters.alpha.opacity > 50) 
          cur.filters.alpha.opacity -= 10; 
       else if (window.highlighting) 
          clearInterval(highlighting);
    }
    else
    {
       if (cur.style.opacity > 0.5) 
          cur.style.opacity -= 0.1; 
       else if (window.highlighting) 
          clearInterval(highlighting);
    }
}
function resizewindow()
{
    var sx=window.screen.availWidth;
    var sy=window.screen.availHeight;
    window.resizeTo(sx,sy);
    window.moveTo(0,0);
}
