/**
 * Cool javascript library. 
 */
var CoolJS = new function ()
{
	
	
	return {
		/**
		 * Calculates the absolute position and dimension of the given element.
		 * @param element the element to calculate the position and dimension of.
		 * @return the calculated rectangle as {left:integer, top:integer, width: integer, height: integer}
		 */
		getRectangle: function (element)
		{
			var rectangle = {left:0, top:0, width: 0, height: 0};
			if (!element)
			{
				return rectangle;
			}

			var rootElement = element;
			
			var left = 0;
			var top = 0;
		
			while (element) 
			{
				left += element.offsetLeft;
				top += element.offsetTop;
				element = element.offsetParent;
			}
		
			return {left: rootElement.getWidth () + left, top: rootElement.getHeight () + top, width: rootElement.getWidth (), height: rootElement.getHeight ()}; 			
		},
		
		/**
		 * Returns the specified URL parameter.
		 * Returns the specified URL parameter or null if the parameter could not be found.
		 * @return the specified URL parameter or null if the parameter could not be found.
		 */
		getUrlParameter: function (name)
		{
			name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
			var regexS = "[\\?&]"+name+"=([^&#]*)";
			var regex = new RegExp( regexS );
			var results = regex.exec( window.location.href );
			return results == null ? null : results[1];
		},
		
		validateEmail: function (email)
		{
			var validMail = /^[ 	]*\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+[ 	]*$/
			return validMail.test (email);
		}
		
	};
};

