/*
 * Función para la encuesta
 */
function abreVentana(theURL,winName,features) {
	var winl = (screen.width - 450) / 2;
	var wint = (screen.height - 350) / 2;
	win = window.open(theURL,winName,features+',left='+winl+',top='+wint);
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }  
}
/*Fin función para encuesta*/
var whitespace = " \t\n\r";

function isEmpty(s)
{
   return ((s == null) || (s.length == 0))
}
function showRemotePremiosJADA() {
	self.name = "principal";

	var windowprops = "toolbar=0,location=0,directories=0,status=0, " +
	"menubar=0,scrollbars=0,resizable=0,width=350,height=200,top=270,left=250";

	OpenWindow = window.open("premios.htm", "remote", windowprops);
	}

	function closeRemote() {
		timer = setTimeout('window.close();', 10);
	}
function isWhitespace (s)

{   var i;

    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    return true;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function popupform(myform, windowname)
{
	if (! window.focus)return true;
	window.open('', windowname, 'status=no,scrollbars=no,width=590,height=255');
	myform.target=windowname;
	return true;
}

function IsNumeric(strString){
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;
   for (i = 0; i < strString.length && blnResult == true; i++){
		  strChar = strString.charAt(i);
		  if (strValidChars.indexOf(strChar) == -1) {
			 blnResult = false;
		   }
     }
   return blnResult;
}

function otros(ot) {
  if(ot.value=="Otro") {
      document.getElementById("especifico"+ot.name).style.display = "inline";
	} else {
      document.getElementById("especifico"+ot.name).style.display = "none";
   }
}

function chequeaSuscripcion (form){
	
	if (form.nombre.value == "") {
        alert( "Por favor, escribe tu nombre." );
        form.nombre.focus();
        return false ;
    }
	if (form.apellidos.value == "") {
        alert( "Por favor, escribe tu primer apellido." );
        form.apellidos.focus();
        return false ;
    }	
	if (form.direccion.value == "")  {
        alert( "Por favor, escribe tu direcci\xf3n." );
        form.direccion.focus();
        return false ;
    }
	if (form.poblacion.value == "")  {
        alert( "Por favor, escribe tu poblaci\xf3n." );
        form.poblacion.focus();
        return false ;
    }
	if (form.provincia.value == "")  {
        alert( "Por favor, escribe tu provincia." );
        form.provincia.focus();
        return false ;
    }
	if ((form.cp.value == "") || (!IsNumeric(form.cp.value))) {
        alert( "Por favor, escribe tu c\xf3digo postal." );
        form.cp.focus();
        return false ;
    }	
	if (form.telefono.value == "")  {
        alert( "Por favor, escribe tu tel\xe9fono de contacto." );
        form.telefono.focus();
        return false ;
    }	var x = form.email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(x)){
        alert( "Por favor, escribe tu direcci\xf3n de correo electr\xf3nico correctamente." );
        form.email.focus();
        return false ;
    }
	var x2 = form.email2.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(x2)){
        alert( "Por favor, escribe tu direcci\xf3n de correo electr\xf3nico correctamente." );
        form.email2.focus();
        return false ;
    }	

	if ((form.email.value != form.email2.value)) {
        alert( "Por favor, verifica que has escrito tu e-mail de forma id\xe9ntica en ambas ocasiones." );	
		form.email2.focus();
        return false ;
    }		

	if (form.soy.value == "")  {
        alert( "Por favor, selecciona tu especialidad." );
        form.soy.focus();
        return false ;
    }
	if ((form.soy.value == "Otro") && (form.soyotro.value == ""))  {
        alert( "Por favor, especifiquela." );
        form.soyotro.focus();
        return false ;
    }

	if (form.practica.value == "")  {
        alert( "Por favor, selecciona tu pr\xe1ctica dental." );
        form.practica.focus();
        return false ;
    }
	if ((form.practica.value == "Otro") && (form.practicaotro.value == ""))  {
        alert( "Por favor, especifiquela." );
        form.practicaotro.focus();
        return false ;
    }
	if (form.area.value == "")  {
        alert( "Por favor, selecciona tu \xe1rea principal de trabajo." );
        form.area.focus();
        return false ;
    }
	if ((form.area.value == "Otro") && (form.areaotro.value == ""))  {
        alert( "Por favor, especifiquela." );
        form.areaotro.focus();
        return false ;
    }						
	if (!form.quesi.checked) {
		alert( "Por favor, marca la casilla solicitada para dar tu aceptaci\xf3n y consentimiento." );
		form.quesi.focus();
		return false ;
	}		
		
	return true ;
}


function chequeaCarta (form){
	
	if (form.comentario.value == "")  {
        alert( "Por favor, escribe tu carta." );
        form.comentario.focus();
        return false ;
    }
	if (form.nombre.value == "") {
        alert( "Por favor, escribe tu nombre." );
        form.nombre.focus();
        return false ;
    }
	if (form.apellidos.value == "") {
        alert( "Por favor, escribe tu primer apellido." );
        form.apellidos.focus();
        return false ;
    }	
	var x = form.email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(x)){
        alert( "Por favor, escribe tu direcci\xf3n de correo electr\xf3nico correctamente." );
        form.email.focus();
        return false ;
    }
	
	if (form.especialidad.value == "")  {
        alert( "Por favor, escribe tu especialidad." );
        form.especialidad.focus();
        return false ;
    }
	
	if (form.provincia.value == "0") {
        alert( "Por favor, selecciona tu provincia." );
        form.provincia.focus();
        return false ;
    }		
	return true ;
}
