//Visor de imágenes Rotate Ads Variable

interval_time = 8000; // 6 seconds between changes
old_item = 0;
current_item = 0;

interval_time_00 = 3000; // 6 seconds between changes
old_item_00 = 0;
current_item_00 = 0;

current_prom = 0;
old_prom = 0;

//JQUERY

$(document).ready(function(){
	
	$("#idioma")
	.mouseenter(
		function(){
			$("#idioma").animate({
			"right": "0px"
   			},500);}
	)
	.mouseleave(
		function(){
			$("#idioma").animate({
			"right": "-119px"
   			},500);}
	);
	
	$("#services")
	.mouseenter(
		function(){
			$("#services_menu").slideToggle('fast');}
	)
	.mouseleave(
		function(){
			$("#services_menu").slideToggle('fast');}
	);
	
	$("#about_div_01, #about_div_02, #about_div_03")
	.toggle(
		function(){
			$("#"+this.id+" div h1.indicador").html('[-]');
			$("#"+this.id+" div").animate({
			"top": 469 - $("#"+this.id+" div").height() + "px"
			},500
			);},
		function(){
			$("#"+this.id+" div h1.indicador").html('[+]');
			$("#"+this.id+" div").animate({
			"top": "450px"
			},500
			);}
	);
	
	$("#service_div_01")
	.toggle(
		function(){
			$("#"+this.id).animate({
			"right": "108px" 
			},500
			);
			$("#"+"service_div_0"+2).animate({
			"right": "72px" 
			},500
			);
			$("#"+"service_div_0"+3).animate({
			"right": "36px" 
			},500
			);
			$("#"+"service_div_0"+4).animate({
			"right": "0px" 
			},500
			);
			},
		function(){
			}
	);
	
	$("#service_div_02")
	.toggle(
		function(){
			$("#"+this.id).animate({
			"right": "72px" 
			},500
			);
			$("#"+"service_div_0"+3).animate({
			"right": "36px" 
			},500
			);
			$("#"+"service_div_0"+4).animate({
			"right": "0px" 
			},500
			);
			},
		function(){
			$("#"+"service_div_0"+1).animate({
			"right": "900px" 
			},500
			);
			}
	);
	
	$("#service_div_03")
	.toggle(
		function(){
			$("#"+this.id).animate({
			"right": "36px" 
			},500
			);
			$("#"+"service_div_0"+4).animate({
			"right": "0px" 
			},500
			);
			},
		function(){
			$("#"+"service_div_0"+2).animate({
			"right": "864px" 
			},500
			);
			$("#"+"service_div_0"+1).animate({
			"right": "900px" 
			},500
			);
			}
	);
	
	$("#service_div_04")
	.toggle(
		function(){
			$("#"+this.id).animate({
			"right": "0px" 
			},500
			);},
		function(){
			$("#"+"service_div_0"+3).animate({
			"right": "828px" 
			},500
			);
			$("#"+"service_div_0"+2).animate({
			"right": "864px" 
			},500
			);
			$("#"+"service_div_0"+1).animate({
			"right": "900px" 
			},500
			);
			}
	);
	
	$("#"+"service_div_0"+4).animate({
		"right": "0px" 
		},500
	);	

//rotate ads
	
	item_count = $("div.slideshow-item").size();

    $("div.slideshow-item").each(function(i) {
    	$(this).hide();
    });

    $("div.slideshow-item:eq(" + current_item + ")").fadeIn("slow");

    item_interval = setInterval(item_rotate, interval_time); // time in milliseconds
    
	/* EVENTO QUE PARA LA ANIMACIÓN CUANDO EL MOUSE ESTA ENCIMA
	$('#slideshow-container').hover(function() {
    	clearInterval(item_interval);
    }, function() {
    	item_interval = setInterval(item_rotate, interval_time); //time in milliseconds
    	item_rotate();
    });
	*/
	
	//END rotate ads
	
//rotate mesajes del inicio
	
	item_count_00 = $("div.slideshow-item_00").size();

    $("div.slideshow-item_00").each(function(i) {
    	$(this).hide();
    });

    $("div.slideshow-item_00:eq(" + current_item + ")").fadeIn("slow");

    item_interval_00 = setInterval(item_rotate_00, interval_time_00); // time in milliseconds
	
	/* EVENTO QUE PARA LA ANIMACIÓN CUANDO EL MOUSE ESTA ENCIMA
    $('#slideshow-container_00').hover(function() {
    	clearInterval(item_interval_00);
    }, function() {
    	item_interval_00 = setInterval(item_rotate_00, interval_time_00); //time in milliseconds
    	item_rotate_00();
    });
	*/
	
	//END rotate mensajes del inicio
	
	// ---- PROMOCIONES ---- //
	/*
	// Variable que cuenta cuantos promos hay
	prom_count = $(".prom_banner").size();
	link_prom_count = $(".link_prom").size();
	 
	$(".prom_banner").each(function(i) {
    	$(this).hide();
 	});

	$(".prom_banner:eq(" + current_prom + ")").fadeIn("fast");
	$(".link_prom:eq(" + current_prom + ")").addClass('current_prom');
	
	//Eventos
	$(".link_prom").click(
			function(e){
				
				$(".link_prom").each(
				function(o){
					$(this).removeClass('current_prom');
				});
				
				$("#"+e.currentTarget.id).addClass('current_prom');
				
				var x = e.currentTarget.id.slice(-1);
				
				$(".prom_banner:eq(" + current_prom + ")").fadeOut("fast",
					function(){
					$(".prom_banner:eq(" + x + ")").fadeIn("fast");
					current_prom = parseInt(x);
					}
				);
		}
	);
	*/
	// --- FIN PROMOCIONES --- //
});

//Visor de imágenes Rotate Ads Funcion

function item_rotate() {
	current_item = (old_item + 1) % item_count;
	$("div.slideshow-item:eq(" + old_item + ")").fadeOut("slow", function() {
		$("div.slideshow-item:eq(" + current_item + ")").fadeIn("slow");
	});
	old_item = current_item;
}

function item_rotate_00() {
	current_item_00 = (old_item_00 + 1) % item_count_00;
	$("div.slideshow-item_00:eq(" + old_item_00 + ")").fadeOut("slow", function() {
		$("div.slideshow-item_00:eq(" + current_item_00 + ")").fadeIn("slow");
	});
	old_item_00 = current_item_00;
}

/* PROMOCIONES FUNCIONES */

/* Funcione spara cuando haya más promociones 
function viewArrows(){
		// Declara e inicia la variable 'x' 
		var x = $('#slice_pomitions_cont').css('left');
		// Verifica que se recoge bien la variable mostrandola en la consola Javascript del navegador Chrome
		console.log("Posicion Left: " + x);
}

function moverSliceImgDer(){
	    // Se declara e inicia las variables.
		var x = $('#slice_pomitions_cont').css('left');
		var ancho_img = 151;
		var separacion = 5;
		var pasos = 1;
		
		$('#slice_pomitions_cont').css('left', String(( parseInt(x) - ancho_img - separacion ) * pasos ));	
}
*/
// Acciones al iniciar promociones.
// 

function rollProm(){
	
}

function selectLinkProm(){
	
}

/* FIN PROMOCIONES FUNCIONES */
