var tmg_posi=0;
var tmg_playing=1;
var tmg_curr=0;
function tmg_desthome_slide(num)
{
	
	var offset_posi=(num - tmg_posi)*560;

	//alert(offset_posi);

	if(offset_posi>0)
	{
		$('#tmg_cont1').animate({scrollLeft: '+=' + offset_posi + 'px'}, 560,'swing');
	}else
	{
		offset_posi=0-offset_posi;	
		$('#tmg_cont1').animate({scrollLeft: '-=' + offset_posi + 'px'}, 560,'swing');
	}
	
	tmg_posi=num;
}
$(document).ready(function() {
  if($("#tmg_destacado"))
{
	
	if($('#tmg_dest_value').val()==1)
	{
		$('#tmg_controls_box').hide();
	}else
	{
 $('#tmg_cont1').animate({scrollLeft: '-=' + 2000 + 'px'}, 350,'swing');
 var tmg_timer=setInterval('tmg_desthome_autonext()',7000);
	}
}
 
});
function tmg_desthome_play()
{
	$('#tmg_cntrl_play').hide();
	$('#tmg_cntrl_pause').show();
	
	
	tmg_playing=1;

}
function tmg_desthome_pause()
{
	$('#tmg_cntrl_play').show();
	$('#tmg_cntrl_pause').hide();
	
	
	tmg_playing=0;
	
}
function tmg_desthome_autonext()
{

	if(tmg_playing==1)
	{
		tmg_curr++;
		if(tmg_curr==$('#tmg_dest_value').val())
		{	
			tmg_curr=0;
		}
		tmg_desthome_slide(tmg_curr,0)
	}

}

function tmg_desthome_next()
{
	tmg_desthome_pause();
	
	

	tmg_curr++;
	if(tmg_curr==$('#tmg_dest_value').val())
	{	
		tmg_curr=0;
	}
	tmg_desthome_slide(tmg_curr,0)


}
function tmg_desthome_prev()
{
	tmg_desthome_pause();
	
	tmg_curr=tmg_curr-1;
	if(tmg_curr<0)
	{	
		tmg_curr=$('#tmg_dest_value').val()-1;
	}
	
	tmg_desthome_slide(tmg_curr,0)
	

}
