﻿// JScript 文件

//页面加载时自动调整大小
//页面加载时自动调整大小
function win_onLoad()
{ 
    var table = document.body.getElementsByTagName("table");
    var tb = table[0];
    var width = 752;
    if(tb != null)
    {
        width = tb.width;
    }
 //   alert(tb.offsetHeight);
    var height = tb.offsetHeight;  
   // alert(width);
    width = eval(width * 1 + 30);
    height = eval(height * 1 + 60);
    
    var sWidth  = screen.width;
    var sHeight = screen.height;

    var left = sWidth-((sWidth-width)/2 + width);
    if(left < 0)
    {
        left = 0;
    }
    var top = sHeight-((sHeight-height)/2 + height);
    if(top < 0)
    {
        top = 0;
    }
//alert(width);
    if (width > screen.width-50) 
        width = screen.width-50; 
     
    if (height > screen.height-50) 
        height = screen.height-50; 
 //alert(width);
    window.moveTo(left, top);
    window.resizeTo(width,height);
}

 //打开一个自适应窗口

function OpenAutoFillWin(url)
{

   window.open(url,"url","toolbar=no,resizable=no,scrollbars=yes,location=no, status=no");
}

//弹出窗口
function WindowShow(obj,w,h)
{
    if(w != null && h != null)
    {
        window.open(obj,"","width=" + w + ",height=" + h + ",toolbar=no,resizable=yes,scrollbars=yes,location=no, status=no");
    }
    else if(w != null && h == null)
    {
        window.open(obj,"","width=770" + ",height=" + w + ",toolbar=no,resizable=yes,scrollbars=yes,location=no, status=no");
    }
    else if(w == null && h == null)
    {
        window.open(obj,"","toolbar=no,resizable=yes,scrollbars=yes,location=no, status=no");
    }
}

function WindowshowModalDialog(obj)
{
    window.showModalDialog(obj,null,"toolbar=no,resizable=no,scrollbars=yes,location=no, status=no");
}
//关闭弹出窗口,刷新主窗口
function ReplaceParent(bool)
{
    if(bool == 1)
    {
        opener.window.location.reload();
    }
    window.close();
}

//隐藏显示div
function divDisplay(obj)
{
    var div = document.getElementById(obj);
    
    if(div.style.display == "none")
    {
        div.style.display = "block";
    }
    else
    {
        div.style.display = "none";
    }
}

function toolDisplay(obj1,obj2,obj3)
{
    var div1 = document.getElementById(obj1);
    var div2 = document.getElementById(obj2);
    var div3 = document.getElementById(obj3);

    div1.style.display = "block";
    div2.style.display = "none";
    div3.style.display = "none";
}

function optionDisplay(count,tdname,divname,index)
{
    for(i=1; i<=count; i++)
    {
        var td = document.getElementById(tdname + i);
        var div = document.getElementById(divname + i);
        
        if(i == index)
        {
            td.className = "click";
            div.style.display = "block";
        }
        else
        {
            td.className = "default";
            div.style.display = "none";
        }
    }
}

//Element Items Borrowed From Prototype. Add by SuChuanyi

function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1) 
      return element;

    elements.push(element);
  }

  return elements;
}


var Element = {
  
  toggle: function() {
    for (var i = 0; i < arguments.length; i++) {
      var element = $(arguments[i]);
      element.style.display = 
        (element.style.display == 'none' ? '' : 'none');
    }
  },

  hide: function() {
    for (var i = 0; i < arguments.length; i++) {
      var element = $(arguments[i]);
      element.style.display = 'none';
    }
  },

  show: function() {
    for (var i = 0; i < arguments.length; i++) {
      var element = $(arguments[i]);
      element.style.display = '';
    }
  },

  remove: function(element) {
    element = $(element);
    element.parentNode.removeChild(element);
  },
   
  getHeight: function(element) {
    element = $(element);
    return element.offsetHeight; 
  }
}

//End Element Items

//function alert(message,type)
//{
//    if(type == null || type == 0)
//    {
//        window.showModalDialog("/ADCCSSPortal/Common/Succeed.aspx",message,"dialogHeight:200px;dialogWidth:412px;center:yes;scroll:no;resizable:no;help:no;status:no;directions:no;menubar:no;location:no;toolbar:no;");
//    }
//    else
//    {
//        window.showModalDialog("/ADCCSSPortal/Common/Lost.aspx",message,"dialogHeight:200px;dialogWidth:412px;center:yes;scroll:no;resizable:no;help:no;status:no;directions:no;menubar:no;location:no;toolbar:no;");
//    }
//}
