var isCSS, isW3C, isIE4, isNN4, isIE6CSS;
var windowHeight, windowWidth;

function initAPI(){
  if(document.images){
    isCSS = (document.body && document.body.style) ? true : false;
    isW3C = (isCSS && document.getElementById) ? true : false;
    isIE4 = (isCSS && document.all) ? true : false;
    isNN4 = (document.layers) ? true : false;
    isIE6CSS = (document.compatMode && 
                document.compatMode.indexOf("CSS1") >=0) ? true : false;
    getWindowSize();
  }
}

function getWindowSize(){
  windowHeight = 0;
  windowWidth = 0;

  if(window.innerWidth){
    windowWidth = window.innerWidth;
  }
  else if(isIE6CSS){
    windowWidth = document.body.parentElement.clientWidth;
  }
  else if(document.body && document.body.clientWidth){
    windowWidth = document.body.clientWidth;
  }

  if(window.innerHeight){
    windowHeight = window.innerHeight;
  }
  else if(isIE6CSS){
    windowHeight = document.body.parentElement.clientHeight;
  }
  else if(document.body && document.body.clientHeight){
    windowHeight = document.body.clientHeight;
  }
}

function setTop(obj, top){
  var objref = getStyleObject(obj);
  if(objref){
    if(isCSS){
      if(top>0){
        objref.top = top;
      }
      else {
        objref.top = 0;
      }
    }
  }
}

function setLeft(obj, left){
  var objref = getStyleObject(obj);
  if(objref){
    if(isCSS){
      if(left>0){
        objref.left = left;
      }
      else {
        objref.left = 0;
      }
    }
  }
}

function setHeight(obj, height){
  var objref = getStyleObject(obj);
  if(objref){
    if(isCSS){
      if(height>0){
        objref.height = height;
      }
      else {
        objref.height = 0;
      }
    }
  }
}

function setWidth(obj, width){
  var objref = getStyleObject(obj);
  if(objref){
    if(isCSS){
      if(width>0){
        objref.width = width;
      }
      else {
        objref.width = 0;
      }
    }
  }
}

function seekLayer(doc, name){
  var objref = null;

  for(var i = 0;i < doc.layers.length;i++){
    if(doc.layers[i].name == name){
      objref = doc.layers[i];
      break;
    }
    if(doc.layers[i].document.layers.length > 0){
      objref = seekLayer(doc.layers[i].document, name);
    }
  }

  return objref;
}

function getObject(obj){
  var objref = null;

  if(typeof obj == "string"){
    if(isW3C){
      objref = document.getElementById(obj);
    }
    else if(isIE4){
      objref = document.all(obj);
    }
    else if(isNN4){
      objref = seekLayer(document, obj);
    }
  }
  else{
    objref = obj;
  }

  return objref;
}

function getStyleObject(obj){
  var objref = getObject(obj);  

  if(objref && isCSS){
    objref = objref.style;
  }

  return objref;
}

function show (obj){
  var objref = getStyleObject(obj);
  if(objref){
    objref.visibility = 'visible';
  }
}

function hide (obj){
  var objref = getStyleObject(obj);
  if(objref){
    objref.visibility = 'hidden';
  }
}

function setBgColor (obj, color){
  var objref = getStyleObject(obj);
  if(objref){
    if(isCSS){
      objref.backgroundColor = color;
    }
  }
}

function setBgImage (obj, image){
  var objref = getStyleObject(obj);
  if(objref){
    if(isCSS){
      objref.backgroundImage = image;
      objref.backgroundRepeat = 'repeat-x';
    }
  }
}

function setFontWeight (obj, weight){
  var objref = getStyleObject(obj);
  if(objref){
    if(isCSS){
      objref.fontWeight = weight;
    }
  }
}

function setFontStyle (obj, style){
  var objref = getStyleObject(obj);
  if(objref){
    if(isCSS){
      objref.fontStyle = style;
    }
  }
}

function selectTab(menuobj,tabobj){
  setBgImage (menuobj, "url('/php/pics/tabMenuBackgroundSel.gif')");
  show(tabobj);
}

function deselectTab(menuobj,tabobj){
  setBgImage (menuobj, "url('/php/pics/tabMenuBackground.gif')");
  hide(tabobj);
}
