ruta=window.location.pathname;
array_aux=ruta.split('/');
fichero=array_aux[array_aux.length-1];
array_fichero=fichero.split('.');


if(fichero.length==9)
{
	ruta_www='web';
	idioma=1;
}else
{
	
	ruta_www='web'+array_fichero[0].substr(5);
	idioma=array_idioma.indexOf(ruta_www);
	if (idioma==0 || idioma==undefined) {idioma=1}
};

$(document).ready(function(){	
	$(window).resize();
	load_slide();
	load_banner();
	$('input[name="campotexto0"]').keypress(function(e){
        if (e.which == 13){
            e.preventDefault();
			window.location='web/buscador.php?token='+this.value;
         }
    });
				
});	

function load_banner()
{
	img_loading();
	
	$.ajax({
		url: 'comun/fbannerajax.php',
		type: 'POST',
		dataType: 'html',
		cache: false,
		data: ({
		funcion: 'banner',
		ruta:'',
		idioma:idioma
		}),

		success: function(data) {
			img_loading();
			$("#banner").html(data);
			
		
		},
		
		error: function() {
			img_loading();
		}

	});
}

function load_slide()
{
	img_loading();
	
	$.ajax({
		url:  'comun/findexajax.php',
		type: 'POST',
		dataType: 'html',
		cache: false,
		data: ({
		funcion: 'slide',
		idioma:idioma
		}),

		success: function(data) {
			img_loading();
			
			$("#fotos_slide").html(data);
			$('#slides').slides({
				preload: true,
				preloadImage: 'web/images/loading.gif',
				effect: 'fade',
				crossfade: true,
				fadeSpeed: 350,
				play: 5000,
				pause: 2500,
				hoverPause: false,
				pagination: true,

				animationStart: function(current){
					$('.caption').animate({
						bottom:-35
					},100);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationStart on slide: ', current);
					};
				},
				animationComplete: function(current){
					$('.caption').animate({
						bottom:0
					},200);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationComplete on slide: ', current);
					};
				},
				slidesLoaded: function() {
					$('.caption').animate({
						bottom:0
					},200);
				}

			});
		},
		
		error: function() {
			img_loading();
		}

	});
}
			

