jQuery().ready(function(){
	
	/*
	 * 
	 * $("p").live("myCustomEvent", function(e, myName, myValue){
      $(this).text("Hi there!");
      $("span").stop().css("opacity", 1)
               .text("myName = " + myName)
               .fadeIn(30).fadeOut(1000);
    });
    $("button").click(function () {
      $("p").trigger("myCustomEvent");
    });

	 */
	var tpoImgsms = parseInt($("#hddTpoImgs").val())*500;
	var tpoNewsms = parseInt($("#hddTpoNews").val())*500;
	
	window.setInterval(function moverNoticia(){
		var self = $("#mainnewinfo").children("div");
		var currentNewId = parseInt(self.attr("currentNew"));
		var nextNewId = currentNewId+1;
		if($("#noticiaCarrusel_"+nextNewId).length==0){
			nextNewId = 0;
		}
		if($("#noticiaCarrusel_"+nextNewId).html!=""){
			var nuevoHtml = "" +
			"<h1><a href='"+$("#noticiaCarrusel_"+nextNewId).children(".urlNoticiaCarrusel").html()+"'>"+$("#noticiaCarrusel_"+nextNewId).children(".titularNoticiaCarrusel").html()+"</a></h1>"+
			"<p>"+$("#noticiaCarrusel_"+nextNewId).children(".resumenNoticiaCarrusel").html()+"</p>";
			self.slideUp("fast",function(){
			   $(this).html(nuevoHtml).attr("currentNew",nextNewId);
		   }).slideDown("slow");
		}
		return true;
	},tpoNewsms);

	window.setInterval(function moverImagen(){
		var self = $("#mainnew");
		var nextImgId = ($("#hddBgImgs_"+(parseInt(self.attr("currentImg"))+1)).length==0)?0:parseInt(self.attr("currentImg"))+1;
		var nuevoImg = "url('"+$("#hddBgImgs_"+nextImgId).val()+"') repeat-x 200px top transparent";
		self.css('background', nuevoImg).attr("currentImg",nextImgId);

	},tpoImgsms);
			

});
