var eneLib = 
{
	main : {
		init : function() {
			/*TierraLib.scrollpanel.init();
			TierraLib.carousel.init();
			TierraLib.shadowbox.init();
			TierraLib.cufon.init();*/
			eneLib.toggle.init();
			/*TierraLib.photoGallerySlider.init();*/
		}
	},	
	
	/** << Set scrollpanel 
	* ---------------------*/
	scrollpanel : {
		init : function() {
			$('.scrollPane').jScrollPane();
		}
	},
	
	
	/** << Set tabs 
	* ---------------------*/
	tabs : {
		init : function() {
			$("#tabs").tabs();							
		}
		
	},
	
	carousel : {
		init : function(){
    		jQuery('#mycarousel').jcarousel({scroll:1});
		}
	},
	
	
	subMenu: {
		init : function() {
			  $('#ambientes').hover(function() {
				$('#contentAmbientes').slideToggle();
			  });
			  
			   $('#tasca').hover(function() {
				$('#contentTasca').slideToggle();
			  });
			  
			   $('#salon').hover(function() {
				$('#contentSalon').slideToggle();
			  });
		}
	},
	
	
	subMenuCarta: {
		init : function() {
			  $('#carta').hover(function() {
				$('#contentCarta').slideToggle();
			  });
		}
	},
	
	
	
	/** << Set shadowbox 
	* ---------------------*/
	shadowbox : {
		init : function() { 
							Shadowbox.loadSkin('classic', 'js/shadowbox-2.0/src/skin');
							Shadowbox.loadLanguage('en', 'js/shadowbox-2.0/src/lang');
							Shadowbox.loadPlayer(['html', 'iframe', 'img'], 'js/shadowbox-2.0/src/player');
							window.onload = function(){
							 Shadowbox.init( { 
									animSequence:'snyc'			
								}); 
							};
			/*Shadowbox.init({
			    handleOversize: "drag",
			    modal: true
			});*/


		}
	},
	
	contactForm : {
		init : function()
		{
			MyApp.contactForm.validate();
			MyApp.contactForm.LimpiarCampos();
		},
		
		validate : function()
		{
			$("#nombre, #apellido, #pais").alpha({allow:" -"});
			$("#telefono").numeric({allow:"-"});
			$("#email").alphanumeric({allow:"-_.@"});
			
			var v = $("#formContact").validate({
				errorElement : 'span',
				onkeyup: false,
				onblur: false,
				errorClass: "invalid",
				rules: {
					nombre: { required: true  },
					apellido: { required: true  },
					telefono: { required: true  },
					email: { required: true, email:true  },
					pais: { required:true }
				},
				messages: {
					nombre: { required: 'Este campo es obligatorio'  },
					apellido: { required: 'Este campo es obligatorio'  },
					telefono: { required: 'Este campo es obligatorio'  },
					email: { required: 'Este campo es obligatorio' , email:'Escriba un email v&aacute;lido' },
					pais: { required: 'Este campo es obligatorio'  }
				},
				submitHandler: function(form) {
					form.submit();
				},
				success: function(span) { // set   as text for IE
					span.html(" ").addClass("checked");
				}
			});
		},
		
		defaultInputValues : function()
		{
			$('input:text').click(function(){
				if($(this).val()== $(this).attr("title")){
					$(this).val("");
				}							 
			});
			$('input:text').focusout(function(){
					if($(this).val()== ""){
						$(this).val($(this).attr("title"));
					}							 
				});
				
			$("textarea").focus(function(){
					if($(this).html()==$(this).attr("title")){
						$(this).html('');
					}							 
				});
			
			$("input[type=text]").focus(function(){
				$("#comentario").html($("#comentario").attr("title"));
			});	
		},	
			
		LimpiarCampos: function()
		{ 
			$("#enviar").click(function(){
				$('input:text').each(function (i) {
					if($(this).val()== $(this).attr("title")){
							$(this).val("");
						}	
			 	 });
			});
		}
	},
	
	toggle : {
		init : function() {
        $('#minimizar').toggle (
            function(e) {
                e.preventDefault();
				$('#contentMain').fadeOut("slow");
                /*$('#contentSecundary').hide({direction: "right"},600);*/
                $('img', this).attr('src','images/btnAbrirCaja.png');
                $(this).attr('title','Maximizar');
            },
            function(e) {
                e.preventDefault();
				$('#contentMain').fadeIn("slow");
                /*$('#contentSecundary').show({direction: "right"},600);*/
                $('img', this).attr("src","images/btnCerrarCaja.png");
                $(this).attr('title','Minimizar');
            }
        );
	   }
	},
	
	photoGallerySlider : {
		init : function(){
			var alreadyDrawn = false;
			
			var feed = $('#photo-gallery-left');
			feed.css("display", "block").data("showing", false).children("form").hide()
			feed.children("img").click(function() {
				var t = feed;
				if(t.data("showing") == false) {
					t.animate({
						marginRight: "0",
						height: "133px"
					}).data("showing", true).children("img").attr("src", "/images/botones/btn-photo-gallery.png").css("top", "0").siblings().show();
					//$('div#container-gallery-right').css('display','block');
				} else {
					t.animate({
						marginRight: "-522px",
						height: "133px"
					}).data("showing", false).children("img").attr("src", "/images/botones/btn-photo-gallery.png").css("top", "0").siblings().hide();
					//$('div#container-gallery-right').css('display','block');
				}
			})
		}
	}		
}

