/**
*	returns the exact left and top position of an element
*
*	@param {object} elm html element for which the position has to be determined
* @return {array} array with two elements type integer, [0] is left position, [1] is top position in pixel
*/
function findPos(elm) {
	var curleft = curtop = 0;
	if (elm.offsetParent) {
		curleft = elm.offsetLeft
		curtop = elm.offsetTop
		while (elm = elm.offsetParent) {
			curleft += elm.offsetLeft
			curtop += elm.offsetTop
		}
	}
	return [curleft,curtop];
}

/**
*	returns the height of an element
*
*	@param {object} elm html element for which the height has to be determined
* @return {integer} height in pixel
*/
function getElementHeight(elm)
{
	if(elm.style.pixelHeight)
	{
		return(elm.style.pixelHeight);
	}
	else
	{
		return(elm.offsetHeight);
	}	
}

/**
*	returns the width of an element
*
*	@param {object} elm html element for which the width has to be determined
* @return {integer} width in pixel
*/
function getElementWidth(elm)
{
	if(elm.style.pixelWidth)
	{
		return(elm.style.pixelWidth);
	}
	else
	{
		return(elm.offsetWidth);
	}	
}

/**
*	checks if an html element is contained by another element
*
* @param {object} container potential parent element
* @param {object} containee potential child element
* @return {bool} true if containee is contained by container, false otherwise 
*/
function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

/**
*	checks if the mouse enters an element, improved mouseover detection
*
* @param {object} element html element for which the mouseover is detected
*	@param {event} evt event object, e.g. mouse over of child element
*	@return {bool}
*/
function checkMouseEnter (element, evt) {
  if (element.contains && evt.fromElement) {
    return !element.contains(evt.fromElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

/**
*	checks if the mouse leaves an element, improved mouseout detection
*
* @param {object} element html element for which the mouseout is detected
*	@param {event} evt event object, e.g. mouse out of child element
*	@return {bool}
*/
function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

/**
*	returns the width of the viewport / window, cross-browser compatible
*
* @return {integer} width of viewport
*/
function f_clientWidth() {
        if (typeof(window.innerWidth) == 'number')
                return window.innerWidth;
        if (document.documentElement && document.documentElement.clientWidth)
                return document.documentElement.clientWidth;
        if (document.body && document.body.clientWidth)
                return document.body.clientWidth;
        return null;
}

/**
*	returns the height of the viewport / window, cross-browser compatible
*
* @return {integer} height of viewport
*/
function f_clientHeight() {
        if (typeof(window.innerHeight) == 'number')
                return window.innerHeight;
        if (document.documentElement && document.documentElement.clientHeight)
                return document.documentElement.clientHeight;
        if (document.body && document.body.clientHeight)
                return document.body.clientHeight;
        return null;
}

/**
*	returns the left-right scrolling position of the viewport / window, cross-browser compatible
*
* @return {integer} amount of pixels scrolled to the left
*/
function f_scrollLeft() {
        if (typeof(window.pageXOffset) == 'number')
                return window.pageXOffset;
        if (document.body && document.body.scrollLeft)
                return document.body.scrollLeft;
        if (document.documentElement && document.documentElement.scrollLeft)
                return document.documentElement.scrollLeft;
        return 0;
}

/**
*	returns the top-bottom scrolling position of the viewport / window, cross-browser compatible
*
* @return {integer} amount of pixels scrolled to the bottom
*/
function f_scrollTop() {
        if (typeof(window.pageYOffset) == 'number')
                return window.pageYOffset;
        if (document.body && document.body.scrollTop)
                return document.body.scrollTop;
        if (document.documentElement && document.documentElement.scrollTop)
                return document.documentElement.scrollTop;
        return 0;
}
 
 
function doTranslate(lang)
{
if(lang=="google")
{
document.location.href='http://translate.google.com/translate?hl=en';
}
else if(lang)
{
document.location.href='http://translate.google.com/translate?js=n&prev=_t&ie=UTF-8&u='+escape(document.location.href)+'&sl=auto&tl='+lang+'&history_state0=';
}
}
