function setStatus(s) {
  window.status = s;
  return true;
}

var isIE = (document.all) ? true : false;

function getDocElm(elm) {
 if(isIE){
   return document.all[elm];
 } else {
   return document.getElementById(elm);
 }
}

function getDIV(val, className) {
  span = document.createElement('DIV');
  if (!isNull(className)) {
    span.className=className;
  }
  span.appendChild(document.createTextNode(val));
  return span;
}


function isNull(ver){return (ver == this._undef || ver == null);}

function getObjPos(obj){ // returns x,y of obj position>
  var x = 0;
  var y = 0;
  var o = obj;
  while( !isNull(o) ){
    var _x = 0;
    var _y = 0;
    var _x2 = 0;
    var _y2 = 0;
    var br = false;
    if(o.style.position=='fixed'){
      if(o.style.pixelTop){
        _x = o.style.pixelLeft;
        _y = o.style.pixelTop;
      }else if(o.style.top){
        _x = parseInt(o.style.left);
        _y = parseInt(o.style.top);
      }
      br = true;
    }else{
      _x = o.offsetLeft;
      _y = o.offsetTop;
      if(o.scrollLeft){_x2 = -o.scrollLeft;}
      if(o.scrollTop){_y2 = -o.scrollTop;}
    }

    if(_x)x+=_x;
    if(_x2)x+=_x2;
    if(_y)y+=_y;
    if(_y2)y+=_y2;

    if(br){
      break;
    }
    if(o==o.offsetParent){
      break;
    }
    o = o.offsetParent;
  }

  var pos = new Object();
  pos.x = x;
  pos.y = y;
  return pos;
}


var preloadFlag = false;
var imgsToPreload = new Array();

function preloadImages() {
  if (document.images) {
    for (var i = 0; i < imgsToPreload.length; i++) {
      newImage(imgsToPreload[i]);
    }
    preloadFlag = true;
  }
}

function addImgToPreload(img) {
  imgsToPreload[imgsToPreload.length] = img;
}

function openWin(exitURL, w, h, resize) {
  if (exitURL == null || exitURL == "null") {
    return;
  }
  if (resize == null) {
    resize = "0";
  }
  var featureStr = "toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=" + resize + ",width=" + w + ",height=" + h + ",ScreenX=" + ((window.screen.width-w)/2) + ",ScreenY=" + ((window.screen.height-h)/2) + ",left=" + ((window.screen.width-w)/2) + ",top=" + ((window.screen.height-h)/2);

  self.focus();
  var ExitWindow = window.open(exitURL,'Pop', featureStr);
  ExitWindow.focus();
}


var curTip = null;
function showInsideTip(tipId) {
  hideInsideTip();

  curTip = getDocElm(tipId);
  if (curTip != null) {
    var width = parseInt(curTip.offsetWidth);
	  var height = parseInt(curTip.offsetHeight);

    var intCalFrameH = height;
    var intCalFrameW = width;
    var intScrollTop = document.body.scrollTop;
    var intScrollLeft = document.body.scrollLeft;

    if (intCalFrameH > document.body.clientHeight) {
      intCalFrameH = document.body.clientHeight-20;
      curTip.style.pixelHeight = intCalFrameH;
    }

    if (intCalFrameW > document.body.clientWidth) {
      intCalFrameW = document.body.clientWidth-20;
      curTip.style.pixelWidth = intCalFrameW;
    }

	curTip.style.top = (document.body.clientHeight - intCalFrameH)/2 + intScrollTop;
	curTip.style.left = (document.body.clientWidth - intCalFrameW)/2 + intScrollLeft;
	curTip.style.visibility='visible';
  }
  event.cancelBubble = true;
}

function hideInsideTip() {
  if (curTip != null) {
    curTip.style.visibility='hidden';
  }
}

function _dbg(o){
  window.DBGOBJ = o;
  window.open('/ta/js/_dbg.html?dbg=window.opener.DBGOBJ','_blank','',false);return;
}

function body_onclick() {
  hideInsideTip();
}

function body_onresize() {
  hideInsideTip();
}

function left_nav_in(div) {
  if (!div.onclick) {
    div.onclick=new Function("", "window.location='" + div.firstChild.firstChild.href + "';return false;");
  }
  div.prevClass=div.className;
  div.className='insideNavSel';
}

function left_nav_out(div) {
  div.className= div.prevClass;
}

var selectedSubForm = null;
function mnu_in(type) {
//  if (!div.onclick) {
//    div.onclick=new Function("", "window.location='" + div.firstChild.firstChild.href + "';return false;");
//  }
  getDocElm('TabLeft_' + type).prevClass=getDocElm('TabLeft_' + type).className;
  getDocElm('TabLeft_' + type).className='ls';
  getDocElm('TabRight_' + type).prevClass=getDocElm('TabRight_' + type).className;
  getDocElm('TabRight_' + type).className='rs';
  getDocElm('TabCenter_' + type).prevClass=getDocElm('TabCenter_' + type).className;
  getDocElm('TabCenter_' + type).className='cs';

  if (selectedSubForm) {
    selectedSubForm.style.display='none';
    selectedSubForm=null;
  }

  selectedSubForm = getDocElm('SubMenu_' + type);
  if (selectedSubForm) {
    selectedSubForm.style.display='block';
    var mnuPos = getObjPos(getDocElm('TabCenter_' + type));
    selectedSubForm.style.top = (mnuPos.y - 25) + 'px';
    selectedSubForm.style.left = (getObjPos(getDocElm('TopMenu')).x-10) + 'px';
  }
}

function mnu_out(type) {
  getDocElm('TabLeft_' + type).className= getDocElm('TabLeft_' + type).prevClass;
  getDocElm('TabRight_' + type).className= getDocElm('TabRight_' + type).prevClass;
  getDocElm('TabCenter_' + type).className= getDocElm('TabCenter_' + type).prevClass;
}


