$(document).ready(function(){
			
	var tiempo_entre_letras = 70;
	var sistema_operativo = navigator.appVersion.toLowerCase();
	var navegador = navigator.appName;
		
	function setearTopLeftSiEsLinux(id_imagen){
		
		// Si se utiliza Linux se modifica el valor top y left para las seis imagenes
		if (sistema_operativo.indexOf('windows') == -1) {
			$("#"+id_imagen).css({ "top":"150px", "left":"238px" });//250
		}	
	}
					
	function crearImagenUno(){
		
		$('<div id="imagen1" class="imagen"></div>').appendTo('#intro_animado');
		//setearTopLeftSiEsLinux("imagen1");
		animarImagenUno();
	}
	
	function crearImagenDos(){
		
		$('<div id="imagen2" class="imagen"></div>').appendTo('#intro_animado');
		//setearTopLeftSiEsLinux("imagen2");
		animarImagenDos();
	}
	
	function crearImagenTres(){
		
		$('<div id="imagen3" class="imagen"></div>').appendTo('#intro_animado');
		//setearTopLeftSiEsLinux("imagen3");
		animarImagenTres();
	}
	
	function crearImagenCuatro(){
		
		$('<div id="imagen4" class="imagen"></div>').appendTo('#intro_animado');
		//setearTopLeftSiEsLinux("imagen4");
		animarImagenCuatro();
	}
	
	function crearImagenCinco(){
		
		$('<div id="imagen5" class="imagen"></div>').appendTo('#intro_animado');
		//setearTopLeftSiEsLinux("imagen5");
		animarImagenCinco();
	}
	
	function crearImagenSeis(){
		
		$('<div id="imagen6" class="imagen"></div>').appendTo('#intro_animado');
		//setearTopLeftSiEsLinux("imagen6");
		animarImagenSeis();
	}
	
	function crearEscudo(){
		
		$('<div id="escudo"></div>').appendTo('#intro_animado');
		
		// Si se utiliza Linux se modifica el valor top y left
		if (sistema_operativo.indexOf('windows') == -1) {
			$("#escudo").css({ "top":"170px", "left":"295px" });
		}
		
		$("#escudo").fadeIn(700, function(){
			animarEscudo();
		});	
	}
	
	function crearTitulo(){
		
		$('<div id="titulo">Honorable Concejo Deliberante<br>Partido de General Pueyrredon</div>').appendTo('#intro_animado');
		
		// Si se utiliza Linux se modifica el valor top y left
		if (sistema_operativo.indexOf('windows') == -1) {
			$("#titulo").css({ "top":"270px", "left":"197px" });
		}
		
		$("#titulo").fadeIn('slow', function(){
			animarTitulo();
		});		
	}
	
	function animarEscudo(){
		
		var valor_left = 295;
		/**
		// Si se utiliza Linux se modifica el valor de left
		if (sistema_operativo.indexOf('windows') == -1) {
			valor_left = 295;
		}
		/**/
		$("#escudo").animate({ top: 100, left: valor_left }, 700, function(){
			crearTitulo();
		});
	}
	
	function animarTitulo(){
		
		var valor_left = 197;
		/**
		// Si se utiliza Linux se modifica el valor de left
		if (sistema_operativo.indexOf('windows') == -1) {
			valor_left = 197;
		}
		/**/
		$("#titulo").animate({ top: 220, left: valor_left }, 700, function(){
			animarVolveAEnamorarte();
		});
	}
	
	function animarVolveAEnamorarte(){
		mostrarVolveAEnamorarte();
	}
	
	function animarImagenUno()
	{
		/**
		if ( navegador == "Microsoft Internet Explorer" )
		{
			var valor_top = "-=148";
			var valor_left = "-=235";
		}
		else
		{
			var valor_top = "-=148";
			var valor_left = "-=235";
		}
		/**/
		var valor_top = "-=148";
		var valor_left = "-=238";
		
		$('#imagen1').animate({ width: '+=219', height: '+=172' }, 1200, function(){
			$('#imagen1').animate({ top: valor_top, left: valor_left, width: "-=30", height: "-=30" }, 700, function(){
				$("#imagen1").css("-moz-border-radius", "0px 22px 22px 0px");
				$("#imagen1").css("-webkit-border-radius", "0px 22px 22px 0px");
				$("#imagen1").css("border-radius", "0px 22px 22px 0px");
				crearImagenDos();
			});
		});		
	}
	
	function animarImagenDos()
	{
		/**
		if (navegador == "Microsoft Internet Explorer"){
			var valor_top = "+=3";
			var valor_left = "-=235";
		}else{
			var valor_top = "+=3";
			var valor_left = "-=235";
		}
		/**/
		var valor_top = "+=3";
		var valor_left = "-=238";
		
		$('#imagen2').animate({ width: '+=219', height: '+=172'}, 1200, function(){
			$("#imagen2").animate({ top: valor_top, left: valor_left, width: "-=30", height: "-=30" }, 700, function(){
				$("#imagen2").css("-moz-border-radius", "0px 22px 22px 0px");
				$("#imagen2").css("-webkit-border-radius", "0px 22px 22px 0px");
				$("#imagen2").css("border-radius", "0px 22px 22px 0px");
				crearImagenTres();
			});
		});		
	}
	
	function animarImagenTres()
	{
		/**
		if (navegador == "Microsoft Internet Explorer"){
			var valor_top = "+=155";
			var valor_left = "-=235";
		}else{
			var valor_top = "+=155";
			var valor_left = "-=235";
		}
		/**/
		var valor_top = "+=155";
		var valor_left = "-=238";
		
		$('#imagen3').animate({ width: '+=219', height: '+=172'}, 1200, function(){
			$("#imagen3").animate({ top: valor_top, left: valor_left, width: "-=30", height: "-=30" }, 700, function(){
				$("#imagen3").css("-moz-border-radius", "0px 22px 22px 0px");
				$("#imagen3").css("-webkit-border-radius", "0px 22px 22px 0px");
				$("#imagen3").css("border-radius", "0px 22px 22px 0px");
				crearImagenCuatro();
			});
		});		
	}
	
	function animarImagenCuatro(){
	
		if (navegador == "Microsoft Internet Explorer"){
			var valor_top = 2;
			var valor_left = 501;
		}else{
			var valor_top = 2;
			var valor_left = 503;
			
			// Si se utiliza Linux se modifica el valor de left
			if (sistema_operativo.indexOf('windows') == -1) {
				valor_left = 504;
			}
		}
		$('#imagen4').animate({ width: '+=219', height: '+=172' }, 1200, function(){
			$("#imagen4").animate({ top: valor_top, left: valor_left, width: "-=30", height: "-=30" }, 700, function(){
				$("#imagen4").css("-moz-border-radius", "22px 0px 0px 22px");
				$("#imagen4").css("-webkit-border-radius", "22px 0px 0px 22px");
				$("#imagen4").css("border-radius", "22px 0px 0px 22px");
				crearImagenCinco();
			});
		});		
	}
	
	function animarImagenCinco(){
	
		if (navegador == "Microsoft Internet Explorer"){
			var valor_top = 154;
			var valor_left = 501;
		}else{
			var valor_top = 154;
			var valor_left = 503;
			
			// Si se utiliza Linux se modifica el valor de left
			if (sistema_operativo.indexOf('windows') == -1) {
				valor_left = 504;
			}
		}
		$('#imagen5').animate({ width: '+=219', height: '+=172'}, 1200, function(){
			$("#imagen5").animate({ top: valor_top, left: valor_left, width: "-=30", height: "-=30" }, 700, function(){
				$("#imagen5").css("-moz-border-radius", "22px 0px 0px 22px");
				$("#imagen5").css("-webkit-border-radius", "22px 0px 0px 22px");
				$("#imagen5").css("border-radius", "22px 0px 0px 22px");
				crearImagenSeis();
			});
		});		
	}
	
	function animarImagenSeis(){
	
		if (navegador == "Microsoft Internet Explorer"){
			var valor_top = 305;
			var valor_left = 501;
		}else{
			var valor_top = 307;
			var valor_left = 503;
			
			// Si se utiliza Linux se modifica el valor de left
			if (sistema_operativo.indexOf('windows') == -1) {
				valor_left = 504;
			}
		}
		$('#imagen6').animate({ width: '+=219', height: '+=172'}, 1200, function(){
			$("#imagen6").animate({ top: valor_top, left: valor_left, width: "-=30", height: "-=30" }, 700, function(){
				$("#imagen6").css("-moz-border-radius", "22px 0px 0px 22px");
				$("#imagen6").css("-webkit-border-radius", "22px 0px 0px 22px");
				$("#imagen6").css("border-radius", "22px 0px 0px 22px");
				crearEscudo();
			});
		});		
	}
	
	// SE REEMPLAZA aenamorarte POR amardelplata DEJANDO volver SIN TOCAR
	function reemplazarPorAMarDelPlata(){
		
		$("#volvea17").html("a").css("color", "#fff").hide().fadeIn(tiempo_entre_letras, function(){
			$("#volvea16").html("t").css("color", "#fff").hide().fadeIn(tiempo_entre_letras, function(){
				$("#volvea15").html("a").css("color", "#fff").hide().fadeIn(tiempo_entre_letras, function(){
					$("#volvea14").html("l").css("color", "#fff").hide().fadeIn(tiempo_entre_letras, function(){
						$("#volvea13").html("p").css("color", "#fff").hide().fadeIn(tiempo_entre_letras, function(){
							$("#volvea12").html("l").css("color", "#fff").hide().fadeIn(tiempo_entre_letras, function(){
								$("#volvea11").html("e").css("color", "#fff").hide().fadeIn(tiempo_entre_letras, function(){
									$("#volvea10").html("d").css("color", "#fff").hide().fadeIn(tiempo_entre_letras, function(){
										$("#volvea9").html("r").css("color", "#fff").hide().fadeIn(tiempo_entre_letras, function(){
											$("#volvea8").html("a").css("color", "#fff").hide().fadeIn(tiempo_entre_letras, function(){
												$("#volvea7").html("m").css("color", "#fff").hide().fadeIn(tiempo_entre_letras, function(){
													$("#volvea6").html("a").css("color", "#fff").hide().fadeIn(tiempo_entre_letras, function(){
														$("#volvea18").fadeIn(2000, function(){
															removerVolveAMarDelPlata();
														});	
													});
												});	
											});			
										});	
									});	
								});	
							});	
						});	
					});	
				});	
			});	
		});	
	}	
	
	// Se remueve letra por letra de volveamardelplata de atras hacia adelante
	function removerVolveAMarDelPlata() {
		
		$("#volvea18").fadeOut(2000, function(){
			$("#volvea17").fadeOut(tiempo_entre_letras, function(){
				$("#volvea16").fadeOut(tiempo_entre_letras, function(){
					$("#volvea15").fadeOut(tiempo_entre_letras, function(){
						$("#volvea14").fadeOut(tiempo_entre_letras, function(){
							$("#volvea13").fadeOut(tiempo_entre_letras, function(){
								$("#volvea12").fadeOut(tiempo_entre_letras, function(){
									$("#volvea11").fadeOut(tiempo_entre_letras, function(){
										$("#volvea10").fadeOut(tiempo_entre_letras, function(){
											$("#volvea9").fadeOut(tiempo_entre_letras, function(){
												$("#volvea8").fadeOut(tiempo_entre_letras, function(){
													$("#volvea7").fadeOut(tiempo_entre_letras, function(){
														$("#volvea6").fadeOut(tiempo_entre_letras, function(){
															$("#volvea5").fadeOut(tiempo_entre_letras, function(){
																$("#volvea4").fadeOut(tiempo_entre_letras, function(){
																	$("#volvea3").fadeOut(tiempo_entre_letras, function(){
																		$("#volvea2").fadeOut(tiempo_entre_letras, function(){
																			$("#volvea1").fadeOut(tiempo_entre_letras, function(){
																				mostrarVolveAEnamorarte();
																			});
																		});	
																	});
																});
															});		
														});
													});
												});
											});
										});
									});	
								});
							});
						});		
					});
				});
			});
		});
	}
	
	// Se muestra letra por letra volveaenamorarte de izquierda a derecha		
	function mostrarVolveAEnamorarte() {
		
		$("#volvea1").html("v").fadeIn(tiempo_entre_letras, function(){
			
			$("#volvea2").html("o").fadeIn(tiempo_entre_letras, function(){
				
				$("#volvea3").html("l").fadeIn(tiempo_entre_letras, function(){
					
					$("#volvea4").html("v").fadeIn(tiempo_entre_letras, function(){
						
						$("#volvea5").html(""+'\u00e9'+"").fadeIn(tiempo_entre_letras, function(){
							
							$("#volvea6").html("a").fadeIn(700, function(){
								
								$("#volvea6").css("color","#003454");
								$("#volvea7").html("e").fadeIn(tiempo_entre_letras, function(){
									
									$("#volvea7").css("color","#003454");
									$("#volvea8").html("n").fadeIn(tiempo_entre_letras, function(){
										
										$("#volvea8").css("color","#003454");
										$("#volvea9").html("a").fadeIn(tiempo_entre_letras, function(){
											
											$("#volvea9").css("color","#003454");
											$("#volvea10").html("m").fadeIn(tiempo_entre_letras, function(){
												
												$("#volvea10").css("color","#003454");	
												$("#volvea11").html("o").fadeIn(tiempo_entre_letras, function(){
													
													$("#volvea11").css("color","#003454");
													$("#volvea12").html("r").fadeIn(tiempo_entre_letras, function(){
														
														$("#volvea12").css("color","#003454");
														$("#volvea13").html("a").fadeIn(tiempo_entre_letras, function(){
															
															$("#volvea13").css("color","#003454");
															$("#volvea14").html("r").fadeIn(tiempo_entre_letras, function(){
																
																$("#volvea14").css("color","#003454");
																$("#volvea15").html("t").fadeIn(tiempo_entre_letras, function(){
																	
																	$("#volvea15").css("color","#003454");
																	$("#volvea16").html("e").fadeIn(tiempo_entre_letras, function(){
																		
																		$("#volvea16").css("color","#003454");
																		$("#volvea17").html("").fadeIn(2000, function(){
																			
																			$("#volvea18").fadeIn(2000, function(){
																				reemplazarPorAMarDelPlata();
																			});
																		});
																	});	
																});
															});
														});		
													});
												});
											});
										});
									});
								});	
							});
						});
					});		
				});
			});
		});
	}
	
	function ocultarVolveAEnamorarte(){
		
		for (var i = 1; i < 19; i++) {
			var letra = "#volvea"+i;
			$(letra).hide();
		}
	}	
	
	function iniciarAnimacion(){
		
		ocultarVolveAEnamorarte();
		crearImagenUno();
	}
	//alert(sistema_operativo);
	iniciarAnimacion();
});	

