var el = function(e){
	this.version=0.3;
	this.by="Michael Markie";
	this.developing=false;
	this.unsupportedBrowsers = ['SymbianOS','iPhone','iPod'];
	
	//Detect which method of elements that are used for example ID, Class, Tag Name or a Object.
	if(typeof e == "string"){
		// # defines a element ID
		if(e.substring(0,1) == "#" && document.getElementById(e.replace('#','')))
			this.e = document.getElementById(e.replace('#',''));
		// . defines a element Class
		else if(e.substring(0,1) == '.' && document.getElementsByClassName(e.replace('.','')))
			this.e = document.getElementsByClassName(e.replace('.',''));
		// No alphanumerics defines a Element Tag name, resulting in a array.
		else if(document.getElementsByTagName(e))
			this.e = document.getElementsByTagName(e);
	}else if(typeof e == "object"){
		this.e=e;
	}
	
	this.css = function(property,value){
		if(this.e == "[object NodeList]" || this.e == "[object HTMLCollection]" || this.e.length >= 1){
			//If it is a array list loop through the elements and change the CSS values.
			for(var i in this.e){
				//if the style exists change the css property by passing it through the el library again which allows the cross browser CSS to kick in.
				if(this.e[i] && this.e[i].style)
					el(this.e[i]).css(property,value);
			}
		}else{
			//Cross Browser Compatibility Begin.
			//Mostly used to support old browser versions and internet explorer.
			if(property == "opacity"){
				if(IE){
					this.e.style['filter']="alpha(opacity="+(value*100)+")";
					//zoom is used because of a bug when using filter in certain areas would not work.
					this.e.style['zoom']=1;
				}
				this.e.style['-moz-opacity']=value;
				this.e.style['-khtml-opacity']=value;
			}
			if(property == "text-overflow"){
				this.e.style['-o-text-overflow']=value;
			}
			//Cross Browser Compatibility End.
			
			this.e.style[property] = value;
		}
		return this;
	};
	this.addClass = function(cls){
		this.e.className+=" "+cls;
		return this;
	};
	this.removeClass = function(cls){
		this.e.className=this.e.className.replace(RegExp('(\\s|^)'+cls+'(\\s|$)'),' ');
		return this;
	};
	this.append = function(text){
		this.e.innerHTML+=text;
		return this;
	};
	this.content = function(text){
		this.e.innerHTML=text;
		return this;
	};
	this.createElement = function(ele){
		var cElement = document.createElement(ele);
		if(this.e == "[object NodeList]" || this.e == "[object HTMLCollection]" || this.e.length >= 1){
			for(var i in this.e){
				if(typeof this.e[i] == "object")
					this.e[i].appendChild(cElement);
			}
		}else{
			this.e.appendChild(cElement);
		}
		
		this.e = cElement;
		cElement=null;
		return this;
	};
	this.childElement = function(){
		if(this.e.children[0])
			this.e = this.e.children[0];
		return this;
	};
	this.setAttribute = function(name,value){
		this.e.setAttribute(name,value);
		return this;
	};
	this.parentElement = function(){
		if(this.e.parentNode)
			this.e = this.e.parentNode;
		return this;
	};
	this.ajax = function(v){
		timer.start();
		var xhr = window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP"),
		e = this.e;
		if(xhr){
			xhr.onreadystatechange = function(){
				if(xhr.readyState != 4){
					if(typeof v.loading == "function")
						v.loading();
				}else{
					if(v.overwrite)
						e.innerHTML=xhr.responseText;
					else
						e.innerHTML+=xhr.responseText;
					
					
					if(typeof v.complete == "function"){
						v.complete(timer.end());
						e=null,xhr=null;
					}
				}
			}
			xhr.open("GET",v.url,true); 
			xhr.send(null);
		}
		return this;
	};
	this.animate = function(v){
		if(this.e.style[v.property]){
			timer.start();
			var px = this.e.style[v.property].match('px'),
			start = extractNumber(this.e.style[v.property]),
			e = this.e;
			
			if(start<v.to){
				var animate = setInterval(function(){
					if(start<v.to){
						el(e).css(v.property,start+px)
						start=start+v.jump;
					}else{
						clearInterval(animate);
						el(e).css(v.property,v.to+px);
						if(typeof v.completed == "function")
							v.completed(e,timer.end());
						px=null,start=null,e=null;
					}
				},(IE)?3:20);
			}else if(start>v.to){
				var animate = setInterval(function(){
					if(start>v.to){
						el(e).css(v.property,start+px)
						start=start-v.jump;
					}else{
						clearInterval(animate);
						el(e).css(v.property,v.to+px);
						if(typeof v.completed == "function")
							v.completed(e,timer.end());
						px=null,start=null,e=null;
					}
				},(IE)?3:20);
			}
		}
		return this;
	};
	this.ready = function(func){
		var oldonload = window.onload;
		if(typeof window.onload != "function"){
			window.onload = func;
		}else{
			window.onload = function(){
				oldonload();
				func();
			}
		}
	};
	
	
	if(this instanceof el)
		return this.el;
	else
		return new el(e);
}