function swap(targetId,buttonId){
  
  if (document.getElementById)
        {
        target = document.getElementById(targetId);
        buttonName = document.getElementById(buttonId);
        
            if (target.style.display == "none")
                {
                target.style.display = "block";
                } 
            
            else 
                {
                target.style.display = "none"; 
                }
        }
}
function cerrar(){
//	this.opener.location.reload();
	this.close();
}
function cerrar_Archivos(){
	this.close();
}



function validarEnter (e,idprod,origen,pagina) {
	tecla = (document.all)?e.keyCode:e.which; //aquí tecla toma un valor numérico. Si el navegador es IE el valor que toma es e.keyCode Si es Firefox o netscape e.which
	if(tecla==13){
		if((document.forms[0].txtUsuario.value!="") && (document.forms[0].txtPass.value!="")){
			document.forms[0].action="/BOREX/ES/users/comprobarUsuarioTienda.php?origen="+origen+"&idprod="+idprod+"&pagina="+pagina;;
			document.forms[0].method="post";
			document.forms[0].target="_self";
			document.forms[0].submit();
		}
		else{
			alert("Debes rellenar todos los campos.")
			document.forms[0].txtUsuario.focus();
			return;
		}
	}
}  

//VALIDAR FORMULARIO DE CONTACTO
function validar_Contacto()
				{
				  var todook;
				  todook=0
				  //comprobamos que el campo nombre no esta vacio
				  if (document.forms[0].Nombre.value.length < 2)
				  {
					alert("Rellene correctamente el campo \"Nombre\".");
					document.forms[0].Nombre.focus();
					todook=1;
					return;
				  }
				
				  //comprobamos que el campo nombre solo tiene letras
				  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚabcdefghijklmnñopqrstuvwxyzáéíóú ";
				  var checkStr = document.forms[0].Nombre.value;
				  var allValid = true;
				  for (i = 0;  i < checkStr.length;  i++)
				  {
					ch = checkStr.charAt(i);
					for (j = 0;  j < checkOK.length;  j++)
					  if (ch == checkOK.charAt(j))
						break;
					if (j == checkOK.length)
					{
					  allValid = false;
					  break;
					}
				  }
				  if (!allValid)
				  {
					alert("Escriba sólo letras en el campo \"Nombre\".");
					document.forms[0].Nombre.focus();
					todook=1;
					return;
				  }
				
				  //comprobamos que el campo telefono no esta vacio
				  if (document.forms[0].Telefono.value.length < 1)
				  {
					alert("Rellene el campo \"Telefono\".");
					document.forms[0].Telefono.focus();
					todook=1;
					return;
				  }
				
				  //comprobamos que el campo telefono solo tenga numeros
				  var checkOK = "0123456789";
				  var checkStr = document.forms[0].Telefono.value;
				  var allValid = true;
				  for (i = 0;  i < checkStr.length;  i++)
				  {
					ch = checkStr.charAt(i);
					for (j = 0;  j < checkOK.length;  j++)
					  if (ch == checkOK.charAt(j))
						break;
					if (j == checkOK.length)
					{
					  allValid = false;
					  break;
					}
				  }
				  if (!allValid)
				  {
					alert("Escriba sólo números en el campo \"Telefono\".");
					document.forms[0].Telefono.focus();
					todook=1;
					return;
				  }
				  //comprobamos que el campo email no esta vacio y lleva arroba
				  if ((document.forms[0].Mail.value.indexOf ('@', 0) == -1)||(document.forms[0].Mail.value.length < 5)) {
					alert("Escriba una dirección de correo válida en el campo \"Dirección de correo\".");
					document.forms[0].Mail.focus();
					todook=1;
					return;
				  }
						//si la variable es false entonces guardamos al vliente
						if (todook==0){
							document.forms[0].action="/PICAJEXPRESS/ES/contacto/index.php?origen=1";
							document.forms[0].method="post";
							document.forms[0].target="_self";
							document.forms[0].submit();
						}
				}
			
function validar_Pedido()
{
				  var todook;
				  todook=0
				  //comprobamos que el campo nombre no esta vacio
				  if (document.forms[0].Nombre.value.length < 2)
				  {
					alert("Rellene correctamente el campo \"Nombre\".");
					document.forms[0].Nombre.focus();
					todook=1;
					return;
				  }
				
				  //comprobamos que el campo nombre solo tiene letras
				  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚabcdefghijklmnñopqrstuvwxyzáéíóú ";
				  var checkStr = document.forms[0].Nombre.value;
				  var allValid = true;
				  for (i = 0;  i < checkStr.length;  i++)
				  {
					ch = checkStr.charAt(i);
					for (j = 0;  j < checkOK.length;  j++)
					  if (ch == checkOK.charAt(j))
						break;
					if (j == checkOK.length)
					{
					  allValid = false;
					  break;
					}
				  }
				  if (!allValid)
				  {
					alert("Escriba sólo letras en el campo \"Nombre\".");
					document.forms[0].Nombre.focus();
					todook=1;
					return;
				  }
				
				  //comprobamos que el campo telefono no esta vacio
				  if (document.forms[0].telefono.value.length < 1)
				  {
					alert("Rellene el campo \"Telefono\".");
					document.forms[0].telefono.focus();
					todook=1;
					return;
				  }
				
				  //comprobamos que el campo telefono solo tenga numeros
				  var checkOK = "0123456789";
				  var checkStr = document.forms[0].telefono.value;
				  var allValid = true;
				  for (i = 0;  i < checkStr.length;  i++)
				  {
					ch = checkStr.charAt(i);
					for (j = 0;  j < checkOK.length;  j++)
					  if (ch == checkOK.charAt(j))
						break;
					if (j == checkOK.length)
					{
					  allValid = false;
					  break;
					}
				  }
				  if (!allValid)
				  {
					alert("Escriba sólo números en el campo \"Teléfono\".");
					document.forms[0].telefono.focus();
					todook=1;
					return;
				  }
				  //comprobamos que el campo email no esta vacio y lleva arroba
				  if ((document.forms[0].correo.value.indexOf ('@', 0) == -1)||(document.forms[0].correo.length < 5)) {
					alert("Escriba una dirección de correo válida en el campo \"E-Mail\".");
					document.forms[0].correo.focus();
					todook=1;
					return;
				  } 
				  
				   //comprobamos que el campo archivo no esta vacio
				  if (document.forms[0].logo1.value.length < 1)
				  {
					alert("Debe adjuntar un archivo a digitalizar.");
					document.forms[0].logo1.focus();
					todook=1;
					return;
				  }
				  //comprobamos que el campo ancho no esta vacio
				  if (document.forms[0].Alto.value.length < 1 && document.forms[0].Ancho.value.length < 1 )
				  {
					alert("Debe indicar el ancho o el alto de la imagen a digitalizar.");
					document.forms[0].Ancho.focus();
					todook=1;
					return;
				  }
				 
				 //comprobamos que el campo file format no esta vacio
				  // if (document.forms[0].Tarifa.value="")
				   //{
					 //alert("Seleccione la tarifa que se corresponde con su diseño.");
				 //	document.forms[0].Tarifa.focus();
				 //	return;
				  // }
				 
				  //comprobamos que el campo colores no esta vacio
				//  if (document.forms[0].colores.value.length < 1)
				 // {
				//	alert("Rellene correctamente el campo \"NºColores\".");
				//	document.forms[0].colores.focus();
				//	return;
				 // }
				  
				  //comprobamos que el campo Colores solo tenga numeros
				 // var checkOK = "0123456789";
				 // var checkStr = document.forms[0].colores.value;
				 // var allValid = true; 
				 // for (i = 0;  i < checkStr.length;  i++)
				 // {
				//	ch = checkStr.charAt(i);
				//	for (j = 0;  j < checkOK.length;  j++)
				//	  if (ch == checkOK.charAt(j))
				//		break;
				//	if (j == checkOK.length)
				//	{
				//	  allValid = false;
				//	  break;
				//	}
				//  }
				//  if (!allValid)
				//  {
				//	alert("Escriba sólo números en el campo NºColores.");
				//	document.forms[0].colores.focus();
				//	return;
				//  }
				  
						//si la variable es false entonces guardamos al vliente
						if (todook==0){
							//document.forms[0].action="/PICAJEXPRESS/ES/pedidos/index_paso_2.php";
							document.forms[0].action="/PICAJEXPRESS/ES/pedidos/index.php?logosguardados=1&origen=1";
							document.forms[0].method="post";
							document.forms[0].target="_self";
							document.forms[0].submit();
						}
				}
/*ENVIAR ARCHIVOS PEDIDO*/
function enviar_Archivos(){
		var ventana;
	//ventana=window.open("logosUsuario.php","Logos_Presupuesto","height=400,width=570,scrollbars=YES,Menubar=NO,Toolbar=NO");
	ventana=window.open("pop_Archivos.php","Cargar_Disenios","height=300,width=570,scrollbars=YES,Menubar=NO,Toolbar=NO");
	ventana.focus()

	}
function enviar_Archivos_2(){
	  //comprobamos que el campo Ancho no esta vacio
				   if (document.forms[0].logo1.value.length < 1)
				  {
					alert("Debe seleccionar algún archivo.");
					document.forms[0].logo1.focus();
					return;
				  }
				  
				  if (document.forms[0].Ancho.value.length < 1)
				  {
					alert("Rellene el campo \"Ancho\".");
					document.forms[0].Ancho.focus();
					return;
				  }
				  //comprobamos que el campo Ancho solo tenga numeros
				  var checkOK = "0123456789";
				  var checkStr = document.forms[0].Ancho.value;
				  var allValid = true;
				  for (i = 0;  i < checkStr.length;  i++)
				  {
					ch = checkStr.charAt(i);
					for (j = 0;  j < checkOK.length;  j++)
					  if (ch == checkOK.charAt(j))
						break;
					if (j == checkOK.length)
					{
					  allValid = false;
					  break;
					}
				  }
				  if (!allValid)
				  {
					alert("Escriba sólo números en el campo \"Ancho\".");
					document.forms[0].Ancho.focus();
					return;
				  }
				  //comprobamos que el campo Ancho no esta vacio
				  if (document.forms[0].Ancho.value.length < 1)
				  {
					alert("Rellene el campo \"Ancho\".");
					document.forms[0].Ancho.focus();
					return;
				  }
				  
				  
				  if (document.forms[0].Alto.value.length < 1)
				  {
					alert("Rellene el campo \"Alto\".");
					document.forms[0].Alto.focus();
					return;
				  }
				 //comprobamos que el campo Alto solo tenga numeros
				  var checkOK = "0123456789";
				  var checkStr = document.forms[0].Alto.value;
				  var allValid = true;
				  for (i = 0;  i < checkStr.length;  i++)
				  {
					ch = checkStr.charAt(i);
					for (j = 0;  j < checkOK.length;  j++)
					  if (ch == checkOK.charAt(j))
						break;
					if (j == checkOK.length)
					{
					  allValid = false;
					  break;
					}
				  }
				  if (!allValid)
				  {
					alert("Escriba sólo números en el campo \"Alto\".");
					document.forms[0].Alto.focus();
					return;
				  }
				   //comprobamos que el campo Ancho no esta vacio
				//  if (document.forms[0].Alto.value.length < 1)
				//  {
				//	alert("Rellene el campo \"Alto\".");
				//	document.forms[0].Alto.focus();
				//	return ;
				 // }
				  //comprobamos que el campo Alto solo tenga numeros
				//  var checkOK = "0123456789";
				//  var checkStr = document.forms[0].Alto.value;
				//  var allValid = true;
				//  for (i = 0;  i < checkStr.length;  i++)
				//  {
				//	ch = checkStr.charAt(i);
				//	for (j = 0;  j < checkOK.length;  j++)
				//	  if (ch == checkOK.charAt(j))
				//		break;
				//	if (j == checkOK.length)
				//	{
				//	  allValid = false;
				//	  break;
				//	}
				//  }
				//  if (!allValid)
				//  {
				//	alert("Escriba sólo números en el campo \"Alto\".");
				//	document.forms[0].Alto.focus();
				//	return;
				//  }
	document.forms[0].action="pop_Archivos.php?logosguardados=1";
	document.forms[0].method="post";
	document.forms[0].target="_self";
	document.forms[0].submit();
}
			

//FUNCION PARA PODER UTILIZAR TARGET Y QUE VALIDE W3C
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
} 
