(function($){
	$.fn.hasher = function(opc){
		
		/*
		 * @opc
		 * 	#init 	: function
		 * 	#end	: function
		 * 	#base	: selector to load Content
		 */
		//aNadimos los parametros bAsicos
		var base	= {
        	'init'		: false,
			'end'		: false,
			'selector'	: ''
			};
		if(opc){ 
			$.extend(base,opc);
			}
		
		if (!base.selector) {
			return this;
		}
		$(window).bind('hashchange',function(){
			//call init CallBack
			if(base.init){base.init();}
			var site = location.hash.replace('#!','');
			
			$.get(site,{'layout':'empty'},function(data){
				$(base.selector).empty().append(data);
				//call End CallBack
				if(base.end){base.end();}
			},'html');
			
			}).trigger('hashchange');
		
		//para mantener la encadenaciOn de eventos
		return this.each(function(){
			//iniciamos el cOdigo
			var a	= $(this);
			var h	=	a.attr('href').replace(/\w*?:\/\/.*?\//,'/');
			if(!h){
				return;
			}
			a.attr('href','#!'+h);
		});
	};
})(jQuery);
