var UlActivo=null;
var IlActivo=null;
var ArtActivo=null;
var TipActivo=null;
var aacctivo=new Array();

function getParam( name )
{	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec( window.location.href );
	if( results == null )
		return "";
	else
		return results[1];
}

function toggleActivo(e)
{	if(ArtActivo!=null)
		ArtActivo.fade('out');
	ArtActivo=$(e);
	ArtActivo.fade('in');
	h=ArtActivo.getHeight();
	$('col2').setStyle('height',String(h)+'px');
}
function toggleTip(e)
{	if(TipActivo!=null)
		TipActivo.fade('out');
	TipActivo=$(e);
	TipActivo.fade('in');
}
function hideTip()
{	TipActivo.fade('out');
	TipActivo=null;
}

function markItem()
{	if(IlActivo!=null)
		IlActivo.style.color='#9e9e9e';
	this.setStyle('color','#bd0926');
	IlActivo=this;
}
function markItemId(id)
{	if(IlActivo!=null)
		IlActivo.style.color='#9e9e9e';
	o=$(id);
	o.setStyle('color','#bd0926');
	IlActivo=o;
}

function togglejj(){
	if(UlActivo!=null && UlActivo!=this)
	{	UlActivo.d.slide('toggle');
		UlActivo.a.setStyles({'background-image':'url(img/sdmenubigon.jpg)',color:'#FFF'});
		UlActivo.open=false;
		UlActivo=null;
	}
	this.d.slide('toggle');
	if(this.open==true)
	{	this.a.setStyles({'background-image':'url(img/sdmenubigon.jpg)',color:'#FFF'});
		this.open=false;
		UlActivo=null;
	}
	else
	{	this.a.setStyles({'background-image':'url(img/sdmenubigoff.jpg)',color:'#75787a'});
		this.open=true;
		UlActivo=this;
	}
}

window.addEvent('domready',function(){
	$$('#col1 ul li').each(function(e){
		dv=e.getElement('ul')
		if(dv)
		{
//			dv.set('slide');
//			dv.slide('hide');
			aa=e.getElement('a');
			var jj={d:dv,a:aa,open:false};
			aa.addEvent('click',togglejj.bindWithEvent(jj));
		}
	});
	var regexs='"i[0-9]+"';
	$$('#col1 ul li ul li a').each(function(e){
		e.addEvent('click',markItem.bindWithEvent(e));

	});
	$$('.articulo').each(function(e){e.fade('hide');});
	$$('.divtip').each(function(e){e.fade('hide');});
	$$('.divtip1').each(function(e){	e.fade('hide');});
	s=getParam('art');
	if(s!="")
	{	h=s.split(',');
		StartDiv=h[0];
		StartLinkId=h[1];
	}
	if(typeof(StartDiv)!="undefined")
	{ 
		toggleActivo(StartDiv);
	}
	if(typeof(StartLinkId)!="undefined")
	{
		markItemId(StartLinkId);
		}
	
 var RqClima=new Request(
 	{
		url:'/GetClima.py',
		method:'get',
		onSuccess:function(texts){
			$('clima').set('html',texts);
		}
		}
	).send();

 var RqCotiza=new Request(
 	{
		url:'/aval/GetCotiza.py',
		method:'get',
		onSuccess:function(texts){
			$('cotiza').set('html',texts);
		}
		}
	).send();
});

