var alertTimerId = 0;
var myId = "";

function mostrarCapa(id) {
    
    if (myId != "")
    {
        hideLayerFast();
        clearTimeout ( alertTimerId );
    }
    
    var d = document.getElementById(id);
	
	if (myId != "" )
    {
        if (d) {d.style.display='block';}
         
    }
    else
    {
       $("ul#"+ id +"").fadeIn("50"); //Puede haber UN BUG si se pasa super rapido en varios menus al mismo tiempo
    }
    
    myId = id;
    
}

function ocultarCapa() {
    alertTimerId = setTimeout ( "hideLayer()", 1500 );
}

function hideLayerFast()
{
    var d = document.getElementById(myId);
	if (d) {d.style.display='none';}
	//$("ul#"+ myId +"").fadeOut("100");
}
function hideLayer()
{
     $("ul#"+ myId +"").fadeOut("100");
    myId = "";
}



//Funciones relacionadas al carrucel de la nota principal

carrucelPrincipal=function ()
{
	var arrayArticulos=new Array();
	var intIndice=0;
	var blnRotar=true;
	this.add=function (strAnteTitulo,strTitulo,strEntradilla,strUrl,imgUrl)
	{
		var obj=new Object ;
		var objImg=new Image();
		objImg.src=imgUrl;
		obj.titulo=strTitulo;
		obj.antetitulo=strAnteTitulo;
		obj.entradilla=strEntradilla;
		obj.url=strUrl;
		obj.imgUrl=objImg.src;
		arrayArticulos.push(obj);
		return;
	}
	this.getArts=function()
	{
		return arrayArticulos;
	}
	this.getArt=function()
	{
		return arrayArticulos[intIndice];
	}
	this.next =function()
	{
		intIndice++;
		if (intIndice>arrayArticulos.length-1)
		{
			if(blnRotar){
				intIndice=0;
			}
			else{	
				intIndice=arrayArticulos.length-1
			}
		}
	}
	this.prev =function()
	{
		intIndice=intIndice-1;
		if (intIndice<0)
		{
			if(blnRotar){
				intIndice=arrayArticulos.length-1;
			}
			else{	
				intIndice=0;
			}
		}
	}
	
}
function fSig(oCarr)
{
	oCarr.next();
	fRefresh(oCarr);
}
function fAnt(oCarr){
	oCarr.prev();
	fRefresh(oCarr);
}

function fRefresh(oCarr)
{

	var objArt=oCarr.getArt();
	$("#notaPrincipalHome .imagenPrincipal a").attr("href",objArt.url);
	$("#notaPrincipalHome .imagenPrincipal a img").attr("src",objArt.imgUrl);
	$("#notaPrincipalHome .contenedorNota .antetitulo").html(objArt.antetitulo);
	$("#notaPrincipalHome .contenedorNota .titular a").html(objArt.titulo);
	$("#notaPrincipalHome .contenedorNota .titular a").attr("href",objArt.url);
	$("#notaPrincipalHome .contenedorNota .entradilla").html(objArt.entradilla);

}

//Funciones relacionadas con el carrucel de walpapers
function mycarousel_initCallback(carousel) {

    jQuery('#carouselWallpaper-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#carouselWallpaper-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
	
};
