$(document).ready(function(){
	var vel = 300;
	
	// Estilos para la navegación secundaria y selector de idioma
	$("#todo_pie nav ul li").css("border-right", "1px solid #666666");
	$("#selector_idioma ul li").css("border-right", "1px solid #cccccc");
	$("#todo_pie nav ul li, #selector_idioma ul li").css("padding-left", "10px");
	$("#todo_pie nav ul li:first-child, #selector_idioma ul li:first-child").css("padding-left", "0px");
	$("#todo_pie nav ul li:last-child, #selector_idioma ul li:last-child").css("border-right", "none");

	// Enlaces del pie
	$("#todo_pie a").hover(
		function() {
			$(this).stop().animate(
				{
					color: "#e7e7e7"
				}, vel
			);
		},
		function() {
			$(this).stop().animate(
				{
					color: "#909090"
				}, vel
			);
		}
	);
	
	// Selector de idioma
	$("#selector_idioma a").hover(
		function() {
			$(this).stop().animate(
				{
					color: "#000000"
				}, vel
			);
		},
		function() {
			$(this).stop().animate(
				{
					color: "#909090"
				}, vel
			);
		}
	);
	
	// Enlaces normales
	$("#todo_contenido a:not(.boton)").hover(
		function() {
			$(this).stop().animate(
				{
					color: "#DC8B1C"
				}, vel
			);
		},
		function() {
			$(this).stop().animate(
				{
					color: "#dc201c"
				}, vel
			);
		}
	);

	// Botones
	if(!(/MSIE (\d+\.\d+);/.test(navigator.userAgent))) {
		$("#todo_contenido a.boton.verde, input.boton.verde, input.sendbutton").hover(
			function() {
				$(this).stop().animate(
					{
						backgroundColor: "#8FCD1A"
					}, vel
				);
			},
			function() {
				$(this).stop().animate(
					{
						backgroundColor: "#404040"
					}, vel
				);
			}
		);
		$("#todo_contenido a.boton.naranja, input.boton.naranja").hover(
			function() {
				$(this).stop().animate(
					{
						backgroundColor: "#DC8B1C"
					}, vel
				);
			},
			function() {
				$(this).stop().animate(
					{
						backgroundColor: "#404040"
					}, vel
				);
			}
		);
		$("#todo_contenido a.boton.azul, input.boton.azul").hover(
			function() {
				$(this).stop().animate(
					{
						backgroundColor: "#1B5A8E"
					}, vel
				);
			},
			function() {
				$(this).stop().animate(
					{
						backgroundColor: "#404040"
					}, vel
				);
			}
		);
	}

	// Galería de trabajos
	//$("ul.trabajos li a img").fadeTo(0, 0.8);
	$("ul.trabajos li a img").hover(function() {
		$(this).stop().fadeTo(200, 0.8);
	},
	function() {
		$(this).stop().fadeTo(200, 1.0);
	});

	// Cajas de texto
	var cajas = "input[type=text], textarea";
	$(cajas).live("focusin",
		function() {
			var color = "#cccccc";
			$(this).stop().animate(
				{
					borderTopColor: color,
					borderBottomColor: color,
					borderLeftColor: color,
					borderRightColor: color
				}, vel
			);
		}
	);
	$(cajas).live("focusout",
		function() {
			var color = "#e7e7e7";
			$(this).stop().animate(
				{
					borderTopColor: color,
					borderBottomColor: color,
					borderLeftColor: color,
					borderRightColor: color
				}, vel
			);
		}
	);
	
	// Scroll en lista de servicios
	$("ul.lista_servicios a").click(function(event) {
		event.preventDefault();
		var full_url = this.href;
		var parts = full_url.split("#");
		var trgt = parts[1];
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;
		$('html, body').animate({scrollTop:target_top}, vel);
	});
	
	$("a.arriba").click(function(event) {
		event.preventDefault();
		$('html, body').animate({scrollTop:0}, vel);
	});
});

