function getUrlParameter(name)
{
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp(regexS);
	var results = regex.exec(window.location.href);
	if (results == null)
		return "";
	else
		return results[1];
}


function compruebaemail(doc) 
{
	error=0;

	if(!emailCheck (doc.frmRecordar.email.value)){	
		alert("el e-mail es incorrecto");
		doc.getElementById("email").focus();
		error=1;
	}
	
	if(error==0){
		doc.frmRecordar.submit();
	}
}

function compruebacampos(doc) 
{
	error=0;
	if(doc.frmRegistro.cmbTratamiento.value==0)
	{
		alert("el tratamiento ha de estar seleccionado");
		doc.getElementById("cmbTratamiento").focus();
		error=1;
	}

	else if(doc.frmRegistro.cmbProfesion.value==0)
	{
		alert("la profesión ha de estar seleccionada");
		doc.getElementById("cmbProfesion").focus();
		error=1;
	}

	else if(doc.frmRegistro.cmbEdad.value==0)
	{
		alert("la edad ha de estar seleccionada");
		doc.getElementById("cmbEdad").focus();
		error=1;
	}

	else if(doc.frmRegistro.cmbPaises.value==0)
	{
		alert("el país ha de estar seleccionado");
		doc.getElementById("cmbPaises").focus();
		error=1;
	}

	else if(doc.frmRegistro.cmbProvincias.value==0)
	{
		alert("la provincia ha de estar seleccionada");
		doc.getElementById("cmbProvincias").focus();
		error=1;
	}

	else if(doc.frmRegistro.nombre.value=="")
	{
		alert("el nombre ha de estar informado");
		doc.getElementById("nombre").focus();
		error=1;
	}

	else if(doc.frmRegistro.apellido1.value=="")
	{
		alert("el Primer apellido ha de estar informado");
		doc.getElementById("apellido1").focus();
		error=1;
	}
	else if(doc.frmRegistro.apellido2.value=="")
	{
		alert("el Segundo apellido ha de estar informado");
		doc.getElementById("apellido2").focus();
		error=1;
	}
	else if(!emailCheck (doc.frmRegistro.email.value)){	
		alert("el e-mail es incorrecto");
		doc.getElementById("email").focus();
		error=1;
	}
	else if(doc.frmRegistro.password.value=="")
	{
		alert("el password ha de estar informado");
		doc.getElementById("password").focus();
		error=1;
	}
	else if(doc.frmRegistro.password2.value=="")
	{
		alert("confirme su password ha de estar informado");
		doc.getElementById("password2").focus();
		error=1;
	}
	else  if (doc.frmRegistro.password.value!=doc.frmRegistro.password2.value)
    {
		alert("Los dos campos password deben ser iguales");
		doc.frmRegistro.password.value="";
		doc.frmRegistro.password2.value="";
		doc.getElementById("password1").focus();
		error=1;
    }
	
	
	if(error==0){
		doc.frmRegistro.submit();
	}
}

function emailCheck (emailStr) 
{
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	
	if (user.match(userPat)==null) {
	    return false
	}
	
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
		    if (IPArray[i]>255) {
			return false
		    }
	    }
	    return true
	}
	
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {

	    return false
	}
	
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
	    domArr[domArr.length-1].length>3) {

	   return false
	}
	
	if (len<2) {
	   var errStr="This address is missing a hostname!"
	   return false
	}
	
	return true;
}


