function GoToUrl(url)
{
	window.location = url;
}

function textoUrlSafe(texto)
{
	texto = texto.toLowerCase();
	
    texto = texto.replace(/ /gi,'-');
    texto = texto.replace(/\u00e1/gi,'a');
    texto = texto.replace(/\u00e9/gi,'e');
    texto = texto.replace(/\u00ed/gi,'i');
    texto = texto.replace(/\u00f3/gi,'o');
    texto = texto.replace(/\u00fa/gi,'u');
    texto = texto.replace(/\u00f1/gi,'n');
	return texto;
}

function buscadorTexto(lang, texto)
{
	if (texto)
	{
		texto = textoUrlSafe(texto);
		window.location.href = lang + '/buscarjugador/texto/'+texto;
	}
	return false;
}

function showOficinaFoto(ofno)
{
	document.getElementById('oficinaimagengrande').src = '/images/oficinas/'+ofno+'_grande.jpg';
	document.getElementById('textooficina').innerHTML = document.getElementById(ofno).value;
}

function setImageUrl(obj, url)
{
	obj.src = url;
}

function setBuscadorResultado(texto)
{
	document.getElementById('textfield').value = texto;
}

function popupVideoJugador(id)
{
	window.open ("/getrecurso.php?id="+id,"mywindow","status=0,toolbar=0,width=520,height=450"); 
}

function oficinasExpandir()
{
	document.getElementById('oficinas-ar-colapsado').style.display='none';
	document.getElementById('oficinas-ar-expandido').style.display='';	
	document.getElementById('mapa-ar-colapsado').style.display='none';
	document.getElementById('mapa-ar-expandido').style.display='';	
}

function oficinasColapsar()
{
	document.getElementById('oficinas-ar-expandido').style.display='none';
	document.getElementById('oficinas-ar-colapsado').style.display='';	
	document.getElementById('mapa-ar-expandido').style.display='none';
	document.getElementById('mapa-ar-colapsado').style.display='';	
}

function reloadCaptcha()
{
	document.getElementById('captcha').src='/captcha_image.php?' + (new Date()).getTime();
}

function cambiarBuscadorJuvenil(valor)
{
	document.getElementById('buscadorjugador_juveniles').style.display = 'none';
	document.getElementById('buscadorjugador_profesionales').style.display = 'none';
	document.getElementById('buscadorjugador_todos').style.display = 'none';
	
	if (!valor || valor == '')
	{
		document.getElementById('buscadorjugador_todos').style.display = '';
	}
	if (valor == '/juvenil')
	{
		document.getElementById('buscadorjugador_juveniles').style.display = '';
	}
	if (valor == '/profesional')
	{
		document.getElementById('buscadorjugador_profesionales').style.display = '';
	}
}

function confirmation(idlang, stringname, callbackyes, callbackno)
{
	$.colorbox({
		href: '/confirmationbox.php?lang='+idlang+'&string='+stringname, 
		onClosed: function(){
			if (typeof callbackno == "function") callbackno();
		}, 
		onComplete: function(){
			$('.confirmationno, .confirmationyes').unbind('click');
			$('.confirmationno').click(function(){
				$.colorbox.close();
				if (typeof callbackno == "function") callbackno();
			});
			$('.confirmationyes').click(function(){
				$.colorbox.close();
				if (typeof callbackyes == "function") callbackyes();
			});
		} });
}
