var supported = (document.getElementsByTagName)
if (supported){
	document.write("<STYLE TYPE='text/css'>");
	document.write(".sub {display: none}");
	document.write("</STYLE>");

	var max = 3;
	var shown = new Array();
	for (var i=1;i<=max;i++){
		shown[i+1] = false;
	}
}
var anterior='';
var anteriorabierto=false;

function blocking(i) {
	if ( (anterior != i)&&(anterior!="") ){
	// si el anterior es distinto al actual, lo abro.
		if  (anteriorabierto){
			blocking2( anterior );
	  	//document.getElementById('menu'+anterior).style.fontWeight="normal";
	  	document.getElementById('menu'+anterior).style.color="#AA8259";
		}
		blocking2( i );
  	//document.getElementById('menu'+i).style.fontWeight='bold';
  	document.getElementById('menu'+i).style.color="#0E963E";
		anteriorabierto = true;
	}else{
	// si el anterior es el actual, lo abro o lo cierro.
		blocking2( i );
		if (anteriorabierto){
			anteriorabierto = false;
	  	//document.getElementById('menu'+i).style.fontWeight='normal';
  	  document.getElementById('menu'+i).style.color="#AA8259";
		}else{
			anteriorabierto = true;
	  	//document.getElementById('menu'+i).style.fontWeight='bold';
  		document.getElementById('menu'+i).style.color="#0E963E";
		}
	}	
	anterior = i;
}
function blockingIntranet(i) {
	// si estamos intentando cerrar un padre, no deberķamos dejar hacerlo.
	if ( (anterior != i)&&(anterior!="") ){ // si el anterior es distinto al actual, lo abro, a no se que sea su padre.
		if  (anteriorabierto){
	  	document.getElementById('menu'+anterior).style.fontWeight="normal";
	  	document.getElementById('menu'+anterior).style.color="#000000";
		}
		blocking2( i );
  	document.getElementById('menu'+i).style.fontWeight='bold';
  	document.getElementById('menu'+i).style.color="#0E963E";
		anteriorabierto = true;
	}else{
		// si el anterior es el actual, lo abro o lo cierro.
		blocking2( i );

	}	
	anterior = i;
}

function blockingProgramasReserva(i) {
	// si estamos intentando cerrar un padre, no deberķamos dejar hacerlo.
	if ( (anterior != i)&&(anterior!="") ){ // si el anterior es distinto al actual, lo abro, a no se que sea su padre.
		if  (anteriorabierto){
	  	document.getElementById('number'+anterior).style.fontWeight="normal";
	  	document.getElementById('number'+anterior).style.color="#000000";
		}
		blocking2( i );
  	document.getElementById('number'+i).style.fontWeight='bold';
  	document.getElementById('number'+i).style.color="#0E963E";
		anteriorabierto = true;
	}else{
		// si el anterior es el actual, lo abro o lo cierro.
		blocking2( i );

	}	
	anterior = i;
}

function blockingTratamientosReserva(i) {
	// si estamos intentando cerrar un padre, no deberķamos dejar hacerlo.
	if ( (anterior != i)&&(anterior!="") ){ // si el anterior es distinto al actual, lo abro, a no se que sea su padre.
		if  (anteriorabierto){
	  	document.getElementById('number'+anterior).style.fontWeight="normal";
	  	document.getElementById('number'+anterior).style.color="#000000";
		}
		blocking2( i );
  	document.getElementById('number'+i).style.fontWeight='bold';
  	document.getElementById('number'+i).style.color="#0E963E";
		anteriorabierto = true;
	}else{
		// si el anterior es el actual, lo abro o lo cierro.
		blocking2( i );

	}	
	anterior = i;
}

function collapse(i) {
	current = 'none';
	if (document.getElementById) {
		if ( document.getElementById('number'+i) != null ){
			document.getElementById('number'+i).style.display = current;
		}
	} else if (document.all) {
		if ( document.all['number'+i] != null ){
			document.all['number'+i].style.display = current;
		}
	}
}

function blocking2(i) {
	if (!supported){
		alert('This link is a dummy.');
		return;
	}
	shown[i] = (shown[i]) ? false : true;
	current = (shown[i]) ? 'block' : 'none';
	contador = 0;
	if (document.getElementById) {
		if ( document.getElementById('number'+i) != null ){
			document.getElementById('number'+i).style.display = current;
			if ( document.getElementById('imagen'+i) != null ){
				if ( current == 'block' ){
					document.getElementById('imagen'+i).src = "../images/minusonly.png";
				}else{
					document.getElementById('imagen'+i).src = "../images/plusonly.png";
				}
			}
		}
	} else if (document.all) {
		if ( document.all['number'+i] != null ){
			document.all['number'+i].style.display = current;
		}
	}
}

function getElements(obj) {
 for (var i=0;i < obj.childNodes.length;i++)
  if (obj.childNodes[i].nodeType==1) // Elements only
    getElements(obj.childNodes[i])
}

function cerrarTodos() {
	if (!supported){
		alert('This link is a dummy.');
		return;
	}	
	current = 'none';
	for (i=0;i<document.forms[0].elements.length;i++){ 
		nombre = document.forms[0].elements[i].id;
		if ( nombre != ""){
			if ( nombre.indexOf(".") != -1 ) {
				nombres = nombre.split(".");
				// padre.nivel.contador
				nombre = nombres[0];
				/*
				if ( !isNAN(nombres[1]){
					nombre = nombre + '.' + nombres[1];
				}
				*/
			}
			if ( ( nombre.indexOf("check") == -1 ) ){
				//if ( ( nombre != anterior )&&(nombre != "")){
				if (nombre != ""){
					collapse( nombre );		
				}
			}
		}
	}
}
function blocking3(i) {
	if ( (anterior != i)&&(anterior!=0) ){
	// si el anterior es distinto al actual, lo abro.
		if  (anteriorabierto){
			blocking2( anterior );
	  	document.getElementoById('menu'+anterior).style.fontWeight='normal';
		}
		anteriorabierto = false;
	  document.getElementoById('menu'+i).style.fontWeight='bold';
	}else{
		anteriorabierto = false;
	}	
	anterior = i;
}

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

function CargaInicial (){
}
function targetBlank (url) {
  blankWin = window.open(url,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes');
}
function mostrarImagen( imagen, texto ){ 
	window.open("../galeria/index.php?imagen=" + imagen + "&texto=" + texto,"Imagen","width=290,height=400,scrollbars=YES,status=NO") 
} 
function mostrarFlash( flash ){ 
	window.open("../galeria/flash.php?flash=" + flash,"Flash","width=430,height=500,scrollbars=YES,status=NO") 
} 
function mostrarCondicionesContratacion( idioma ){ 
	window.open("../legal/condiciones.php?id_idioma=" + idioma ,"CondicionesContratacion","width=430,height=500,scrollbars=YES,status=NO") 
} 
function mostrarAvisoContacto( idioma ){ 
	window.open("../legal/contacto.php?id_idioma=" + idioma ,"AvisoContacto","width=430,height=500,scrollbars=YES,status=NO") 
} 
function mostrarAvisoOferta( idioma ){ 
	window.open("../legal/oferta.php?id_idioma=" + idioma ,"AvisoContacto","width=430,height=500,scrollbars=YES,status=NO") 
} 
function mostrarAvisoRegistrese( idioma ){ 
	window.open("../legal/registrese.php?id_idioma=" + idioma ,"AvisoContacto","width=430,height=500,scrollbars=YES,status=NO") 
} 

function targetBlank (url) {
  blankWin = window.open(url,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes');
}									

