
 function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



function MM_openBrWindow(theURL, ventana) { //v2.0
      var tV = theURL.indexOf ('Virt');
      var w = tV != -1 ? 500 :450;
      var h = tV != -1 ? 366 : 620;
      window.open(theURL,ventana,'width=' + w + ',height=' + h + "'" );
}


/*para comprobacion del formulario*/
//define los caracteres de espacios en blanco;
	var whiteSpace = " \t\n\r";
	function isEmpty(s){
	 	var i;
		if ((s == null) || (s.length == 0))
			{
		return true;
				//busca la cadena para comprobar que tenga caracteres
				//que no sean espacios en  blanco
			}

		for(i = 0; i < s.length; i++){
				var c = s.charAt (i);
				if(whiteSpace.indexOf (c) == -1){
					return false;
				}
			}
		return true;
			//todos los caracteres son espacios en blanco
	}
	//

      function email(field)
	{
	//para validar e mail
		var positionOfAt;
		var s = field.value;
		if(isEmpty(s))
		{
			alert ("por favor ingrese una dirección de e-mail");
			field.focus();
			return false;
		}
		positionOfAt = s.indexOf ('@',1);
		if ((positionOfAt == -1) || (positionOfAt == (s.length-1))){
		  alert ('dirección de e-mail no valida');
		  document.forms[nombre_form].e_mail.focus()
		  return false;
		}
	return true;
	}
	/*
	*los campos del formularios
	*/
	
      function codigoPostal(field){
      var s = field.value;
      
            if(isEmpty(s) || isNaN (s) )
		{
			alert ("por favor ingrese un número de  codigo postal válido");
			field.focus();
			return false;
		}
		
		if(s.length < 5 ){
		    alert ("por favor controle si la cantidad de números ingresados es correcta");
		    	field.focus();
			return false;
		}
		return true;
      }
      
    function telefono(field){
      var s = field.value;
      
            if(isEmpty(s) || isNaN (s) )
		{
			alert ("por favor ingrese un número de telefóno sin espacios\n ni código de país");
			field.focus();
			return false;
		}
		
		if(s.length < 9 ){
		var ingresados = s.length;
		    alert ("por favor controle si la cantidad de números ingresados es correcta\nUsted a ingresado " + ingresados + " dígitos\nEs necesario ingresar un número de 9 digitos." );
		    	field.focus();
			return false;
		}
		return true;
    }  
      
function validate()
	{
		 

		if (isEmpty(document.forms[nombre_form].nombre.value))
			{
				alert("por favor ingrese su nombre");
				document.forms[nombre_form].nombre.focus();
				return false;
			}
			
		if (isEmpty(document.forms[nombre_form].apellidos.value))
			{
				alert("por favor ingrese su apellido");
				document.forms[nombre_form].apellidos.focus();
				return false;
			}
			
		if (isEmpty(document.forms[nombre_form].provincia.value))
			{
				alert("por favor ingrese una provincia");
				document.forms[nombre_form].provincia.focus();
				return false;
			}
		
		if (isEmpty(document.forms[nombre_form].poblacion.value))
			{
				alert("por favor ingrese una población");
				document.forms[nombre_form].poblacion.focus();
				return false;
			}
			
	     if (isEmpty(document.forms[nombre_form].tipo_via.value))
			{
				alert("por favor ingrese el tipo de via");
				document.forms[nombre_form].tipo_via.focus();
				return false;
			}
			
	     if (isEmpty(document.forms[nombre_form].nombre_de_via.value))
			{
				alert("por favor ingrese el nombre de via");
				document.forms[nombre_form].nombre_de_via.focus();
				return false;
			}
			
		if (isEmpty(document.forms[nombre_form].numero_piso.value))
			{
				alert("por favor ingrese un numero de piso, puerta etc;");
				document.forms[nombre_form].numero_piso.focus();
				return false;
			}
			
		if (!codigoPostal(document.forms[nombre_form].codigo_postal))
			{
				return false;
			}
                  
       	if (!telefono(document.forms[nombre_form].telefono))
			{
				return false;
			}
                  				
		if (!email(document.forms[nombre_form].e_mail)){
				return false;
			}  
			
		if (isEmpty(document.forms[nombre_form].color.value))
			{
				alert("por favor ingrese el color de la prenda");
				document.forms[nombre_form].color.focus();
				return false;
			}
					
return true;
	}	

