var pag = 0;
$(document).ready(function(){
	var delay = 500;
	var rango = 1;
	var divmov = $('#header_sliding_content');
	
	var wt = 0;
	var ancho = 630;
	$('.featured').each(function(index){
		wt += 630;
	});divmov.css('width',wt);
	
	var type = 0;
	
	$('a').each(function(index){
		if($('a:eq(' + index + ')').attr('rel')=='sliding'){
			if(type==0){
				$('a:eq(' + index + ')').click(function(){
					var mov = 0;
					pag--;
					if(pag<0){pag=0;}
					var widthpanel = rango*ancho;
					mov = -(widthpanel*pag);
					divmov.animate({left: mov},{ queue:false, duration:delay});
				});
			}else if(type==1){
				$('a:eq(' + index + ')').click(function(){
					var mov = 0;
					pag++;
					var widthpanel = rango*parseInt(ancho);
					if(pag >= (wt/widthpanel)){pag=0;}
					mov = -(widthpanel*pag);
					divmov.animate({left: mov},{ queue:false, duration:delay});
					//alert(widthpanel);
					//alert(wt);
				});
			}
			type++;
		}
		
		
		
	});
});

function resulttado(){
	var delay = 500;
	var rango = 1;
	var divmov = $('#header_sliding_content');
	var wt = 0;
	var ancho = 630;
	$('.featured').each(function(index){
		wt += 630;
	});divmov.css('width',wt);
	
	var intervalo = setInterval(function() { 
			var mov = 0;
			pag++;
			var widthpanel = rango*parseInt(ancho);
			if(pag >= (wt/widthpanel)){pag=0;}
			mov = -(widthpanel*pag);
			divmov.animate({left: mov},{ queue:false, duration:delay});
			//alert(widthpanel);
					//alert(wt);
		}, 5000);
}

function mueveReloj(){ 
   	momentoActual = new Date() 
   	hora = momentoActual.getHours() 
   	minuto = momentoActual.getMinutes() 
   	segundo = momentoActual.getSeconds() 

   	str_segundo = new String (segundo) 
   	if (str_segundo.length == 1) 
      	 segundo = "0" + segundo 

   	str_minuto = new String (minuto) 
   	if (str_minuto.length == 1) 
      	 minuto = "0" + minuto 

   	str_hora = new String (hora) 
   	if (str_hora.length == 1) 
      	 hora = "0" + hora 

   	horaImprimible = hora + " : " + minuto + " : " + segundo 

   	//document.form_reloj.reloj.value = horaImprimible 
	$('#hora').html(horaImprimible);

   	setTimeout("mueveReloj()",1000) 
}
