
/**
* Turboshop 4 Any browser functions and browser detection functions
* (c) Digivate Limited 2003-2005
* Pete Darling 10/2003 updated 05/08/2005 pAd
**/

/**
* Get Pointer to document object in any browser
* @param string element id for hot/editable area
**/
function tsGetElementById(id)
{
  var ret = null;
  
  if (id!=null&&id!='')
  {  
	  if (document.layers) //Netscape 4
	   	ret = eval('document.' + id);
	  else if (navigator.userAgent.indexOf("Opera") != -1) //Opera
	  	 	ret = eval("document.all."+id);
	  else // all others . . .	the dom  		
	  	 	ret = document.getElementById(id);
  }	  
  return ret;
}

/**
* Get Pointer to iframe document object in any browser
* @param string iframe id
**/
function getIFrameDocument(aID)
{
  // if contentDocument exists, W3C compliant (Mozilla)
  if (document.getElementById(aID).contentDocument)
  {
    return document.getElementById(aID).contentDocument;
  } else
  {
    // IE
    return document.frames[aID].document;
  }
}

/**
* Get Pointer to iframe object in any browser
* @param string iframe id
**/
function getIFrame(aID)
{
	if ((frames) && (frames[aID])) return frames[aID];
	else if (eval('window.'+aID)) return eval('window.'+aID);
	else if (eval('document.'+aID)) return eval('document.'+aID);
	else return false;
}



/**
* Get left postion of an element in the document
**/
function getOffsetLeft (el)
{
  var ol = el.offsetLeft;
  while ((el = el.offsetParent) != null)
    ol += el.offsetLeft;
  return ol;
}

/**
* Get top postion of an element in the document, in Mozilla and Opera this returns the bottom so must use browserOffsetHeight() function
**/
function getOffsetTop (el)
{
  var ot = el.offsetTop;
  while((el = el.offsetParent) != null)
   ot += el.offsetTop;
  return ot;
}

/**
* Get Pointer to a parents document object in any browser
* @param string element id for hot/editable area
**/
function tsGetParentElementById(id)
{
  if (parent.document.layers) //Netscape 4
   	return eval('parent.document.' + id);
  else if (isOpera()) // Opera
  	 	return eval("parent.document.all."+id);
  else // all others . . .
  return parent.document.getElementById(id);
}

/**
* Returns true if browser is Mozilla.org browser and not Mozilla compatible such as IE
**/
function isMozilla()
{
	return ((navigator.userAgent.indexOf('Mozilla')>-1) && (navigator.userAgent.indexOf('MSIE')==-1));
}

/**
* Returns true if browser is Opera
**/
function isOpera()
{
	return (navigator.userAgent.indexOf("Opera") != -1);
}

function isIE()
{
//	if (document.frames) return true;
	//else return false;
	return (navigator.appName.indexOf('Internet Explorer') != -1)
}

