/**
 * 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, enlace, txt1, txt2)
{
	if (obj.style.display == 'none')
	{
		obj.style.display = 'block';
		if(!txt1) var txt1 = 'Cerrar';
		if(enlace) enlace.innerHTML = txt1;

	}
	else
	{
		obj.style.display = 'none';
		if(!txt2) var txt2 = 'Leer +';
		if(enlace) enlace.innerHTML = txt2;
	}
}

/**
 * Show or hides a div layer
 * @param   object   the div layer to show the innerHTML
 * @param	object   the src div layer from where get the data
 */
function switchContent (obj, src)
{
	obj.innerHTML = src.innerHTML;
}

/**
 * Show or hides a div layer
 * @param   object   the div layer to hide or show
 * @param	object   the button to change value
 */
function changeVisibility (obj1, obj2, enlace, txt1, txt2)
{
	if (obj1.style.display == 'none')
	{
		obj1.style.display = 'block';
		obj2.style.display = 'none';
		if(enlace) enlace.innerHTML = txt1;

	}
	else
	{
		obj1.style.display = 'none';
		obj2.style.display = 'block';
		if(enlace) enlace.innerHTML = txt2;
	}
}

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("El nombre no puede estar vacío.");
		document.formulario.nombre.focus();
		ok=false;
	}
	if (ok && document.formulario.telefono.value=="") {
		alert("El teléfono no puede estar vacío.");
		document.formulario.telefono.focus();
		ok=false;
	}
	if (ok && document.formulario.email.value=="") {
		alert("Debe introducir una dirección de correo.");
		document.formulario.email.focus();
		ok=false;
	}

	if (ok && !checkmail(document.formulario.email.value)) {
		alert("Por favor, introduzca una dirección de correo válida.");
		document.formulario.email.focus();
		ok=false;
	}

	if (ok && document.formulario.condiciones.checked==false) {
		alert("Debe aceptar las condiciones legales.");
		document.formulario.condiciones.focus();
		ok=false;
	}

	return ok;
}

function mapa_ampliar() {
	document.getElementById("mapa").style.top="90px";
	document.getElementById("mapa").style.left="50%";
	document.getElementById("mapa").style.height="386px";
	document.getElementById("mapa").style.width="638px";
	document.getElementById("mapa").style.marginLeft="-319px";
	document.getElementById("mapa").innerHTML="<div style='z-index:990010;position:absolute;top:-50px;left:0px;'><img src='img/planog.jpg' border='0' alt='plano' /></div><div style='position:absolute;right:260px;top:-40px;z-index:990020;'><a href='javascript:mapa_cerrar()'><img src='img/cerrar.gif' border='0' alt'X'/></a></div><div style='position:absolute;right:260px;top:270px;z-index:990020;'><a href=\"javascript:mapa_imprimir();\" title=\"Imprimir\"><img src='img/imprimir.png' border='0' alt='imprimir' /></a></div>";
	document.getElementById("mapa").style.visibility="visible";
}

function mapa_cerrar() {
	document.getElementById("mapa").style.top="0px";
	document.getElementById("mapa").style.left="0px";
	document.getElementById("mapa").style.height="1px";
	document.getElementById("mapa").style.width="1px";
	document.getElementById("mapa").style.marginLeft="0px";
	document.getElementById("mapa").style.visibility="hidden";
}

function mapa_imprimir()
{
	window.open("index.php?pagina=plano.html","plano","")
}
