/*
 * JS BASIC LIBS
 * 
 * Basic always used JS functionality
 * 
 * 
 */



	var Basic = {} ;

	Basic.getPosition = function( oElement )
	{
		var curleft = curtop = 0;
		if ( oElement.offsetParent ) 
		{
			do 
			{
				curleft += oElement.offsetLeft;
				curtop  += oElement.offsetTop;
			} 
			while (oElement = oElement.offsetParent);
			
			return { 'x': curleft, 'y' : curtop } ;
		}
		return { 'x': 0, 'y' : 0 } ;		
	} ;
	
	
	
	Basic.setCookie = function( sName, sValue, nDays )
	{
		if ( nDays ) 
		{
			var oDate = new Date();
			oDate.setTime( oDate.getTime()+( nDays*24*60*60*1000));
			var sExpires = "; expires=" + oDate.toGMTString();
		}
		else 
			var sExpires = "";
			document.cookie = sName + "=" + sValue + sExpires + "; path=/";
	};
	
	Basic.getCookie = function( sName )
	{
		var nameEQ = sName + "=";
		var ca = document.cookie.split( ';' );
		for(var i=0;i < ca.length;i++ ) 
		{
		      var c = ca[i];
		      while( c.charAt(0)==' ') 
		    	  c = c.substring( 1,c.length );
		      if ( c.indexOf(nameEQ) == 0 ) 
		    	  return c.substring( nameEQ.length,c.length );
		}
		return null;
	};

	Basic.eraseCookie = function( sName )
	{
		Basic.setCookie( sName, "", -1 );
	};
	
	Basic.addLoadEvent = function( oFunc ) 
	{ 
		var oldonload = window.onload; 
		if ( typeof window.onload != 'function' ) 
			window.onload = oFunc; 
		else 
			window.onload = function() 
			{ 
				if ( oldonload ) 
					oldonload(); 
				oFunc(); 
			};
	};


	
