var selector, enlaces;
function categoriesHide(enlaces)
{
	enlaces.each(function (a)
	{
		var linkArray=a.href.split("#");
		if (linkArray.length>0)
		{
			var content = $(linkArray[1]).next().next();
			Element.hide(content);	
			
		}
		Element.removeClassName(a,"selected");
	});
	
	
}
function categoryShow(e)
{

	categoriesHide(enlaces);
	var a=Event.element(e);
	
	if(e.tagName=="A"){
		a=e;
	}

	if(a.href==undefined) a=a.parentNode;
	
	var linkArray=a.href.split("#");
	if (linkArray.length>0)
	{
	// casi siempre usaremos este	Element.show(linkArray[1]);	
		var content = $(linkArray[1]).next().next();
		Element.show(content);
	}
	Element.addClassName(a,"selected");
	//Element.show();
	
}
function Initialize()
{

	//var enlaces = new Array("regiones","tipos");
	//var categoriesSelector=$("promotionSelector");
//	alert (categoriesSelector.getElementsByTagName("ul"));
	var uls=$A(document.getElementsByTagName("ul"));
	
	selector=$$("ul.categories")
	
	if (selector.length>0){
			selector=selector[0];
			enlaces=$A(selector.getElementsByTagName("a"));
			enlaces.each(function (enlace)
			{
				Event.observe(enlace,"click",categoryShow);
				enlace.onclick=function(){return false};
				
			});
			categoriesHide(enlaces);
			categoryShow(enlaces[0]);
	}
}


Event.observe(window,"load",Initialize);
