var vventana='';
var ventana="";
var ventana_conexion='';
var nvecesboton=0;
var nvecesbotonatacar=0;
var nvecesbotonreorg=0;
var nvecesbotondados=0;
var ns4 = (document.layers)? true:false;
var ie4 = (document.all)? true:false;

var MAXCONTADORES=20;
var globalnelementos=0;
globalnombreelemento = new ca(MAXCONTADORES);
globaltiempototalsegundos = new ca(MAXCONTADORES);
var globaltextodias;
var globaltextodia;
var globaltextohoras;
var globaltextominutos;
var globaltextosegundos;

var contador_itinerario=0;
var n_tropas_itinerario=0;
itinerario_paises = new ca(MAXCONTADORES);

var MAXTITULOS=20;
var MAXSUBTITULOS=20;

var bicontador=0;
var cambia=0;


atit = new ca(MAXTITULOS);
oc_atit = new ca(MAXTITULOS);
obj_subtit = new ca(MAXTITULOS);
oc_obj_subtit = new ca(MAXTITULOS);
for(var z=0;z<atit.length;z++){
	obj_subtit[z]=new ca(MAXSUBTITULOS);
	oc_obj_subtit[z]=new ca(MAXSUBTITULOS);
	}


document.onkeydown = pulsarTecla;
if (ns4) document.captureEvents(Event.KEYDOWN);
var indicemenuseleccionado=-1;
var indiceopcionmenuseleccionado=-1;
var indicefilalistapartida=-1;



function init_menu(v_MAXTITULOS,v_MAXSUBTITULOS){
	var i,j;
	for(i=0;i<v_MAXTITULOS;i++){
		atit[i] = 'f';
		try{ oc_atit[i]=document.getElementById("octit"+i).style; } catch(e){}
		for(j=0;j<v_MAXSUBTITULOS;j++){
			try{
				obj_subtit[i][j]=document.getElementById("sbt"+i+j).style;
				oc_obj_subtit[i][j]=document.getElementById("ocsbt"+i+j).style;
				} catch(e) {}
			}
		}
	if(ns4){
	   for(i=0;i<v_MAXTITULOS;i++){
		atit[i] = 'f';
		try{ oc_atit[i]=document.getElementById("octit"+i); } catch(e){}
		for(j=0;j<v_MAXSUBTITULOS;j++){
			try{
				obj_subtit[i][j]=document.getElementById("sbt"+i+j);
				oc_obj_subtit[i][j]=document.getElementById("ocsbt"+i+j);
				} catch(e) {}
			}
		    }		
		}
	}
	
	
function mee(idelemento,mostrar_esconder){
	try{
		if(mostrar_esconder==0){
			document.getElementById(idelemento).style.visibility='hidden';
			}
		if(mostrar_esconder==1){
			document.getElementById(idelemento).style.visibility='visible';
			}
		} catch(e){}
	if(ns4){
		try{
			if(mostrar_esconder==0){
				document.getElementById(idelemento).visibility='hide';
				}
			if(mostrar_esconder==1){
				document.getElementById(idelemento).visibility='show';
				}
			} catch(e){}
		}
	
	
}
	
function click_capa(nombrecapas,numerocapa,n_capas){
	var i;
	try{
		for(i=0;i<n_capas;i++){
			document.getElementById(nombrecapas+i).style.visibility='hidden';
			}
		document.getElementById(nombrecapas+numerocapa).style.visibility='visible';
		} catch(e){}
	if(ns4){
		try{
			for(i=0;i<n_capas;i++){
				document.getElementById(nombrecapas+i).visibility='hide';
				}
			document.getElementById(nombrecapas+numerocapa).visibility='show';
			} catch(e){}
		}
	}




function selectorCapa(nombrecapas,n_capas,seleccionador){
	var capaseleccionada;
	capaseleccionada=document.getElementById(seleccionador).value;
	borrarCapasSeleccionMapa();
	try{
		document.getElementById(nombrecapas+capaseleccionada).style.visibility='visible';
		if(ns4){
			document.getElementById(nombrecapas+capaseleccionada).visibility='show';		
			}
		}catch(e){}
	}

function init_sombra_menu(v_MAXTITULOS,v_MAXSUBTITULOS,v_ac,v_lc,v_acs,v_lcs,v_x,v_y,v_sh,v_ind){		
	var inicio_atras_y=v_y+5;
	var inicio_atras_x=v_x+5;
	var aux1,aux2;
	document.open();	
	for(i=0;i<v_MAXTITULOS;i++){
		aux1=inicio_atras_x+i*(v_lc+v_sh);
		document.write("<div id='octit"+i+"' class='octit1' style='top:"+inicio_atras_y+"; left:"+aux1+";'></div>");
		for(j=0;j<v_MAXSUBTITULOS;j++){
			aux1=inicio_atras_y+v_ac+v_acs*j;
			aux2=inicio_atras_x+v_ind+i*(v_lc+v_sh);
			document.write("<div id='ocsbt"+i+j+"' class='ocsubt1' style='top:"+aux1+"; left:"+aux2+";'></div>");
			}
		}
	document.close();
	}






function DibDatPart(titulo_tabla,color_titulo,clase_tabla,clase_tr,columna1,columna2,separador){
	document.open();
	document.write("<table border=0 class="+clase_tabla+">");
	document.write("<caption align=top><font color="+color_titulo+"><b>"+titulo_tabla+"</b></font></caption>");

	var subtexto1;
	var subtexto2;
	var posicion1=0;
	while(posicion1>-1){
		posicion1=columna1.indexOf(separador);
		posicion2=columna2.indexOf(separador);
		if(posicion1>-1){
			subtexto1=columna1.substring(0,posicion1);
			subtexto2=columna2.substring(0,posicion2);
			columna1=columna1.substring(posicion1+separador.length);
			columna2=columna2.substring(posicion2+separador.length);
			document.write("<tr class="+clase_tr+"><td><b>"+subtexto1+"</b></td><td>"+subtexto2+"</td></tr>");
			}
		}
	document.write("</table>");
	document.close();
	}



function actualizar_tropas_colocacion(indicador,maxtropas,maxids,totaltropas){
	var tropas_actuales=parseInt(document.listacolocacionpaises.tropas_pendientes.value);
	var tropas_colocadas=parseInt(document.getElementById('trtr_'+indicador).value);
	if((isNaN(tropas_colocadas))||(tropas_colocadas>maxtropas)){
		document.getElementById('trtr_'+indicador).value='';
		}
	
	var total_tropas_final=0;
	var tropa_individual=0;
	for(var i=0;i<maxids;i++){
		tropa_individual=parseInt(document.getElementById('trtr_'+i).value);
		if(!(isNaN(tropa_individual))){
			total_tropas_final+=tropa_individual;
			}
		else{
			document.getElementById('trtr_'+i).value='';
			}
		}
	if(totaltropas-total_tropas_final<0){
		document.getElementById('trtr_'+indicador).value='';
		}
	else{
		document.listacolocacionpaises.tropas_pendientes.value=totaltropas-total_tropas_final;
		}
	}


function iratorneo(torneoid,niveltorneoid){
	var urldestinotorneo="r_detalle_torneo.php?Torneo="+torneoid+"&Nivel="+niveltorneoid;
	top.location.href=urldestinotorneo;
	}

function DTBC(tipo,servidor,contenido,colorfondo,ariz,ar,arde,iz,de,abiz,ab,abde){
	document.open();
	if(tipo!="DOWN"){
		document.write("<table border=0 cellpadding=0 cellspacing=0>");
		document.write("<tr><td><img src='"+servidor+ariz+"' border=0></td><td background='"+servidor+ar+"'></td><td><img src='"+servidor+arde+"' border=0></td></tr>");
		document.write("<tr><td background='"+servidor+iz+"'></td><td bgcolor='"+colorfondo+"'>");
		}
	if((tipo!="UP")&&(tipo!="DOWN")){
		document.write(contenido);
		}
	if(tipo!="UP"){
		document.write("</td><td background='"+servidor+de+"'></td></tr>");
		document.write("<tr><td><img src='"+servidor+abiz+"' border=0></td><td background='"+servidor+ab+"'></td><td><img src='"+servidor+abde+"' border=0></td></tr>");
		document.write("</table>");
		}
	document.close();
	}

function mostrar_tiempo_cambiante(nombreelemento,tiempototalsegundos,textodias,textodia,textohoras,textominutos,textosegundos,textodeltacambio){
	globalnombreelemento[globalnelementos]=nombreelemento;
	globaltiempototalsegundos[globalnelementos]=tiempototalsegundos;
	globaltextodias=textodias;
	globaltextodia=textodia;
	globaltextohoras=textohoras;
	globaltextominutos=textominutos;
	globaltextosegundos=textosegundos;
	var deltacambio=parseInt(textodeltacambio);
	globaltiempototalsegundos[globalnelementos]++;
	mostrar_tiempo_que_cambia(globalnelementos,deltacambio);
	globalnelementos++;
	}


function add_info_otros_campos_privilegios(){
	var valor=document.form_comprar_privilegios.PRIVILEGIO.value;
	var v_coste='';
	var v_dias='';
	var v_desc='';
	if(valor!=''){
		v_coste=document.getElementById('coste_'+valor).value;
		v_dias=document.getElementById('dias_'+valor).value;
		v_desc=document.getElementById('desc_'+valor).value;
		}
	document.form_comprar_privilegios.v_coste.value=v_coste;
	document.form_comprar_privilegios.v_dias.value=v_dias;
	document.form_comprar_privilegios.v_desc.value=v_desc;
	
	}


function mostrar_tiempo_que_cambia(i,deltacambio){
	var texto=obtener_tiempo_cambiante(globaltiempototalsegundos[i],globaltextodias,globaltextodia,globaltextohoras,globaltextominutos,globaltextosegundos);
	document.getElementById(globalnombreelemento[i]).value=texto;
	globaltiempototalsegundos[i]+=deltacambio;
	setTimeout('mostrar_tiempo_que_cambia('+i+','+deltacambio+')',1000);
	}

function obtener_tiempo_cambiante(tiempototalsegundos,textodias,textodia,textohoras,textominutos,textosegundos){
	var segundos=parseInt(tiempototalsegundos%60);
	var totalminutos=parseInt((tiempototalsegundos-segundos)/60);
	var minutos=parseInt(totalminutos%60);
	var totalhoras=parseInt((totalminutos-minutos)/60);
	var horas=parseInt(totalhoras%24);
	var totaldias=parseInt((totalhoras-horas)/24);
	var tiempo1="";
	var tiempo0="";
	var resultado="";
	if(segundos!=0){
		tiempo1=" "+segundos+" "+textosegundos;
		}
	if(minutos!=0){
		tiempo1=minutos+" "+textominutos+" "+tiempo1;
		}
	if(horas!=0){
		tiempo1=horas+" "+textohoras+" "+tiempo1;
		}
	if(totaldias==1){
		tiempo0=totaldias+" "+textodia;
		}
	if(totaldias>1){
		tiempo0=totaldias+" "+textodias;
		}
	if(totaldias!=0){
		resultado=tiempo0+" "+tiempo1;
		}
	else{
		resultado=tiempo1;
		}
	return resultado;	
	}


function seleccionar_seleccion(indice,total,color_back){
	for(i=0;i<total;i++){
		document.getElementById("selec_"+i).style.background="";
		if(i==indice){
			document.getElementById("selec_"+i).style.background=color_back;
			}
		}
	}


function colorear(src,color,mouse){
	try{
		src.bgColor=color;
		} catch(e) {}
	src.style.cursor=mouse;
	}
function click_en_imagen_mapa(nombre,destino){
	if(destino=='SELECCION_MAPA_PARTIDA'){
		try{
			document.form_crear_partida.JUEGO.value=nombre;
			} catch(e){}
		}
	}
function pulsar_boton(){
	nvecesboton++;
	if(nvecesboton>1){
		return false;
		}
	else{
		return true;
		}
	}
	
function pulsar_boton_confirmacion(confirmar_flg,mensaje){
	var respuesta;
	nvecesboton++;
	if(nvecesboton>1){
		respuesta = false;
		}
	else{
		respuesta = true;
		}
	if((confirmar_flg==1)&&(respuesta == true)){
		respuesta = confirm(mensaje);
		if(respuesta==false){
			nvecesboton--;
			}
		}
	return respuesta;
	}
	
function abrir_chat_partida(partidaid){
	try{
		parent.document.getElementsByTagName('frameset')[0].rows='70%,30%,0%';
		parent.r_frame_chat.location.href="r_control_chat_frames.php?Partida=" + partidaid;
		} catch(e){};
	}
function busqueda_seleccion(textoerror){
	var respuesta = true;
	var texto = document.formseleccion.valor.value;
	if((texto=="")||(texto==null)){
		respuesta = false;
		alert(textoerror);
		}
	return respuesta;
	}
function evaluar_rendicion(texto){
	var respuesta = confirm(texto);
	return respuesta;
	}

function pulsar_boton_reorganizar(confirmar_flg,mensaje){
	var respuesta;
	nvecesbotonreorg++;
	if(nvecesbotonreorg>1){
		respuesta = false;
		}
	else{
		respuesta = true;
		}
	if((confirmar_flg==1)&&(respuesta == true)){
		respuesta = confirm(mensaje);
		if(respuesta==false){
			nvecesbotonreorg--;
			}
		}
	return respuesta;
	}
function pulsar_boton_pasar_dados(confirmar_flg,mensaje){
	var respuesta;
	nvecesbotondados++;
	if(nvecesbotondados>1){
		respuesta = false;
		}
	else{
		respuesta = true;
		}
	if((confirmar_flg==1)&&(respuesta == true)){
		respuesta = confirm(mensaje);
		if(respuesta==false){
			nvecesbotondados--;
			}
		}
	return respuesta;
	}





function verificar_servidor_apoyo(valor){
	return valor;
	}


function CojerValorCookie(indice) {
	var galleta = document.cookie;
	var finDeCadena = galleta.indexOf(";", indice);
	if (finDeCadena == -1){
		finDeCadena = galleta.length;
		}
	return unescape(galleta.substring(indice, finDeCadena));
	}

function CojerCookie(nombre) {
	var galleta = document.cookie;
	var arg = nombre + "=";
	var alen = arg.length;
	var glen = galleta.length;

	var i = 0
	while (i < glen) {
		var j = i + alen;
		if (galleta.substring(i, j) == arg){
			return CojerValorCookie(j);
			}
		i = galleta.indexOf(" ", i) + 1;
		if (i == 0){
			break;
			}
		}
	return null;
	}

function GuardarCookie (nombre, valor) {
	document.cookie = nombre + "=" + escape(valor) + "; path=/"
	}

function test_cookies(mensaje_ko) {
	if (CojerCookie("CR_cookie_test") != "CRCR") {
		alert(mensaje_ko);
		}
	}

function evaluar_modificacion_password(formulario,textopassword){
	var resultado=true;
	if((formulario.PASS1.value!="")&&(formulario.PASS2.value!="")){
		if(formulario.PASS1.value.length<6){
			alert(textopassword);
			resultado=false;
			}
		}
	return resultado;
	}

function evaluar_creacion_usuario(formulario,textologin,textopassword){
	var resultado = true;
	if(formulario.PASSWORD1.value.length<6){
		alert(textopassword);
		resultado = false;
		}
	if((resultado==true)&&(formulario.LOGIN.value.length<6)){
		alert(textologin);
		resultado = false;
		}
	return resultado;
	}

function seleccionar_itinerario(paisid,textopais){
	var rutaactual;
	try{
		if(document.programar_itinerario.paisorigen.value==""){
			document.programar_itinerario.paisorigen.value=textopais;
			}
		else{
			document.programar_itinerario.paisdestino.value=textopais;
			}
		rutaactual = document.programar_itinerario.ruta.value;
		if(rutaactual==""){
			rutaactual = paisid;
			}
		else{
			rutaactual = rutaactual + "," + paisid;
			}
		document.programar_itinerario.ruta.value=rutaactual;
		} catch(e){}
	}	
	
	
function enfocar_generico(valor){
	try{
		if(valor==1){
			document.form_login.Password.focus();
			}
		else{
			document.form_login.Login.focus();
			}
		} catch(e){}
	try{
		document.formseleccion.valor.focus();
		} catch(e){}
	try{
		document.form_crear_partida.NOMBRE.focus();
		} catch(e){}
	try{
		document.formubicar.N_TROPAS.focus();
		} catch(e){}
	try{
		document.formubicaruno.N_TROPAS.focus();
		} catch(e){}
	try{
		document.formatacar.numero_ataques.focus();
		} catch(e){}
	try{
		document.formmovertropasataque.N_TROPAS.focus();
		} catch(e){}
	try{
		document.formreorganizar.N_TROPAS.focus();
		} catch(e){}	

	}
function enfocar_login(){
	document.form_login.Login.focus();
	}
function enfocar_login_chat(){
	document.formulario_envio.texto.focus();
	}
function open_window_low(url,wdth,hght){
	open_window(url,wdth,hght,1);
	}
function open_window(url,wdth,hght,scrll){
	var scrolling='no';
	var fin='NO';
	if(scrll==1){
		scrolling='yes';
		}
	while(fin=='NO'){
		if(ventana==''){
			ventana = open(url, 'displayWindow', 'width=' + wdth + ',height=' + hght +',status=no,toolbar=no,menubar=no,scrollbars=' + scrolling);
			fin='SI';
			}
		else{
			ventana.close();
			ventana='';
			}
		}
	}
function open_window_conexion(url,wdth,hght,scrll){
	var scrolling='no';
	var fin='NO';
	if(scrll==1){
		scrolling='yes';
		}
	while(fin=='NO'){
		if(ventana_conexion==''){
			ventana_conexion = open(url, 'displayWindow', 'width=' + wdth + ',height=' + hght +',status=no,toolbar=no,menubar=no,scrollbars=' + scrolling);
			fin='SI';
			}
		else{
			ventana_conexion.close();
			ventana_conexion='';
			}
		}
	}
function open_window_complejo(url,wdth,hght,scrll,nombre,men){
	var scrolling="no";
	var fin="NO";
	var menu="no";
	if(men==1){
		menu="yes";
		}
	if(scrll==1){
		scrolling="yes";
		}
	if(nombre==""){
		nombre="displayWindow";
		}
	while(fin=="NO"){
		if(ventana==""){
			ventana = open(url, nombre, "width=" + wdth + ",height=" + hght +",status="+menu+",toolbar=no,menubar=" + menu + ",scrollbars=" + scrolling);
			fin="SI";
			}
		else{
			ventana.close();
			ventana="";
			}
		}
	}
function actualizar_numero_max_jugadores(){
	var equip = document.form_crear_partida.EQUIPOS.value;
	var maxjugad = document.form_crear_partida.MAX_JUGADORES.value;
	var nuevomaxjugad = maxjugad;
	if((equip==2)&&(maxjugad==3)){
		nuevomaxjugad=4;
		}
	if((equip==2)&&(maxjugad==5)){
		nuevomaxjugad=6;
		}
	if(equip==3){
		nuevomaxjugad=6;
		}
	if(nuevomaxjugad!=maxjugad){
		document.form_crear_partida.MAX_JUGADORES.value=nuevomaxjugad;
		}
	}
function ca(l){
	this.length = l;
	for(var i=0;i<l;i++){
		this[i]='';
		}
	return this;
	}
function den(i,obj,col,var_color){
	document.body.style.cursor="pointer";
	obj.style.background=col;
	if(var_color!=""){
		obj.style.color=var_color;
		}
	atit[i]='d';
	act(i);
	}
function fue(i,obj,col,var_color){
	document.body.style.cursor="default";
	obj.style.background=col;
	if(var_color!=""){
		obj.style.color=var_color;
		}
	atit[i]='f';
	act(i);
	}

function esconder_selects(antiseve){
	if(ie4){
		try{
			document.form_crear_partida.TIPO.style.visibility=antiseve;
			document.form_crear_partida.REGLAS.style.visibility=antiseve;
			document.form_crear_partida.ORDEN_TURNO.style.visibility=antiseve;
			document.form_crear_partida.MODO.style.visibility=antiseve;
			document.form_crear_partida.MOSTRAR_OBJETIVO.style.visibility=antiseve;
			document.form_crear_partida.EQUIPOS.style.visibility=antiseve;
			document.form_crear_partida.MAX_JUGADORES.style.visibility=antiseve;
			document.form_crear_partida.N_COBRA_CARTA.style.visibility=antiseve;
			document.form_crear_partida.TIPO_INCOGNITA.style.visibility=antiseve;
			document.form_crear_partida.PACTOS.style.visibility=antiseve;
			document.form_crear_partida.LIMITE_TROPAS_PAIS.style.visibility=antiseve;
			document.form_crear_partida.N_TURNOS_CAPITAL.style.visibility=antiseve;
			document.form_crear_partida.Castigo.style.visibility=antiseve;
			document.form_crear_partida.EXPERIENCIA_MIN.style.visibility=antiseve;
			document.form_crear_partida.EXPERIENCIA_MAX.style.visibility=antiseve;
			document.form_crear_partida.INDICE_ACCESOS_DIA_MIN.style.visibility=antiseve;
			document.form_crear_partida.JUEGO.style.visibility=antiseve;
			}catch(e){}
		try{
			document.OPCIONES_USUARIO.DIAS_MAX_CONGELAR_AUTOM.style.visibility=antiseve;
			document.OPCIONES_USUARIO.N_REG_LIST.style.visibility=antiseve;
			document.OPCIONES_USUARIO.ZONAS_HORARIAS.style.visibility=antiseve;
			}catch(e){}
		try{
			document.temporadaclan.temporadaid.style.visibility=antiseve;
			}catch(e){}
		try{
			document.selectestavanzadas.columna.style.visibility=antiseve;
			}catch(e){}
		try{
			document.FormInsertarFAQ.Idioma.style.visibility=antiseve;
			}catch(e){}
		try{
			document.formactudatosusu.PAIS.style.visibility=antiseve;
			document.formactudatosusu.ANYO_NACIMIENTO.style.visibility=antiseve;
			document.formactudatosusu.EJERCITO_PREFERIDO_ID.style.visibility=antiseve;
			}catch(e){}
		try{
	 		document.MOSTRAR.VIEW.style.visibility=antiseve;
	 		}catch(e){}
	 	try{
	 		document.MOSTRAR.ORDENACION.style.visibility=antiseve;
	 		}catch(e){}
	 	try{
	 		document.MOSTRAR.SENTIDO.style.visibility=antiseve;
	 		}catch(e){}
		try{
	 		document.MOSTRARTORNEOS.VIEW.style.visibility=antiseve;
	 		}catch(e){}
	 	try{
	 		document.MOSTRARTORNEOS.ORDENACION.style.visibility=antiseve;
	 		}catch(e){}
	 	try{
	 		document.MOSTRARTORNEOS.SENTIDO.style.visibility=antiseve;
	 		}catch(e){}
	 	try{
			document.FORMPERFIL.ELIDIOMA.style.visibility=antiseve;
	 		}catch(e){}
	 	try{
			document.ESTADISTICA_VER.estad.style.visibility=antiseve;
	 		}catch(e){}
	 	try{
			document.TIPO_ESTADISTICA.tipo.style.visibility=antiseve;
	 		}catch(e){}
		try{
			document.DarCreditosForm.TIPO_CREDITOS.style.visibility=antiseve;
			}catch(e){}
	 	try{
			document.FormBusqueda.QUERY_JUEGO.style.visibility=antiseve;
			document.FormBusqueda.QUERY_JUGADORES.style.visibility=antiseve;
			document.FormBusqueda.QUERY_DISTRIBUCION_JUGADORES.style.visibility=antiseve;
			document.FormBusqueda.QUERY_REGLAS.style.visibility=antiseve;
			document.FormBusqueda.QUERY_INCOGNITA.style.visibility=antiseve;
			document.FormBusqueda.QUERY_RIVALES_INCOGNITA.style.visibility=antiseve;
			document.FormBusqueda.QUERY_CONGELACION.style.visibility=antiseve;
			document.FormBusqueda.QUERY_ESTADO.style.visibility=antiseve;
	 		}catch(e){}
	 	try{
			document.FormBusquedaForo.QUERY_BUSCO.style.visibility=antiseve;
			document.FormBusquedaForo.QUERY_CREADO_DESPUES_DE_DIA.style.visibility=antiseve;
			document.FormBusquedaForo.QUERY_CREADO_DESPUES_DE_MES.style.visibility=antiseve;
			document.FormBusquedaForo.QUERY_CREADO_DESPUES_DE_ANYO.style.visibility=antiseve;
			document.FormBusquedaForo.QUERY_CREADO_ANTES_DE_DIA.style.visibility=antiseve;
			document.FormBusquedaForo.QUERY_CREADO_ANTES_DE_MES.style.visibility=antiseve;
			document.FormBusquedaForo.QUERY_CREADO_ANTES_DE_ANYO.style.visibility=antiseve;
	 		}catch(e){}
	 	try{
			document.FormBusqueda.QUERY_ESTADO.style.visibility=antiseve;
			document.FormBusqueda.QUERY_TIPO_PARTICIPANTES.style.visibility=antiseve;
			document.FormBusqueda.QUERY_TIPO_PREMIO.style.visibility=antiseve;
			document.FormBusqueda.QUERY_TIPO_CATEGORIA.style.visibility=antiseve;
	 		}catch(e){}
		}
	}
function act(i){
	var visi='visible';
	var vino='hidden';
	if(ns4){
		visi='show';
		vino='hide';
		}
	var seve='';
	var antiseve='';
	if(atit[i]=='d'){
		seve=visi;
		antiseve=vino;
		}
	if(atit[i]=='f'){
		seve=vino;
		antiseve=visi;
		}
	oc_atit[i].visibility=seve;
	atit[i].visibility=visi;
	for(var j=0;j<obj_subtit[i].length;j++){
		oc_obj_subtit[i][j].visibility=seve;
		obj_subtit[i][j].visibility=seve;
		}
	esconder_selects(antiseve);
	}
function openwindowselect(url,wdth,hght){
	var fin='NO';
	while(fin=='NO'){
		if(vventana==''){
			vventana = open(url, 'selectWindow', 'width=' + wdth + ',height=' + hght +',status=no,toolbar=no,menubar=no,scrollbars=yes');
			fin='SI';
			}
		else{
			vventana.close();
			vventana='';
			}
		}
	}

function cambiar_valor(){
	document.variables.ACCION.value='CAMBIAR';
	document.variables.submit();
	}


function inicializar_banner(){
	var diferencia=document.banner.text.size-msg.length;
	var i;
	if(diferencia>0){
		for(i=0;i<diferencia;i++){
			msg=msg+'  ';
			}
		}
	setTimeout('banner()',100);
	}
function banner(){
	var timestep=100;
	var porcion=msg.substring(0,1);
        msg=msg.substring(1,msg.length)+porcion;
        document.banner.text.value=msg;
        banTime1=setTimeout('banner()',timestep);
	}


function pulsar_boton_atacar(formulario){
	nvecesbotonatacar++;
	if(nvecesbotonatacar>1){
		return false;
		}
	else{
		return true;
		}
	}
function procesar_usuario_lista_confianza(variable,texto,textoobligar){
	var salir=false;
	var respuesta;
	while(!salir){
		respuesta = prompt(texto,"");
		if(respuesta==null){
			salir=true;
			}
		else{
			if(respuesta==""){
				alert(textoobligar);
				}
			else{
				salir=true;
				document.acciones_usuario.MODO.value=variable;
				document.acciones_usuario.DESCRIPCION.value=respuesta;
				document.acciones_usuario.submit();
				}
			}
		}
	
	}



function ver_respuesta_faq(nombreitem,ver){
	var visi='visible';
	var vino='hidden';
	if(ns4){
		visi='show';
		vino='hide';
		}
	
	if(ver==1){
		document.getElementById(nombreitem).style.visibility=visi;
		}
	if(ver==0){
		document.getElementById(nombreitem).style.visibility=vino;
		}
	}


function esconder_selects_int(numero_entero){
	if(numero_entero==0){
		esconder_selects("hidden");
		}
	if(numero_entero==1){
		esconder_selects("visible");
		}
	
	}

function mostrar_menu_raton(){
	
	ventana_menu_raton.style.left=document.body.scrollLeft+event.clientX;
	ventana_menu_raton.style.top=document.body.scrollTop+event.clientY;
	ventana_menu_raton.style.visibility='visible';
	
	esconder_selects("hidden");	
	
	return false;
	}
function ocultar_menu_raton(){
	ventana_menu_raton.style.visibility='hidden';
	esconder_selects("visible");
	}


function enfocar_item_menu_raton(backcolor){
	if (event.srcElement.className=="item_ventana_menu_raton"){
		event.srcElement.style.backgroundColor=backcolor;
		event.srcElement.style.cursor="pointer";
		event.srcElement.style.fontWeight="bold";
		}
	}

function desenfocar_item_menu_raton(backcolor){
	if (event.srcElement.className=="item_ventana_menu_raton"){
		event.srcElement.style.backgroundColor=backcolor;
		event.srcElement.style.cursor="default";
		event.srcElement.style.fontWeight="normal";
		}
	}


function actualizar_formulario_creacion_partida(){
	try{
		var tipo = document.form_crear_partida.TIPO.value;
		if(tipo=="Cerrada"){
			document.form_crear_partida.MAX_JUGADORES.disabled=true;
			document.form_crear_partida.LIMITACION_JUGADORES_PUBLICA.disabled=true;
			}
		if(tipo=="Abierta"){
			document.form_crear_partida.MAX_JUGADORES.disabled=false;
			document.form_crear_partida.LIMITACION_JUGADORES_PUBLICA.disabled=false;
			}
		var modo = document.form_crear_partida.MODO.value;
		if((modo=="CAPITAL_RISK_AN")||(modo=="CAPITAL_RISK_CM")){
			document.form_crear_partida.N_TURNOS_CAPITAL.disabled=false;
			document.form_crear_partida.CAPITAL_ALEATORIA.disabled=false;
			}
		else{
			document.form_crear_partida.N_TURNOS_CAPITAL.disabled=true;
			document.form_crear_partida.CAPITAL_ALEATORIA.disabled=true;
			}
		if((modo=="CONQUISTA_MUNDO")||(modo=="CAPITAL_RISK_CM")){
			document.form_crear_partida.MOSTRAR_OBJETIVO.disabled=true;
			}
		else{
			document.form_crear_partida.MOSTRAR_OBJETIVO.disabled=false;
			}
		var sincartas = document.form_crear_partida.SIN_CARTAS.checked;
		if(sincartas==true){
			document.form_crear_partida.N_COBRA_CARTA.disabled=true;
			}
		else{
			document.form_crear_partida.N_COBRA_CARTA.disabled=false;
			}
		}catch(e){}
	}




function pulsarTecla(e) {
  var i,j;
  var TeclaPulsada;
  var tecladerecha=39;
  var teclaizquierda=37;
  var teclaarriba=38;
  var teclaabajo=40;
  var teclaenter=13;
  if (ns4) {
	var TeclaN=e.which;
	TeclaPulsada=parseInt(TeclaN);
	}
  if (ie4) {
	var TeclaIE=event.keyCode;
	TeclaPulsada=parseInt(TeclaIE);
	}
   
   if((TeclaPulsada==tecladerecha)||(TeclaPulsada==teclaizquierda)){
   	try{
		if(TeclaPulsada==tecladerecha){
			indicemenuseleccionado++;
			}
		if(TeclaPulsada==teclaizquierda){
			indicemenuseleccionado--;
			}
		indiceopcionmenuseleccionado=-1;
		for(i=0;i<99;i++){
			try{
				fue(i,document.getElementById("tit"+i),"#CC0000","");	
				for(j=0;j<99;j++){
					try{
						fue(j,document.getElementById("sbt"+i+""+j),"#FFD5AA","#000000");
						} catch(e3){
							break;
							}
					}
				} catch(e2){
					break;
					}
			}
		den(indicemenuseleccionado,document.getElementById("tit"+indicemenuseleccionado),"#EE0000","");
		return false;
	   	} catch(e){
			indicemenuseleccionado=-1;
   			}
   	}
   if((TeclaPulsada==teclaabajo)||(TeclaPulsada==teclaarriba)){
   	if(indicemenuseleccionado>=0){
   		try{
	   		if(TeclaPulsada==teclaabajo){
   				indiceopcionmenuseleccionado++;
   				}
   			if(TeclaPulsada==teclaarriba){
	   			indiceopcionmenuseleccionado--;
   				}
			for(i=0;i<99;i++){
				try{
					fue(indicemenuseleccionado,document.getElementById("sbt"+indicemenuseleccionado+""+i),"#FFD5AA","#000000");
					} catch(e2){
						break;
						}
				}
			den(indicemenuseleccionado,document.getElementById("sbt"+indicemenuseleccionado+""+indiceopcionmenuseleccionado),"#FFE6CE","#CC0000");
			return false;
   			} catch(e){
	   			indiceopcionmenuseleccionado=0;
   				try{
					den(indicemenuseleccionado,document.getElementById("sbt"+indicemenuseleccionado+""+indiceopcionmenuseleccionado),"#FFE6CE","#CC0000");
					return false;
					} catch(e2){}
   				}
		}
	else{
		try{
			colorear(document.getElementById("f_tr_"+indicefilalistapartida),"#FFFFFF","default");
			} catch(e2){}
		if(TeclaPulsada==teclaabajo){
			indicefilalistapartida++;
			}
		if(TeclaPulsada==teclaarriba){
			indicefilalistapartida--;
			}
		try{
			colorear(document.getElementById("f_tr_"+indicefilalistapartida),"#FFD5AA","pointer");
			return false;
			} catch(e2){
				indicefilalistapartida=-1;
				}
		}
   	}
    if(TeclaPulsada==teclaenter){
    	if((indicemenuseleccionado>=0)&&(indiceopcionmenuseleccionado>=0)){
    		try{
	    		pC(indicemenuseleccionado,indiceopcionmenuseleccionado);
    			return false;
    			} catch(e){}
    		}
    	else{
    		try{
    			pclpa(indicefilalistapartida);
    			return false;    		
    			} catch(e){}
    		}	
    	}
  	
   	
}


function mapa_on(tipo_evento,pais,estado_ejercito,mi_ejercito,n_tropas,ejercito_en_pais,nombre_pais,itinerario){

//	document.getElementById('n_tropas_'+pais).style.fontWeight='bold';
	mee('nto'+pais,1);
	var continente = document.getElementById('ccc'+pais).value;
	document.getElementById('nc'+continente).style.fontWeight='bold';
	
	var strresultado='';
	strresultado=strresultado+'pais: '+pais+' / ';
	strresultado=strresultado+'estado_ejercito: '+estado_ejercito+' / ';
	strresultado=strresultado+'mi_ejercito: '+mi_ejercito+' / ';
	strresultado=strresultado+'n_tropas: '+n_tropas+' / ';
	strresultado=strresultado+'ejercito_en_pais: '+ejercito_en_pais+' / ';
	
	var marcar_itinerario=0;
	var marcado_itinerario=0;
	
	try{
	
				if(itinerario==1){
					if(contador_itinerario==0){
						if(ejercito_en_pais==mi_ejercito){
							n_tropas_itinerario = n_tropas+1;
							if(n_tropas_itinerario>2){
								marcar_itinerario=1;
								}
							}
						}
					else{
						if(ejercito_en_pais!=mi_ejercito){
							marcar_itinerario=1;
							for(j=0;j<contador_itinerario;j++){
								if(itinerario_paises[j]==pais){
									marcar_itinerario=0;
									break;
									}
								}
							}
						}
					}
				if(marcar_itinerario==1){
					if(n_tropas_itinerario>1){
						itinerario_paises[contador_itinerario]=pais;
						seleccionar_itinerario(pais,nombre_pais);
						contador_itinerario++;
						n_tropas_itinerario--;
						marcado_itinerario=1;
						}
					}

	
	
				if((estado_ejercito==1)&&(itinerario!=1)){
					if(ejercito_en_pais == mi_ejercito){
						if(n_tropas>3){
							seleccionar_valor(pais,'ATAQUE_ORIGEN');
							}
						if((n_tropas>1)&&(n_tropas<4)){
							seleccionar_valor(pais,'ATAQUE_ORIGEN_LOW');
							}
						if(n_tropas==1){
							seleccionar_valor(pais,'ATAQUE_CAPITAL');
							}					
						}
					else{
						seleccionar_valor(pais,'ATAQUE_DESTINO');
						}
					}
				if(estado_ejercito==2){
					if(bicontador==2){
						bicontador=0;
						}
					if((ejercito_en_pais == mi_ejercito)&&(n_tropas>1)&&(bicontador==0)&&(tipo_evento==1)){
						seleccionar_valor(pais,'REORGANIZAR_ORIGEN');
						cambia=1;
						}
					if((ejercito_en_pais == mi_ejercito)&&(bicontador==1)&&(tipo_evento==1)){
						seleccionar_valor(pais,'REORGANIZAR_DESTINO');
						cambia=1;
						}
					if(cambia==1){
						bicontador++;
						cambia=0;
						}
					}	
				if(estado_ejercito==3){
					if(ejercito_en_pais == mi_ejercito){
						seleccionar_valor(pais,'UBICAR_PAIS');
						}
					}	
	





			if((itinerario==1)&&(contador_itinerario>0)&&(marcado_itinerario==1)){
//				document.getElementByName("label_orden_itinerario_"+pais).value=contador_itinerario;
				document.getElementById("n_orden_itinerario_"+pais).innerHTML=contador_itinerario;
				document.getElementById("n_orden_itinerario_sombra_"+pais).innerHTML=contador_itinerario;
				mee("n_orden_itinerario_"+pais,1);
				mee("n_orden_itinerario_sombra_"+pais,1);
				}








		} catch(e){ }
	
//	alert(strresultado);
	
}

function mapa_off(pais,estado_ejercito,mi_ejercito,n_tropas,ejercito_en_pais){
//	document.getElementById('n_tropas_'+pais).style.fontWeight='normal';
	mee('nto'+pais,0);
	var continente = document.getElementById('ccc'+pais).value;
	document.getElementById('nc'+continente).style.fontWeight='normal';
}



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_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];}
}



try{
	ajax=inicializar_objeto_ajax();	
	} catch(e){}
function inicializar_objeto_ajax(){
	try{
		objeto=new ActiveXObject("Msxml2.XMLHTTP"); 
        }catch(e1){
        	try{ 
			objeto=new ActiveXObject("Microsoft.XMLHTTP"); 
		}catch(e2){ 
			objeto=false; 
			} 
		} 
        if(!objeto && typeof XMLHttpRequest!='undefined') { 
                objeto = new XMLHttpRequest(); 
        	} 
        return objeto;
	}

function comunicar_servidor(accion,valoresadicionales,divid,addsubs,tiempo,html_proceso){
	var textoretorno="";
	var varaccion="accion="+accion;
	var varURL="r_proceso_ajax_generico_servidor.php?";
	if(html_proceso!=""){
			try{
				document.getElementById(divid).innerHTML=html_proceso;
				} catch(e){}
			}
	ajax.open("GET",varURL+"&"+varaccion+valoresadicionales+"&v_a_t="+tiempo,true); 
	ajax.onreadystatechange=function(){ 
        	if(ajax.readyState==4){
			textoretorno=unescape(ajax.responseText);
			textoretorno=textoretorno.replace(/\+/gi," ");
        		if(addsubs==1){
        			try{
        				document.getElementById(divid).innerHTML+=textoretorno;
        				} catch(e){}
        			}
        		else{
        			try{
        				document.getElementById(divid).innerHTML=textoretorno;
        				} catch(e){}
        			}
			} 
		} 
	ajax.send(null);
	}







