 /**
  * JavaScript for the jaron.de main navigation.
  *
  * @author Steffen Friedrich (steffen.friedrich@pingping.ag, www.pingping.ag)
  ***/

function get( id )
{ return document.getElementById( id );
}

function add2url(url, additive)
{	if(additive.indexOf('?')==0 || additive.indexOf('&')==0)
		additive = additve.substr(1);
	return url+(url.indexOf('?')==-1 ? '?' : '&')+additive;
}


/*  Returns top-left coordinates of element and optionally stores those values.
 *  If storing is desired the stored values will be returned if any could be found.
 *  If no element is supplied the Viewport of the top-left coordinates will be returned.
 *  Those values cannot be stored.
 *  @author Steffen Friedrich, steffen.friedrich@pingping.ag
 **/
 function topLeftCoords( element, store )
 { var x=y=0,coords;
     if( !element )
     {    if( window.pageYOffset )
         { y = window.pageYOffset;
           x = window.pageXOffset;
         }else
         { y = document.documentElement.scrollTop;
           x = document.documentElement.scrollLeft;

           if( !x && !y )
           {    x = document.body.scrollLeft;
               y = document.body.scrollTop;
           }
         }
       return {'x':x,'y':y};
     }

     if( store && element.coords )
         return element.coords;
     var pele = element;

     if (pele.offsetParent)
   { do{x+=pele.offsetLeft;y+=pele.offsetTop;}
     while (pele = pele.offsetParent);
     coords = {'x':x,'y':y};
     if( store ) element.coords = coords;
     return coords;
   }
 }