function ampliador() 
{
jQuery("#ampliar, #ampliarhead, #ampliarhead2, #ampliarhead3, .ampliarheader").click(function () {
	
	
	
		jQuery("#header").css( {backgroundPosition: "0 0"} );
		var navegador = navigator.appName 
		if (navegador == "Microsoft Internet Explorer") {
		jQuery("#header").animate({
				height: "709"
		}, "slow");
		jQuery("#footer").animate({
				top: "480"
		}, "slow");
		jQuery("#contenido").fadeOut("slow");
		jQuery("#boxder-coleccion").fadeIn("slow");
		jQuery("#horizontal-scroller").fadeIn("slow");
		}
		else if (navegador == "Opera") {
			jQuery("#header").animate({
				height: "709"
		}, "slow");
			jQuery("#footer").animate({
				top: "495"
		}, "slow");
			jQuery("#contenido").fadeOut("slow");
			jQuery("#boxder-coleccion").fadeIn("slow");
			jQuery("#horizontal-scroller").fadeIn("slow");
		}
		else {
			jQuery("#header").animate({
				height: "709"
		}, "slow");
			jQuery("#footer").animate({
				top: "495"
		}, "slow");
			jQuery("#contenido").fadeOut("slow");
			jQuery("#boxder-coleccion").fadeIn("slow");
			jQuery("#horizontal-scroller").fadeIn("slow");
		}
		jQuery("#ampliar").remove();
		jQuery("#showhead").remove();
		jQuery("#slideheader").remove();
		jQuery("#ampliarhead").parent().replaceWith("<li><a class='nivel' href='#'>Itinerario recomendado</a></li>");

		
		easyscroll();

			//Agregado germán
		if(jQuery(this).attr('class') == "ampliarheader") {
			if(jQuery(this).attr('id') != "") { 
				setTimeout("activarItinerario("+jQuery(this).attr('id')+")", 500);
			}	
		}		

		return false;
});
};

sfHover = function() {

		jQuery("#menu li.raiz").mouseover(function () {
			jQuery(this).addClass('sfhover');
		});
		jQuery("#menu li.raiz a").mouseout(function () {
			jQuery("#menu li").removeClass('sfhover');
		});
		jQuery("#menu li.raiz ul").mouseout(function () {
			jQuery("#menu li").removeClass('sfhover');
		});
		jQuery("#menu li.raiz ul").mouseout(function () {
			imagenon = jQuery(this).parent().find('img');
			padre = imagenon.attr('src');
			if(/_on/.test(padre)) {
			newsrc = padre.replace('_on','');
			jQuery(imagenon).attr({ src : newsrc});	
			}
		});
		jQuery("#menu li.raiz ul").mouseover(function () {
			imagenon = jQuery(this).parent().find('img');
			padre = imagenon.attr('src');
			ftipo = padre.substring(padre.lastIndexOf('.'));
			newsrc = padre.replace(ftipo, '_on'+ftipo);
			jQuery(imagenon).attr({ src : newsrc});
		});
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function audioguia() 
{
jQuery(".textos-slideheader li.audioguia a").click(function () {
	agObra = jQuery(this).attr('class');
	agIdioma = jQuery(this).attr('href');
	if (jQuery('#box-audioguia').length) {
		jQuery('#box-audioguia').remove();
	}
	else {
		jQuery('.textos-slideheader li.audioguia').append("<div id='box-audioguia'><script type='text/javascript'>var so = new SWFObject('"+ROOT+"audioguia.swf?sfile="+agObra+".mp3&sroot="+ROOT+"&idioma="+agIdioma+"', 'box-audioguia', '66', '17', '8', '#121212');so.addParam('wmode','transparent');so.write('box-audioguia');</script></div>");
	}
	return false;
});
}

function Vidsordos() {
		jQuery.nyroModalSettings({
			debug: false,
			addImageDivTitle: true,
			swf: { wmode: 'transparent' },
			processHandler: function(settings) {
				var url = settings.url;
				if (url && url.indexOf('http://www.youtube.com/watch?v=') == 0) {
					jQuery.nyroModalSettings({
						type: 'swf',
						height: 250,
						width: 330,
						url: url.replace(new RegExp("watch\\?v=", "i"), 'v/')
					});
				}
			},
			endShowContent: function(elts, settings) {
				jQuery('.resizeLink', elts.contentWrapper).click(function(e) {
					e.preventDefault();
					jQuery.nyroModalSettings({
						width: Math.random()*1000,
						height: Math.random()*1000
					});
					return false;
				});
				jQuery('.bgLink', elts.contentWrapper).click(function(e) {
					e.preventDefault();
					jQuery.nyroModalSettings({
						bgColor: '#'+parseInt(255*Math.random()).toString(16)+parseInt(255*Math.random()).toString(16)+parseInt(255*Math.random()).toString(16)
					});
					return false;
				});
			}
		});
		
		jQuery('#manual').click(function(e) {
			e.preventDefault();
			var content = 'Content wrote in JavaScript<br />';
			jQuery.each(jQuery.browser, function(i, val) {
				content+= i + " : " + val+'<br />';
			});
			jQuery.fn.nyroModalManual({
				bgColor: '#3333cc',
				content: content
			});
			return false;
		});
		jQuery('#manual2').click(function(e) {
			e.preventDefault();
			jQuery('#imgFiche').nyroModalManual({
				bgColor: '#cc3333'
			});
			return false;
		});
		jQuery('#myValidForm').submit(function(e) {
			e.preventDefault();
			if (jQuery("#myValidForm :text").val() != '') {
				jQuery('#myValidForm').nyroModalManual();
			} else {
				alert("Enter a value before going to " + jQuery('#myValidForm').attr("action"));
			}
			return false;
		});
		jQuery('#block').nyroModal({
			'blocker': '#blocker'
		});
		
		function preloadImg(image) {
			var img = new Image();
			img.src = image;
		}
		
		preloadImg(ROOT+'/ajaxLoader.gif');
		preloadImg('img/prev.gif');
		preloadImg('img/next.gif');
		
	};
	
	// Page enhancement
	jQuery(function() {
		var allPre = jQuery('pre');
		allPre.each(function() {
			var pre = jQuery(this);
			var link = jQuery('<a href="#" class="showCode">Show Code</a>');
			pre.hide().before(link).before('<br />');
			link.click(function(event) {
					event.preventDefault();
					pre.slideToggle('fast');
					return false;
				});
		});
		var shown = false;
		jQuery('#showAllCodes').click(function(event) {
			event.preventDefault();
			if (shown)
				allPre.slideUp('fast');
			else
				allPre.slideDown('fast');
			shown = !shown;
			return false;
		});
	});


window.onload=function(){
	jQuery('#slideheader').css("left", "325px");
	jQuery('#slideheader').css("position", "absolute");
	jQuery('#slideheader').css("height", "192px");
	jQuery('#slideheader').css("padding", "35px 0px 0px 22px");
	MM_preloadImages(ROOT+'images/menu/es/el-museo_on.gif',ROOT+'images/menu/es/visitar-el-museo_on.gif',ROOT+'images/menu/es/la-coleccion_on.gif',ROOT+'images/menu/es/exposiciones_on.gif',ROOT+'images/menu/es/actualidad_on.gif',ROOT+'images/menu/es/educacion_on.gif',ROOT+'images/menu/es/multimedia_on.gif',ROOT+'images/menu/es/biblioteca_on.gif',ROOT+'images/menu/es/tienda-online_on.gif',ROOT+'images/menu/es/inicio_on.gif');
	sfHover();
}
jQuery(document).ready(function() {
	findimg();
	audioguia();
	Vidsordos();
	//Horizontal Sliding
				jQuery('.boxgrid.slideright').hover(function(){
					jQuery(".cover", this).stop().animate({left:'0px'},{queue:false,duration:500});
				}, function() {
					jQuery(".cover", this).stop().animate({left:'325px'},{queue:false,duration:300});
				});
	ampliador();
	jQuery("div.scrollable").scrollable();
});
