// JavaScript Document

var idiomas=new Array('castellano', 'galego');


/***************************************************/

function mostrarSubmenu(prefijo, id, num_elems_menu){
	for(i=0; i<num_elems_menu; i++){
		if(i==id){
			if(document.getElementById(prefijo+i)){
				document.getElementById(prefijo+i).className='menu_item_activo';
			}
			if(document.getElementById('submenu_'+i)){document.getElementById('submenu_'+i).style.display='block';}	
		}else{
			if(document.getElementById(prefijo+i)){
				document.getElementById(prefijo+i).className='menu_item';
			}
			
			if(document.getElementById('submenu_'+i)){document.getElementById('submenu_'+i).style.display='none';}
		}
	}
}

/***************************************************/

function ocultarSubmenus(prefijo, id, num_elems_menu){
	for(i=0; i<num_elems_menu; i++){
		if(document.getElementById('submenu_'+i)){document.getElementById('submenu_'+i).style.display='none';}
		if(id==i && document.getElementById(prefijo+i)){document.getElementById(prefijo+i).className='menu_item_activo';
		}else{
			if(document.getElementById(prefijo+i)){document.getElementById(prefijo+i).className='menu_item';}
		}		
	}
}

/***************************************************/

function seleccionarTab(id, max_num){
	for(i=0; i<max_num; i++){
		if(document.getElementById('tab_'+i)){
			if(id==i){
				document.getElementById('tab_'+i).className='tab_activo';
				document.getElementById('capa_'+i).style.display='block';			
			}else{
				document.getElementById('tab_'+i).className='tab';
				document.getElementById('capa_'+i).style.display='none';					
			}
		}
	}
}

/***************************************************/

function desplegarCapa(prefijo, prefijo_imagen, id, num_capas){
	for(i=0; i<num_capas; i++){
		if(document.getElementById(prefijo+i)){
			if(i!=id){			
				document.getElementById(prefijo+i).style.display='none';
				if(document.getElementById(prefijo_imagen+i)){
					document.getElementById(prefijo_imagen+i).src='imgs/flecha_abajo.jpg';
				}
			}else{
				if(document.getElementById(prefijo+i).style.display=='block'){
					document.getElementById(prefijo+i).style.display='none';
					if(document.getElementById(prefijo_imagen+i)){
						document.getElementById(prefijo_imagen+i).src='imgs/flecha_abajo.jpg';
					}
				}else{
					document.getElementById(prefijo+i).style.display='block';
					if(document.getElementById(prefijo_imagen+i)){
						document.getElementById(prefijo_imagen+i).src='imgs/flecha_arriba.jpg';
					}
				}
			}
		}
	}
}

/***************************************************/

function datosAsociadoCorrectos(){
 	datos_obligatorios=new Array('nombre_apellidos', 'nif', 'domicilio', 'cp_socio', 'localidad_socio', 'provincia_socio', 'movil', 'email', 'usuario', 'centro_trabajo', 'direccion_trabajo', 'cp_trabajo', 'localidad_trabajo', 'provincia_trabajo', 'actividad', 'titular_cuenta', 'banco', 'domicilio_banco', 'entidad', 'oficina', 'dc', 'num_cuenta');
	
	datos_faltan=0;
	for(i=0; i<datos_obligatorios.length; i++){
		if(document.getElementById(datos_obligatorios[i]) && document.getElementById(datos_obligatorios[i]).value!='')	{}
		else{datos_faltan++;}
	}
	
	// si no se está en la parte de edición (sino en el registro de socios de la parte pública)	
	if(document.getElementById('id') && document.getElementById('id').value!=''){//}
//	else{
		// comprobamos que las contraseñas no están vacías y que coincidan
		if(document.getElementById('contrasenha') && document.getElementById('contrasenha')!='' && document.getElementById('contrasenha2') && document.getElementById('contrasenha2').value==document.getElementById('contrasenha').value ){}
		else{datos_faltan=datos_faltan+2;}
	}

	if(datos_faltan>0){
		document.getElementById('msg').innerHTML='Los campos precedidos de <span class="gris">*</span> son obligatorios.<br /><span style="color:#f30;">¡Falta(n) '+datos_faltan+' dato(s)!</span>';
		return false;
	}else{
		document.getElementById('msg').innerHTML='Los campos precedidos de <span class="gris">*</span> son obligatorios';
/*		
		if(document.getElementById('validacion')){
			if(document.getElementById('validacion').checked){}
			else{document.getElementById('msg').innerHTML+='<br /><span style="color:#f30;">Por favor, confirme el envío de los datos seleccionando la casilla situada bajo el formulario.</span>'; return false;}
		}
*/
		return true;
	}
}

/***************************************************/

function cambiarIdioma(idioma){
	document.getElementById('idioma').value=idioma;	
	document.getElementById('form_idioma').submit();
}

/***************************************************/

/*
Open Centered Popup Window Script-
© DHTMLShock (www.dhtmlshock.com)
To add more shock to your site, visit www.DHTMLShock.com
*/
function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
if(window.screen)if(isCenter)if(isCenter=="true"){
var myLeft = (screen.width-myWidth)/2;
var myTop = (screen.height-myHeight)/2;
features+=(features!='')?',':'';
features+=',left='+myLeft+',top='+myTop;
}
window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}


// función para que un 'input' acepte sólo números
function acceptNum(evt){
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key >= 48 && key <= 57) || key==46);
}


var nav4 = window.Event ? true : false;