	/*
		Funcion que devuelve las coordenadas XY del objeto pasado por parametro
	*/
   function findPos(obj) {
               var curleft = curtop = 0;
               if (obj.offsetParent) {
                    curleft = obj.offsetLeft
                    curtop = obj.offsetTop
                    while (obj = obj.offsetParent) {
                         curleft += obj.offsetLeft
                         curtop += obj.offsetTop
                    }
               }
               return [curleft,curtop];
          }





function abreInfo(){
	
	var win = new Window(Application.getNewId(), {className: "dialog",   width:460, height:400, zIndex: 1, resizable: false, minimizable: false, maximizable: false, title: "", showEffect:Effect.BlindDown, hideEffect: Effect.SlideUp, draggable:true})
	
	win.getContent().innerHTML='<iframe  FRAMEBORDER=0 src="/FundMM/jsp/Finfolegal.jsp" scrolling="auto" width="460" FRAMEBORDER=0 height="400"></iframe>'
	
	var enlace = document.getElementById('w3');
	var matriz = findPos(enlace);
	
	win.setLocation(matriz[1]-427, matriz[0]-350);
	win.show();
}     

function validaAlfanumerico(theFormtxtNombre)
{
  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚabcdefghijklmnñopqrstuvwxyzáéíóúüÜºª-. \t\r\n\f";
  var checkStr = theFormtxtNombre.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)
  {
    theFormtxtNombre.focus();
    return (false);
  }
  return (true);
}

function validEmail(email) {
        return ( !(email.indexOf("@") == -1) )
}

function validaNumero(theFormtxtNombre)
{
  var checkOK = "0123456789 \t\r\n\f";
  var checkStr = theFormtxtNombre.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)
  {
    return (false);
  }
  return (true);
}

function enviar(){

    if ((document.forms[0].nombre.value=="")||(document.forms[0].apellidos.value=="")){
	alert("Debe introducir un nombre y un apellido");
	return;
    }
    else if((!validaAlfanumerico(document.forms[0].nombre)) || (!validaAlfanumerico(document.forms[0].apellidos)) ){
    alert("Debe introducir solo caracteres alfabéticos para el  nombre y el apellido");
    return;
    }else{
	if (((document.forms[0].direccion.value=="")||(document.forms[0].provincia.value=="")||(document.forms[0].cp.value==""))&&(document.forms[0].email.value=="")&&(document.forms[0].fax.value=="")){
		alert("Debe introducir una direccion a la que le podamos responder");
		return;
	}else{
		if (!validaNumero(document.forms[0].fax)&&(document.forms[0].fax.value!="")){
			alert("Debe introducir un fax a la que le podamos responder");
			return;			
		}
		if (!validEmail(document.forms[0].email.value)&&(document.forms[0].email.value!="")){
			alert("Debe introducir un email en el que le podamos responder");
			return;
		}
		if ((document.forms[0].direccion.value!="")&&(document.forms[0].provincia.value!="")&&(document.forms[0].cp.value!="")&&(!validaNumero(document.forms[0].cp))){
			alert("Debe introducir un codigo postal a la que le podamos responder");
			return;			
		}
		else{
						if ( (!validaAlfanumerico(document.forms[0].provincia)) || (!validaAlfanumerico(document.forms[0].poblacion)) ||  (!validaNumero(document.forms[0].cp))){
							alert("Debe introducir una dirección correcta a la que le podamos responder");
							return;	
						}
		}					
	}	
		if (!validaNumero(document.forms[0].telefono)&&(document.forms[0].telefono.value!="")){
			alert("Debe introducir un telefono correcto en el que le podamos responder");
			return;
		}
		
	if (document.forms[0].otra.value.length >3000){
			     alert("La longitud máxima del campo OTRA INFORMACIÓN es de 3000 caracteres");
					document.forms[0].otra.focus();	
					return;
   }	
   

 
	
	document.forms[0].submit();
    }

}
    function abreLOPD(){
	var win = new Window(Application.getNewId(), {className: "dialog",   width:460, height:400, zIndex: 1, resizable: false, minimizable: false, maximizable: false, title: "", showEffect:Effect.BlindDown, hideEffect: Effect.SlideUp, draggable:true})
	
	win.getContent().innerHTML='<iframe  FRAMEBORDER=0 src="/FundMM/jsp/tratamiento_datos_personales.htm" scrolling="auto" width="460" FRAMEBORDER=0 height="400"></iframe>'
	
	var enlace = document.getElementById('w3');
	var matriz = findPos(enlace);
		
	win.setLocation(matriz[1]-427, matriz[0]-350);
	win.show();
} 

