function moveitem(keyes)
{
	var items = $$(keyes);
	items[1].style.top = '-310px';
	new Effect.Morph(items[1], {
		duration: 0.1,
		style: 'top:0px',
		afterFinish: function () {
						moveitem(keyes);
					}
	});
	
}

function moveitem1(keyes)
{
	var items = $$(keyes);
	items[0].style.top = '-310px';

	new Effect.Morph(items[0], {
		duration: 0.3,
		style: 'top:0px',
		afterFinish: function () {
						moveitem1(keyes);
					}
	});
}

function moveitem2(keyes,idValue)
{	
	var items = $$(keyes);
	var itop = items[idValue].getStyle('top');
	itop = parseInt(itop.replace(/px/g, ''))
	//alert(itop);
	if(itop <0)
		itop = itop*(-1)
	
	var positionItem = itop - 31;
	
	//alert(positionItem);
	if(positionItem >0)
	{
		new Effect.Morph(items[idValue], {
					duration: 0.1,
					style: 'top:-'+positionItem+'px'
		});
	}
	else
	{
		new Effect.Morph(items[idValue], {
			duration: 0.1,
			style: 'top: 0px',
			afterFinish: function () {
						items[idValue].style.top = '-310px';
					}
		});
	//	items[0].style.top = '-310px';
	}
}

function moveitem3(keyes,idValue,numberItem,cero)
{	
	
	var positionItem = numberItem *31;
	
	//alert(keyes+'<->'+idValue+'<->'+numberItem+'<->'+cero+'>>>'+positionItem);
	
	var items = $$(keyes);
	var itop = items[idValue].getStyle('top');
	itop = parseInt(itop.replace(/px/g, ''))
	//alert(itop);
	if(itop <0)
		itop = itop*(-1)
	
	if(positionItem != itop)
	{
	
//	var positionItem = itop - 31;
	
	//alert(positionItem);
		if(positionItem == 0 && itop == cero)
		{
			//ya esta en cero
		}
		else
		{
			if(positionItem >=1)
			{
				new Effect.Morph(items[idValue], {
							duration: 0.1,
							style: 'top:-'+positionItem+'px'
				});
			}
			else
			{
				new Effect.Morph(items[idValue], {
					duration: 0.1,
					style: 'top: 0px',
					afterFinish: function () {
								items[idValue].style.top = '-'+cero+'px';
							}
				});
			//	items[0].style.top = '-310px';
			}
		}
	}
}


function missingTime(ayo,mes,dia,id) {
	var hora = 0;
	var minuto = 0;
	var segundo = 0;
	//var dif = dia + ' del ' + mes + ' de ' + ayo + ', a las ' + hora + ':';
	//if (minuto < 10) { dif+='0'; }
	///dif+=minuto + '<br>';
	//document.getElementById('evento' + id).innerHTML=dif
	var a = new Date();
	dif = new Date(ayo,mes - 1,dia,hora,minuto,segundo);
	dif = (dif.getTime() - a.getTime())/1000;
	if (dif < 0) {
		 //document.getElementById('contar' + id).innerHTML="<font color='#FF0000'>Lleg&oacute; el evento!!</font>"; 
		 //lanzo el ajax para cambiar el estado del asesinato
		}
	else {
		dia		= Math.floor(dif/60/60/24);
		hora	= Math.floor((dif - dia*60*60*24)/60/60);
		minuto	= Math.floor((dif - dia*60*60*24 - hora*60*60)/60);
		segundo	= Math.floor(dif - dia*60*60*24 - hora*60*60 - minuto*60);
		var txt = '';
		var dayParam = '#day'+id+' li img';
		var HorParam = '#Hr'+id+' li img';
		var MinParam = '#Min'+id+' li img';
		var SegParam = '#seg'+id+' li img';
		
		
		//parametros para mover el reloj
		switch (String(dia).length) { 
			case 1: //SOLO UN DIA
				 moveitem3(dayParam,0,0,310);
				 moveitem3(dayParam,1,0,310);
				 moveitem3(dayParam,2,dia,310);
			break 
			case 2: // DOS DIAS
				 moveitem3(dayParam,0,0,310);
				 moveitem3(dayParam,1,String(dia).substr(0,1),310);
				 moveitem3(dayParam,2,String(dia).substr(1,1),310);
			break 
			
			case 3: //TRES DIAS
				 moveitem3(dayParam,0,String(dia).substr(0,1),310);
				 moveitem3(dayParam,1,String(dia).substr(1,1),310);
				 moveitem3(dayParam,2,String(dia).substr(2,1),310);
			break 
			
			default: //DEFAULT 0
				moveitem3(dayParam,0,0,310); 
				moveitem3(dayParam,1,0,310);
				moveitem3(dayParam,2,0,310);
		} 
		
		// Parametro Horas
		switch (String(hora).length) { 
			case 1: //SOLO UN HORA
				 moveitem3(HorParam,0,0,93);
				 moveitem3(HorParam,1,hora,310);
			break 
			case 2: // DOS HORAS
				 moveitem3(HorParam,0,String(hora).substr(0,1),93);
				 moveitem3(HorParam,1,String(hora).substr(1,1),310);
			break 
			default: //DEFAULT 0
				moveitem3(HorParam,0,0,93); 
				moveitem3(HorParam,1,0,310);
		}
		
		//Parametro Minutos
		switch (String(minuto).length) { 
			case 1: //SOLO UN MINUTO
				 moveitem3(MinParam,0,0,217);
				 moveitem3(MinParam,1,minuto,310);
			break 
			case 2: // DOS MINUTOS
				 moveitem3(MinParam,0,String(minuto).substr(0,1),217);
				 moveitem3(MinParam,1,String(minuto).substr(1,1),310);
			break 
			default: //DEFAULT 0
				moveitem3(MinParam,0,0,217); 
				moveitem3(MinParam,1,0,310);
		}
		
		//Parametros por segundo
		switch (String(segundo).length) { 
			case 1: //SOLO UN MINUTO
				 moveitem3(SegParam,0,0,217);
				 moveitem3(SegParam,1,segundo,310);
			break 
			case 2: // DOS MINUTOS
				 moveitem3(SegParam,0,String(segundo).substr(0,1),217);
				 moveitem3(SegParam,1,String(segundo).substr(1,1),310);
			break 
			default: //DEFAULT 0
				moveitem3(SegParam,0,0,217); 
				moveitem3(SegParam,1,0,310);
		}
	}
}



function countItems()
{	
	//milisegundos
	moveitem('#mil1 li img');
	moveitem1('#mil1 li img');
	moveitem('#mil2 li img');
	moveitem1('#mil2 li img');
	setInterval("missingTime(2011,6,17,1)",1000);
	setInterval("missingTime(2011,6,18,2)",1000);
	
	//Segundos
	
	//setInterval("moveitem2('#seg1 li img',1)",1000);
	
}
//	document.getElementById()
