function activarVideos() {
	//flowplayer("a.flowplayer", "html/flash/flowplayer-3.2.7.swf");
	flowplayer("a.flowplayer", "html/flash/flowplayer-3.2.7.swf", {
		clip: { 
		    autoBuffering: true,  
			autoPlay: false
		}
	});	
}

function main_menu_load(tipo, id) {
	// Dirección de envío
    var url = 'mainmenu.' + tipo;
	if ($('#menu_desplegable').attr('_current') == id) {
		$('#menu_desplegable').effect('blind');
		$('#menu_desplegable').attr({
			'_current': 0
		});
		return;
	} else {
		$('#menu_desplegable').attr({
			'_current': id
		});
	}
	
	$.ajax({
		url: url,
		type: "POST",
		data: {
			'id': id
		},
		beforeSend: function(msg){
			$('#menu_desplegable').html('<img src="html/images/loader.gif" alt="" />');
			
			$("#main_menu_items a.main_menu_selected").removeClass('main_menu_selected');
			
			if ($('#menu_desplegable').css('display') == 'none') {
				//$("#menu_desplegable").css({'height':'20px'});
				$("#menu_desplegable").show();
			}
		},
		success: function(msg){
			$('#menu_desplegable').html(msg);
			$('#main_menu_item_' + id).addClass('main_menu_selected');
			/*var menu_desplegableHeight_before = $("#menu_desplegable").height();
			$("#menu_desplegable").css({'height':'auto','position':'absolute','visibility':'hidden','display':'block'});
			var menu_desplegableHeight = $("#menu_desplegable").height();
			$("#menu_desplegable").css({'height': menu_desplegableHeight_before + 'px','position':'relative','visibility':'visible','display':'block'});		
			$('#menu_desplegable').animate({'height':menu_desplegableHeight + 'px'});*/
			
			//Según el tipo, hacer acciones JS
			if ($("#cantidad_bloques_header_ajax_id").length > 0) {
				activateAjaxHeadAnimation($("#cantidad_bloques_header_ajax_id").attr('value'));
			}	
		},
		error: function(){
			$('#menu_desplegable').hide();
		}
	});
}


function show_header_media(href, id, tipo) {
	//Comprobar si es un recurso interno o un embed de youtube.
	try {
		switch (tipo) {
			case 'flv':
					flowplayer(id, "html/flash/flowplayer-3.2.7.swf", href);		
				break;
			case 'swf':
				var html = '<object height="375" width="500" type="application/x-shockwave-flash" data="' + href + '" style="height=375;width: 500px;">';
				html += '<param value="' + href + '" name="data">';
				html += '<param value="' + href + '" name="src">';
				html += '</object>';
				$('#' + id).html(html);
				break;
			case 'avi':
			case 'mpg':
			case 'mpeg':
			case 'wav':
			case 'mp3':
			case 'mov':
				var html = '<object classid="clsid:6bf52a52-394a-11d3-b153-00c04f79faa6" height=375;width: 500px; codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701">';
				html += '<param name="url" value="' + href + '" />';
				html += '<embed type="application/x-mplayer2" width="500" height="375" src="' + href + '">';
				html += '</embed>';
				html += '</object>';
				$('#' + id).html(html);
				break;
			case 'youtube':
				if (id == 'desplegable_hotel_media') {
					var html = '<iframe width="465" height="355" src="' + href + '?autoplay=1" frameborder="0" allowfullscreen></iframe>';
				} else {
					var html = '<iframe width="500" height="369" src="' + href + '?autoplay=1" frameborder="0" allowfullscreen></iframe>';
				}
				
				$('#' + id).html(html);
				break;
		}
	} catch (e) {
		$('#' + id).html('error loading content: ' + e);
	}
}

function sendAjax(button) {

	// Formulario
    var f = button.form;

    // Dirección de envío
    var url = 'form.sendAjax';

    // Deshabilitar el botón
	button.disabled = true;
	
	$.ajax({
		url: url,
		type: "POST",
		data: $(f).serialize(),
		success: function(msg){
			try {
				var data = jQuery.parseJSON(msg);
				var messages = data.messages;
				var errores = [];
				
				if (messages) {
					$.each(messages, function(key, val){
						$.each(val, function(key2, val2){
							if((key2=='isEmpty') || (key2=='emailAddressInvalidFormat') || (key2=='hostnameLocalNameNotAllowed') || (key2=='fileUploadErrorNoFile')) {
								errores.push('  - ' + val.title + ' - ' + $('body').data(key2));
							}
						});
					});
				}
				if (errores.length == 0) {
					alert($('body').data('form_ok'));
					f.reset();
				} else {
					alert($('body').data('formfield_ko') + ':\n\n' + errores.join('\n'));
				}
			} catch (e) {
				alert($('body').data('form_ko'));
			}
			button.disabled = false;
		},
		error: function(){
			alert($('body').data('form_ko'));
			button.disabled = false;
		}
	});

	// Cancelar el submit
	return false;
}

function onBlur(){
    $('body').data('animating_header', false);
	$('body').data('animating_header_ajax', false);
};
function onFocus(){
    $('body').data('animating_header', true);
	$('body').data('animating_header_ajax', true);
};

if (/*@cc_on!@*/false) { // check for Internet Explorer
    document.onfocusin = onFocus;
    document.onfocusout = onBlur;
}
else {
    window.onfocus = onFocus;
    window.onblur = onBlur;
}

function activateHeadAnimation(){
    var cantidad_headers = parseInt($('#cantidad_bloques_header').attr('value'), 10);
    if (cantidad_headers > 1) {
        $('body').data('animating_header', true);
        $('body').data('current_animating_header', 1);
        $('body').data('max_animating_header', cantidad_headers);
        var timer = setInterval(headAnimation, 10000);
    }
}

function headAnimation(){
    if ($('body').data('animating_header') === true) {
        var current = $('body').data('current_animating_header');
        var max = $('body').data('max_animating_header');
        
        var next = current + 1;
        if (next > max) {
            next = 1;
        }
        unsetHeader(current);
        setHeader(next);
    }
}

function selectSingleHeader(id){
    $('body').data('animating_header', false);
    var current = $('body').data('current_animating_header');
	if(current != undefined) {
		if (current != id) {
			unsetHeader(current);
			setHeader(id);
		}
	}
}

function unsetHeader(id){
    $('#header_imagen_' + id).fadeOut();
    $('#header_button_' + id).attr('src', 'html/images/btn_0' + id + '.png');
    
}

function setHeader(id){
    $('#header_imagen_' + id).fadeIn();
    $('#header_button_' + id).attr('src', 'html/images/btn_0' + id + '_on.png');
    $('body').data('current_animating_header', id);
    
	changeHeaderText();
}


function activateAjaxHeadAnimation(id){
	if ($("#cantidad_bloques_header_ajax" + id).length > 0) {
		var cantidad_headers = parseInt($('#cantidad_bloques_header_ajax' + id).attr('value'), 10);
		if (cantidad_headers > 1) {
			$('body').data('animating_header_ajax', true);
			$('body').data('current_animating_header_ajax', 1);
			$('body').data('max_animating_header_ajax', cantidad_headers);
			ajax_header_timer = setInterval("headAjaxAnimation('" + id + "')", 10000);
		}
	}
}
function headAjaxAnimation(id){
	if (id == $("#cantidad_bloques_header_ajax_id").attr('value')) {
		if ($('body').data('animating_header_ajax') === true) {
			var current = $('body').data('current_animating_header_ajax');
			var max = $('body').data('max_animating_header_ajax');
			
			var next = current + 1;
			if (next > max) {
				next = 1;
			}
			unsetAjaxHeader(current);
			setAjaxHeader(next);
		}
	}
}

function selectSingleAjaxHeader(id){
    $('body').data('animating_header_ajax', false);
    var current = $('body').data('current_animating_header_ajax');
	if(current != undefined) {
		if (current != id) {
			unsetAjaxHeader(current);
			setAjaxHeader(id);
		}
	}
}

function unsetAjaxHeader(id){
    $('#header_imagen_' + id + '_ajax').fadeOut();
    $('#header_button_' + id + '_ajax').attr('src', 'html/images/btn_0' + id + '.png');
    
}

function setAjaxHeader(id){
    $('#header_imagen_' + id + '_ajax').fadeIn();
    $('#header_button_' + id + '_ajax').attr('src', 'html/images/btn_0' + id + '_on.png');
    $('body').data('current_animating_header_ajax', id);
}


function changeHeaderText(){
    var $marginLefty = $("#header_area_block_trans");
    $marginLefty.animate({
        right: '-344px'
    }, 500, "easeInOutCubic", function(){
        $(".header_area_block_trans_texto_item").each(function(index){
            $(this).hide();
        });
        var current = $('body').data('current_animating_header');
        $('#header_text_' + current).show();
        if ($('#header_text_' + current).html() === '') {
            $marginLefty.animate({
                right: '-370px'
            }, 500, "easeInOutCubic");
        }
        else {
            $marginLefty.animate({
                right: 0
            }, 500, "easeInOutCubic");
        }
    });
}

function activarZoom(){
    //Activar el fancyzoom sobre los a con class jszoom
    $('a.jszoom').fancybox({
        'hideOnContentClick': true,
        'transitionIn': 'elastic',
        'transitionOut': 'elastic'
    });
    
    $('a.jszoomgaleria').fancybox({
        'hideOnContentClick': true,
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'titlePosition': 'over',
        'titleFormat': function(title, currentArray, currentIndex, currentOpts){
            return '<span id="fancybox-title-over">Imagen ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
        }
    });
    
    $('a.jszoomslideshow').fancybox({
        'hideOnContentClick': true,
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'titlePosition': 'over',
        'cyclic': true,
        'titleFormat': function(title, currentArray, currentIndex, currentOpts){
            return '<span id="fancybox-title-over">Imagen ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
        },
        'onComplete': function(){
            var t = setTimeout(function(){
                clearTimeout(t);
                $.fancybox.next();
            }, 4000);
        }
    });
}

function head_media_gallery(id, direction) {
	if (direction == 'next') {
		var next = 1;
	} else {
		var next = -1;
	}
	var main_layer = $('#header_fotos_media_bloque_' + id);
	var current_img = main_layer.attr('_current');
	var next_img = parseInt(current_img, 10) + next;
	
	//Comprobar si existe el siguiente imagen
	var next_img_element = $('#header_fotos_media_' + id + '_img_' + next_img);
	var current_img_element = $('#header_fotos_media_' + id + '_img_' + current_img);
	if (next_img_element.length > 0){
		current_img_element.fadeOut();
		next_img_element.fadeIn();
		main_layer.attr('_current', next_img);
	}
}
function head_media_folder(id) {
	var folder_contents_layer = $('#desplegable_hotel_media_folder_contents');
	var current_folder = folder_contents_layer.attr('_current');
	var current_folder_element = $('#header_fotos_media_bloque_' + current_folder);
	var next_folder_element = $('#header_fotos_media_bloque_' + id);
	if (next_folder_element.length > 0){
		current_folder_element.fadeOut();
		next_folder_element.fadeIn();
		folder_contents_layer.attr('_current', id);
	}
}

function activarMapa(center, zoom){
	var default_marker = 'html/images/map_cluster_blue1.png';
	if ($("#gmap").length > 0) {
		$('#gmap').gmap3({
			action: 'init',
			options: {
				center: center,
				zoom: zoom,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			}
		});
		
		//Añadir los polionos (antes de marcadores)
	    var polygonos_array = $('body').data('googlemaps_layer_polygonos');
		for (var i = 0, len = polygonos_array.length; i < len; ++i) {
			polygon = polygonos_array[i];
			var paths = polygon.paths;
			paths = paths.replace(/(\r\n|\n|\r)/gm,"");
			paths = '[' + paths + ']';
			
			$('#gmap').gmap3({
				action: 'addPolygon',
				tag: 'layer_' + i,
				options: {
					strokeColor: polygon.options.strokeColor,
					fillColor: polygon.options.fillColor,
					strokeOpacity: 0.8,
					strokeWeight: 1,
					fillOpacity: 0.35,
					zIndex: 1
				},
				paths: JSON.parse(paths)
			});
		}
		
		//Añadir los marcadores
		$('#gmap').gmap3({
			action: 'addMarkers',
			tag: 'layer',
			radius: 15,
			markers: $('body').data('googlemaps_layer_markers'),
			clusters: {
				// This style will be used for clusters with more than 0 markers
				0: {
					content: '<div class="cluster-1" style="background: url(\'' + default_marker + '\') no-repeat scroll 0 0 transparent;"><span class="cluster">CLUSTER_COUNT</span></div>',
					width: 34,
					height: 39
				},
				// This style will be used for clusters with more than 100 markers
				100: {
					content: '<div class="cluster cluster-2">CLUSTER_COUNT</div>',
					width: 34,
					height: 39
				}
			},
			marker: {
				options: {
					draggable: false
				},
				events:{
	                click: function(marker, event, data){
						var map = $(this).gmap3('get'),
						infowindow = $(this).gmap3({action:'get', name:'infowindow'});
											
						var html = '<div class="linea_infowindow">';						
						html += '<div class="izq">';
						
						if (data.nombre) {
							html += '<div class="linea_cabecera">';
							html += '<p><strong>' + data.nombre + '</strong></p>';
							html += '</div>';
						}
						
						if (data.contenido) {
							html += '<div class="linea">';
							html += '<p>' + data.contenido + '</p>';
							html += '</div>';
						}
						
						html += '</div>';
						html += '<div class="dcha">';
						
						if (data.imagen) {
							html += '<div class="linea">';
							html += '<img src="' + data.imagen + '" alt=""/>';
							html += '</div>';							
						}
						
						if (data.enlace) {
							html += '<div class="linea">';
							html += '<p class="mas_informacion"><a href="' + data.enlace + '"title="' + data.enlace + '">' + $('body').data('mas_info') + '</a></p>';
							html += '</div>';
						}
						
						html += '</div>';
						html += '</div>';
						
						if (infowindow){
							infowindow.open(map, marker);
							infowindow.setContent(html);
						} else {
							$(this).gmap3({action:'addinfowindow', anchor:marker, options:{content: html}});
						}
					}
				}
			}
		});
	}
}



function toggle_map_layer(id, default_marker) {
	var valor_checked = $('#' + id).attr('value');
	if (valor_checked == 0) {
		$('#' + id).attr('value', 1);
		

	} else {
		$('#' + id).attr('value', 0);
		
		$('#gmap').gmap3({
			action: 'clear',
			tag: 'layer_' + id
		});
	}
}

function corners(){
	$(".gallery_inner_thin").corner("round 4px").parent().css('padding', '1px').corner("round 5px");
	$(".oferta_border_thin").corner("round 15px"); 
    $(".inner_thin").corner("round 6px"); 
    /*$(".inner_thin").each(function(index){
        var img = $(this).find('img').first();
        var width = img.width();
        var height = img.height();
		
        $(this).css({
            'width': width + 'px',
            'height': height + 'px'
        });
    });*/
}

/**
 * Buscar las galerias y activarlas.
 */
function activateGalleries() {
	$('.gallery').each(function(index){
		if ($(this).attr('_type') == 'horizontal') {
			activateGalleryHorizontal($(this).attr('_gallery_id'));
		} else {
			activateGalleryVertical($(this).attr('_gallery_id'));
		}
	});
}

function activateGalleryHorizontal(id) {
	var scroll_area = $('#galeria_scroll_' + id);
	if (scroll_area.data() !== null) {
		scroll_area.attr('_animating', '0');
		
		var scroll_container = scroll_area.parent();
		var maxheight = scroll_container.height();
		var scrollstep_item = scroll_area.height()/(scroll_area.children()).length;
		var items_per_scroll = 	Math.round(maxheight/scrollstep_item);
		var scrollstep = scrollstep_item * items_per_scroll;
		
		$('#galeria_prev_' + id).click(function() {
			if (scroll_area.attr('_animating') != '1'){	
				var top = scroll_area.position().top;
				scroll_area.attr('_animating', '1');
				
				if (top>=0) {
					scroll_area.animate({'top':'20px'}, {duration: 200, queue: false, complete: function() {
						$(this).animate({'top':'0px'}, {duration: 500, easing: 'easeOutBounce', queue: false, complete: function(){
							scroll_area.attr('_animating', '0');
						}});
					}});
				} else {
					scroll_area.animate({'top': (top+scrollstep)+'px'}, {duration: 800, easing: 'easeInOutCubic', queue: false, complete: function(){
						scroll_area.attr('_animating', '0');
					}});
				}
			}
		});
		
		$('#galeria_next_' + id).click(function() {
			if (scroll_area.attr('_animating') != '1'){
				var top = scroll_area.height()+scroll_area.position().top-maxheight;
				scroll_area.attr('_animating', '1');
				
				if(top<=0) {
					scroll_area.animate({'top':'-=20px'}, {duration: 200, queue: false, complete: function() {
						$(this).animate({'top':'+=20px'}, {duration: 500, easing: 'easeOutBounce', queue: false, complete: function(){
							scroll_area.attr('_animating', '0');
						}});
					}});
				} else {
					scroll_area.animate({'top':'-='+scrollstep+'px'}, {duration: 800, easing: 'easeInOutCubic', queue: false, complete: function(){
						scroll_area.attr('_animating', '0');
					}});
				}
			}
		});
		
		//Comprobar el imagen grande
		var gallery_layer = $('#gallery_main_layer_' + id);
		if (gallery_layer.data() !== null) {
			var $children = scroll_area.children();
			
			//Apuntar el primer hijo seleccionada
			scroll_area.attr('_current', $children.first().attr('id'));
			
			//Crear los eventos de los hijos
			$children.click(function(e) {
				var hide_img = scroll_area.attr('_current');
				var show_img = $(this).attr('id');
				var img_id = show_img.split('_').pop();
				if (hide_img != show_img) {
					scroll_area.attr('_current', show_img);					
					$('#' + hide_img + '_big').hide('fade',  {}, 1000);
					$('#' + show_img + '_big').show('slide', {
						direction: 'right'
					}, 1000);
					$('#gallery_main_layer_' + img_id).animate({
						height: $('#' + show_img + '_big').css('height')
					}, 1000);
				}		
			});
		}
	}
}

function activateGalleryVertical(id){
	var scroll_area = $('#galeria_scroll_' + id);
	if (scroll_area.data() !== null) {
		scroll_area.attr('_animating', '0');
		
		var scroll_container = scroll_area.parent();
		var maxwidth = scroll_container.width();
		var scrollstep_item = scroll_area.width()/(scroll_area.children()).length;
		var items_per_scroll = 	Math.round(maxwidth/scrollstep_item);
		scrollstep = scrollstep_item * items_per_scroll;
		
		$('#galeria_prev_' + id).click(function() {
			if (scroll_area.attr('_animating') != '1'){	
				var izq = scroll_area.position().left;
				scroll_area.attr('_animating', '1');
				
				if (izq>=0) {
					scroll_area.animate({'left':'50px'}, {duration: 200, queue: false, complete: function() {
						$(this).animate({'left':'0px'}, {duration: 500, easing: 'easeOutBounce', queue: false, complete: function(){
							scroll_area.attr('_animating', '0');
						}});
					}});
				} else {
					scroll_area.animate({'left': (izq+scrollstep)+'px'}, {duration: 1500, easing: 'easeInOutCubic', queue: false, complete: function(){
						scroll_area.attr('_animating', '0');
					}});
				}
			}
		});
		
		$('#galeria_next_' + id).click(function() {
			if (scroll_area.attr('_animating') != '1'){
				var dcha = scroll_area.width()+scroll_area.position().left-maxwidth;
				scroll_area.attr('_animating', '1');
				
				if(dcha<0) {
					scroll_area.animate({'left':'-=50px'}, {duration: 200, queue: false, complete: function() {
						$(this).animate({'left':'+=50px'}, {duration: 500, easing: 'easeOutBounce', queue: false, complete: function(){
							scroll_area.attr('_animating', '0');
						}});
					}});
				} else {
					scroll_area.animate({'left':'-='+scrollstep+'px'}, {duration: 1500, easing: 'easeInOutCubic', queue: false, complete: function(){
						scroll_area.attr('_animating', '0');
					}});
				}
			}
		});
		
		//Comprobar el imagen grande
		var gallery_layer = $('#gallery_main_layer_' + id);
		if (gallery_layer.data() !== null) {
			var $children = scroll_area.children();
			
			//Apuntar el primer hijo seleccionada
			scroll_area.attr('_current', $children.first().attr('id'));
			
			//Crear los eventos de los hijos
			$children.click(function(e) {
				var hide_img = scroll_area.attr('_current');
				var show_img = $(this).attr('id');
				if (hide_img != show_img) {
					scroll_area.attr('_current', show_img);	
					var img_id = show_img.split('_').pop();				
					$('#' + hide_img + '_big').hide('fade', 1000);
					$('#' + show_img + '_big').show('slide', {
						direction: 'right'
					}, 1000);
					$('#gallery_main_layer_' + img_id).animate({
						height: $('#' + show_img + '_big').css('height')
					}, 1000);
				}		
			});
		}
	}
}

function lockScrollOfertas() {
	if ($("#nav_ofertas").length > 0) {
		jQuery('#nav_ofertas').containedStickyScroll({
			duration: 100,
			unstick: false
		});
	}
}

function activarValidacionesFormularios() {
	if ($("#form_reserva").length > 0){
        $("#form_reserva").validate({
          rules: {
            regalar_nombre: {
              required: "#form_regalar:checked"
            },
            regalar_telefono: {
              required: "#form_regalar:checked"
            },
            regalar_email: {
              required: "#form_regalar:checked",
              email: "#datos_del_envio:checked"
            },
            viajero1_nombre: {
              required: "#form_contratar_seguro:checked"
            },
            viajero1_apellidos: {
              required: "#form_contratar_seguro:checked"
            },
            viajero2_nombre: {
              required: "#form_contratar_seguro:checked"
            },
            viajero2_apellidos: {
              required: "#form_contratar_seguro:checked"
            },
            viajero3_nombre: {
              required: "#form_contratar_seguro:checked"
            },
            viajero3_apellidos: {
              required: "#form_contratar_seguro:checked"
            },
            viajero4_nombre: {
              required: "#form_contratar_seguro:checked"
            },
            viajero4_apellidos: {
              required: "#form_contratar_seguro:checked"
            },
            viajero5_nombre: {
              required: "#form_contratar_seguro:checked"
            },
            viajero5_apellidos: {
              required: "#form_contratar_seguro:checked"
            },
            viajero6_nombre: {
              required: "#form_contratar_seguro:checked"
            },
            viajero6_apellidos: {
              required: "#form_contratar_seguro:checked"
            },
            viajero7_nombre: {
              required: "#form_contratar_seguro:checked"
            },
            viajero7_apellidos: {
              required: "#form_contratar_seguro:checked"
            },
            viajero8_nombre: {
              required: "#form_contratar_seguro:checked"
            },
            viajero8_apellidos: {
              required: "#form_contratar_seguro:checked"
            },
            viajero9_nombre: {
              required: "#form_contratar_seguro:checked"
            },
            viajero9_apellidos: {
              required: "#form_contratar_seguro:checked"
            },
            viajero10_nombre: {
              required: "#form_contratar_seguro:checked"
            },
            viajero10_apellidos: {
              required: "#form_contratar_seguro:checked"
            }
          }
        });
    }

    if ($("#clientdataform").length > 0){
        $("#clientdataform").validate({
          rules: {
            env_nombre: {
              required: "#datos_del_envio:unchecked"
            },
            env_direccion: {
              required: "#datos_del_envio:unchecked"
            },
            env_localidad: {
              required: "#datos_del_envio:unchecked"
            },
            env_cp: {
              required: "#datos_del_envio:unchecked"
            },
            env_email: {
              required: "#datos_del_envio:unchecked",
              email: "#datos_del_envio:unchecked"
            },
            pais: {
              required: function(element) {
                return $("#destino").val() != 1;
              }
            },
            env_pais: {
              required: function(element) {
                return (($("#envio_destino2").val() != 1) && ($("#datos_del_envio").is(':checked')));
              }
            }
          }
        });
    }
	
	if ($("#form_tarjeta_monedero").length > 0){
        $("#form_tarjeta_monedero").validate({
          rules: {
            importe: {
              required: true,
			  number:true,
      		  min: 50,
			  max: 1000
            }
          }
        });
    }
}


function blockswitch(value) {
	var b1 = document.getElementById('block-1');
	var b2 = document.getElementById('block-2');
	var b3 = document.getElementById('block-3');
	var b1b = document.getElementById('block-1b');
	var b2b = document.getElementById('block-2b');
	var b3b = document.getElementById('block-3b');
	var s1 = document.getElementById('select3');
	var s2 = document.getElementById('programa');
	var s3 = document.getElementById('textarea');
	switch(value){
		case 'Alojamiento Hotel':
			b1.style.display = '';
			b2.style.display = 'none';
			b3.style.display = 'none';
			b1b.style.display = '';
			b2b.style.display = 'none';
			b3b.style.display = 'none';
			s1.disabled = false;
			s2.disabled = true;
			s3.disabled = true;
		break;
		case 'Programa Termal (Alojamiento + Tratamientos)':
			b1.style.display = 'none';
			b2.style.display = '';
			b3.style.display = 'none';
			b1b.style.display = 'none';
			b2b.style.display = '';
			b3b.style.display = 'none';
			s1.disabled = true;
			s2.disabled = false;
			s3.disabled = true;
		break;
		case 'Tratamientos Balneario':
			b1.style.display = 'none';
			b2.style.display = 'none';
			b3.style.display = '';
			b1b.style.display = 'none';
			b2b.style.display = 'none';
			b3b.style.display = '';
			s1.disabled = true;
			s2.disabled = true;
			s3.disabled = false;
		break;
		case '(no elegido)':
			b1.style.display = 'none';
			b2.style.display = 'none';
			b3.style.display = 'none';
			b1b.style.display = 'none';
			b2b.style.display = 'none';
			b3b.style.display = 'none';
			s1.disabled = true;
			s2.disabled = true;
			s3.disabled = true;
		break;
	}
}

/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/
 
var Base64 = {
 
	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
 
	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = Base64._utf8_encode(input);
 
		while (i < input.length) {
 
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);
 
			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;
 
			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}
 
			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
 
		}
 
		return output;
	},
 
	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;
 
		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
 
		while (i < input.length) {
 
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));
 
			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;
 
			output = output + String.fromCharCode(chr1);
 
			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}
 
		}
 
		output = Base64._utf8_decode(output);
 
		return output;
 
	},
 
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}
