var DOM = (document.getElementById)? true : false;
var OP  = (window.opera)? true : false;
var OP5 = (OP && DOM)? true : false;
var NS  = (window.outerWidth && !OP)? true : false;
var MOZ = (NS && DOM)? true : false;
var NS4 = (NS && !DOM)? true : false;
var IE  = (document.all && !OP)? true : false;
var IE5 = (IE && DOM)? true : false;
var IE4 = (IE && !DOM)? true : false;
var WIN = (navigator.userAgent.indexOf('Win')!=-1)? true : false;

function thisObj(objName){
  if(IE4){ 
    return document.all[objName].style;
  } else if(DOM){
    return document.getElementById(objName).style;
  } else if(NS4){
    return document.layers[objName];
  } else{
    return null;
  }
}

function moveObjTo(objName,x,y){
  thisObj(objName).left=x;thisObj(objName).top=y;
}

function moveObjBy(objName,x,y){
  thisObj(objName).left=parseInt(thisObj(objName).left)+x;	   
  thisObj(objName).top=parseInt(thisObj(objName).top)+y;
}

function showObj(objName){
  thisObj(objName).visibility = (NS4)? "show" : "visible";
}

function hideObj(objName){
  thisObj(objName).visibility = (NS4)? "hide" : "hidden";
}


function clipObj(objName,x1,x2,y1,y2){
  if(NS4){
    if(x1!="auto") {thisObj(objName).clip.left=x1;}
    if(x2!="auto") {thisObj(objName).clip.right=x2;}
    if(y1!="auto") {thisObj(objName).clip.top=y1;}
    if(y2!="auto") {thisObj(objName).clip.bottom=y2;}
  }	else{
    if(x1!="auto") {x1=x1+'px ';} else {x1=x1+" ";}
    if(x2!="auto") {x2=x2+'px ';} else {x2=x2+" ";}
    if(y1!="auto") {y1=y1+'px ';} else {y1=y1+" ";}
    if(y2!="auto") {y2=y2+'px ';} else {y2=y2+" ";}
    thisObj(objName).clip="rect("+y1+x2+y2+x1+")";
  }
}

function colorObj(objName,col){
  if(NS4){
    thisObj(objName).bgColor=col;
  } else{
    thisObj(objName).backgroundColor=col;
  }
}

function setZindex(objName,z){
  thisObj(objName).zIndex=z;
}

function leftPos(refName){
 ref=document.images[refName];
 return (document.layers)? ref.x : getLeft(ref);
}

function topPos(refName){
  ref=document.images[refName];
  return (document.layers)? ref.y : getTop(ref);
}

function getLeft(refObj){
  xPos = refObj.offsetLeft;
  parentObj=refObj.offsetParent;
  while(parentObj != null) {
   xPos+=parentObj.offsetLeft;parentObj=parentObj.offsetParent
  }
  return xPos;
}

function getTop(refObj){
  yPos = refObj.offsetTop;
  parentObj=refObj.offsetParent;
  while(parentObj != null){
    yPos+=parentObj.offsetTop;parentObj=parentObj.offsetParent
  }
  return yPos;
}
