		// bubbles
		$(function() {
			var duration = 500;
			
			var myBubbles = $('.bubble');
			
			myBubbles.css('opacity', 0);
			$('#bubbleWrap').css('visibility', 'visible')
			
			var vis = 0;
			
			function showBubble(i)
			{
				myBubbles.eq(vis).stop().animate( {
					'opacity' : 0,
					'margin-top' : '0px'
				}, duration);	
				vis = i;

				myBubbles.eq(i).stop().animate({
					'opacity' : 1,
					'margin-top' : '-15px'
				}, duration);	
			}
			
			showBubble(0);
			
			// Add our events to the pages
			$('.page').each(function(i, el) {
				// el.set('morph', {link : 'cancel'});
				
				$(el).bind('mouseenter', function() {
						showBubble(i);
					});
			});
		});
		
		// menus
		var speed = "slow"
	
		function showsubmenu(submenu) {
			active_submenu = submenu;
			$(submenu).stop().fadeTo(speed, 1).css("z-index", 1);
		}
		
		function hidesubmenu(menu) {
			$(menu).stop().fadeTo(speed, 0, function() {
				$(menu).hide();
			});
		}
		
		$(function() {
			$(".submenu").each(function(index, element) {
					var submenu = "#" + $(this).attr("id");
					
					$(this).mouseover(function(evt) {
							if(active_submenu == submenu)
								showsubmenu(submenu);
						}).mouseleave(function(evt) {
							hidesubmenu(submenu);
						});
				});

			$(".menu").each(function(index, element) {
					var submenu = "#sub" + ($(this).attr("id"));
					$(this).mouseover(function(evt)	{
							showsubmenu(submenu);
						}).mouseleave(function(evt) {
							if($(evt.relatedTarget) != $(submenu))
								hidesubmenu(submenu);
						});
				});
		});
		
		// contacto
		function validateEmail(str)
		{
			var emailPattern =/^.+@.+\..{2,6}$/;							   
			var illegalChars=/[\(\)\<\>\,\;\:\\\/\"\[\]]/;

			return emailPattern.test(str) && !str.match(illegalChars);
		}
		
		if(typeof String.prototype.trim !== 'function')
		{
			String.prototype.trim = function()
			{
				return this.replace(/^\s+|\s+$/g, ''); 
			}
		}		
   
		function ContactoEnviar()
		{
			var name = $("#field_contact_name").val().trim();
			var email = $("#field_contact_email").val().trim();
			var phone = $("#field_contact_phone").val().trim();
			var comment = $("#field_contact_comment").val().trim();
			
			$("#contact_result").html("");
			
			if(name == "*nombre..." || name.length == 0)
			{
				alert("-- introduzca un nombre");
				return;
			}
			
			if(!validateEmail(email) != "")
			{
				alert("-- introduzca un email valido");
				return;
			}
			
			if(comment == "*comentarios..." || comment.length == 0)
			{
				alert("-- introduzca un telefono");
				return;
			}
			
			$("#field_contact_send").attr('disabled', 'disabled');
			$("#contact_result").html("Su comentario esta siendo enviado..");
			
			$.ajax({
				url: "contacto/contacto.php",
				type: "POST",
				datatype: "text",
				data: {
					"nombre": name,
					"email": email,
					"tlf": phone,
					"comentarios": comment
				},			
				success: function(data)	{
					$("#contact_result").html(data);
				},
				error: function() {
					$("#contact_result").html("Su comentario no ha podido ser enviado. Por favor, inténtelo de nuevo mas tarde.");
				},
				complete: function() {
					$("#field_contact_send").attr('disabled', '');
				}
			});
		}
		
		// facebook
		$(document).ready(function() {
		$(".button").hover(function() {
			$(this).attr("src","img/facebook_sisan_on.png");
				}, function() {
			$(this).attr("src","img/facebook_sisan_off.png");
		});
		});
		// twitter
		$(document).ready(function() {
		$(".button1").hover(function() {
			$(this).attr("src","img/tiny-timeline-bird2_on.png");
				}, function() {
			$(this).attr("src","img/tiny-timeline-bird2_off.png");
		});
	});

