/*un interruptor*/
var sContador = null;
var sContador2 = null;
/*otro*/
var contador = false;
/*el tiempo de retardo. modificar al gusto*/
var tiempo = 360;	
/*esto lo utilizamos para saber exctamente qué menú ocultar (así no tenemos que ocultar todos. Se guarda el último menú desplegado*/
var menuActivo = '';
var elemActivo = '';

/**
 * añade retardo al ocultamiento de los menus
 * @Copyright VECTOR
 * @date 01/01/2007
 * @see sin referencias
 */
function iniciarContador(){
	clearTimeout(sContador2);
	sContador2 = null;
	if(elemActivo!=''){
		pintaLI(elemActivo);
	}
	if (contador == false){
		sContador = setTimeout(function(){
		ocultaMenus();
		if(document.getElementById('contenido')){
			if(document.getElementById('contenido').getElementsByTagName('applet')[0]){
				for(i=0;i<document.getElementById('contenido').getElementsByTagName('applet').length;i++){
					document.getElementById('contenido').getElementsByTagName('applet')[i].style.visibility='visible';
				}
			}else if(document.getElementById('contenido').getElementsByTagName('object')[0]){
				for(i=0;i<document.getElementById('contenido').getElementsByTagName('object').length;i++){
					document.getElementById('contenido').getElementsByTagName('object')[i].style.visibility='visible';
				}
			}
		}
		
		}, tiempo);
		
		contador = true;
	}
}
/**
 * paro el contador para ocultar menus
 * @Copyright VECTOR
 * @date 01/01/2007
 * @see sin referencias
 */
function pararContador(){
	if (contador){
		clearTimeout(sContador);
       	sContador = null;
    	contador = false;
    }
}
/**
 * oculto menús
 * @Copyright VECTOR
 * @date 01/01/2007
 * @see sin referencias
 */
function ocultaMenus(){
	if(document.getElementById(menuActivo)){
		document.getElementById(menuActivo).style.display='none';
		document.getElementById(menuActivo).parentNode.className=document.getElementById(menuActivo).parentNode.className.replace('activo','');
		pintaLI(menuActivo);
		menuActivo = '';
	}
		  controlaSelects(false);
}
/**
 * muestro el menú
 * @Copyright VECTOR
 * @date 01/01/2007
 * @see sin referencias
 */
function muestraMenu(este){
		pintaLI(este);
		elemActivo = este;
		sContador2 = setTimeout(function(){
		 document.getElementById(este).style.width=document.getElementById(este).parentNode.offsetWidth+'px';
	   document.getElementById(este).style.top=document.getElementById(este).parentNode.offsetHeight+'px';
	   document.getElementById(este).style.display='block';
	   if(document.getElementById('contenido')){
		   if(document.getElementById('contenido').getElementsByTagName('applet')[0]){
			   for(i=0;i<document.getElementById('contenido').getElementsByTagName('applet').length;i++){
					document.getElementById('contenido').getElementsByTagName('applet')[i].style.visibility='hidden';
				}
		   }else if(document.getElementById('contenido').getElementsByTagName('object')[0]){
			   for(i=0;i<document.getElementById('contenido').getElementsByTagName('object').length;i++){
					document.getElementById('contenido').getElementsByTagName('object')[i].style.visibility='hidden';
				}
		   }
	   }
       if(menuActivo!=''){
           ocultaMenus();
       }
       menuActivo = este;
	   elemActivo = '';
	   controlaSelects(true);
   }, 350);
} 

function controlaSelects(ocultar){
	if(ocultar){
		for(i=0;i<document.getElementsByTagName('select').length;i++){
			if(!document.getElementsByTagName('select')[i].addEventListener){
				document.getElementsByTagName('select')[i].style.visibility='hidden';
			}
	    }
	}else{
		for(i=0;i<document.getElementsByTagName('select').length;i++){
			if(!document.getElementsByTagName('select')[i].addEventListener){
				document.getElementsByTagName('select')[i].style.visibility='visible';
			}
	    }
	}
}
/**
 * coloreo el li activo
 * @Copyright VECTOR
 * @date 01/01/2007
 * @see sin referencias
 */
function pintaLI(este){
	if(este=='todos'){
		for(i=0;i<document.getElementById('alojamenu').getElementsByTagName('a').length;i++){
			if(document.getElementById('alojamenu').getElementsByTagName('a')[i].className.indexOf('activohover')!=-1){
				document.getElementById('alojamenu').getElementsByTagName('a')[i].className = document.getElementById('alojamenu').getElementsByTagName('a')[i].className.replace('activohover','');
			}
		}
	}else{
		if(document.getElementById(este).parentNode.getElementsByTagName('a')[0].className.indexOf('activohover')!=-1){
			document.getElementById(este).parentNode.getElementsByTagName('a')[0].className=document.getElementById(este).parentNode.getElementsByTagName('a')[0].className.replace('activohover','');
		}else{
			document.getElementById(este).parentNode.getElementsByTagName('a')[0].className+=' activohover';	
		}
	}
}

function siguienteNodo(nodoOrigen,tipoNodo){
	if(nodoOrigen.nextSibling){
		var resultado = nodoOrigen.nextSibling;
		if(nodoOrigen.nextSibling.nodeName.toUpperCase()!=tipoNodo.toUpperCase()){
			resultado = resultado.nextSibling;
		}
		return resultado;
	}
}
function anteriorNodo(nodoOrigen,tipoNodo){
	if(nodoOrigen.previousSibling){
		var resultado = nodoOrigen.previousSibling;
		while(resultado.nodeName.toUpperCase()!=tipoNodo.toUpperCase()){
			resultado = resultado.previousSibling;
		}
		return resultado;
	}
}

/*pestañas fotos-videos*/
function tuneaFotosVideos(minube){
    if (minube == undefined) { minube = ''; } /* si minube no viene vacio es que lo ha llamado el módulo minube - anf */
	if(document.getElementById('fotos_videos' + minube)){
		if(document.getElementById('fotos_videos' + minube).className.indexOf('fotostuneadas')<1){
			var fotosvideos = document.getElementById('fotos_videos' + minube);
			fotosvideos.className+=' fotostuneadas';
            if (minube == '_minube') { /* viene de minube - anf */
                clearInterval(intervalPrintFotosVideosMinube);
            } else { /* viene del modulo de imagenes y videos ya existente - anf */
                clearInterval(intervalPrintFotosVideos);
            }
			//fotosvideos.getElementsByTagName('strong')[0].className+=' activo';
			//fotosvideos.getElementsByTagName('div')[0].className+=' activo';
			if(fotosvideos.getElementsByTagName('strong')[0].addEventListener){
				fotosvideos.getElementsByTagName('strong')[0].addEventListener('click',function funcion(){activaFotosVideos(this,minube);},false);
				fotosvideos.getElementsByTagName('strong')[1].addEventListener('click',function funcion(){activaFotosVideos(this,minube);},false);
			}
			else{
				fotosvideos.getElementsByTagName('strong')[0].onclick=function funcion(){activaFotosVideos(this,minube);};
				fotosvideos.getElementsByTagName('strong')[1].onclick=function funcion(){activaFotosVideos(this,minube);};
			}
			document.getElementById('pestanavideos' + minube).style.left = anteriorNodo(document.getElementById('pestanavideos' + minube),'p').childNodes[0].offsetWidth+5+"px";
			/*ahora ajustamos el margen de las fotos*/
			for(i=0;i<fotosvideos.getElementsByTagName('img').length;i++){
				fotosvideos.getElementsByTagName('img')[i].style.marginTop = (fotosvideos.getElementsByTagName('img')[i].parentNode.parentNode.offsetHeight - fotosvideos.getElementsByTagName('img')[i].offsetHeight)/2-1+"px";
			}
			/*ahora el del vídeo*/
			//for(i=0;i<fotosvideos.getElementsByTagName('object').length;i++){
				//fotosvideos.getElementsByTagName('object')[i].style.marginTop = (fotosvideos.getElementsByTagName('img')[i].parentNode.parentNode.offsetHeight - fotosvideos.getElementsByTagName('img')[i].offsetHeight)/2+10+"px";
			//}
		}
	}
}
function activaFotosVideos(esta,minube){
    if (minube == undefined) { minube = ''; } /* si minube no viene vacio es que lo ha llamado el módulo minube - anf */
	for(i=0;i<document.getElementById('fotos_videos' + minube).getElementsByTagName('div').length;i++){
		document.getElementById('fotos_videos' + minube).getElementsByTagName('div')[i].className=document.getElementById('fotos_videos' + minube).getElementsByTagName('div')[i].className.replace('activo','');
	}
	for(i=0;i<document.getElementById('fotos_videos' + minube).getElementsByTagName('strong').length;i++){
		document.getElementById('fotos_videos' + minube).getElementsByTagName('strong')[i].className=document.getElementById('fotos_videos' + minube).getElementsByTagName('strong')[i].className.replace('activo','');
	}
	esta.className+=' activo';
	siguienteNodo(esta.parentNode,'DIV').className+=' activo';
	var fotosvideos = document.getElementById('fotos_videos' + minube);
	/*ahora ajustamos el margen de las fotos*/
	for(i=0;i<fotosvideos.getElementsByTagName('img').length;i++){
		fotosvideos.getElementsByTagName('img')[i].style.marginTop = (fotosvideos.getElementsByTagName('img')[i].parentNode.parentNode.offsetHeight - fotosvideos.getElementsByTagName('img')[i].offsetHeight)/2-1+"px";
	}
}


function colocaPestanyas(esta){
	for(i=0;i<esta.parentNode.parentNode.getElementsByTagName('p').length;i++){
		if(esta.parentNode.className.indexOf('activo')!=-1){
			if(document.getElementById('pestanyascuadradas').offsetWidth>400){
				esta.style.width='100px';
			}else{
				esta.style.width='92px';
			}
		}else{
			esta.parentNode.parentNode.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].style.width=(218-esta.style.width)/2+'px';
			
		}
		//alert(esta.parentNode.parentNode.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].style.width);
	}
	for(i=1;i<esta.parentNode.parentNode.getElementsByTagName('p').length;i++){
		esta.parentNode.parentNode.getElementsByTagName('p')[i].style.left = esta.parentNode.parentNode.getElementsByTagName('p')[i-1].childNodes[0].offsetWidth+esta.parentNode.parentNode.getElementsByTagName('p')[i-1].offsetLeft+1+"px";
	}
}
function activaPestanya(esta){
	if(esta.parentNode.className.indexOf('activo')==-1){
		desactivaPestanyas(esta);
		esta.parentNode.className+=' activo';
		esta.getElementsByTagName('a')[0].innerHTML = esta.getElementsByTagName('a')[0].getAttribute('title');
		if(document.getElementById('pestanyascuadradas').offsetWidth>400){
			esta.style.width='100px';
		}else{
			esta.style.width='92px';
		}
		siguienteNodo(esta.parentNode,'DIV').className+=' activo';
		colocaPestanyas(esta);
	}
}
function desactivaPestanyas(esta){
	for(i=0;i<esta.parentNode.parentNode.getElementsByTagName('p').length;i++){
		if(esta.parentNode.parentNode.getElementsByTagName('p')[i].className.indexOf('activo')!=-1){
			esta.parentNode.parentNode.getElementsByTagName('p')[i].className=esta.parentNode.parentNode.getElementsByTagName('p')[i].className.replace('activo','');
		}
		if(document.getElementById('pestanyascuadradas').offsetWidth>400){
			esta.parentNode.parentNode.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].style.width='100px';
		}else{
			esta.parentNode.parentNode.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].style.width='51px';
		}
		
		if(i>0){
			esta.parentNode.parentNode.getElementsByTagName('p')[i].style.left=esta.parentNode.parentNode.getElementsByTagName('p')[i-1].childNodes[0].offsetWidth+esta.parentNode.parentNode.getElementsByTagName('p')[i-1].offsetLeft+1+"px";
		}
		
		var textotitulo = esta.parentNode.parentNode.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].getAttribute('title');
		if(document.getElementById('pestanyascuadradas').offsetWidth<400){
			if(textotitulo.length>9){
			textotitulo=textotitulo.substr(0,8);
			textotitulofinal = textotitulo+'...';
			}else{
				textotitulofinal = textotitulo;
			}
			esta.parentNode.parentNode.getElementsByTagName('p')[i].getElementsByTagName('a')[0].innerHTML = textotitulofinal;
		}
	}
	for(i=0;i<esta.parentNode.parentNode.getElementsByTagName('div').length;i++){
		if(esta.parentNode.parentNode.getElementsByTagName('div')[i].className.indexOf('activo')!=-1){
			esta.parentNode.parentNode.getElementsByTagName('div')[i].className=esta.parentNode.parentNode.getElementsByTagName('div')[i].className.replace('activo','');
		}
	}
}

function activaPlaya(este){
	var laCaja = document.getElementById('playasdestacadas');
	var elMenu = laCaja.getElementsByTagName('ul')[0];
	for(i=0;i<elMenu.getElementsByTagName('a').length;i++){
		elMenu.getElementsByTagName('a')[i].className=elMenu.getElementsByTagName('a')[i].className.replace('activo','');
		if(este==elMenu.getElementsByTagName('a')[i]){
			var indice=i;
		}
	}
	elMenu.getElementsByTagName('a')[indice].className='activo';
	var arrayPlayas = new Array;
	for(i=0;i<document.getElementById('contenidoscompmenu').getElementsByTagName('div').length;i++){
		if(document.getElementById('contenidoscompmenu').getElementsByTagName('div')[i].className.indexOf('compmenu_contenido')!=-1){
			arrayPlayas.push(document.getElementById('contenidoscompmenu').getElementsByTagName('div')[i]);
			document.getElementById('contenidoscompmenu').getElementsByTagName('div')[i].className=document.getElementById('contenidoscompmenu').getElementsByTagName('div')[i].className.replace('playaactiva','');
			document.getElementById('contenidoscompmenu').getElementsByTagName('div')[i].style.display='none';
		}
	}
	arrayPlayas[indice].className+=' playaactiva';
	arrayPlayas[indice].style.display='block';
}

function tuneaPestanyasCuadradas(){
	if(document.getElementById('pestanyascuadradas')){
		if(document.getElementById('pestanyascuadradas').className.indexOf('tuneado')<1){
			var pestanas = document.getElementById('pestanyascuadradas');			
			var titulo = new Array;
			pestanas.className+=' tuneado';
			clearInterval(intervalPrint);
			for(i=0;i<pestanas.getElementsByTagName('p').length;i++){
				if(pestanas.getElementsByTagName('p')[i].className.indexOf('titulo')!=-1){
					titulo.push(pestanas.getElementsByTagName('p')[i]);
					//asignamos comportamiento a los strong de los titulos
					if(pestanas.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].addEventListener){
						pestanas.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].addEventListener('click',function funcion(){activaPestanya(this);},false);
					}
					else{
						pestanas.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].onclick=function funcion(){activaPestanya(this);};
					}
						if(pestanas.getElementsByTagName('p')[i].className.indexOf('activo')==-1){
						
							if(pestanas.offsetWidth>400){
								pestanas.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].style.width='100px';
							}else{
								pestanas.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].style.width='51px';
							}
							pestanas.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].style.height='12px';
							pestanas.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].style.minHeight='12px';
							
							var textotitulo = pestanas.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].getAttribute('title');
							if(pestanas.offsetWidth<400){
								if(textotitulo.length>9){
								textotitulo=textotitulo.substr(0,8);
								textotitulofinal = textotitulo+'...';
								}else{
									textotitulofinal = textotitulo;
								}
								pestanas.getElementsByTagName('p')[i].getElementsByTagName('a')[0].innerHTML = textotitulofinal;
							}
						}else{
							if(pestanas.offsetWidth>400){
								pestanas.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].style.width='100px';
							}else{
								pestanas.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].style.width='92px';
							}
							pestanas.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].style.height='12px';
							pestanas.getElementsByTagName('p')[i].getElementsByTagName('strong')[0].style.minHeight='12px';
							pestanas.getElementsByTagName('p')[i].getElementsByTagName('a')[0].innerHTML = pestanas.getElementsByTagName('p')[i].getElementsByTagName('a')[0].getAttribute('title');
						}
				}
			}
			for(i=1;i<titulo.length;i++){
				titulo[i].style.left = titulo[i-1].childNodes[0].offsetWidth+titulo[i-1].offsetLeft+1+"px";
			}
		}
	} 
}

function muestraOpina(este){
		if(document.getElementById('alojaopina').style.display!='block'){
			document.getElementById('alojaopina').style.display='block';
			document.getElementById('transparente').style.display='block';
			document.getElementById('alojaopina').style.top=este.parentNode.parentNode.offsetTop+'px';
			document.getElementById('transparente').style.height=document.getElementsByTagName('html')[0].scrollHeight+'px';
			document.getElementById('transparente').style.width=document.getElementsByTagName('html')[0].scrollWidth+'px';
				if (window.captureEvents){
				//mozillas
					document.getElementById('transparente').onclick=muestraOpina;
				}
				else{
				//explorers
					document.getElementById('transparente').onclick=muestraOpina;
				}
		}else{
			document.getElementById('alojaopina').style.display='none';
			document.getElementById('transparente').style.display='none';
		}		
		return false;
}
/**
 * coloreo el li activo
 * @Copyright VECTOR
 * @date 01/01/2007
 * @see sin referencias
 */
function pintaLI(este){
	if(este=='todos'){
		for(i=0;i<document.getElementById('alojamenu').getElementsByTagName('a').length;i++){
			if(document.getElementById('alojamenu').getElementsByTagName('a')[i].className.indexOf('activohover')!=-1){
				document.getElementById('alojamenu').getElementsByTagName('a')[i].className = document.getElementById('alojamenu').getElementsByTagName('a')[i].className.replace('activohover','');
			}
		}
	}else{
		if(document.getElementById(este).parentNode.getElementsByTagName('a')[0].className.indexOf('activohover')!=-1){
			document.getElementById(este).parentNode.getElementsByTagName('a')[0].className=document.getElementById(este).parentNode.getElementsByTagName('a')[0].className.replace('activohover','');
		}else{
			document.getElementById(este).parentNode.getElementsByTagName('a')[0].className+=' activohover';	
		}
	}
}

function siguienteNodo(nodoOrigen,tipoNodo){
	if(nodoOrigen.nextSibling){
		var resultado = nodoOrigen.nextSibling;
		if(nodoOrigen.nextSibling.nodeName.toUpperCase()!=tipoNodo.toUpperCase()){
			resultado = resultado.nextSibling;
		}
		return resultado;
	}
}
function anteriorNodo(nodoOrigen,tipoNodo){
	if(nodoOrigen.previousSibling){
		var resultado = nodoOrigen.previousSibling;
		while(resultado.nodeName.toUpperCase()!=tipoNodo.toUpperCase()){
			resultado = resultado.previousSibling;
		}
		return resultado;
	}
}


function tuneaPlayasdestacadas(){
	var laCaja = document.getElementById('playasdestacadas');
	if(document.getElementById('playasdestacadas').className.indexOf('playastuneadas')<1){
		laCaja.className+=' playastuneadas';
		clearInterval(intervalPrintPlayas);
		laCaja.getElementsByTagName('ul')[0].style.display='block';
		
		var elAlto=0;
		for(i=0;i<laCaja.getElementsByTagName('div')[0].getElementsByTagName('div').length;i++){
			if(laCaja.getElementsByTagName('div')[0].getElementsByTagName('div')[i].className=="padding"){
			if(elAlto<laCaja.getElementsByTagName('div')[0].getElementsByTagName('div')[i].offsetHeight){
					elAlto = laCaja.getElementsByTagName('div')[0].getElementsByTagName('div')[i].offsetHeight;
				}
			}
		}
		if(elAlto>laCaja.getElementsByTagName('ul')[0].offsetHeight){
				laCaja.getElementsByTagName('div')[0].style.minHeight=elAlto+30+'px';
			
			
		}else{
			laCaja.getElementsByTagName('div')[0].style.height=laCaja.getElementsByTagName('ul')[0].offsetHeight+0+'px';
		}
		for(i=0;i<laCaja.getElementsByTagName('div').length;i++){
			if(laCaja.getElementsByTagName('div')[i].className.indexOf('paginacion')!=-1){
				laCaja.getElementsByTagName('div')[i].style.display='block';
				//anteriorNodo(laCaja.getElementsByTagName('div')[i],'A').className=anteriorNodo(laCaja.getElementsByTagName('div')[i],'A').className.replace('right','left');
			}
			if((laCaja.getElementsByTagName('div')[i].className.indexOf('compmenu_contenido')!=-1)&&(laCaja.getElementsByTagName('div')[i].className.indexOf('playaactiva')==-1)){
				laCaja.getElementsByTagName('div')[i].style.display='none';
			}
		}
		
		var elMenu = laCaja.getElementsByTagName('ul')[0];
		var i=0;
		for(i=0;i<elMenu.getElementsByTagName('a').length;i++){
			if(elMenu.getElementsByTagName('a')[i].addEventListener){
				elMenu.getElementsByTagName('a')[i].addEventListener('click',function funcion(){activaPlaya(this);},false);
			}
			else{
				elMenu.getElementsByTagName('a')[i].onclick=function funcion(){activaPlaya(this);return false;};
			}	
		}
		
		if(elMenu.offsetHeight>elAlto){
			laCaja.getElementsByTagName('div')[0].style.minHeight=elMenu.offsetHeight+40+'px';
		}
	}
	
}


function activaPlaya(este){
	var laCaja = document.getElementById('playasdestacadas');
	var elMenu = laCaja.getElementsByTagName('ul')[0];
	for(i=0;i<elMenu.getElementsByTagName('a').length;i++){
		elMenu.getElementsByTagName('a')[i].className=elMenu.getElementsByTagName('a')[i].className.replace('activo','');
		if(este==elMenu.getElementsByTagName('a')[i]){
			var indice=i;
		}
	}
	elMenu.getElementsByTagName('a')[indice].className='activo';
	var arrayPlayas = new Array;
	for(i=0;i<document.getElementById('contenidoscompmenu').getElementsByTagName('div').length;i++){
		if(document.getElementById('contenidoscompmenu').getElementsByTagName('div')[i].className.indexOf('compmenu_contenido')!=-1){
			arrayPlayas.push(document.getElementById('contenidoscompmenu').getElementsByTagName('div')[i]);
			document.getElementById('contenidoscompmenu').getElementsByTagName('div')[i].className=document.getElementById('contenidoscompmenu').getElementsByTagName('div')[i].className.replace('playaactiva','');
			document.getElementById('contenidoscompmenu').getElementsByTagName('div')[i].style.display='none';
		}
	}
	arrayPlayas[indice].className+=' playaactiva';
	arrayPlayas[indice].style.display='block';
}

function muestraOpina(este){
		if(document.getElementById('alojaopina').style.display!='block'){
			document.getElementById('alojaopina').style.display='block';
			document.getElementById('transparente').style.display='block';
			document.getElementById('alojaopina').style.top=este.parentNode.parentNode.offsetTop+'px';
			document.getElementById('transparente').style.height=document.getElementsByTagName('html')[0].scrollHeight+'px';
			document.getElementById('transparente').style.width=document.getElementsByTagName('html')[0].scrollWidth+'px';
				if (window.captureEvents){
				//mozillas
					document.getElementById('transparente').onclick=muestraOpina;
				}
				else{
				//explorers
					document.getElementById('transparente').onclick=muestraOpina;
				}
		}else{
			document.getElementById('alojaopina').style.display='none';
			document.getElementById('transparente').style.display='none';
		}		
		return false;
}

/**
 * valida el combo ir a
 * @Copyright VECTOR
 * @date 27/01/2009
 * @see sin referencias
 */
function valida_ir(form) {
  if (document.getElementById('type').selectedIndex < 2) {
    alert('Debe seleccionar un elemento');
	return false;
  }
}

/**
 * oculta/muestra las descripciones completas de los bloques de la parte administrativa
 * @Copyright VECTOR
 * @date 27/01/2007
 * @see sin referencias
 */
function oculto(a) {
  var cp = document.getElementById(a);
  if (cp.style.display == 'none') {
    cp.style.display = 'block';
  } else if (cp.style.display == 'block') {
    cp.style.display = 'none';
  }
}
/**
 * obtiene los datos de los formularios y realiza la llamada ajax a la pieza php que devuelve los datos para el mapa. Realiza la llamada a la función del mapa
 * @Copyright VECTOR
 * @date 27/01/2007
 * @see sin referencias
 */
 
$(function() {
  $('.ajax').click(function(e) {
    var aux = new Array();
	var params = new Array();
	var tipo_mapa = document.getElementById('edit-tipo-mapa').value;
	if (tipo_mapa == 'comollegar') {
	  aux[0] = document.getElementById('edit-tren');
	  aux[1] = document.getElementById('edit-bus');
	  aux[2] = document.getElementById('edit-aeropuerto');
	  aux[3] = document.getElementById('edit-puerto');
	}
	if (tipo_mapa == 'turistico') {
	  aux[0] = document.getElementById('edit-parque-ocio');
	  aux[1] = document.getElementById('edit-municipio');
	  aux[2] = document.getElementById('edit-webcam');
	  aux[3] = document.getElementById('edit-nautica');
	  aux[4] = document.getElementById('edit-golf');
	  aux[5] = document.getElementById('edit-nautica');
	  aux[5] = document.getElementById('edit-playa');
	}
	if (tipo_mapa == 'mapawebcam') {
	  var combo = document.getElementById('combo_mapa_sup');
	  aux[0] = combo.options[combo.selectedIndex].value;
	}
	var n = 0;
	var loading = new Array();
    for (var i=0;i<aux.length;i++) {
	  if (aux[i].checked) {
	    params[n] = aux[i].value;
		loading[n] = document.getElementById('loading-'+aux[i].value);
		loading[n].style.display = 'block';
		n++;
	  }
	}
	if (tipo_mapa == 'mapawebcam') {
	  var tipos = aux[0];
	} else {
	  var tipos = params.join('\',\'');
	}

    $.post("http://"+location.host+Drupal.settings.mapas.basePath+"callback_ajax_mapa", {tipos: tipos,tipo_mapa: tipo_mapa}, function(input) {
	  var datos = eval(input);
      initialize(datos,tipo_mapa);
	  for (var i=0;i<loading.length;i++) {
	   loading[i].style.display = 'none';
	  } 
    });
	return false;
  })
});
/**
 * Genera el mapa con los datos que se le pasan
 * @Copyright VECTOR
 * @date 27/01/2007
 * @see sin referencias
 */

 var google;
 
function initialize(datas,tipo_mapa) {

  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map"));
	var center = new Array();
	var zoom;
	if (datas[0]['center'] != null) {
	  center = datas[0]['latlong'].split(',');
	  zoom = datas[0]['zoom'];
	} else {
	  center[0] = '39.476486';
	  center[1] = '-0.373535';
	  zoom = 8;
	}
    map.setCenter(new GLatLng(center[0],center[1]), zoom);
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl()); 

    var baseIcon = new GIcon(G_DEFAULT_ICON);
    baseIcon.shadow = "";
    baseIcon.iconSize = '';
    baseIcon.iconAnchor = new GPoint(10,33);
    baseIcon.infoWindowAnchor = new GPoint(9, 2);

    function createMarker() {
	  if (tipo_mapa == 'comollegar') {
        var texto = datas[i]['texto'];
	  } else {
	    var texto = datas[i]['link'];
	  } 
      var icono = new GIcon(baseIcon);
      icono.image = 'http://'+location.host+Drupal.settings.mapas.basePath+'sites/all/themes/valencia/img/'+datas[i]['marca']; 
      markerOptions = { icon:icono };
	  var ll = datas[i]['latlong'].split(',');
	  var point = new GLatLng(ll[0],ll[1]);
      var marker = new GMarker(point, markerOptions);

      GEvent.addListener(marker, "mouseover", function() {
         marker.openInfoWindowHtml(texto);
      });
      return marker;
    }
    for (var i = 0; i < datas.length; i++) {  
      map.addOverlay(createMarker());
    }
  }
}
function marcaTodos(){
	$('.form-checkbox').attr('checked','checked');
	return false;
}
function desmarcaTodos(){
	$('.form-checkbox').attr('checked','');
	return false;
}

/**
 * Seleccion de contenidos en multiples idiomas para nodos WS
 * @Copyright VECTOR
 * @date 28/07/2010
 * @see sin referencias
 */
$(document).ready( function(){
  $('#edit-field-ws-descripcion-zho-value-wrapper,#edit-field-ws-descripcion-ita-value-wrapper,#edit-field-ws-descripcion-rus-value-wrapper,#edit-field-ws-descripcion-eng-value-wrapper, #edit-field-ws-descripcion-fra-value-wrapper, #edit-field-ws-descripcion-deu-value-wrapper, #edit-field-ws-descripcion-jpn-value-wrapper, #edit-field-ws-descripcion-val-value-wrapper').css('display','none');
  $('#wysiwyg4field-ws-descripcion-0-value,#wysiwyg4field-ws-descripcion-zho-value,#wysiwyg4field-ws-descripcion-ita-value,#wysiwyg4field-ws-descripcion-rus-value,#wysiwyg4field-ws-descripcion-eng-value,#wysiwyg4field-ws-descripcion-fra-value,#wysiwyg4field-ws-descripcion-deu-value,#wysiwyg4field-ws-descripcion-jpn-value,#wysiwyg4field-ws-descripcion-val-value').css('display','none');

  $('#edit-field-ws-ofertas-zho-value-wrapper,#edit-field-ws-ofertas-ita-value-wrapper,#edit-field-ws-ofertas-rus-value-wrapper,#edit-field-ws-ofertas-eng-value-wrapper, #edit-field-ws-ofertas-fra-value-wrapper, #edit-field-ws-ofertas-deu-value-wrapper, #edit-field-ws-ofertas-jpn-value-wrapper, #edit-field-ws-ofertas-val-value-wrapper').css('display','none');
  $('#wysiwyg4field-ws-ofertas-0-value,#wysiwyg4field-ws-ofertas-ita-value,#wysiwyg4field-ws-ofertas-rus-value,#wysiwyg4field-ws-ofertas-zho-value,#wysiwyg4field-ws-ofertas-eng-value,#wysiwyg4field-ws-ofertas-fra-value,#wysiwyg4field-ws-ofertas-deu-value,#wysiwyg4field-ws-ofertas-jpn-value,#wysiwyg4field-ws-ofertas-val-value').css('display','none');
 
  $('#btn_selector_0, #btn_selector_zho, #btn_selector_ita, #btn_selector_rus, #btn_selector_eng, #btn_selector_fra, #btn_selector_deu, #btn_selector_jpn, #btn_selector_val').click( function(){
    $('#btn_selector_0, #btn_selector_zho, #btn_selector_ita, #btn_selector_rus, #btn_selector_eng, #btn_selector_fra, #btn_selector_deu, #btn_selector_jpn, #btn_selector_val').parent().removeClass('tabs-selected active');
    $(this).parent().addClass('tabs-selected active');
    var lang = $(this).attr('id');
    lang = lang.split('selector_');
    $('#edit-field-ws-descripcion-0-value-wrapper,#edit-field-ws-descripcion-zho-value-wrapper,#edit-field-ws-descripcion-ita-value-wrapper,#edit-field-ws-descripcion-rus-value-wrapper,#edit-field-ws-descripcion-eng-value-wrapper, #edit-field-ws-descripcion-fra-value-wrapper, #edit-field-ws-descripcion-deu-value-wrapper, #edit-field-ws-descripcion-jpn-value-wrapper, #edit-field-ws-descripcion-val-value-wrapper').css('display','none');
    $('#edit-field-ws-descripcion-'+lang[1]+'-value-wrapper').css('display','block');
    return false;
  });
  
  $('#btn_of_selector_0, #btn_of_selector_zho, #btn_of_selector_ita, #btn_of_selector_rus, #btn_of_selector_eng, #btn_of_selector_fra, #btn_of_selector_deu, #btn_of_selector_jpn, #btn_of_selector_val').click( function(){
    $('#btn_of_selector_0, #btn_of_selector_zho, #btn_of_selector_ita, #btn_of_selector_rus, #btn_of_selector_eng, #btn_of_selector_fra, #btn_of_selector_deu, #btn_of_selector_jpn, #btn_of_selector_val').parent().removeClass('tabs-selected active');
    $(this).parent().addClass('tabs-selected active');
    var lang = $(this).attr('id');
    lang = lang.split('selector_');
    $('#edit-field-ws-ofertas-0-value-wrapper,#edit-field-ws-ofertas-zho-value-wrapper,#edit-field-ws-ofertas-ita-value-wrapper,#edit-field-ws-ofertas-rus-value-wrapper,#edit-field-ws-ofertas-eng-value-wrapper, #edit-field-ws-ofertas-fra-value-wrapper, #edit-field-ws-ofertas-deu-value-wrapper, #edit-field-ws-ofertas-jpn-value-wrapper, #edit-field-ws-ofertas-val-value-wrapper').css('display','none');
    $('#edit-field-ws-ofertas-'+lang[1]+'-value-wrapper').css('display','block');
    return false;
  });

});

