window.addEvent('domready', function(e) {
	$$('.input_imei').addEvent('keyup', function(e) 
	{ 
		if (e.code == 8)
		{
			match = e.target.getProperty('id').match(/imei_([0-9]+)/); 
			nb = match[1].toInt() - 1;
			nb2 = nb + 1;
			if (nb >= 0)
			{
				if ($('imei_'+nb2).value == '')
				{
					$('imei_'+nb).value = '';
					$('imei_'+nb).focus();
				}
				else
					$('imei_'+nb2).value = '';
			}
			e.stop();
		}
		else if (e.target.value != '' && e.target.value >= '0'  && e.target.value <= '9')
		{
			match = e.target.getProperty('id').match(/imei_([0-9]+)/); 
			nb = match[1].toInt() + 1;
			if (nb < 15)
				$('imei_'+nb).focus();
		}
		else
			e.target.value = '';
});
});

var moveTimer;
var tmphtml;
function mover(topmove, leftmove, moveheight, movewidth)
{
	topfinal = 238;
	leftfinal = 760;
	widthfinal = $('panier_content').getStyle('width').toInt();
	heightfinal = $('panier_content').getStyle('height').toInt();
	
	if ($('cadre_move').getStyle('top').toInt() <= topfinal && $('cadre_move').getStyle('left').toInt() >= leftfinal)
	{
		$('cadre_move').style.display = 'none';
		$('panier').set('html', tmphtml);
	}
	else
	{
		//$('cadre_move').setStyle('top', 100);
		if ($('cadre_move').getStyle('top').toInt() > topfinal)
			$('cadre_move').setStyle('top', $('cadre_move').getStyle('top').toInt() - topmove);
		if ($('cadre_move').getStyle('left').toInt() < leftfinal)
			$('cadre_move').setStyle('left', $('cadre_move').getStyle('left').toInt() + leftmove);
		if (movewidth > 0 && $('cadre_move').getStyle('width').toInt() > widthfinal)
			$('cadre_move').setStyle('width', $('cadre_move').getStyle('width').toInt() - movewidth);
		if (movewidth > 0 && $('cadre_move').getStyle('width').toInt() < widthfinal)
			$('cadre_move').setStyle('width', $('cadre_move').getStyle('width').toInt() + movewidth);
		if (moveheight > 0 && $('cadre_move').getStyle('height').toInt() > heightfinal)
			$('cadre_move').setStyle('height', $('cadre_move').getStyle('height').toInt() - moveheight);
		if (moveheight > 0 && $('cadre_move').getStyle('height').toInt() < heightfinal)
			$('cadre_move').setStyle('height', $('cadre_move').getStyle('height').toInt() + moveheight);	
		setTimeout("mover("+topmove+","+leftmove+","+moveheight+","+movewidth+")", 30);
	}
}

function moveCadre(nbstep)
{
	topfinal = 238;
	leftfinal = 760;
	
	$('cadre_move').setStyle('top',337);
	$('cadre_move').setStyle('left',110);
	$('cadre_move').setStyle('width', 140);
	$('cadre_move').setStyle('height', 240);
	
	widthfinal = $('panier_content').getStyle('width').toInt();
	heightfinal = $('panier_content').getStyle('height').toInt();
	
	leftmove =((leftfinal - $('cadre_move').getStyle('left').toInt()) / nbstep);
	topmove = (($('cadre_move').getStyle('top').toInt() - topfinal) / nbstep);
	if (widthfinal > $('cadre_move').getStyle('width').toInt())
		movewidth = (widthfinal - $('cadre_move').getStyle('width').toInt()) / nbstep;
	else
		movewidth = (($('cadre_move').getStyle('width').toInt() - widthfinal) / nbstep);
	if (heightfinal > $('cadre_move').getStyle('height').toInt())
		moveheight = (heightfinal - $('cadre_move').getStyle('height').toInt()) / nbstep;
	else
		moveheight = (($('cadre_move').getStyle('height').toInt() - heightfinal) / nbstep);
	mover(topmove, leftmove, moveheight, movewidth);
}