$(function() {
  $("#nav-stop").click(function() { $('#noticiaheadlinetext, #portadaimgcontainer').cycle('pause'); $('#nav-play').css("display","inline"); $('#nav-stop').css("display","none"); return false; });
  $("#nav-play").click(function() { $('#noticiaheadlinetext, #portadaimgcontainer').cycle('resume');  $('#nav-stop').css("display","inline"); $('#nav-play').css("display","none");  return false; });
    
  $("#variety-stop").click(function() { $('.varietyslide').cycle('pause'); $('#variety-play').css("display","inline"); $('#variety-stop').css("display","none"); return false; });
  $("#variety-play").click(function() { $('.varietyslide').cycle('resume');  $('#variety-stop').css("display","inline"); $('#variety-play').css("display","none");  return false; });
    
  $("#cartelera-stop").click(function() { $('#carteleracontainer').cycle('pause'); $('#cartelera-play').css("display","inline"); $('#cartelera-stop').css("display","none"); return false; });
  $("#cartelera-play").click(function() { $('#carteleracontainer').cycle('resume');  $('#cartelera-stop').css("display","inline"); $('#cartelera-play').css("display","none");  return false; });

  $("#agenda-stop").click(function() { $('#agenda-contenedor').cycle('pause'); $('#agenda-play').css("display","inline"); $('#agenda-stop').css("display","none"); return false; });
  $("#agenda-play").click(function() { $('#agenda-contenedor').cycle('resume');  $('#agenda-stop').css("display","inline"); $('#agenda-play').css("display","none");  return false; });


  $("#articlephoto-stop").click(function() { $('#article-gallery').cycle('pause'); $('#articlephoto-play').css("display","inline"); $('#articlephoto-stop').css("display","none"); return false; });
  $("#articlephoto-play").click(function() { $('#article-gallery').cycle('resume');  $('#articlephoto-stop').css("display","inline"); $('#articlephoto-play').css("display","none");  return false; });
  $("#articlephoto-caption").click(function(){
    //$(".item-caption").each(function(){$(this).toggleClass("caption-visible");$(this).toggleClass("caption-hidden");} );
    $(".item-caption").each(function(){
      //$(this).animate({"height": "toggle", "opacity": "toggle"}, "slow");
      //$(this).animate({"height": "toggle", "opacity": "toggle"}, "fast");
      $(this).toggleClass("caption-visible").toggleClass("caption-hidden");
      //$(this).animate({"height": "toggle", "opacity": "toggle"}, "slow").toggleClass("caption-hidden");
    });
  })
});
function toggle_subcomments( id ){
	var estado=$("#subcomment_"+id).attr("class");
	var emptycontainer= $("#subcomment_"+id).children();
	if(emptycontainer.length<=1){
		//alert(emptycontainer.length);
		grabAsync('subcomment_'+id,'/includes/subcomentarios.php?page=1&idcomentario='+id);
	}
	if(estado == "oculto"){
		//grabAsync('subcomment_'+id,'/includes/subcomentarios.php?page=1&idcomentario='+id);
		$("#subcomment_"+id).removeClass("oculto").addClass("visible").show("slow");
		$("#toggle_subcomments_"+id).text("Ocultar subcomentarios");


	}else if(estado=="visible"){
		//grabAsync('subcomment_'+id,'/includes/subcomentarios.php?page=1&idcomentario='+id);
		$("#subcomment_"+id).removeClass("visible").addClass("oculto").hide("slow");
		$("#toggle_subcomments_"+id).text("Mostrar subcomentarios");

	}
}

$(document).ready(function() {
  /* Clasificados */
  $("#classifiedPgs").cycle({
    fx: 'scrollHorz',
    timeout: 0, 
    pager:'#classifieds ul.options li.menu',
    pagerAnchorBuilder: function(idx, slide) { 
      // return selector string for existing anchor 
      return '#classifieds ul.options li.menu a:eq(' + idx + ')'; 
    } 
  });
  
       $('#portadaimgcontainer, #noticiaheadlinetext,#portadaimgcontainersuplementos,#noticiaheadlinetext2').cycle({
	fx:     'scrollHorz', 
	timeout:  18000,
	next:   '#nav-next', 
	prev:   '#nav-prev', 
	pager:  '#noticias-pgs',
	pause: false,
	pagerAnchorBuilder: function(idx, slide) { 
        	/*return '<a href="#" class=""></a>'; */
        	return '#noticias-pgs a:eq(' + idx + ')'; 
    	} ,
	activePagerClass: 'selected',
	updateActivePagerLink: function(pager, currSlideIndex) { 
		$(pager).find('a').filter('a:eq('+currSlideIndex+')').addClass('selected'); 
	}
	}).cycle('resume');

      $('#agenda-contenedor').cycle({
	fx:     'scrollUp', 
	timeout:  6000,
	next:   '#agenda-next', 
	prev:   '#agenda-prev', 
	pager:  '#agenda-pgs',
	pagerAnchorBuilder: function(idx, slide) { 
        return '<a href="#" class=""></a>'; 
    	} ,
	pause: true,
	activePagerClass: 'selected',
	updateActivePagerLink: function(pager, currSlideIndex) { 
		$(pager).find('a').filter('a:eq('+currSlideIndex+')').addClass('selected'); 
	}
	}).cycle('pause');

      $('.varietyslide').cycle({
	fx:     'fade', 
	timeout:  10000,
	next:   '#variety-next', 
	prev:   '#variety-prev', 
	pause: true,
	pager:   '#variety-pgs', 
	activePagerClass: 'selected',
	pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        	return '#variety-pgs a:eq(' + idx + ')'; 
    	},
	updateActivePagerLink: function(pager, currSlideIndex) { 
		$(pager).find('a').filter('a:eq('+currSlideIndex+')').addClass('selected'); 
	}
	/*,
	after: function(currSlideElement, nextSlideElement, options, forwardFlag){
		$currImg= $(currSlideElement).find('span.varietyimgtoload');
		$('#variedadesimg').animate({opacity: 0.0},500);
		$('#variedadesimg').attr("src",$currImg.attr("title"));
		$('#variedadesimg').animate({opacity: 1.0},1000);
	}*/
	}).cycle('pause');
     /* 
      $('#varietycontainer').cycle({
	fx:     'fade', 
	timeout:  8000,
	pager:   '#variety-pgs', 
	pagerAnchorBuilder: function(idx, slide) { 
        return '<a href="#" class=""></a>'; 
    	},
	pause: true,
	activePagerClass: 'selected',
	}).cycle('pause');
      */
	$('#carteleracontainer').cycle({
	fx:     'scrollLeft', 
	timeout:  3000,
	speed: 1000,
	next:   '#cartelera-next', 
	prev:   '#cartelera-prev', 
	pager:  '#cartelera-pgs',
	pagerAnchorBuilder: function(idx, slide) { 
        return '<a href="#" class=""></a>'; 
    	} ,
	pause: true,
	activePagerClass: 'selected',
	updateActivePagerLink: function(pager, currSlideIndex) { 
		$(pager).find('a').filter('a:eq('+currSlideIndex+')').addClass('selected'); 
	}
	}).cycle('resume');
	
	$("#article-gallery").cycle({
		fx:     'fade', 
		timeout:  100,
		speed: 2000,
		//next:   '#articlephoto-next', 
		next:   '.article-photo, #articlephoto-next', 
		prev:   '#articlephoto-prev', 
		pause: true
	}).cycle('pause');
	/*$('li.type-selected').removeClass('type-selected');
	$('li.tipoclasificado').eq(1).addClass('type-selected');*/


});

