//declaro variables globales...
var infowindow;
var map;
var numOfImgs = 0;
var mouseX = 0;
var mouseY = 0;
imgURL = new Array();
preloadImg = new Image();
//********************************************************************
// INICIO funciones jQuery (se cargan sólo si cargamos jQuery)
//********************************************************************
if (typeof jQuery != 'undefined') {//jQuery está cargado

    $(document).ready(function () {

        //if(jQuery().datepicker) {//datepicker está cargado
        if ($("#inpDatepickerIn").length > 0) {//existe el campo de fechas

            $("#inpDatepickerIn").datepicker({
                minDate: 0,
                maxDate: "+1Y",
                dateFormat: "D, d M yy",
                altField: $('input[id*="inpDatepickerInALT"]'),
                altFormat: "yymmdd",
                firstDay: 1,
                beforeShow: customRange,
                onClose: customRange
            });

            $("#inpDatepickerOut").datepicker({
                minDate: 1,
                maxDate: "+1Y+1M",
                dateFormat: "D, d M yy",
                altField: $('input[id*="inpDatepickerOutALT"]'),
                altFormat: "yymmdd",
                firstDay: 1,
                beforeShow: customRange,
                onClose: customRange
            });

            $('#inpDatepickerIn').datepicker('setDate', new Date($('input[id*="inpDatepickerInALT"]').val().substring(0, 4), parseInt($('input[id*="inpDatepickerInALT"]').val().substring(4, 6)) - 1, $('input[id*="inpDatepickerInALT"]').val().substring(6, 8)));
            $('#inpDatepickerOut').datepicker('setDate', new Date($('input[id*="inpDatepickerOutALT"]').val().substring(0, 4), parseInt($('input[id*="inpDatepickerOutALT"]').val().substring(4, 6)) - 1, $('input[id*="inpDatepickerOutALT"]').val().substring(6, 8)));

            $('img[id*="imgDatePickerIn"]').click(function () {
                if ($("#ui-datepicker-div").css("display") == "none") {
                    $("#inpDatepickerIn").datepicker("show");
                }
            });

            $('img[id*="imgDatePickerOut"]').click(function () {
                if ($("#ui-datepicker-div").css("display") == "none") {
                    $("#inpDatepickerOut").datepicker("show");
                }
            });

            $('#inpDatepickerIn,#inpDatepickerOut,select[id*="drpAdults"],[id*="drpKids"]').change(function () {
                blink('input[id*="btnBuscar"]');
            });

        }

        function blink(selector) {
            $(selector).animate({ color: "red" }, 800).delay(600).animate({ color: "black" }, 1000, function () {
                blink(this);
            });
        }

        function blinkWarning(selector) {
            $(selector).animate({ backgroundColor: "#fbeff9" }, 1000).delay(800).animate({ backgroundColor: "#ffd3ff" }, 1000, function () {
                blinkWarning(this);
            });
        }

        function customRange(input) {
            var newDateIn = new Date($('#inpDatepickerIn').datepicker("getDate"));
            var newDateInMin = new Date(newDateIn);
            newDateIn.setDate(newDateIn.getDate() + 3);
            newDateInMin.setDate(newDateInMin.getDate() + 1);
            $('#inpDatepickerOut').datepicker("option", "minDate", newDateInMin);
            if ($('#inpDatepickerOut').datepicker("getDate") <= $('#inpDatepickerIn').datepicker("getDate")) {
                $('#inpDatepickerOut').datepicker('setDate', newDateIn).datepicker("option", "minDate", newDateInMin);
            }
        }

        if ($("#jCarousel").length > 0) {
            $(function () {
                $("#jCarousel").jCarouselLite({
                    auto: 5000,
                    pause: true,
                    visible: 7,
                    scroll: 3
                });
            });
        }
        
        if ($("#accordion").length > 0) {
        	$("#accordion").accordion({ autoHeight: false });
        }

        $('a[href="#top"]').click(function (event) {
            event.preventDefault();
            $('html, body').animate({ scrollTop: 0 }, 'fast');
        });

        blinkWarning('#tblWarning');

        $('.jQcss[jQtag*="bookingOptionDIV_"]').click(function () {
            var thisLink = $(this);
            var divID = $('#' + $(this).attr('jQtag'));
            divID.slideToggle(function () {
                if (!divID.is(':visible')) {
                    updateSizeScrollBarPromo('resta', divID.outerHeight());
                }
                else {
                    updateSizeScrollBarPromo('suma', (divID.outerHeight() - thisLink.outerHeight()));
                }
            });
        });

        $('.jQcss[id*="ctlCalendar_imgMapZones"]').click(function () {
            $('#ctlCalendar_mapZonesIFrame').slideToggle(function () {
                if (!$('#ctlCalendar_mapZonesIFrame').is(':visible')) {
                    updateSizeScrollBarPromo('resta', $('#ctlCalendar_mapZonesIFrame').outerHeight());
                }
                else {
                    updateSizeScrollBarPromo('suma', $('#ctlCalendar_mapZonesIFrame').outerHeight());
                }
                $('.jQcss[id*="ctlCalendar_imgMapZones"]').toggle();
            });
        });

        $('#ctlMenu_ctlCalendar_chkCal_options').click(function () {
            $('#calSide_optionsDIV').slideToggle(function () {
                if ($('#scrollBarPromoDIV').size()) {
                    if (!$('#calSide_optionsDIV').is(':visible')) {
                        updateSizeScrollBarPromo('suma', $('#calSide_optionsDIV').outerHeight());
                    }
                    else {
                        updateSizeScrollBarPromo('resta', $('#calSide_optionsDIV').outerHeight());
                    }
                }
            });
        });

    });

}
//********************************************************************
// FIN funciones jQuery
//********************************************************************

//FUNCIÓN PARA UTILIZAR EN LOS ONLOAD()
function loader(){
	//------>>>añado el onmousemove para detectar la posición del mouse
    //document.body.onclick = getMouseXY;
	document.onmousemove=getMouseXY;
	//------>>>preload de imägenes de hoteles para ficha de establecimiento
	for (x=0; x<document.images.length; x++){
		if (document.images[x].id.indexOf('hotelIMG_')==0){
			imgURL[numOfImgs] = document.images[x].src.replace("S.jpg", ".jpg");
			numOfImgs++;
		}
	}
	for (x=0; x<imgURL.length; x++){
        preloadImg.src = imgURL[x];
	}
}
//FUNCIÓN PARA CREAR EL COOKIE CON LAS PREFERENCIAS DEL MAPA
function writeMapZonesCookie() {
    var mapOpened = 0;
    var latitude;
    var longitude;
    var mapLabels = 1;
    var mapType = new String();
    var cookieText = new String();
    var expDate = new Date();
    //si mapZonesDIV es esta abierto... Si está cerrado impongo latitude y longitude porque google no sabe calcularlo...
    if (parent.document.getElementById('ctlCalendar_mapZonesIFrame').style.display != 'none') {
        mapOpened = 1;
        latitude = map.getCenter().lat();
        longitude = map.getCenter().lng();
    }
    else {
        mapOpened = 0;
        latitude = 40.42916917593521;
        longitude = -3.7396646456298877;
    }

    if (document.getElementById('mapZonesBarDIV').style.display == "block") {
        mapLabels = 1;
    }
    else {
        mapLabels = 0;
    }
    cookieText = "mapZonesSettings=mapOpened=" + mapOpened + "&latitude=" + latitude + "&longitude=" + longitude + "&zoomFactor=" + map.getZoom() + "&mapType=google.maps.MapTypeId." + map.getMapTypeId().toUpperCase() + "&mapLabels=" + mapLabels;
    expDate.setDate(expDate.getDate() + 30);
    cookieText += ";expires=" + expDate.toGMTString();
    document.cookie = cookieText;
}
//función para obtener la posición del mouse. Las guardamos en mouseX y mouseY
function getMouseXY(e) {
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		mouseX = e.pageX;
		mouseY = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		mouseX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		mouseY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
}
//Función que resetea los combo select para el número de habitaciones. Necesario xq en FF al hacer reload o volver a la página conserva el último valor seleccionado. Lo uso en la ficha del establecimiento
function reseteaDrpNumHabit(){
	var elem = document.getElementById('Form1').elements;
	for(var i = 0; i < elem.length; i++)
	{
		if (elem[i].type=='select-one'){
			var elemID = elem[i].id;
			if (elemID.indexOf('dgrdTipoOcup__ctl')!=-1){
				document.getElementById(elemID).selectedIndex=0;
			}
		}
	} 
}
//Función para formatear los números de JS con coma o punto. La uso desde el JS que está dentro de dethotel.aspx
Number.prototype.formatMoney = function(c, d, t){
	var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
	return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};
//Función que cambia la altura del scroll bar y la modifica para IE
function fixScrollBarPromo(){
	document.getElementById('scrollBarPromoDIV').style.display = 'block';
	sniffBrowsers();
	if (ie){
		document.getElementById('scrollBarPromoDIV').style.overflow='auto';
		document.getElementById('scrollBarPromoDIV').style.overflowX='hidden';
		document.getElementById('scrollBarPromoDIV').style.scrollbar3dlightColor='#B9B9B9';
		document.getElementById('scrollBarPromoDIV').style.scrollbarArrowColor='#B9B9B9';
		document.getElementById('scrollBarPromoDIV').style.scrollbarShadowColor='#F3F3F3';
		document.getElementById('scrollBarPromoDIV').style.scrollbarTrackColor='#F3F3F3';//la parte de atras
		document.getElementById('scrollBarPromoDIV').style.scrollbarFaceColor='#EAEAEA';//la barra que movemos
		document.getElementById('scrollBarPromoDIV').style.scrollbarHighlightColor='#EAEAEA';
		document.getElementById('scrollBarPromoDIV').style.scrollbarDarkShadowColor='#B9B9B9';
	}
	else{
        if (mac_OSX){
            document.getElementById('scrollBarPromoDIV').style.overflow = 'auto';
            document.getElementById('scrollBarPromoDIV').style.overflowX = 'hidden';
        }
        else{
		document.getElementById('scrollBarPromoDIV').style.overflow='hidden';
        }
	}
	document.getElementById('scrollBarPromoDIV').style.height = ((getTopPosition(document.getElementById('tableFooter')) + document.getElementById('tableFooter').offsetHeight) -20 - getTopPosition(document.getElementById('scrollBarPromoDIV'))) + 'px';
	document.getElementById('scrollBarPromoDIV').style.visibility = 'visible';
}
//Función que cambia la altura del scroll bar
function updateSizeScrollBarPromo(operacion, variacion) {
	if (operacion=='suma'){
		document.getElementById('scrollBarPromoDIV').style.height = (document.getElementById('scrollBarPromoDIV').offsetHeight + variacion) + 'px';
	}
	else{
		document.getElementById('scrollBarPromoDIV').style.height = (document.getElementById('scrollBarPromoDIV').offsetHeight - variacion) + 'px';
	}
}
//función para leer el valor de una cookie
function readCookie(name){
	var cookieValue = "";
	var search = name + "=";
	if(document.cookie.length > 0){ 
		offset = document.cookie.indexOf(search);
		if (offset != -1){ 
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			cookieValue = unescape(document.cookie.substring(offset, end))
		}
	}
	return cookieValue;
}
//Función que utilizo para habilitar o deshabilitar categorías al pinchar en el checkbox del tipo de establecimiento
function disableCats(obj, chkToHide, num){
	var status = true;
	if (document.getElementById(obj).checked==true){
		status = false;
	}
	else{
		status = true;
	}
	for (i=0;i<=num;i++){
		document.getElementById(chkToHide + i).disabled=status;
	}	
}
//Esta función la creo para eliminar el disable de los checkboxes antes de enviar el formulario. Sino ASP.net no considera los valores de selección...
function disableCatsFix(chkToHide, num){
	for (i=0;i<=num;i++){
		document.getElementById(chkToHide + i).disabled=false;
	}
}
//Función que utilizo para validar el valor introducido en los campos del calendario de tarifas
function checkPrecio(obj) {
	var validValues = "0123456789";
	num = obj.value.toString();
	
	for (i=0;i<num.length;i++){
		ch = num.charAt(i);
		if (validValues.indexOf(ch)<0){
			document.getElementById(obj.id).value=document.getElementById(obj.id).defaultValue;
		}
	}
	if (parseInt(num)<=0){
		document.getElementById(obj.id).value=document.getElementById(obj.id).defaultValue;
	}
	if (document.getElementById(obj.id).value==''){
		document.getElementById(obj.id).value=document.getElementById(obj.id).defaultValue;
	}
	if (document.getElementById(obj.id).value!=document.getElementById(obj.id).defaultValue){
		if (document.getElementById('admin_dispoTarif_guardar').disabled==true){
			document.getElementById('lblError_DIV').style.display="none";
			blinkButton = setInterval("doBlink(document.getElementById('admin_dispoTarif_guardar'))",700);
			document.getElementById('admin_dispoTarif_guardar').disabled=false;
		}
	}
}
//Función que utilizo para validar el valor introducido en los campos del calendario de disponibilidad
function checkDisponibilidad(obj) {
	var validValues = "0123456789";
	num = obj.value.toString();
	
	for (i=0;i<num.length;i++){
		ch = num.charAt(i);
		if (validValues.indexOf(ch)<0){
			document.getElementById(obj.id).value=0;
		}
	}
	if (parseInt(num)>0){
		document.getElementById(obj.id).className='cal_available';
	}
	else {
		if (document.getElementById(obj.id).value=='00') document.getElementById(obj.id).value=0;
		document.getElementById(obj.id).className='cal_nonAvailable';
	}
	if (document.getElementById(obj.id).value==''){
		document.getElementById(obj.id).value=0;
	}
	if (document.getElementById('admin_dispoTarif_guardar').disabled==true){
		document.getElementById('lblError_DIV').style.display="none";
		document.getElementById('admin_dispoTarif_guardar').disabled=false;		
		blinkButton = setInterval("doBlink(document.getElementById('admin_dispoTarif_guardar'))",700);
	}
}
function doBlink(obj) {
	if (document.getElementById(obj.id).style.color!='red'){
		document.getElementById(obj.id).style.color='red';
	}
	else{
		document.getElementById(obj.id).style.color='black';
	}
}
//Función que utilizo en varios campos de texto para asegurar que el valor introducido es un número entero positivo
function onlyNumbersField(obj) {
	var doAlert = false;
	var validValues = "0123456789";
	num = obj.value.toString();
	
	for (i=0;i<num.length;i++){
		ch = num.charAt(i);
		if (validValues.indexOf(ch)<0){
			doAlert = true;
		}
	}
	if (doAlert==true || document.getElementById(obj.id).value==''){
		setTimeout("document.getElementById('" + obj.id + "').focus();", 10);
		alert("Introduzca un numero entero");
		document.getElementById(obj.id).value=document.getElementById(obj.id).defaultValue;
	}
}
//Función que utilizo en varios campos de texto para asegurar que el valor introducido es un número entero positivo. NO adminte 0
function onlyNumbersFieldNoCero(obj) {
	var doAlert = false;
	var validValues = "0123456789";
	num = obj.value.toString();
	
	for (i=0;i<num.length;i++){
		ch = num.charAt(i);
		if (validValues.indexOf(ch)<0){
			doAlert = true;
		}
	}
	if (doAlert==true || document.getElementById(obj.id).value=='' || document.getElementById(obj.id).value<=0){
		setTimeout("document.getElementById('" + obj.id + "').focus();", 10);
		alert("Introduzca un numero entero superior a cero");
		document.getElementById(obj.id).value=document.getElementById(obj.id).defaultValue;
	}
}
function disableButton(obj_01,stopBlink) {
	if (!stopBlink) var stopBlink = false;
	if (stopBlink==true){
		clearInterval(blinkButton);	
	}
	document.getElementById(obj_01.id).disabled=true;
}
function getMiddlePointX(obj) {
	var curleft = 0;
	var half = obj.offsetWidth/2;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	curleft = curleft + half;	
	return curleft;
}
function getLeftPosition(obj){
	var curleft = 0;
	if(obj.offsetParent)
		while(1) 
		{
		  curleft += obj.offsetLeft;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.x)
		curleft += obj.x;
	return curleft;
}
function getTopPosition(obj){
	var curtop = 0;
	if(obj.offsetParent)
		while(1)
		{
		  curtop += obj.offsetTop;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.y)
		curtop += obj.y;
	return curtop;
}
//FUNCIÓN QUE CAMBIA LAS IMÁGENES Y EL COLOR DEL BORDE
function imgChange(obj, doChange) {
	for (x=0; x<document.images.length; x++){
		if (document.images[x].id.indexOf('hotelIMG_')==0){
			document.images[x].className='imgBorder';
		}
	}
	document.images[obj.id].className='imgBorderRed';
	if (doChange == true){
		for (x=0; x<imgURL.length; x++){
			if (imgURL[x]==document.images[obj.id].src.replace("S.jpg", ".jpg")){
				document.images['hotelIMG'].src=imgURL[x];
			}
		}
	}
}
//FUNCIÓN PARA MOSTRAR/OCULTAR LAYERS
function showLayer(obj){
    if (obj.style.display == 'none') {
        obj.style.display = 'block';
    }
    else {
        obj.style.display = 'none';
    }
}
//FUNCIÓN PARA MOSTRAR/OCULTAR LAYERS
function toggleVisibility(obj){
    if (obj.style.visibility == 'hidden') {
        obj.style.visibility = 'visible';
    }
    else {
        obj.style.visibility = 'hidden';
    }
}
//FUNCIÓN PARA CAMBIAR class
function changeStyle(obj, fromClass, toClass) {
    if (obj.className == fromClass) {
        obj.className = toClass;
    }
    else {
        obj.className = fromClass;
    }
}
//FUNCIÓN PARA CAMBIAR visibilidad
function changeVisibility(obj, fromVisibility, toVisibility){
    if (obj.style.visibility == fromVisibility) {
        obj.style.visibility = toVisibility;
    }
    else {
        obj.style.visibility = fromVisibility;
    }
}
//FUNCIÓN cerrar la ventana abierta. La uso desde gMapWINDOW y gHotelMapWINDOW
function closeControl(controlDiv, map) {
	controlDiv.style.padding = "5px";
	
	var hintClose = new String();
	if (parent.frames.length > 0 ){
		hintClose = parent.fb.data.strings.hintClose;
	}
	
	var img=new Image();
	img.src="/images/cross.gif";
	img.style.width = "17px";
	img.style.height = "17px";
	
	var controlUI = document.createElement("DIV");
	controlUI.style.backgroundColor = "white";
	controlUI.style.border = "1px solid black";
	controlUI.style.cursor = "pointer";
	controlUI.style.width = "17px";
	controlUI.style.height = "17px";
	controlUI.title = hintClose;
	controlDiv.appendChild(controlUI);
	controlUI.appendChild(img);
  
	google.maps.event.addDomListener(controlUI, "click", function() {
		parent.fb.end();
	});
}
//FUNCIÓN PARA CREAR LOS MARCADORES
function createMarker(map, latlng, name, tagTitle, iconColor) {
	if (!iconColor){
		var marker = new google.maps.Marker({position: latlng, map: map, title: tagTitle});
	}
	else{
		//creo la sombra y los iconos de distintos colores
		var shadow = new google.maps.MarkerImage("/images/mm_20_shadow.png",
			new google.maps.Size(22,20),
			new google.maps.Point(0,0),
			new google.maps.Point(6,18));
			
		switch (iconColor){
			case "iconRed":
				var image = new google.maps.MarkerImage("/images/mm_20_red.png",
					new google.maps.Size(12,20),
					new google.maps.Point(0,0),
					new google.maps.Point(6,18));
				break;
			case "iconGreen":
				var image = new google.maps.MarkerImage("/images/mm_20_green.png",
					new google.maps.Size(12,20),
					new google.maps.Point(0,0),
					new google.maps.Point(6,18));
				break;
			case "iconYellow":
				var image = new google.maps.MarkerImage("/images/mm_20_orange.png",
					new google.maps.Size(12,20),
					new google.maps.Point(0,0),
					new google.maps.Point(6,18));
				break;
			case "iconBlue":
				var image = new google.maps.MarkerImage("/images/mm_20_blue.png",
					new google.maps.Size(12,20),
					new google.maps.Point(0,0),
					new google.maps.Point(6,18));
				break;
			case "iconBase":
				var image = new google.maps.MarkerImage("/images/mm_20_base.png",
					new google.maps.Size(14,8),
					new google.maps.Point(0,0),
					new google.maps.Point(7,4));
				shadow = null;
				break;
		}
		var shape = {
			coord: [1, 1, 1, 20, 18, 20, 18 , 1],
			type: "poly"
		};
		var marker = new google.maps.Marker({
			position: latlng,
			map: map,
			shadow: shadow,
			icon: image,
			title: tagTitle,
			shape: shape
		});
	}
      
	google.maps.event.addListener(marker, "click", function() {
		if (infowindow) infowindow.close();
		infowindow = new google.maps.InfoWindow({content: name});
		infowindow.open(map, marker);
	});
	google.maps.event.addListener(map, "click", function() {
		if (infowindow) infowindow.close();
	});
	return marker;
}
//función que utilizo en la ficha del hotel para ajustar el tamaño del DIV con la ficha del establecimiento y del mapa
function fixHotelFicha() {
    document.getElementById('hotelFichaDIV').style.height = (getTopPosition(document.getElementById('lnkDireccion')) - getTopPosition(document.getElementById('hotelFichaDIV'))) + 13 + 'px';
    document.getElementById('hotelMapIFrame').style.height = (getTopPosition(document.getElementById('streetMapIFrame')) - getTopPosition(document.getElementById('hotelFichaDIV'))) - 12 + 'px';
}
//función para mostrar planos de como llegar en los viajes de dia
function gDirectionsMap(language, fromHere, toHere) {

    var latitude = 40.418569904183;
    var longitude = -3.70224897120523;
    var latlng = new google.maps.LatLng(latitude, longitude);

    var directionsDisplay = new google.maps.DirectionsRenderer();
    var directionsService = new google.maps.DirectionsService();

    var request = {
        origin: fromHere,
        destination: toHere,
        travelMode: google.maps.DirectionsTravelMode.DRIVING
    };

    directionsService.route(request, function (response, status) {
        if (status == google.maps.DirectionsStatus.OK) {
            directionsDisplay.setDirections(response);
        }
    });

    //defino las opciones del mapa
    var myOptions = {
        zoom: 15,
        center: latlng,
        mapTypeControl: true,
        mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU },
        navigationControl: true,
        navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL },
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    //creo el mapa
    map = new google.maps.Map(document.getElementById("mapDIV"), myOptions);
    directionsDisplay.setMap(map);

}
function gMap(obj, language, markerTitle, latitude, longitud, zoomFactor, markerSet) {
    fb.start('/maps/gMap.html?language=' + language + '&markerTitle=' + markerTitle + '&latitude=' + latitude + '&longitud=' + longitud + '&zoomFactor=' + zoomFactor + '&markerSet=' + markerSet + '', ' width:400 height:300 scrolling:no doAnimations:true resizeDuration:1.5 overlayOpacity:0 padding:2 panelPadding:0 showClose:false boxLeft:' + (mouseX + 10) + ' boxTop:' + (mouseY - fb.getScroll().top));
}
//función que abre popup con plano de ubicación para direcciones
//aquí utilizo el markersGuia.xml que tiene los marcadores usados en la guía
function gMapWINDOW(language, markerTitle, latitude, longitud, zoomFactor, markerSet) {

    if (latitude == null || longitude == null) {
        latitude = 40.418569904183;
        longitude = -3.70224897120523;
    }

    var latlng = new google.maps.LatLng(latitude, longitude);

    //defino las opciones del mapa
    var myOptions = {
        zoom: zoomFactor,
        center: latlng,
        mapTypeControl: true,
        mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU },
        navigationControl: true,
        navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL },
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    //creo el mapa
    map = new google.maps.Map(document.getElementById("mapDIV"), myOptions);

    //creo y posiciono el closeControlDiv
    if (parent.frames.length > 0) {
        var closeControlDiv = document.createElement("DIV");
        var close = new closeControl(closeControlDiv, map);
        closeControlDiv.index = 0;
        map.controls[google.maps.ControlPosition.TOP_RIGHT].push(closeControlDiv);
    }

    if (markerSet != null) {
        //Leo los marcadores de markersGuia.xml
        downloadUrl("/markersGuia.xml", function (data) {
            var markers = data.documentElement.getElementsByTagName("marker");
            var inURL = new String();
            var outURL = new String();

            for (var i = 0; i < markers.length; i++) {
                var set = markers[i].getAttribute("set");
                if (set == markerSet) {
                    var address = markers[i].getAttribute("address");
                    var point = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
                    var placeName = new String();
                    var inURL = new String();
                    var outURL = new String();
                    var address = markers[i].getAttribute("address");
                    switch (language.toLowerCase()) {
                        case "sp":
                            placeName = markers[i].getAttribute("placeName_sp");
                            if (markers[i].getAttribute("URL_sp") != '') {
                                inURL = "<a href=" + markers[i].getAttribute("URL_sp") + " target='_parent'>";
                                outURL = "</a>";
                            }
                            break;
                        case "en":
                            placeName = markers[i].getAttribute("placeName_en");
                            if (markers[i].getAttribute("URL_en") != '') {
                                inURL = "<a href=" + markers[i].getAttribute("URL_en") + " target='_parent'>";
                                outURL = "</a>";
                            }
                            break;
                        case "fr":
                            placeName = markers[i].getAttribute("placeName_fr");
                            if (markers[i].getAttribute("URL_fr") != '') {
                                inURL = "<a href=" + markers[i].getAttribute("URL_fr") + " target='_parent'>";
                                outURL = "</a>";
                            }
                            break;
                        default:
                            placeName = markers[i].getAttribute("placeName_en");
                            if (markers[i].getAttribute("URL_en") != '') {
                                inURL = "<a href=" + markers[i].getAttribute("URL_en") + " target='_parent'>";
                                outURL = "</a>";
                            }
                    }
                    var markerTitle = "<b>" + inURL + placeName + outURL + "</b><br>" + address;
                    var marker = createMarker(map, point, markerTitle, placeName, null);
                }
            }
        });
    }
    else {
        if (markerTitle != null) {
            var markerTitle = markerTitle;
        }
        var marker = createMarker(map, latlng, markerTitle, markerTitle, null);
        marker.setAnimation(google.maps.Animation.DROP);
    }
}
function gHotelMap(obj, ID, language, popUp, zoomFactor) {
    fb.start('/maps/gHotelMap.html?ID=' + ID + '&language=' + language + '&popUp=' + popUp + '&zoomFactor=' + zoomFactor + '', ' width:400 height:300 scrolling:no doAnimations:true resizeDuration:1.5 overlayOpacity:0 padding:2 panelPadding:0 showClose:false boxLeft:' + (mouseX + 10) + ' boxTop:' + (mouseY - fb.getScroll().top));
}
//función que utilizo para mostrar los establecimientos en un google maps
function gHotelMapWINDOW(ID, language, popUp, zoomFactor) {

    popUp = eval(popUp);
    //Leo los marcadores de markersHotels.xml
    downloadUrl("/public/2009/markersHotels.xml", function (data) {
        //leo los establecimientos disponibles (del parent o del documento en cuentión) y añado el establecimiento actual a la lista de disponibles por si no lo estaba (xa asegurarme de q crea marcador...)
        var sEstabsConDispo = new String();
        if (parent.frames.length > 0) {
            sEstabsConDispo = parent.document.getElementById("ctlMenu_hddnEstabsConDispo").value + ID.substring(4) + ";";
        }
        else {
            sEstabsConDispo = document.getElementById("ctlMenu_hddnEstabsConDispo").value + ID.substring(4) + ";";
        }

        var markers = data.documentElement.getElementsByTagName("marker");
        var URL = new String();
        var latlng = new google.maps.LatLng(40.418569904183, -3.70224897120523);

        //defino las opciones del mapa
        var myOptions = {
            zoom: zoomFactor,
            center: latlng,
            mapTypeControl: true,
            mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU },
            navigationControl: true,
            navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL },
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        //creo el mapa
        map = new google.maps.Map(document.getElementById("mapDIV"), myOptions);
        
        //centro el mapa y creo la sombra...
        for (var i = 0; i < markers.length; i++) {
            var set = markers[i].getAttribute("set");
            if (markers[i].getAttribute("ID") == ID) {
                latlng = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
                //crea la sombra gris para el marker centrado del establecimiento en cuesti—n
                map.setCenter(latlng);
                var marker = createMarker(map, latlng, null, null, "iconBase");
            }
        }

        //creo los marcadores
        for (var i = 0; i < markers.length; i++) {
            var IDonlyNumber = markers[i].getAttribute("ID").substring(4);
            if (sEstabsConDispo.indexOf(IDonlyNumber) != -1) {//muestra sólo los marcadores para los establecimientos con disponibilidad...
                var set = markers[i].getAttribute("set");
                if (set == "hotel" || set == "hostal" || set == "apartahotel" || set == "apartamento") {
                    var point = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
                    var address = markers[i].getAttribute("address");
                    var tagTitle = new String();
                    var estabImg = new String();
                    switch (language.toLowerCase()) {
                        case "sp":
                            URL = "<a href=" + markers[i].getAttribute("URL_sp") + " target='_parent'>" + markers[i].getAttribute("placeName_sp") + "</a>";
                            tagTitle = markers[i].getAttribute("placeName_sp");
                            estabImg = "<br><a href=" + markers[i].getAttribute("URL_sp") + " target='_parent'><img src='/images/accommodation/" + IDonlyNumber + ".jpg' onMouseOver=this.className='imgBorderRed' onMouseOut=this.className='imgBorder' class='imgBorder' width='113' height='85' border='0' style='margin-top:5px'></a>";
                            break;
                        case "en":
                            URL = "<a href=" + markers[i].getAttribute("URL_en") + " target='_parent'>" + markers[i].getAttribute("placeName_en") + "</a>";
                            tagTitle = markers[i].getAttribute("placeName_en");
                            estabImg = "<br><a href=" + markers[i].getAttribute("URL_en") + " target='_parent'><img src='/images/accommodation/" + IDonlyNumber + ".jpg' onMouseOver=this.className='imgBorderRed' onMouseOut=this.className='imgBorder' class='imgBorder' width='113' height='85' border='0' style='margin-top:5px'></a>";
                            break;
                        case "fr":
                            URL = "<a href=" + markers[i].getAttribute("URL_fr") + " target='_parent'>" + markers[i].getAttribute("placeName_fr") + "</a>";
                            tagTitle = markers[i].getAttribute("placeName_fr");
                            estabImg = "<br><a href=" + markers[i].getAttribute("URL_fr") + " target='_parent'><img src='/images/accommodation/" + IDonlyNumber + ".jpg' onMouseOver=this.className='imgBorderRed' onMouseOut=this.className='imgBorder' class='imgBorder' width='113' height='85' border='0' style='margin-top:5px'></a>";
                            break;
                        default:
                            URL = "<a href=" + markers[i].getAttribute("URL_en") + " target='_parent'>" + markers[i].getAttribute("placeName_en") + "</a>";
                            tagTitle = markers[i].getAttribute("placeName_en");
                            estabImg = "<br><a href=" + markers[i].getAttribute("URL_en") + " target='_parent'><img src='/images/accommodation/" + IDonlyNumber + ".jpg' onMouseOver=this.className='imgBorderRed' onMouseOut=this.className='imgBorder' class='imgBorder' width='113' height='85' border='0' style='margin-top:5px'></a>";
                    }
                    var markerTitle = "<p align=left class=parrafoSaltoCeroPx><b>" + URL + "</b><br>" + address + estabImg + "</p>";
                    switch (set) {
                        case "hotel":
                            var marker = createMarker(map, point, markerTitle, tagTitle, "iconRed");
                            break;
                        case "hostal":
                            var marker = createMarker(map, point, markerTitle, tagTitle, "iconGreen");
                            break;
                        case "apartahotel":
                            var marker = createMarker(map, point, markerTitle, tagTitle, "iconYellow");
                            break;
                        case "apartamento":
                            var marker = createMarker(map, point, markerTitle, tagTitle, "iconBlue");
                            break;
                    }
                    //añado el bounce...
                    if (markers[i].getAttribute("ID") == ID) {
                        marker.setAnimation(google.maps.Animation.DROP);
                    }
                }
            }
        }

        //creo y posiciono el closeControlDiv
        if (popUp == true) {
            var closeControlDiv = document.createElement("DIV");
            var close = new closeControl(closeControlDiv, map);
            closeControlDiv.index = 0;
            map.controls[google.maps.ControlPosition.TOP_RIGHT].push(closeControlDiv);
        }
    });

}
//función que uso para imprimir el streetView en la ficha del hotel
function gStreetMap(latitude, longitude, language) {
    var streetViewLocation = new google.maps.LatLng(latitude, longitude);
    var nearestLatLng = null;
    var client = new google.maps.StreetViewService();
    client.getPanoramaByLocation(streetViewLocation, 200, function (result, status) {
        if (status == google.maps.StreetViewStatus.OK) {
            nearestLatLng = result.location.latLng;
            var panoramaOptions = {
                addressControl: false,
                position: nearestLatLng,
                pov: {
                    heading: -90,
                    pitch: 10,
                    zoom: 1
                }
            };
            var panorama = new google.maps.StreetViewPanorama(document.getElementById("mapDIV"), panoramaOptions);
        }
    });
}
//función para mostrar el plano con las zonas del mapa de Madrid
function gZonesMap(language) {

    //valores por defecto por si no hay cookie
    var mapOpened = 0;
    var latitude = 40.42916917593521;
    var longitude = -3.7396646456298877;
    var latlng = new google.maps.LatLng(latitude, longitude);
    var zoomFactor = 14;
    var mapType = "google.maps.MapTypeId.ROADMAP";
    var mapLabels = 1;
    var showPolys = 1;
    var polys = [];
    var labels = [];

    //leo valores del cookie mapZonesSettings
    if (document.cookie.length > 0) {
        if (document.cookie.indexOf('mapZonesSettings') != -1) {
            var mapZonesCookie = readCookie("mapZonesSettings");
            var bits = mapZonesCookie.split("&");
            for (var i = 0; i < bits.length; i++) {
                bits[i] = bits[i].substr(bits[i].indexOf("=") + 1);
            }
            mapOpened = parseInt(bits[0]);
            if (mapOpened == 1) {
                if (parent.document.getElementById('ctlCalendar_imgMapZonesClosed').style.display == 'block') {
                    showLayer(parent.document.getElementById('ctlCalendar_imgMapZonesClosed'));
                    showLayer(parent.document.getElementById('ctlCalendar_imgMapZonesOpened'));
                }
                parent.document.getElementById('ctlCalendar_mapZonesIFrame').style.display = 'block'
            }
            else {
                parent.document.getElementById('ctlCalendar_mapZonesIFrame').style.display = 'none'
            }
            latitude = parseFloat(bits[1]);
            longitude = parseFloat(bits[2]);
            latlng = new google.maps.LatLng(latitude, longitude);
            zoomFactor = parseInt(bits[3]);
            mapType = String(bits[4]);
            mapLabels = parseInt(bits[5]);
        }
    }

    //defino las opciones del mapa
    var myOptions = {
        zoom: zoomFactor,
        center: latlng,
        mapTypeControl: true,
        mapTypeControlOptions: { style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR },
        navigationControl: true,
        navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL },
        mapTypeId: eval(mapType)
    };

    //creo el mapa
    map = new google.maps.Map(document.getElementById("mapDIV"), myOptions);

    // === Creo los custom controles ===
    var controlDiv = document.createElement("DIV");
    var zoneDiv = document.createElement("DIV");
    var labelDiv = document.createElement("DIV");
    var side_bar_html = new String();
    var openlabelContainerTitle = new String();
    var openlabelContainerName = new String();

    switch (language.toLowerCase()) {
        case 'sp':
            openlabelContainerTitle = "Mostrar/ocultar listado de zonas";
            openlabelContainerName = "Zonas";
            break;
        case 'en':
            openlabelContainerTitle = "Show/hide Madrid zones list";
            openlabelContainerName = "Zones";
            break;
        case 'fr':
            openlabelContainerTitle = "Montrer/cacher la liste des zones";
            openlabelContainerName = "Zones";
            break;
        default:
            openlabelContainerTitle = "Show/hide Madrid zones list";
            openlabelContainerName = "Zones";
    }

    controlDiv.index = 0;
    controlDiv.style.marginRight = "5px";

    zoneDiv.id = "mapZonesBarOpenerDIV";
    zoneDiv.title = openlabelContainerTitle;
    zoneDiv.style.backgroundColor = "white";
    zoneDiv.style.border = "1px solid black";
    zoneDiv.style.height = "17px";
    zoneDiv.style.width = "70px";
    zoneDiv.style.fontSize = '12px';
    zoneDiv.style.cursor = "pointer";
    zoneDiv.innerHTML = "<TABLE border='0' width='100%' height='17' cellSpacing='0' cellPadding='0' align='center'><TR><TD style='padding-left:5px;'><b>" + openlabelContainerName + "</b></TD><TD align='right' valign='middle' style='padding-right:5px;'><IMG SRC='/images/mapZonesArrow.gif' WIDTH='11' HEIGHT='6' BORDER='0'></TD></TR></TABLE>";

    google.maps.event.addDomListener(zoneDiv, "click", function () {
        showLayer(document.getElementById('mapZonesBarDIV'));
        if (document.getElementById('mapZonesBarDIV').style.display == "block") {
            mapLabels = 1;
        }
        else {
            mapLabels = 0;
        }
    });

    labelDiv.id = "mapZonesBarDIV";
    labelDiv.style.position = "absolute";
    labelDiv.style.right = "0px";
    labelDiv.style.overflow = "auto";
    labelDiv.style.backgroundColor = "white";
    labelDiv.style.border = "1px solid black";
    labelDiv.style.height = "240px";
    labelDiv.style.width = "100px";
    labelDiv.style.fontSize = '11px';
    labelDiv.style.paddingLeft = "5px";
    if (mapLabels == 1) {
        labelDiv.style.display = "block";
    }
    else {
        labelDiv.style.display = "none";
    }
    //=====================	

    downloadUrl("/markersZones.xml", function (data) {

        // ========= proceso los polígonos ===========
        var zonas = data.documentElement.getElementsByTagName("zona");

        // leo todas las zonas
        for (var a = 0; a < zonas.length; a++) {
            // y los atributos de cada zona
            var label = zonas[a].getAttribute("name");
            var color = zonas[a].getAttribute("color");
            // leo cada punto del poly
            var points = zonas[a].getElementsByTagName("point");
            var pts = []; //cada uno de los puntos del poly
            var polyCenter = new google.maps.LatLngBounds(); //para calcular el centro del poly

            for (var i = 0; i < points.length; i++) {
                pts[i] = new google.maps.LatLng(parseFloat(points[i].getAttribute("lat")), parseFloat(points[i].getAttribute("lng")));
                //muestra los marcadores de los polys
                //var marker = createMarker(map, pts[i], null, null, "iconRed");
                polyCenter.extend(pts[i]);
            }

            // creo cada poly
            var poly = new google.maps.Polygon({
                paths: pts,
                strokeColor: "#000000",
                strokeOpacity: 0.2,
                strokeWeight: 2,
                fillColor: color,
                fillOpacity: 0.2,
                title: label,
                clickable: true
            });

            poly.setMap(map);

            side_bar_html += '<a href="javascript:map.panTo(new google.maps.LatLng(' + polyCenter.getCenter().lat() + ',' + polyCenter.getCenter().lng() + '));" class="grayDarkToRed" title="' + label + '">' + label + '<\/a><br>';


			//INICIO código para mostrar el tooltip debajo de los polys.
			function LatLngControl(map) {
			    this.ANCHOR_OFFSET_ = new google.maps.Point(8, 8);
			    this.node_ = this.createHtmlNode_();
			
			    // Add control to the map. Position is irrelevant.
			    map.controls[google.maps.ControlPosition.TOP].push(this.node_);
			    // Bind this OverlayView to the map so we can access MapCanvasProjection to convert LatLng to Point coordinates.
			    this.setMap(map);
			    // Register an MVC property to indicate whether this custom control is visible or hidden. Initially hide control until mouse is over map.
			    this.set('visible', false);
			}
			
			// Extend OverlayView so we can access MapCanvasProjection.
			LatLngControl.prototype = new google.maps.OverlayView();
			LatLngControl.prototype.draw = function () { };
			
			LatLngControl.prototype.createHtmlNode_ = function () {
			    var divNode = document.createElement('div');
			    divNode.id = 'latlng-control';
			    divNode.className = 'marcoToolTip';
			    divNode.index = 100;
			    return divNode;
			};
			
			LatLngControl.prototype.visible_changed = function () {
			    this.node_.style.display = this.get('visible') ? '' : 'none';
			};
			
			LatLngControl.prototype.updatePosition = function (latLng, tipTitle) {
			    var projection = this.getProjection();
			    var point = projection.fromLatLngToContainerPixel(latLng);
			
			    // Update control position to be anchored next to mouse position.
			    this.node_.style.left = point.x + this.ANCHOR_OFFSET_.x + 'px';
			    this.node_.style.top = point.y + this.ANCHOR_OFFSET_.y + 'px';
			
			    // Update control to display the tooltip
			    this.node_.innerHTML = tipTitle;
			};
			//FIN código para mostrar el tooltip debajo de los polys.



            // Create new control to display latlng and coordinates under mouse.
            var latLngControl = new LatLngControl(map);

            // Register event listeners
            google.maps.event.addListener(poly, 'mouseover', function () {
                this.setOptions({ fillOpacity: this.fillOpacity + 0.2 });
                latLngControl.set('visible', true);
                //console.log(this.title);
            });
            google.maps.event.addListener(poly, 'mouseout', function () {
                this.setOptions({ fillOpacity: this.fillOpacity - 0.2 });
                latLngControl.set('visible', false);
            });
            google.maps.event.addListener(poly, 'mousemove', function (mEvent) {
                latLngControl.updatePosition(mEvent.latLng, this.title);
            });
            google.maps.event.addListener(poly, "click", function () {
                if (infowindow) infowindow.close();
            });

        }

        labelDiv.innerHTML = side_bar_html;
    });

    controlDiv.appendChild(zoneDiv);
    controlDiv.appendChild(labelDiv);
    map.controls[google.maps.ControlPosition.RIGHT_TOP].push(controlDiv);

    //Leo los marcadores de markersHotels.xml
    downloadUrl("/public/2009/markersHotels.xml", function (data) {
        //leo los establecimientos disponibles
        var sEstabsConDispo = new String();
        if (parent.frames.length > 0) {
            sEstabsConDispo = parent.document.getElementById("ctlMenu_hddnEstabsConDispo").value;
        }
        else {
            sEstabsConDispo = document.getElementById("ctlMenu_hddnEstabsConDispo").value;
        }

        var markers = data.documentElement.getElementsByTagName("marker");
        var URL = new String();

        //creo los marcadores
        for (var i = 0; i < markers.length; i++) {
            var IDonlyNumber = markers[i].getAttribute("ID").substring(4);
            if (sEstabsConDispo.indexOf(IDonlyNumber) != -1) {//muestra sólo los marcadores para los establecimientos con disponibilidad...
                var set = markers[i].getAttribute("set");
                if (set == "hotel" || set == "hostal" || set == "apartahotel" || set == "apartamento") {
                    var point = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
                    var address = markers[i].getAttribute("address");
                    var tagTitle = new String();
                    var estabImg = new String();
                    switch (language.toLowerCase()) {
                        case "sp":
                            URL = "<a href=" + markers[i].getAttribute("URL_sp") + " target='_parent'>" + markers[i].getAttribute("placeName_sp") + "</a>";
                            tagTitle = markers[i].getAttribute("placeName_sp");
                            estabImg = "<br><a href=" + markers[i].getAttribute("URL_sp") + " target='_parent'><img src='/images/accommodation/" + IDonlyNumber + ".jpg' onMouseOver=this.className='imgBorderRed' onMouseOut=this.className='imgBorder' class='imgBorder' width='113' height='85' border='0' style='margin-top:5px'></a>";
                            break;
                        case "en":
                            URL = "<a href=" + markers[i].getAttribute("URL_en") + " target='_parent'>" + markers[i].getAttribute("placeName_en") + "</a>";
                            tagTitle = markers[i].getAttribute("placeName_en");
                            estabImg = "<br><a href=" + markers[i].getAttribute("URL_en") + " target='_parent'><img src='/images/accommodation/" + IDonlyNumber + ".jpg' onMouseOver=this.className='imgBorderRed' onMouseOut=this.className='imgBorder' class='imgBorder' width='113' height='85' border='0' style='margin-top:5px'></a>";
                            break;
                        case "fr":
                            URL = "<a href=" + markers[i].getAttribute("URL_fr") + " target='_parent'>" + markers[i].getAttribute("placeName_fr") + "</a>";
                            tagTitle = markers[i].getAttribute("placeName_fr");
                            estabImg = "<br><a href=" + markers[i].getAttribute("URL_fr") + " target='_parent'><img src='/images/accommodation/" + IDonlyNumber + ".jpg' onMouseOver=this.className='imgBorderRed' onMouseOut=this.className='imgBorder' class='imgBorder' width='113' height='85' border='0' style='margin-top:5px'></a>";
                            break;
                        default:
                            URL = "<a href=" + markers[i].getAttribute("URL_en") + " target='_parent'>" + markers[i].getAttribute("placeName_en") + "</a>";
                            tagTitle = markers[i].getAttribute("placeName_en");
                            estabImg = "<br><a href=" + markers[i].getAttribute("URL_en") + " target='_parent'><img src='/images/accommodation/" + IDonlyNumber + ".jpg' onMouseOver=this.className='imgBorderRed' onMouseOut=this.className='imgBorder' class='imgBorder' width='113' height='85' border='0' style='margin-top:5px'></a>";
                    }
                    var markerTitle = "<p align=left class=parrafoSaltoCeroPx><b>" + URL + "</b><br>" + address + estabImg + "</p>";
                    switch (set) {
                        case "hotel":
                            var marker = createMarker(map, point, markerTitle, tagTitle, "iconRed");
                            break;
                        case "hostal":
                            var marker = createMarker(map, point, markerTitle, tagTitle, "iconGreen");
                            break;
                        case "apartahotel":
                            var marker = createMarker(map, point, markerTitle, tagTitle, "iconYellow");
                            break;
                        case "apartamento":
                            var marker = createMarker(map, point, markerTitle, tagTitle, "iconBlue");
                            break;
                    }
                }
            }
        }
    });
}

//INICIO funciones para abrir archivos xml
/**
* Returns an XMLHttp instance to use for asynchronous
* downloading. This method will never throw an exception, but will
* return NULL if the browser does not support XmlHttp for any reason.
* @return {XMLHttpRequest|Null}
*/
function createXmlHttpRequest() {
 try {
   if (typeof ActiveXObject != 'undefined') {
     return new ActiveXObject('Microsoft.XMLHTTP');
   } else if (window["XMLHttpRequest"]) {
     return new XMLHttpRequest();
   }
 } catch (e) {
   changeStatus(e);
 }
 return null;
};

/**
* This functions wraps XMLHttpRequest open/send function.
* It lets you specify a URL and will call the callback if
* it gets a status code of 200.
* @param {String} url The URL to retrieve
* @param {Function} callback The function to call once retrieved.
*/
function downloadUrl(url, callback) {
 var status = -1;
 var request = createXmlHttpRequest();
 if (!request) {
   return false;
 }

 request.onreadystatechange = function() {
   if (request.readyState == 4) {
     try {
       status = request.status;
     } catch (e) {
       // Usually indicates request timed out in FF.
     }
     if (status == 200) {
       callback(request.responseXML, request.status);
       request.onreadystatechange = function() {};
     }
   }
 }
 request.open('GET', url, true);
 try {
   request.send(null);
 } catch (e) {
   changeStatus(e);
 }
};

/**
 * Parses the given XML string and returns the parsed document in a
 * DOM data structure. This function will return an empty DOM node if
 * XML parsing is not supported in this browser.
 * @param {string} str XML string.
 * @return {Element|Document} DOM.
 */
function xmlParse(str) {
  if (typeof ActiveXObject != 'undefined' && typeof GetObject != 'undefined') {
    var doc = new ActiveXObject('Microsoft.XMLDOM');
    doc.loadXML(str);
    return doc;
  }

  if (typeof DOMParser != 'undefined') {
    return (new DOMParser()).parseFromString(str, 'text/xml');
  }

  return createElement('div', null);
}

/**
 * Appends a JavaScript file to the page.
 * @param {string} url
 */
function downloadScript(url) {
  var script = document.createElement('script');
  script.src = url;
  document.body.appendChild(script);
}
//FIN funciones para abrir archivos xml

//********************************************************************
// Credit Card Number Validator Written By: Lokesh
//                                   Date : 04/08/2004
// Uses Linh mod-10 formula to determine the validity and then
// calls different functions to check what category the number belongs
// to.
//********************************************************************
var invalid = "Invalid";
//********************************************************************
// Check the Linh Mod-10 validity
function CheckCreditCardNum(num) {
    var len = num.length;
    var first;
    var sum = 0;
    var mul = 1;
    var i;
    var numAtI;
    var tempSum;
    var theway;
    var txtcard;
    theway = "";
    for (i = (len - 1); i >= 0; --i) {
        numAtI = parseInt(num.charAt(i));
        tempSum = numAtI * mul;
        theway += numAtI + " x " + mul + "=" + tempSum;
        if (tempSum > 9) {
            first = tempSum % 10;
            theway += " => " + 1 + " + " + first + "=";
            tempSum = 1 + first;
            theway += tempSum + " ";
        }
        theway += "\n";
        sum += tempSum;

        if (mul == 1)
            mul++;
        else
            mul--;
    }
    theway += "----------\nSum:   " + sum + "\n";
    //*********************************************************
    // Comment this line if you want to see the calculation
    theway = "";
    if (sum % 10) {
        if (len == 15) {
            txtcard = CheckFor15(num, 0);
            if (txtcard == invalid) {
                //alert("The number: "+ num +" is not valid!! ");
                return false;
            }
        }
        else {
            //alert("The number: "+ num +" is not valid!! ");
            return false;
        }

    }

    {
        switch (len) {
            case 13:
                txtcard = CheckFor13(num);
                break;
            case 14:
                txtcard = CheckFor14(num);
                break;
            case 15:
                txtcard = CheckFor15(num, 1);
                break;
            case 16:
                txtcard = CheckFor16(num);
                break;
            default:
                txtcard = invalid;
        }
        if (txtcard == invalid) {
            //alert("The number: "+ num +" is not valid!! ");
            return false;
        }
        else
            theway += "The number: " + num + " is valid!! \nand it looks like it is: " + txtcard;
    }
    //alert(theway);
    return true;
}

//***********************************************************************************
// Checks for Visa..
function CheckFor13(number) {
    if (parseInt(number.charAt(0)) == 4)
        return "Visa";
    return invalid;
}
//************************************************************************************
// Check for Diners Club
function CheckFor14(number) {
    if (parseInt(number.charAt(0)) != 3)
        return invalid;
    if ((parseInt(number.charAt(1)) == 6) || (parseInt(number.charAt(1)) == 8))
        return "Diners Club/Carte Blanche"
    if (!(parseInt(number.charAt(1))))
        if ((parseInt(number.charAt(2)) >= 0) && (parseInt(number.charAt(2)) <= 5))
            return "Diners Club/Carte Blanche"
        return invalid;
    }
    //************************************************************************************
    // Check for American Express, enRoute, JCB
    function CheckFor15(number, chec) {
        if ((number.charAt(0) == 3) && ((number.charAt(1) == 4) || (number.charAt(1) == 7)) && chec)
            return "American Express";
        var FirstFour = parseInt(number.charAt(0)) * 1000;
        FirstFour += parseInt(number.charAt(1)) * 100;
        FirstFour += parseInt(number.charAt(2)) * 10;
        FirstFour += parseInt(number.charAt(3));
        //alert(FirstFour);
        if ((FirstFour == 2014) || (FirstFour == 2149))
            return "enRoute";

        if (((FirstFour == 2131) || (FirstFour == 1800)) && chec)
            return "JCB";

        return invalid;
    }
    //************************************************************************************
    // Check for Visa, MasterCard, Discover or JCB
    function CheckFor16(number) {
        var a = parseInt(number.charAt(0));
        var b = parseInt(number.charAt(1));
        //alert (a);
        switch (a) {
            case 5:
                if ((b > 0) && (b < 6))
                    return "MasterCard";
                else
                    return invalid;
                break;
            case 4:
                return "Visa";
                break;
            case 6:
                if ((b == 0) && (parseInt(number.charAt(2)) == 1) && (parseInt(number.charAt(3)) == 1))
                    return "Discover";
                else
                    return invalid;
                break;
            case 3:
                return "JCB";
                break;
            default:
                return invalid;
                break;
        }
    }

/*
#########################################################################################333
#########################################################################################333
DESDE AQUÍ HASTA EL FINAL ESTÁ EL CÓDIGO NECESARIO PARA EL MENÚ LATERAL
http://www.aspandjavascript.co.uk/javascript/
#########################################################################################333
#########################################################################################333
*/
var ns4;
var op5;
var op6;
var agt;
var mac;
var ie;
var saf;
var mac_ie;
var mac_OSX;


function sniffBrowsers() {
	ns4 = document.layers;
	op5 = (navigator.userAgent.indexOf("Opera 5")!=-1) ||(navigator.userAgent.indexOf("Opera/5")!=-1);
	op6 = (navigator.userAgent.indexOf("Opera 6")!=-1) ||(navigator.userAgent.indexOf("Opera/6")!=-1);
	agt=navigator.userAgent.toLowerCase();
	mac = (agt.indexOf("mac")!=-1);
	ie = (agt.indexOf("msie") != -1);
	saf = (agt.indexOf("safari") != -1);
	mac_ie = mac && ie;
	mac_OSX = (navigator.appVersion.indexOf("Mac OS X 10_7") != -1) || (navigator.userAgent.indexOf("Mac OS X 10_8") != -1);
}
function getStyleObject(objectId, doc) {
    if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
		return getObjNN4(document,objectId);
    } else {
	return false;
    }
}
function changeObjectVisibility(objectId, newVisibility) {
    var styleObject = getStyleObject(objectId, document);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	return false;
    }
}
function findImage(name, doc) {
	var i, img;
	for (i = 0; i < doc.images.length; i++) {
    	if (doc.images[i].name == name) {
			return doc.images[i];
		}
	}
	for (i = 0; i < doc.layers.length; i++) {
    	if ((img = findImage(name, doc.layers[i].document)) != null) {
			img.container = doc.layers[i];
			return img;
    	}
	}
	return null;
}
function getImage(name) {
	if (document.layers) {
    	return findImage(name, document);
	}
	return null;
}
function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}
function getElementHeight(Elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.height;
	} else {
		var elem;
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		if (op5) {
			xPos = elem.style.pixelHeight;
		} else {
			xPos = elem.offsetHeight;
		}
		return xPos;
	} 
}
function getElementWidth(Elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.width;
	} else {
		var elem;
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		if (op5) {
			xPos = elem.style.pixelWidth;
		} else {
			xPos = elem.offsetWidth;
		}
		return xPos;
	}
}
function getElementLeft(Elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.pageX;
	} else {
		var elem;
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		xPos = elem.offsetLeft;
		tempEl = elem.offsetParent;
  		while (tempEl != null) {
  			xPos += tempEl.offsetLeft;
	  		tempEl = tempEl.offsetParent;
  		}
		return xPos;
	}
}
function getElementTop(Elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.pageY;
	} else {
		if(document.getElementById) {	
			var elem = document.getElementById(Elem);
		} else if (document.all) {
			var elem = document.all[Elem];
		}
		yPos = elem.offsetTop;
		tempEl = elem.offsetParent;
		while (tempEl != null) {
  			yPos += tempEl.offsetTop;
	  		tempEl = tempEl.offsetParent;
  		}
		return yPos;
	}
}
function getImageLeft(myImage) {
	var x, obj;
	if (document.layers) {
		var img = getImage(myImage);
    	if (img.container != null)
			return img.container.pageX + img.x;
		else
			return img.x;
  	} else {
		return getElementLeft(myImage);
	}
	return -1;
}
function getImageTop(myImage) {
	var y, obj;
	if (document.layers) {
		var img = getImage(myImage);
		if (img.container != null)
			return img.container.pageY + img.y;
		else
			return img.y;
	} else {
		return getElementTop(myImage);
	}
	return -1;
}
function getImageWidth(myImage) {
	var x, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.width;
	} else {
		return getElementWidth(myImage);
	}
	return -1;
}
function getImageHeight(myImage) {
	var y, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.height;
	} else {
		return getElementHeight(myImage);
	}
	return -1;
}
function moveXY(myObject, x, y) {
	obj = getStyleObject(myObject)
	if (ns4) {
		obj.top = y;
 		obj.left = x;
	} else {
		if (op5) {
			obj.pixelTop = y;
 			obj.pixelLeft = x;
		} else {
			obj.top = y + 'px';
 			obj.left = x + 'px';
		}	
	}
}
function changeClass(Elem, myClass) {
	var elem;
	if(document.getElementById) {
		var elem = document.getElementById(Elem);
	} else if (document.all){
		var elem = document.all[Elem];
	}
	if (op5 || op6) elem.style.className = myClass;
	else elem.className = myClass;
}
function changeBGColour(myObject, colour) {
	if (ns4) {
		var obj = getObjNN4(document, myObject);
		obj.bgColor=colour;
	} else {
		var obj = getStyleObject(myObject);
		if (op5) {
			obj.background = colour;	
		} else {
			obj.backgroundColor = colour;
		}	
	}
}
function changeImage(target, source) {
	var imageObj;
	
	if (ns4) {
		imageObj = getImage(target);
		if (imageObj) imageObj.src = eval(source).src; 
	} else {
		imageObj = eval('document.images.' + target);
		if (imageObj) imageObj.src = eval(source).src; 
	}
}

var timeOn = null;

var numMenus = 50;

var currentMenuNo = 0;
var menuActive = new Array(numMenus);
var tier = new Array(numMenus);
var borderMod = new Array(numMenus);
var offClass = new Array(numMenus);
var onClass = new Array(numMenus);
var offColours = new Array(numMenus);
var onColours = new Array(numMenus);
var labelBulletName = new Array(numMenus);
var menuType = new Array(numMenus);
var menus = new Array(numMenus);

function bulletPoint(offURL, onURL) {	
	this.offImage = new Image();
	this.offImage.src = offURL;
	this.onImage = new Image();
	this.onImage.src = onURL;
	this.URL = String(offURL);
}
function openMe(newin) {
        flyout=window.open(newin,"flyout","")
}
function borderCell(B) {
	return '<td width="1" bgcolor="' + B + '" style="width:1px;height:1px;"></td>';
}
function borderRow(B, C) {
	return '<tr><td height="1" colspan="' + C + '" bgcolor="' + B + '" style="width:1px;height:1px;"></td></tr>';
}
function menuOver() {
	clearTimeout(timeOn);
}
function menuOut() {
	timeOn = setTimeout("hideAllMenus()", 1000);
}
function showMenu(m_No, eventObj) {
	hideAllMenusTier(tier[m_No]-1);
	var borderModSize = borderMod[m_No];
	if (ns4) {
		changeBGColour('menuLabel' + m_No, onColours[m_No]);
	} else {
		changeBGColour('labelCell' + m_No, onColours[m_No]);
		changeClass('menuLink' + m_No, onClass[m_No]);
	}
	if (labelBulletName[m_No] != null){
		changeImage('menuBullet' + m_No, labelBulletName[m_No] + '.onImage');
	}
	menuActive[m_No] = true;
	if (menuType[m_No] != 'blank') {
		if (ns4) labelObj = 'menuLabel'+m_No;
		else labelObj = 'labelCell'+m_No;
		
		x = getElementLeft(labelObj)-borderModSize;
		y = getElementTop(labelObj) + getElementHeight(labelObj);

		if (menus[m_No].align == 'center')  x = x + ((getElementWidth(labelObj)-getElementWidth('menu'+m_No))/2);
		if (menus[m_No].align == 'right') x = x + ((getElementWidth(labelObj)-getElementWidth('menu'+m_No))) + (borderModSize*2);

		moveXY('menu' + m_No, x, y);

		if(changeObjectVisibility('menu' + m_No, 'visible')) return true;
    	else return false;
	}
}
function showMenuSide(m_No, eventObj, myTier) {
	hideAllMenusTier(tier[m_No]-1);
	var borderModSize = borderMod[m_No];
	if (ns4) {
		changeBGColour('menuLabel' + m_No, onColours[m_No]);
	} else {
		changeBGColour('labelCell' + m_No, onColours[m_No]);
		changeClass('menuLink' + m_No, onClass[m_No]);
	}
	if (labelBulletName[m_No] != null) changeImage('menuBullet' + m_No, labelBulletName[m_No] + '.onImage');
	menuActive[m_No] = true;
	if (menuType[m_No] != 'blank') {
		if (ns4) {
			labelObj = 'menuLabel'+m_No;
		} else {
			labelObj = 'labelCell'+m_No;
			if (mac_ie) labelObj = 'labelRow'+m_No;
		}
		x = getElementLeft(labelObj);
		y = getElementTop(labelObj) - borderModSize;

		if (menus[m_No].align=='right') x = x + getElementWidth(labelObj);
		else x = x - getElementWidth('menu'+m_No);

		moveXY('menu' + m_No, x, y);
	
		if(changeObjectVisibility('menu' + m_No, 'visible')) return true;
	    else return false;
	}
}
function hideAllMenus() {
	for (var i = 1; i < (currentMenuNo+1); i++) {
		if(menuActive[i] == true) hideMenu(i);
	}
}
function hideAllMenusTier(myTier) {
	for (var i = 1; i < (currentMenuNo+1); i++) {
		if( tier[i] > myTier && menuActive[i] == true) hideMenu(i);
	}
}
function hideMenu(m_No) {
	if (ns4) {
		changeBGColour('menuLabel' + m_No, offColours[m_No]);
	} else {
		changeBGColour('labelCell' + m_No, offColours[m_No]);
		changeClass('menuLink' + m_No, offClass[m_No]);
	}
	if (labelBulletName[m_No] != null){
		changeImage('menuBullet' + m_No, labelBulletName[m_No] + '.offImage');
	}
	menuActive[m_No] = false;
	
	if(changeObjectVisibility('menu' + m_No, 'hidden'))  return true;
    else return false;
}
function menuBar(barName, barWidth, orientation, i_Bor, o_Bor) {
	this.numLabels = 0;
	this.i_Bor = i_Bor;	
	this.o_Bor = o_Bor;	
	this.height = 16;
	this.orientation = orientation;
	this.labelText = new Array();
	this.rowText = new Array();
	this.offClass = 'MenuLabelLink';
	this.onClass = 'MenuLabelLinkOn';
	this.bulletAlign = 'right';
	this.targetType = 'self'; // self, iframe, frame, new
	this.targetFrame = '_self'; // _self, _blank or (i)frame name
	
	
	this.addLabel = function(bullet, labelText, menuNo, labelWidth, offColour, onColour, labelURL, align) {
		this.numLabels += 1;
		tier[menuNo] = 0;		
		if (this.o_Bor != null) borderMod[menuNo] = 1;	
		else borderMod[menuNo] = 0;	
		if (menuNo != null) {
			onColours[menuNo] = onColour;
			offColours[menuNo] = offColour;
			onClass[menuNo] = this.onClass;
			offClass[menuNo] = this.offClass;
			labelBulletName[menuNo] = bullet;
		}
		
		temp = new String('');
		this.rowText[this.numLabels] = new String('');
		if (this.orientation == 'vertical') this.rowText[this.numLabels] += '<tr id="labelRow'+ menuNo + '">';

		temp += '<td style="cursor:pointer;" id="labelCell' + menuNo + '" width="'+ labelWidth + '" bgcolor="' + offColour + '" valign="middle" height="' + this.height + '" ';
		
		if (!ns4) {
			temp += ' onmouseout="menuOut(); "onmouseover="menuOver(); ';
			if (this.orientation == 'vertical') temp += 'return !showMenuSide(' + menuNo + ', event, tier[' + menuNo + ']);" ';
			else temp += 'return !showMenu(' + menuNo + ', event);" ';
		} 		
		temp +='>';
		
		if (ns4) {
			temp +='<ilayer><layer onmouseout="menuOut();" onmouseover="menuOver(); ';
			if (this.orientation == 'vertical') temp +='return !showMenuSide(' + menuNo + ', event, tier[' + menuNo + ']);" ';
			else temp +='return !showMenu(' + menuNo + ', event);" ';
		} else {
			temp +='<div ';
		}
		
		//temp += ' class="myMenuLabel' + align + '" width="' + labelWidth + '"  id="menuLabel' + menuNo +'"><a href="' + labelURL +'" target="' + this.targetFrame + '" class="' + this.offClass + '" id="menuLink' + menuNo +'">';
		if (labelURL != null){
			temp += ' class="myMenuLabel' + align + '" width="' + labelWidth + '"  id="menuLabel' + menuNo +'"><a href="' + labelURL +'" target="' + this.targetFrame + '" class="' + this.offClass + '" id="menuLink' + menuNo +'">';
			if (bullet != null) temp += '<img src="' + eval(bullet + ".URL") + '" border="0" align="' + this.bulletAlign + '" class="labelBulletClass" id="menuBullet' + menuNo + '" name="menuBullet' + menuNo + '">';
			temp += labelText + '</a>';
		}
		else{
			temp += ' class="myMenuLabel' + align + '" width="' + labelWidth + '"  id="menuLabel' + menuNo +'"><a class="' + this.offClass + '" id="menuLink' + menuNo +'">';
			if (bullet != null) temp += '<img src="' + eval(bullet + ".URL") + '" border="0" align="' + this.bulletAlign + '" class="labelBulletClass" id="menuBullet' + menuNo + '" name="menuBullet' + menuNo + '">';
			temp += labelText + '</a>';
		}
		
		if (ns4) temp += '</layer></ilayer>';
		else temp += '</div>';
		
		temp += '</td>';		
		this.labelText[this.numLabels] = new String(temp);

	}
	
	this.writeMenuBar = function() {
		o_Bor = this.o_Bor;
		i_Bor = this.i_Bor;
		menuBarStr = new String();
		menuBarStr += '<div id="' + barName + '"><table border="0" cellpadding="0" cellspacing="0" >';
		if (this.orientation == 'vertical') {
			if (o_Bor != null) menuBarStr += borderRow(o_Bor, 3);
			for (var count = 0; count < this.numLabels; count++) {		
				menuBarStr += this.rowText[count+1];
				if (o_Bor != null) menuBarStr += borderCell(o_Bor);
				menuBarStr += this.labelText[count+1];
				if (o_Bor != null) menuBarStr += borderCell(o_Bor);				
				menuBarStr += '</tr>';
				if (i_Bor != null && count < (this.numLabels-1)) {
					if (o_Bor != null) menuBarStr += '<tr>' + borderCell(o_Bor) + borderCell(i_Bor) + borderCell(o_Bor) + '</tr>';
					else menuBarStr += borderRow(i_Bor, 1);
				}
			}
			if (o_Bor != null) menuBarStr += borderRow(o_Bor, 3);
		} else {
			if (o_Bor != null) {
				if (i_Bor != null) menuBarStr += borderRow(o_Bor, ((this.numLabels*2)+1));
				else menuBarStr += borderRow(o_Bor, (this.numLabels+2));
			}
			menuBarStr += '<tr>';
			if (o_Bor != null) menuBarStr += borderCell(o_Bor); 
			for (var count = 0; count < this.numLabels; count++) {		
				menuBarStr += this.rowText[count+1];			
				menuBarStr += this.labelText[count+1];
				if (i_Bor != null && count < (this.numLabels-1)) {
					menuBarStr += borderCell(i_Bor);
				}
			}
			if (o_Bor != null) {
				menuBarStr += borderCell(o_Bor);
				if (i_Bor != null) menuBarStr += borderRow(o_Bor, ((this.numLabels*2)+1));
				else menuBarStr += borderRow(o_Bor, (this.numLabels+2)); 
			}
			menuBarStr +=  '</tr>';
		}
		menuBarStr += '</table></div>';
		document.write(menuBarStr);
	}
}
function menu(menuWidth, orientation, i_Bor, o_Bor) {
	currentMenuNo += 1;
	this.numItems = 0;
	this.i_Bor = i_Bor;	
	this.o_Bor = o_Bor;	
	this.height = 16;
	this.itemText = new Array();
	this.rowText = new Array();
	this.align = 'left';
	this.offClass = 'MenuItemLink';
	this.onClass = 'MenuItemLinkOn';
	this.orientation = orientation;
	this.bulletAlign = 'right';
	this.targetType = 'self'; // self, iframe, frame, new
	this.targetFrame = '_self'; // _self, _blank or (i)frame name

	this.addItem = function(bullet, itemText, menuNo, itemWidth, offColour, onColour, itemURL, align) {
		this.numItems += 1;
		
		var tempId = currentMenuNo + '_' + this.numItems;
	
		if (menuNo != null) {
			tier[menuNo] = tier[currentMenuNo] + 1;
			onColours[menuNo] = onColour;
			offColours[menuNo] = offColour;
			onClass[menuNo] = this.onClass;
			offClass[menuNo] = this.offClass;
			labelBulletName[menuNo] = bullet;
			if (this.o_Bor != null) borderMod[menuNo] = 1;	
			else borderMod[menuNo] = 0;	
		}
		
		temp = new String('');
		this.rowText[this.numItems] = new String('');
		
		if (menuNo != null) {
			if (this.orientation =='vertical') this.rowText[this.numItems] += '<tr id="labelRow'+ menuNo + '">';
			temp += '<td id="labelCell'+ menuNo + '" width="'+ itemWidth + '" bgcolor="' + offColour + '" valign="middle" height="' + this.height + '" ';
		} else {
			if (this.orientation =='vertical') this.rowText[this.numItems] += '<tr>';
			temp += '<td id="itemCell' + tempId + '" width="'+ itemWidth + '" bgcolor="' + offColour + '" valign="middle" height="' + this.height + '" class="' + align + 'Menu"';
		}		
		if (!ns4) {
			if (menuNo != null) {			
				if (this.orientation =='vertical') temp += ' onmouseover="menuOver(); return !showMenuSide(' + menuNo + ', event, tier[' + menuNo + ']); " onmouseout=" menuOut(); "';
				else temp += ' onmouseover="menuOver(); return !showMenu(' + menuNo + ', event); " onmouseout=" menuOut(); "';
			} else {
				temp += ' onmouseover="changeClass(\'menuLink' + tempId + '\',\'' + this.onClass + '\'); hideAllMenusTier(tier[' + currentMenuNo + ']); menuOver();  changeBGColour(\'itemCell' + tempId + '\', \'' + onColour + '\'); changeImage(\'menuItemBullet' + tempId + '\', \'' + bullet + '.onImage\'); " onmouseout="menuOut(); changeClass(\'menuLink' + tempId + '\',\'' + this.offClass + '\'); changeBGColour(\'itemCell' + tempId + '\', \'' + offColour + '\'); changeImage(\'menuItemBullet' + tempId + '\', \'' + bullet + '.offImage\'); "';
			}
		} 
		temp += '>';
				
		if (ns4) {
			temp += '<ilayer><layer ';
			if(menuNo != null) { 
				if (this.orientation == 'vertical') temp += 'onmouseover="menuOver(); return !showMenuSide(' + menuNo + ', event, tier[' + menuNo + ']);" onmouseout="menuOut();"';
				else temp += 'onmouseover="menuOver(); return !showMenu(' + menuNo + ', event);" onmouseout="menuOut();"';
			} else {
				temp += 'onmouseover="hideAllMenusTier(tier[' + currentMenuNo + ']); menuOver(); changeBGColour(\'menuItem' + tempId + '\', \'' + onColour + '\'); changeImage(\'menuItemBullet' + tempId + '\', \'' + bullet + '.onImage\'); " onmouseout="menuOut(); changeBGColour(\'menuItem' + tempId + '\', \'' + offColour + '\'); changeImage(\'menuItemBullet' + tempId + '\', \'' + bullet + '.offImage\'); "';
			}
		} else {
			temp +='<div ';
		}
		temp += ' class="myMenuItem' + align + '" width="' + itemWidth + '"';
	
		if (menuNo != null) temp += ' id="menuLabel' + menuNo +'"';
		else temp += ' id="menuItem' + tempId +'"';
		
		temp += '><a href="' + itemURL +'" target="' + this.targetFrame + '" class="' + this.offClass + '"';
		if (menuNo != null) temp += 'id="menuLink' + menuNo +'"';
		else temp += 'id="menuLink' + tempId +'"';
		temp +='>';
		
		if (bullet != null) {
			if (menuNo != null) temp += '<img src="' + eval(bullet + ".URL") + '" border="0" align="' + this.bulletAlign + '" class="labelBulletClass" id="menuBullet' + menuNo + '" name="menuBullet' + menuNo + '">';
			else temp += '<img src="' + eval(bullet + ".URL") + '" border="0" align="' + this.bulletAlign + '" class="labelBulletClass" id="menuItemBullet' + tempId + '" name="menuItemBullet' + tempId + '">';
		}
			
		temp += itemText + '</a>';
		
		if (ns4) temp += '</layer></ilayer>';
		else temp += '</div>';

		temp += '</td>';	
		this.itemText[this.numItems] = new String(temp);
	}
	
	this.writeMenu = function() {
		var menuStr = new String();
		o_Bor = this.o_Bor;
		i_Bor = this.i_Bor;
		if (this.numItems == 0) menuType[currentMenuNo] = 'blank';
		else menuType[currentMenuNo] = 'default';
		menuStr += '<div id="menu' + currentMenuNo + '" name="menu' + currentMenuNo + '" class="myMenu" width="' + menuWidth + '"';
		if (!ns4) menuStr += ' style="width:' + menuWidth + 'px;"';
		menuStr+= '><table border="0" cellpadding="0" cellspacing="0" width="' + menuWidth + '">';
		if (this.orientation == 'vertical') {
			if (o_Bor != null) menuStr += borderRow(this.o_Bor, 3);
			for (var count = 0; count < this.numItems; count++) {
				menuStr += this.rowText[count+1];
				if (o_Bor != null) menuStr += borderCell(o_Bor);
				menuStr += this.itemText[count+1];
				if (o_Bor != null) menuStr += borderCell(o_Bor);
				menuStr += '</tr>';
				if (i_Bor != null && count < (this.numItems-1)) {
					if (o_Bor != null) menuStr += '<tr>' + borderCell(o_Bor) + borderCell(i_Bor) + borderCell(o_Bor) + '</tr>';
					else menuStr += borderRow(i_Bor, 1);
				}
			}
			if (o_Bor != null) menuStr += borderRow(o_Bor, 3);
		} else {
			if (o_Bor != null) {
				if (i_Bor != null) menuStr += borderRow(o_Bor, ((this.numItems*2)+1));
				else menuStr += borderRow(o_Bor, (this.numItems+2));
			}
			menuStr += '<tr>';
			if (o_Bor != null) menuStr += borderCell(o_Bor); 
			for (var count = 0; count < this.numItems; count++) {		
				menuStr += this.rowText[count+1];			
				menuStr += this.itemText[count+1];
				if (i_Bor != null && count < (this.numItems-1)) {
					menuStr += borderCell(i_Bor);
				}
			}
			if (o_Bor != null) {
				menuStr += borderCell(o_Bor);
				if (i_Bor != null) menuStr += borderRow(o_Bor, ((this.numItems*2)+1));
				else menuStr += borderRow(o_Bor, (this.numItems+2)); 
			}
			menuStr +=  '</tr>';
		}
		menuStr += '</table></div>';
		document.write(menuStr);
	}
}
function doMenu(){
	sniffBrowsers();
	
	menuItemBullet = new bulletPoint("/images/arrowBlack.gif","/images/arrowRed.gif");
	labelBullet = new bulletPoint("/images/arrowBlack.gif","/images/arrowRed.gif");
	subMenuBullet = new bulletPoint("/images/arrowBlack.gif","/images/arrowRed.gif");
	
	menu_SP = new menuBar(null,135, 'vertical', '#ffffff', null);
	menu_SP.addLabel('labelBullet', 'Informaci&oacute;n b&aacute;sica', 1, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_SP.addLabel('labelBullet', 'Alojamiento', 2, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_SP.addLabel('labelBullet', 'Transporte', 3, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_SP.addLabel('labelBullet', 'Entretenimiento', 4, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_SP.addLabel('labelBullet', 'Museos', 5, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_SP.addLabel('labelBullet', 'Gays y lesbianas', 6, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_SP.addLabel('labelBullet', 'Viajes de d&iacute;a', 8, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_SP.addLabel('labelBullet', 'Comercio', 9, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_SP.height = 16;
	
	menu_EN = new menuBar(null,135, 'vertical', '#ffffff', null);
	menu_EN.addLabel('labelBullet', 'Basic information', 11, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_EN.addLabel('labelBullet', 'Accommodation', 12, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_EN.addLabel('labelBullet', 'Transport', 13, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_EN.addLabel('labelBullet', 'Entertainment', 14, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_EN.addLabel('labelBullet', 'Museums', 15, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_EN.addLabel('labelBullet', 'Gay & lesbian', 16, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_EN.addLabel('labelBullet', 'Day trips', 18, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_EN.addLabel('labelBullet', 'Shopping', 19, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_EN.height = 16;

	menu_FR = new menuBar(null,135, 'vertical', '#ffffff', null);
	menu_FR.addLabel('labelBullet', 'Info essentielle', 21, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_FR.addLabel('labelBullet', 'Logement', 22, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_FR.addLabel('labelBullet', 'Transport', 23, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_FR.addLabel('labelBullet', 'Amusement', 24, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_FR.addLabel('labelBullet', 'Mus&eacute;es', 25, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_FR.addLabel('labelBullet', 'Gays et lesbiennes', 26, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_FR.addLabel('labelBullet', 'Excursions', 28, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_FR.addLabel('labelBullet', 'Commerce', 29, 133, '#ffffff', '#EAEAEA', null, 'left');
	menu_FR.height = 16;
			
	menus[1] = new menu(152, 'vertical', '#CCCCCC', '#999999');
	menus[1].height = 16;
	menus[1].addItem(null, 'Historia', null, 150, '#ffffff', '#EAEAEA', '/sp/informacion/madrid-historia.aspx', 'left');
	menus[1].addItem(null, 'Clima', null, 150, '#ffffff', '#EAEAEA', '/sp/informacion/madrid-clima.aspx', 'left');
	menus[1].addItem(null, 'Seguridad', null, 150, '#ffffff', '#EAEAEA', '/sp/informacion/madrid-seguridad.aspx', 'left');
	menus[1].addItem(null, 'Tel&eacute;fonos de inter&eacute;s', null, 150, '#ffffff', '#EAEAEA', '/sp/informacion/madrid-telefonos.aspx', 'left');
	menus[1].addItem(null, 'Informaci&oacute;n tur&iacute;stica', null, 150, '#ffffff', '#EAEAEA', '/sp/informacion/madrid-info-turismo.aspx', 'left');
	menus[1].writeMenu();
	
	menus[2] = new menu(132, 'vertical', '#CCCCCC', '#999999');
	menus[2].height = 16;
	menus[2].addItem(null, 'Hoteles', null, 130, '#ffffff', '#EAEAEA', '/sp/alojamiento/madrid-hoteles.aspx', 'left');
	menus[2].addItem(null, 'Hostales', null, 130, '#ffffff', '#EAEAEA', '/sp/alojamiento/madrid-hostales.aspx', 'left');
	menus[2].addItem(null, 'Apartamentos', null, 130, '#ffffff', '#EAEAEA', '/sp/alojamiento/madrid-apartamentos.aspx', 'left');
	menus[2].addItem(null, 'Apartahoteles', null, 130, '#ffffff', '#EAEAEA', '/sp/alojamiento/madrid-apartahoteles.aspx', 'left');
	menus[2].addItem(null, 'Alojamiento - Todo', null, 130, '#ffffff', '#EAEAEA', '/sp/alojamiento/madrid-hoteles-info.aspx', 'left');
	menus[2].writeMenu();
	
	menus[3] = new menu(192, 'vertical', '#CCCCCC', '#999999');
	menus[3].height = 16;
	menus[3].addItem('labelBullet', 'Llegar y salir de Madrid', 10, 190, '#ffffff', '#EAEAEA', '/sp/transporte/madrid-llegar.aspx', 'left');
	menus[3].addItem(null, 'Moverse por Madrid', null, 190, '#ffffff', '#EAEAEA', '/sp/transporte/madrid-moverse.aspx', 'left');
	menus[3].addItem(null, 'Plano del Metro', null, 190, '#ffffff', '#EAEAEA', '/sp/transporte/madrid-plano-metro.aspx', 'left');
	menus[3].addItem(null, 'Plano de trenes de cercan&iacute;as', null, 190, '#ffffff', '#EAEAEA', '/sp/transporte/madrid-plano-cercanias.aspx', 'left');
	menus[3].writeMenu();
	
	menus[4] = new menu(192, 'vertical', '#CCCCCC', '#999999');
	menus[4].height = 16;
	menus[4].addItem(null, 'Restaurantes con espect&aacute;culo', null, 190, '#ffffff', '#EAEAEA', '/sp/entretenimiento/madrid-restaurantes-espectaculo.aspx', 'left');
	menus[4].addItem(null, 'Flamenco', null, 190, '#ffffff', '#EAEAEA', '/sp/entretenimiento/madrid-flamenco.aspx', 'left');
	menus[4].addItem(null, 'Toros', null, 190, '#ffffff', '#EAEAEA', '/sp/entretenimiento/madrid-toros.aspx', 'left');
	menus[4].addItem(null, 'F&uacute;tbol', null, 190, '#ffffff', '#EAEAEA', '/sp/entretenimiento/madrid-futbol.aspx', 'left');
	menus[4].addItem(null, 'M&uacute;sica', null, 190, '#ffffff', '#EAEAEA', '/sp/entretenimiento/madrid-musica.aspx', 'left');
	menus[4].addItem(null, 'Opera, teatro y espect&aacute;culos', null, 190, '#ffffff', '#EAEAEA', '/sp/entretenimiento/madrid-espectaculos.aspx', 'left');
	menus[4].addItem(null, 'Cine', null, 190, '#ffffff', '#EAEAEA', '/sp/entretenimiento/madrid-cine.aspx', 'left');
	menus[4].addItem(null, 'Vida nocturna', null, 190, '#ffffff', '#EAEAEA', '/sp/entretenimiento/madrid-noche.aspx', 'left');
	menus[4].addItem(null, 'Ocio con ni&ntilde;os', null, 190, '#ffffff', '#EAEAEA', '/sp/entretenimiento/madrid-infantil.aspx', 'left');
	menus[4].writeMenu();
	
	menus[5] = new menu(152, 'vertical', '#CCCCCC', '#999999');
	menus[5].height = 16;
	menus[5].addItem(null, 'Museo del Prado', null, 150, '#ffffff', '#EAEAEA', '/sp/museos/madrid-museo-prado.aspx', 'left');
	menus[5].addItem(null, 'Museo Thyssen', null, 150, '#ffffff', '#EAEAEA', '/sp/museos/madrid-museo-thyssen.aspx', 'left');
	menus[5].addItem(null, 'Museo Reina Sof&iacute;a', null, 150, '#ffffff', '#EAEAEA', '/sp/museos/madrid-museo-reina-sofia.aspx', 'left');
	menus[5].addItem(null, 'Otros museos', null, 150, '#ffffff', '#EAEAEA', '/sp/museos/madrid-museos.aspx', 'left');
	menus[5].addItem(null, 'Galer&iacute;as y fundaciones', null, 150, '#ffffff', '#EAEAEA', '/sp/museos/madrid-galerias-fundaciones-arte.aspx', 'left');
	menus[5].writeMenu();
	
	menus[6] = new menu(142, 'vertical', '#CCCCCC', '#999999');
	menus[6].height = 16;
	menus[6].addItem(null, 'Chueca', null, 140, '#ffffff', '#EAEAEA', '/sp/gays-lesbianas/madrid-chueca-gay.aspx', 'left');
	menus[6].addItem(null, 'Bares y restaurantes', null, 140, '#ffffff', '#EAEAEA', '/sp/gays-lesbianas/madrid-bares-restaurantes-gay.aspx', 'left');
	menus[6].addItem(null, 'Comercios', null, 140, '#ffffff', '#EAEAEA', '/sp/gays-lesbianas/madrid-comercios-gay.aspx', 'left');
	menus[6].writeMenu();
	
	menus[7] = new menu(162, 'vertical', '#CCCCCC', '#999999');
	menus[7].height = 16;
	menus[7].addItem(null, 'Madrid de los Austrias', null, 160, '#ffffff', '#EAEAEA', '', 'left');
	menus[7].writeMenu();
	
	menus[8] = new menu(162, 'vertical', '#CCCCCC', '#999999');
	menus[8].height = 16;
	menus[8].addItem(null, 'Toledo', null, 160, '#ffffff', '#EAEAEA', '/sp/viajes/madrid-toledo.aspx', 'left');
	menus[8].addItem(null, 'Segovia', null, 160, '#ffffff', '#EAEAEA', '/sp/viajes/madrid-segovia.aspx', 'left');
	menus[8].addItem(null, 'San Lorenzo del Escorial', null, 160, '#ffffff', '#EAEAEA', '/sp/viajes/madrid-escorial.aspx', 'left');
	menus[8].addItem(null, 'Aranjuez', null, 160, '#ffffff', '#EAEAEA', '/sp/viajes/madrid-aranjuez.aspx', 'left');
	menus[8].addItem(null, 'Chinch&oacute;n', null, 160, '#ffffff', '#EAEAEA', '/sp/viajes/madrid-chinchon.aspx', 'left');
	menus[8].writeMenu();
	
	menus[9] = new menu(142, 'vertical', '#CCCCCC', '#999999');
	menus[9].height = 16;
	menus[9].addItem(null, 'Tiendas y mercados', null, 140, '#ffffff', '#EAEAEA', '/sp/comercio/madrid-tiendas.aspx', 'left');
	menus[9].addItem(null, 'Centros comerciales', null, 140, '#ffffff', '#EAEAEA', '/sp/comercio/madrid-centros-comerciales.aspx', 'left');
	menus[9].addItem(null, 'Rastro', null, 140, '#ffffff', '#EAEAEA', '/sp/comercio/madrid-rastro.aspx', 'left');
	menus[9].writeMenu();
	
	menus[10] = new menu(82, 'vertical', '#CCCCCC', '#999999');
	menus[10].height = 16;
	menus[10].addItem(null, 'Avi&oacute;n', null, 80, '#ffffff', '#EAEAEA', '/sp/transporte/madrid-llegar/avion.aspx', 'left');
	menus[10].addItem(null, 'Tren', null, 80, '#ffffff', '#EAEAEA', '/sp/transporte/madrid-llegar/tren.aspx', 'left');
	menus[10].addItem(null, 'Autob&uacute;s', null, 80, '#ffffff', '#EAEAEA', '/sp/transporte/madrid-llegar/autobus.aspx', 'left');
	menus[10].addItem(null, 'Carretera', null, 80, '#ffffff', '#EAEAEA', '/sp/transporte/madrid-llegar/carretera.aspx', 'left');
	menus[10].writeMenu();
	
	menus[11] = new menu(152, 'vertical', '#CCCCCC', '#999999');
	menus[11].height = 16;
	menus[11].addItem(null, 'History', null, 150, '#ffffff', '#EAEAEA', '/en/information/madrid-history.aspx', 'left');
	menus[11].addItem(null, 'Weather', null, 150, '#ffffff', '#EAEAEA', '/en/information/madrid-weather.aspx', 'left');
	menus[11].addItem(null, 'Safety', null, 150, '#ffffff', '#EAEAEA', '/en/information/madrid-safety.aspx', 'left');
	menus[11].addItem(null, 'Useful numbers', null, 150, '#ffffff', '#EAEAEA', '/en/information/madrid-telephones.aspx', 'left');
	menus[11].addItem(null, 'Tourist information', null, 150, '#ffffff', '#EAEAEA', '/en/information/madrid-tourist-info.aspx', 'left');
	menus[11].writeMenu();
	
	menus[12] = new menu(142, 'vertical', '#CCCCCC', '#999999');
	menus[12].height = 16;
	menus[12].addItem(null, 'Hotels', null, 140, '#ffffff', '#EAEAEA', '/en/accommodation/madrid-hotels.aspx', 'left');
	menus[12].addItem(null, 'Hostels', null, 140, '#ffffff', '#EAEAEA', '/en/accommodation/madrid-hostels.aspx', 'left');
	menus[12].addItem(null, 'Apartments', null, 140, '#ffffff', '#EAEAEA', '/en/accommodation/madrid-apartments.aspx', 'left');
	menus[12].addItem(null, 'Aparthotels', null, 140, '#ffffff', '#EAEAEA', '/en/accommodation/madrid-aparthotels.aspx', 'left');
	menus[12].addItem(null, 'Accommodation - All', null, 140, '#ffffff', '#EAEAEA', '/en/accommodation/madrid-hotels-info.aspx', 'left');
	menus[12].writeMenu();
	
	menus[13] = new menu(202, 'vertical', '#CCCCCC', '#999999');
	menus[13].height = 16;
	menus[13].addItem('labelBullet', 'Arriving & departing', 20, 200, '#ffffff', '#EAEAEA', '/en/transport/madrid-arriving.aspx', 'left');
	menus[13].addItem(null, 'Moving around', null, 200, '#ffffff', '#EAEAEA', '/en/transport/madrid-moving-around.aspx', 'left');
	menus[13].addItem(null, 'Madrid Subway (Metro) map', null, 200, '#ffffff', '#EAEAEA', '/en/transport/madrid-subway-map.aspx', 'left');
	menus[13].addItem(null, 'Madrid trains (Cercan&iacute;as) map', null, 200, '#ffffff', '#EAEAEA', '/en/transport/madrid-trains-map.aspx', 'left');
	menus[13].writeMenu();
	
	menus[14] = new menu(172, 'vertical', '#CCCCCC', '#999999');
	menus[14].height = 16;
	menus[14].addItem(null, 'Dinner with show', null, 170, '#ffffff', '#EAEAEA', '/en/entertainment/madrid-dinner-show.aspx', 'left');
	menus[14].addItem(null, 'Flamenco', null, 170, '#ffffff', '#EAEAEA', '/en/entertainment/madrid-flamenco.aspx', 'left');
	menus[14].addItem(null, 'Bullfighting', null, 170, '#ffffff', '#EAEAEA', '/en/entertainment/madrid-bullfighting.aspx', 'left');
	menus[14].addItem(null, 'Soccer', null, 170, '#ffffff', '#EAEAEA', '/en/entertainment/madrid-soccer.aspx', 'left');
	menus[14].addItem(null, 'Music', null, 170, '#ffffff', '#EAEAEA', '/en/entertainment/madrid-music.aspx', 'left');
	menus[14].addItem(null, 'Opera, theatre & shows', null, 170, '#ffffff', '#EAEAEA', '/en/entertainment/madrid-shows.aspx', 'left');
	menus[14].addItem(null, 'Cinema', null, 170, '#ffffff', '#EAEAEA', '/en/entertainment/madrid-cinema.aspx', 'left');
	menus[14].addItem(null, 'Nightlife', null, 170, '#ffffff', '#EAEAEA', '/en/entertainment/madrid-nightlife.aspx', 'left');
	menus[14].addItem(null, 'Children&#39;s entertainment', null, 170, '#ffffff', '#EAEAEA', '/en/entertainment/madrid-children.aspx', 'left');
	menus[14].writeMenu();
	
	menus[15] = new menu(162, 'vertical', '#CCCCCC', '#999999');
	menus[15].height = 16;
	menus[15].addItem(null, 'Prado Museum', null, 160, '#ffffff', '#EAEAEA', '/en/museums/madrid-prado-museum.aspx', 'left');
	menus[15].addItem(null, 'Thyssen Museum', null, 160, '#ffffff', '#EAEAEA', '/en/museums/madrid-thyssen-museum.aspx', 'left');
	menus[15].addItem(null, 'Reina Sof&iacute;a Museum', null, 160, '#ffffff', '#EAEAEA', '/en/museums/madrid-reina-sofia-museum.aspx', 'left');
	menus[15].addItem(null, 'Other museums', null, 160, '#ffffff', '#EAEAEA', '/en/museums/madrid-museums.aspx', 'left');
	menus[15].addItem(null, 'Galleries & foundations', null, 160, '#ffffff', '#EAEAEA', '/en/museums/madrid-art-galleries-foundations.aspx', 'left');
	menus[15].writeMenu();
	
	menus[16] = new menu(142, 'vertical', '#CCCCCC', '#999999');
	menus[16].height = 16;
	menus[16].addItem(null, 'Chueca', null, 140, '#ffffff', '#EAEAEA', '/en/gay-lesbian/madrid-gay-chueca.aspx', 'left');
	menus[16].addItem(null, 'Bars & restaurants', null, 140, '#ffffff', '#EAEAEA', '/en/gay-lesbian/madrid-gay-bars-restaurants.aspx', 'left');
	menus[16].addItem(null, 'Shopping', null, 140, '#ffffff', '#EAEAEA', '/en/gay-lesbian/madrid-gay-shopping.aspx', 'left');
	menus[16].writeMenu();
	
	menus[17] = new menu(142, 'vertical', '#CCCCCC', '#999999');
	menus[17].height = 16;
	menus[17].addItem(null, 'The old city', null, 140, '#ffffff', '#EAEAEA', '', 'left');
	menus[17].writeMenu();
	
	menus[18] = new menu(162, 'vertical', '#CCCCCC', '#999999');
	menus[18].height = 16;
	menus[18].addItem(null, 'Toledo', null, 160, '#ffffff', '#EAEAEA', '/en/day-trips/madrid-toledo.aspx', 'left');
	menus[18].addItem(null, 'Segovia', null, 160, '#ffffff', '#EAEAEA', '/en/day-trips/madrid-segovia.aspx', 'left');
	menus[18].addItem(null, 'San Lorenzo del Escorial', null, 160, '#ffffff', '#EAEAEA', '/en/day-trips/madrid-escorial.aspx', 'left');
	menus[18].addItem(null, 'Aranjuez', null, 160, '#ffffff', '#EAEAEA', '/en/day-trips/madrid-aranjuez.aspx', 'left');
	menus[18].addItem(null, 'Chinch&oacute;n', null, 160, '#ffffff', '#EAEAEA', '/en/day-trips/madrid-chinchon.aspx', 'left');
	menus[18].writeMenu();
	
	menus[19] = new menu(142, 'vertical', '#CCCCCC', '#999999');
	menus[19].height = 16;
	menus[19].addItem(null, 'Local stores', null, 140, '#ffffff', '#EAEAEA', '/en/shopping/madrid-stores.aspx', 'left');
	menus[19].addItem(null, 'Shopping malls', null, 140, '#ffffff', '#EAEAEA', '/en/shopping/madrid-malls.aspx', 'left');
	menus[19].addItem(null, 'Rastro flea market', null, 140, '#ffffff', '#EAEAEA', '/en/shopping/madrid-rastro-flea-market.aspx', 'left');
	menus[19].writeMenu();
	
	menus[20] = new menu(62, 'vertical', '#CCCCCC', '#999999');
	menus[20].height = 16;
	menus[20].addItem(null, 'Airplane', null, 60, '#ffffff', '#EAEAEA', '/en/transport/madrid-arriving/airplane.aspx', 'left');
	menus[20].addItem(null, 'Train', null, 60, '#ffffff', '#EAEAEA', '/en/transport/madrid-arriving/train.aspx', 'left');
	menus[20].addItem(null, 'Bus', null, 60, '#ffffff', '#EAEAEA', '/en/transport/madrid-arriving/bus.aspx', 'left');
	menus[20].addItem(null, 'Road', null, 60, '#ffffff', '#EAEAEA', '/en/transport/madrid-arriving/road.aspx', 'left');
	menus[20].writeMenu();
	
	menus[21] = new menu(152, 'vertical', '#CCCCCC', '#999999');
	menus[21].height = 16;
	menus[21].addItem(null, 'Histoire', null, 150, '#ffffff', '#EAEAEA', '/fr/information/madrid-histoire.aspx', 'left');
	menus[21].addItem(null, 'Climat', null, 150, '#ffffff', '#EAEAEA', '/fr/information/madrid-climat.aspx', 'left');
	menus[21].addItem(null, 'S&eacute;curit&eacute;', null, 150, '#ffffff', '#EAEAEA', '/fr/information/madrid-securite.aspx', 'left');
	menus[21].addItem(null, 'T&eacute;l&eacute;phones d&#39;int&eacute;r&ecirc;t', null, 150, '#ffffff', '#EAEAEA', '/fr/information/madrid-telephones.aspx', 'left');
	menus[21].addItem(null, 'Information touristique', null, 150, '#ffffff', '#EAEAEA', '/fr/information/madrid-info-touristique.aspx', 'left');
	menus[21].writeMenu();

	menus[22] = new menu(132, 'vertical', '#CCCCCC', '#999999');
	menus[22].height = 16;
	menus[22].addItem(null, 'H&ocirc;tels', null, 130, '#ffffff', '#EAEAEA', '/fr/logement/madrid-hotels.aspx', 'left');
	menus[22].addItem(null, 'Hostels', null, 130, '#ffffff', '#EAEAEA', '/fr/logement/madrid-hostels.aspx', 'left');
	menus[22].addItem(null, 'Appartements', null, 130, '#ffffff', '#EAEAEA', '/fr/logement/madrid-appartements.aspx', 'left');
	menus[22].addItem(null, 'Aparthotels', null, 130, '#ffffff', '#EAEAEA', '/fr/logement/madrid-aparthotels.aspx', 'left');
	menus[22].addItem(null, 'Logement - Tout', null, 130, '#ffffff', '#EAEAEA', '/fr/logement/madrid-hotels-info.aspx', 'left');
	menus[22].writeMenu();

	menus[23] = new menu(192, 'vertical', '#CCCCCC', '#999999');
	menus[23].height = 16;
	menus[23].addItem('labelBullet', 'Arriver et sortir de Madrid', 30, 190, '#ffffff', '#EAEAEA', '/fr/transport/madrid-arriver.aspx', 'left');
	menus[23].addItem(null, 'D&eacute;placement', null, 190, '#ffffff', '#EAEAEA', '/fr/transport/madrid-deplacement.aspx', 'left');
	menus[23].addItem(null, 'Plan m&eacute;tro', null, 190, '#ffffff', '#EAEAEA', '/fr/transport/madrid-plan-metro.aspx', 'left');
	menus[23].addItem(null, 'Plan pour trains de banlieu', null, 190, '#ffffff', '#EAEAEA', '/fr/transport/madrid-plan-trains.aspx', 'left');
	menus[23].writeMenu();

	menus[24] = new menu(192, 'vertical', '#CCCCCC', '#999999');
	menus[24].height = 16;
	menus[24].addItem(null, 'Diners anim&eacute;s', null, 190, '#ffffff', '#EAEAEA', '/fr/amusement/madrid-restaurants-spectacle.aspx', 'left');
	menus[24].addItem(null, 'Flamenco', null, 190, '#ffffff', '#EAEAEA', '/fr/amusement/madrid-flamenco.aspx', 'left');
	menus[24].addItem(null, 'Taureaux', null, 190, '#ffffff', '#EAEAEA', '/fr/amusement/madrid-toreaux.aspx', 'left');
	menus[24].addItem(null, 'Football', null, 190, '#ffffff', '#EAEAEA', '/fr/amusement/madrid-football.aspx', 'left');
	menus[24].addItem(null, 'Musique', null, 190, '#ffffff', '#EAEAEA', '/fr/amusement/madrid-musique.aspx', 'left');
	menus[24].addItem(null, 'Operat, th&eacute;&acirc;tre et spectacles', null, 190, '#ffffff', '#EAEAEA', '/fr/amusement/madrid-spectacles.aspx', 'left');
	menus[24].addItem(null, 'Cin&eacute;ma', null, 190, '#ffffff', '#EAEAEA', '/fr/amusement/madrid-cinema.aspx', 'left');
	menus[24].addItem(null, 'Vie nocturne', null, 190, '#ffffff', '#EAEAEA', '/fr/amusement/madrid-nocturne.aspx', 'left');
	menus[24].addItem(null, 'Loisirs pour enfants', null, 190, '#ffffff', '#EAEAEA', '/fr/amusement/madrid-enfants.aspx', 'left');
	menus[24].writeMenu();

	menus[25] = new menu(132, 'vertical', '#CCCCCC', '#999999');
	menus[25].height = 16;
	menus[25].addItem(null, 'Mus&eacute;e du Prado', null, 130, '#ffffff', '#EAEAEA', '/fr/musees/madrid-musee-prado.aspx', 'left');
	menus[25].addItem(null, 'Mus&eacute;e Thyssen', null, 130, '#ffffff', '#EAEAEA', '/fr/musees/madrid-musee-thyssen.aspx', 'left');
	menus[25].addItem(null, 'Mus&eacute;e Reina Sof&iacute;a', null, 130, '#ffffff', '#EAEAEA', '/fr/musees/madrid-musee-reina-sofia.aspx', 'left');
	menus[25].addItem(null, 'Autres mus&eacute;es', null, 130, '#ffffff', '#EAEAEA', '/fr/musees/madrid-musees.aspx', 'left');
	menus[25].addItem(null, 'Galeries d&#39;art', null, 130, '#ffffff', '#EAEAEA', '/fr/musees/madrid-galeries.aspx', 'left');
	menus[25].writeMenu();

	menus[26] = new menu(137, 'vertical', '#CCCCCC', '#999999');
	menus[26].height = 16;
	menus[26].addItem(null, 'Chueca', null, 135, '#ffffff', '#EAEAEA', '/fr/gays-lesbiennes/madrid-chueca-gay.aspx', 'left');
	menus[26].addItem(null, 'Bars et restaurants', null, 135, '#ffffff', '#EAEAEA', '/fr/gays-lesbiennes/madrid-bars-restaurants-gay.aspx', 'left');
	menus[26].addItem(null, 'Boutiques', null, 135, '#ffffff', '#EAEAEA', '/fr/gays-lesbiennes/madrid-boutiques-gay.aspx', 'left');
	menus[26].writeMenu();

	menus[27] = new menu(142, 'vertical', '#CCCCCC', '#999999');
	menus[27].height = 16;
	menus[27].addItem(null, 'The old city', null, 140, '#ffffff', '#EAEAEA', '', 'left');
	menus[27].writeMenu();
	
	menus[28] = new menu(162, 'vertical', '#CCCCCC', '#999999');
	menus[28].height = 16;
	menus[28].addItem(null, 'Toledo', null, 160, '#ffffff', '#EAEAEA', '/fr/excursions/madrid-toledo.aspx', 'left');
	menus[28].addItem(null, 'Segovia', null, 160, '#ffffff', '#EAEAEA', '/fr/excursions/madrid-segovia.aspx', 'left');
	menus[28].addItem(null, 'San Lorenzo del Escorial', null, 160, '#ffffff', '#EAEAEA', '/fr/excursions/madrid-escorial.aspx', 'left');
	menus[28].addItem(null, 'Aranjuez', null, 160, '#ffffff', '#EAEAEA', '/fr/excursions/madrid-aranjuez.aspx', 'left');
	menus[28].addItem(null, 'Chinch&oacute;n', null, 160, '#ffffff', '#EAEAEA', '/fr/excursions/madrid-chinchon.aspx', 'left');
	menus[28].writeMenu();

	menus[29] = new menu(152, 'vertical', '#CCCCCC', '#999999');
	menus[29].height = 16;
	menus[29].addItem(null, 'Boutiques et march&eacute;s', null, 150, '#ffffff', '#EAEAEA', '/fr/commerce/madrid-boutiques.aspx', 'left');
	menus[29].addItem(null, 'Centres commerciaux', null, 150, '#ffffff', '#EAEAEA', '/fr/commerce/madrid-centres-commerciaux.aspx', 'left');
	menus[29].addItem(null, 'March&eacute; aux puces', null, 150, '#ffffff', '#EAEAEA', '/fr/commerce/madrid-rastro.aspx', 'left');
	menus[29].writeMenu();
	
	menus[30] = new menu(62, 'vertical', '#CCCCCC', '#999999');
	menus[30].height = 16;
	menus[30].addItem(null, 'Avion', null, 60, '#ffffff', '#EAEAEA', '/fr/transport/madrid-arriver/avion.aspx', 'left');
	menus[30].addItem(null, 'Train', null, 60, '#ffffff', '#EAEAEA', '/fr/transport/madrid-arriver/train.aspx', 'left');
	menus[30].addItem(null, 'Bus', null, 60, '#ffffff', '#EAEAEA', '/fr/transport/madrid-arriver/bus.aspx', 'left');
	menus[30].addItem(null, 'Route', null, 60, '#ffffff', '#EAEAEA', '/fr/transport/madrid-arriver/route.aspx', 'left');
	menus[30].writeMenu();

	menus[1].align='right';
	menus[2].align='right';
	menus[3].align='right';
	menus[4].align='right';
	menus[5].align='right';
	menus[6].align='right';
	menus[7].align='right';
	menus[8].align='right';
	menus[9].align='right';
	menus[10].align='right';
	menus[11].align='right';
	menus[12].align='right';
	menus[13].align='right';
	menus[14].align='right';
	menus[15].align='right';
	menus[16].align='right';
	menus[17].align='right';
	menus[18].align='right';
	menus[19].align='right';
	menus[20].align='right';
	menus[21].align='right';
	menus[22].align='right';
	menus[23].align='right';
	menus[24].align='right';
	menus[25].align='right';
	menus[26].align='right';
	menus[27].align='right';
	menus[28].align='right';
	menus[29].align='right';
	menus[30].align='right';
	
}
