/* cbe_core.js
 * CBE v4b10 : Cross-Browser DHTML API for IE, Gecko, Opera, Netscape, Konqueror and similar browsers. Download at cross-browser.com
 * Copyright (c) 2002 Michael Foster (mike@cross-browser.com)
 * This library is distributed under the terms of the GNU Lesser General Public License (gnu.org).
*/
function cbeGetElementById(eleId,d) {
  var p,i,x;  

   if(!d) d=document; 
   if((p=eleId.indexOf("?"))>0&&parent.frames.length) 
    {
	 d=parent.frames[eleId.substring(p+1)].document; 
	 eleId=eleId.substring(0,p);
	}
   if(!(x=d[eleId])&&d.all) x=d.all[eleId]; 
   for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][eleId];
   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=cbeGetElementById(eleId,d.layers[i].document);
   if(!x && d.getElementById) x=d.getElementById(eleId); 
   return x;
}

function cbeGetElementByIdStyle(eleId) {
   var ret = cbeGetElementById(eleId);

   if(ret) if(ret.style) ret=ret.style; 
   return ret;
}

// xDef, Copyright 2001-2005 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}


// xNum, Copyright 2001-2005 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xNum()
{
  for(var i=0; i<arguments.length; ++i){if(isNaN(arguments[i]) || typeof(arguments[i])!='number') return false;}
  return true;
}

// xOffsetTop, Copyright 2001-2005 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xOffsetTop(e)
{
  if (!(e=cbeGetElementById(e))) return 0;
  if (xDef(e.offsetTop)) return e.offsetTop;
  else return 0;
}
// xStr, Copyright 2001-2005 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xStr(s)
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}

// xTop, Copyright 2001-2005 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL


function xTop(e, iY)
{
  if(!(e=cbeGetElementById(e))) return 0;
  var css=xDef(e.style);
  if(css && xStr(e.style.top)) {
    if(xNum(iY)) e.style.top=iY+'px';
    else {
      iY=parseInt(e.style.top);
      if(isNaN(iY)) iY=0;
    }
  }
  else if(css && xDef(e.style.pixelTop)) {
    if(xNum(iY)) e.style.pixelTop=iY;
    else iY=e.style.pixelTop;
  }
  return iY;
}

