// JavaScript Document
jQuery(document).ready(function($){

	$('#testimoniosContainer').cycle({
        cleartypeNoBg: true,
		fx:      'scrollHorz',
        timeout:  6000,
        prev:    '#prevTestimonio',
        next:    '#nextTestimonio',
		pager:  '#navTestimonios',
        pagerAnchorBuilder: pagerFactory,
   		nowrap: false
		
	});
	
	
	
	$('.testimonio_click').click(function() { 
		
		 $(this).css('display','none');
		 html_video = $(this).next('.t_video_player').html();
		 html_video = html_video.replace('autostart=false','autostart=true');
		 $(this).next('.t_video_player').html( html_video );
		 
   		 $('#testimoniosContainer').cycle('pause'); 
   		 
   		 page_click();
	});

    function pagerFactory(idx, slide) {
        return '<li class="pager_click"><a href="javascript:;">'+(idx+1)+'</a></li>';
    };
	
	
	
	
});


function testimonio_stop()
{
	$('#testimoniosContainer').cycle('pause'); 	
}

function detein()
{

}

function page_click()
{
	$('.pager_click').click(function() { 
	
		video_reload();
	
	});
	
	$('.prevBtn').click(function() { 
	
		video_reload();
	
	});
	
	$('.nextBtn').click(function() { 
	
		video_reload();
	
	});
	
}

function video_reload()
{
	$('.testimonio_click').css('display','block');
	$('.t_video_player').each(function(index) {
	
		html_video = $(this).html();
			html_video = html_video.replace('autostart=true','autostart=false');
		$(this).html( html_video );
	
	});
}


