﻿// JScript 文件



//去掉字符串前后的空格
String.prototype.trim = function(){
  return this.replace(/(^\s*)|(\s*$)/g, "");
}

function selectclick(oSelect){
	if(oSelect.options[oSelect.selectedIndex].value!="#")
	    window.open(oSelect.options[oSelect.selectedIndex].value,"_blank","");
}

//格式化字符串(如:Format('{0}+{1}={2}', 'a', 'b', 'ab'))
function Format(){
  var i, iCount;
  var str = arguments[0];
  iCount = arguments.length - 1;
  for (i=0; i<iCount; i++){
    var reg = new RegExp('\\{'+i+'\\}', 'g');
    str = str.replace(reg, arguments[i+1]);   
  }
  return str;
}


//把值转换成Boolean型
//Value:要转换的值； bDefaultValue:默认值
function ToBoolean(Value, bDefaultValue){
  switch (typeof(Value)) {
    case "boolean" :
      return Value;
    case "string" : 
      Value = Value.toLowerCase();
      if (Value == "true" || Value == "1") return true;
      if (Value == "false" || Value == "0") return false;
      return bDefaultValue;
    case "undefined" :
      return bDefaultValue;
    default :
      return bDefaultValue;
  }
}

//获取元素位置的类  
var posLib = {
  getClientLeft:    function (el) {
    var r = el.getBoundingClientRect();
    return r.left - this.getBorderLeftWidth(this.getCanvasElement(el));
  },

  getClientTop:    function (el) {
    var r = el.getBoundingClientRect();
    return r.top - this.getBorderTopWidth(this.getCanvasElement(el));
  },

  getLeft:    function (el) {
    return this.getClientLeft(el) + this.getCanvasElement(el).scrollLeft;
  },

  getTop:    function (el) {
    return this.getClientTop(el) + this.getCanvasElement(el).scrollTop;
  },

  getInnerLeft:    function (el) {
    return this.getLeft(el) + this.getBorderLeftWidth(el);
  },

  getInnerTop:    function (el) {
    return this.getTop(el) + this.getBorderTopWidth(el);
  },

  getWidth:    function (el) {
    return el.offsetWidth;
  },

  getHeight:    function (el) {
    return el.offsetHeight;
  },

  getCanvasElement:    function (el) {
    var doc = el.ownerDocument || el.document;    // IE55 bug
    if (doc.compatMode == "CSS1Compat")
      return doc.documentElement;
    else
      return doc.body;
  },

  getBorderLeftWidth:    function (el) {
    return el.clientLeft;
  },

  getBorderTopWidth:    function (el) {
    return el.clientTop;
  },

  getScreenLeft:    function (el) {
    var doc = el.ownerDocument || el.document;    // IE55 bug
    var w = doc.parentWindow;
    return w.screenLeft + this.getBorderLeftWidth(this.getCanvasElement(el)) + this.getClientLeft(el);
  },

  getScreenTop:    function (el) {
    var doc = el.ownerDocument || el.document;    // IE55 bug
    var w = doc.parentWindow;
    return w.screenTop + this.getBorderTopWidth(this.getCanvasElement(el)) + this.getClientTop(el);
  }
}


function openModalDialog(sURL, vArguments, sFeatures, sTitle){
  var sURL = 'openModalDialog.aspx?DialogURL=' + escape(sURL) + '&Title=' + escape(sTitle) + '&__randomnumeric=' + Math.random();
  var oArguments = new Object();
  if (top.oTop != null)  //解决在ModalDialog中再弹出ModalDialog时出错
    oArguments["top"] = top.oTop;
  else
    oArguments["top"] = top;
  oArguments["Arguments"] = vArguments;
  var vReturn = showModalDialog(sURL, oArguments, sFeatures);
  return vReturn;
}


function showcorplist(){
  try{
  document.getElementById('tabChannel').style.display='none';
  document.getElementById('tabCorpList').style.display='';
  }catch(err){}
}
