/**
 * Show or hides a div layer
 * @param   object   the div layer to hide or show
 * @param	object   the button to change value
 */
function toggleVisibility (obj) {
	if (obj.style.display == 'none') {
		obj.style.display = 'block';
	}
	else {
		obj.style.display = 'none';
	}
}

function checkmail(value)
{
	var email = value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function validar()
{
	var ok=true;

	if (ok && document.formulario.nombre.value=="") {
		alert(document.formulario.aviso_nombre.value);
		document.formulario.nombre.focus();
		ok=false;
	}
	if (ok && document.formulario.telefono.value=="") {
		alert(document.formulario.aviso_telefono.value);
		document.formulario.telefono.focus();
		ok=false;
	}
	if (ok && document.formulario.email.value=="") {
		alert(document.formulario.aviso_email.value);
		document.formulario.email.focus();
		ok=false;
	}

	if (ok && !checkmail(document.formulario.email.value)) {
		alert(document.formulario.aviso_emailcheck.value);
		document.formulario.email.focus();
		ok=false;
	}
	if(document.formulario.condiciones)
	{
		if (ok && document.formulario.condiciones.checked==false) {
			alert(document.formulario.aviso_condiciones.value);
			document.formulario.condiciones.focus();
			ok=false;
		}
	}

	return ok;
}

function paginacion(step)
{
	var actual = document.getElementById('actual').value;
	var total = document.getElementById('total').value;

	if(step == "prev")
		actual--;
	if(step == "next")
		actual++;
	document.getElementById('actual').value = actual;
	document.getElementById('la_imagen').innerHTML = document.getElementById('imagen'+actual).innerHTML;

	if(actual==1)
	{
		document.getElementById('prev').style.display='none';
		document.getElementById('next').style.display='inline';
	}
	else if(actual==total)
	{
		document.getElementById('next').style.display='none';
		document.getElementById('prev').style.display='inline';
	}
	else
	{
		document.getElementById('next').style.display='inline';
		document.getElementById('prev').style.display='inline';
	}
}

function tpv() {
	document.getElementById('order').value = document.getElementById('importe').value + "D" + document.getElementById('order').value;
	return true;
}