// JavaScript Document
var _error="";

function $(id){return document.getElementById(id)}

function cambiarFotoGal(id,foto)
{
	var dest=document.getElementById(id);
	dest.src=foto;
}

function enviarNews(mail, condiciones, lang)
{
    currentLang = lang;
    if(condiciones)
    {
        
	    if (isMail(mail))
	    {
	    	document.form1.submit();
	    }
	    else
	    {
		    switch(currentLang)
		    {
		        case "lang1":
		            alert('Mail no valido.');
		            break;
		        case "lang2":
		            alert('Mail not valid.');
		            break;
		        case "lang3":
		            alert('Mail not valid.');
		            break;
		    }
	    }
	}
	else
	{
    	switch(currentLang)
		    {
		        case "lang1":
				    alert("Debe aceptar las condiciones de privacidad.");
				    break;
			    case "lang2":
				    alert("You must accept the privacy policy.");
				    break;
			    case "lang3":
				    alert("Sie müssen unsere Datenschutzklauseln akzeptieren.");
				    break;
		    }

	}
}

function enviarContacto(idioma)
{
	currentLang=idioma;
	
	_error="";
	if (!isEmpty('nombre') && !isEmpty('telefono') && isMail(document.getElementById('email').value))
	{
		document.form1.submit();
	}
	else
	{
		alert(_error);
	}
}

var currentLang="lang1";
function enviarCV(idioma)
{
	currentLang = idioma;
	_error="";
	if (!isEmpty('nombre') && !isEmpty('telefono') && isMail(document.getElementById('email').value) && !isEmpty('nacionalidad') && !isEmpty('curriculo') && isChecked('cbCondiciones'))
	{
		document.form1.submit();
	}
	else
	{
		alert(_error);
	}
}

function enviarProfesional(condiciones, lang)
{
    currentLang = lang;
    if(!condiciones) 
	{
	    switch(currentLang)
		{
			case "lang1":
				alert("Debe aceptar las condiciones de privacidad.");
				break;
			case "lang2":
				alert("You must accept the privacy policy.");
				break;
			case "lang3":
				alert("Sie müssen unsere Datenschutzklauseln akzeptieren.");
				break;
		}
	    return false;
	}	
}

function isChecked(_field)
{
	if(	document.getElementById(_field).checked == true)
	{
		return true;
	}
	else
	{
		switch(currentLang)
		{
			case "lang1":
				_error+="Debe aceptar las condiciones de privacidad.\n";
				break;
			case "lang2":
				_error+="You must accept the privacy policy.\n";
				break;
			case "lang3":
				_error+="Sie müssen unsere Datenschutzklauseln akzeptieren.\n";
				break;
		}
		return false;
	}
}

function actualizarArchivos()
{
	var oHotel=document.getElementById('cbo_pro_hotel').value;
	var oCategoria=document.getElementById('cbo_pro_categoria').value;
	//alert('hotel:'+oHotel+' Cat: '+oCategoria)
	var oURI="profesionales_ficheros.asp?id_hotel="+oHotel+"&id_categoria="+oCategoria;
	ajaxManager('load_page',oURI,'pro_cont');
	
}

function seleccionaEmpleo(valor)
{
	if (document.all)
	{
		// si es para el puto Explorer... grrrr
		window.frames['ifr_empleo'].document.getElementById('titulo').value=valor;
	}
	else
	{
		// para el amigo Mozilla Firefox!! :D
		document.getElementById('ifr_empleo').contentDocument.getElementById('titulo').value=valor;
	}
}

function popupAcepto(lang)
{
    window.open("condiciones.aspx?lang=" + lang,"ventana1","width=400, height=300, scrollbars=yes, menubar=no, location=no, resizable=no")    
}

function verPopup(url, lang)
{
    window.open(url + "?lang=" + lang,"ventana1","width=400, height=300, scrollbars=yes, menubar=no, location=no, resizable=no")
    return false;
} 

function validarRegistro(source, args)
{
	var losInputs = document.getElementsByTagName('INPUT');
	var esValido = true;
	for (i=0;i<losInputs.length;i++)
	{
	    if(losInputs[i].type == "checkbox")
	    {
	        esValido = losInputs[i].checked && esValido;
	    }
	}
	args.IsValid = esValido;
}

function SetUniqueRadioButton(nameregex, current)
{
   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
      elm = document.forms[0].elements[i]
      if (elm.type == 'radio')
      {
         if (re.test(elm.name))
         {
            elm.checked = false;
         }
      }
   }
   current.checked = true;
}