/* ---------------------------------------------------------------- */
function inicio_roll(cod)
{
	var id;
	document.getElementById('aux_'+cod).value = "3";
	document.getElementById('imagen_'+cod).src = 'http://img.youtube.com/vi/' + cod + '/2.jpg';
	id = setInterval("continua_roll('"+cod+"')", 1500);
	document.getElementById('int_'+cod).value = id;
}
/* ---------------------------------------------------------------- */
function parar_roll(cod)
{
	document.getElementById('imagen_'+cod).src = 'http://img.youtube.com/vi/' + cod + '/1.jpg';
	clearInterval(document.getElementById('int_'+cod).value);
	document.getElementById('aux_'+cod).value = "stop";
}
/* ---------------------------------------------------------------- */
function continua_roll(cod)
{
	var num;
	//alert(document.getElementById('aux_'+cod).value);
	if (document.getElementById('aux_'+cod).value != "stop")
	{
		num = parseInt(document.getElementById('aux_'+cod).value);
		//alert("el numero es: " + num);
		document.getElementById('imagen_'+cod).src = 'http://img.youtube.com/vi/' + cod + '/' + document.getElementById('aux_'+cod).value + '.jpg';
		//alert("la imagen es: " + 'http://img.youtube.com/vi/' + cod + '/' + document.getElementById('aux_'+cod).value + '.jpg');
		i = num + 1;
		if (i == 4) { i = 1; }
		//alert("y pongo el aux a: " + i);
		document.getElementById('aux_'+cod).value = i;
	}
}
/* ---------------------------------------------------------------- */
function trim(cadena)
{
    for(i=0; i<cadena.length; )
    {
        if(cadena.charAt(i)==" ")
            cadena=cadena.substring(i+1, cadena.length);
        else
            break;
    }

    for(i=cadena.length-1; i>=0; i=cadena.length-1)
    {
        if(cadena.charAt(i)==" ")
            cadena=cadena.substring(0,i);
        else
            break;
    }
    
    return(cadena);
}
/* ---------------------------------------------------------------- */
function validarContacto()
{
	var error;
	error = "";

	if (trim(document.form_contacto.nombre.value) == "")
	{
		error += " - Debes escribir tu nombre.\n";
	}
	if (trim(document.form_contacto.email.value) == "")
	{
		error += " - Debes escribir tu email.\n";
	}
	if (!(document.getElementById('condiciones').checked))
	{
		error += " - Debes leer y aceptar las condiciones de contacto de www.loswalkman.com.\n";
	}

	if (error == "")
	{
		document.form_contacto.enviar.value = "s";
		document.form_contacto.submit();
	} else {
		alert(error);
	}
}
/* ---------------------------------------------------------------- */