MyApp = {
	Main : {
		init : function() 
		{
		}
	},
	home : {
		slide : function()
		{
    		$('#slide').cycle({ 
			fx: 'fade',
			speed:       1000, 
			timeout:     3000, 
			pager:      '#nav',
            before: function(){
                /*$(".contentTextSlide").hide().delay(1000).fadeIn('');*/
                //alert('Alert');
            },
            after:   function(curr, next, opts){
               // var index = opts.currSlide;
                //alert(index);
				
				//var index = $(".conatinerSlide").index(this);
  				//$("span").text("That was div index #" + index);

				/*$(".contentTextSlide").hide().delay(500).fadeIn('');*/
				
               // var indexv = $(".conatinerSlide").index(index);
				
                //$(".conatinerSlide .contentTextSlide p").hide()
                //indexv.innerHTML = 'Josd'+index;
				
               // $(".conatinerSlide .contentTextSlide p").eq(index).html("byyyyy"+index);
				
                //$(".conatinerSlide .contentTextSlide p").html("Index " + indexv + " was clicked");
                //$('#contentTextSlide p').html('red');
                /*if(index == 0)
                {
                    $('#prevBoutique').removeClass();
                    $('#prevBoutique').addClass('sliders-prev');
                    
                }else{
                    $('#prevBoutique').removeClass();
                    $('#prevBoutique').addClass('sliders-prev-on');
                }
                
                if(index == opts.slideCount - 1)
                {
                    $('#nextBoutique').removeClass();
                    $('#nextBoutique').addClass('sliders-next');
                }else{
                    $('#nextBoutique').removeClass();
                    $('#nextBoutique').addClass('sliders-next-on');
                }*/
            }
			});
		}
	},
	
	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();
							};
		}
	},
	
	
	tabs :{
		init : function(){
				$( "#tabs" ).tabs();
			}
	},	
	
	contactForm : {
		init : function()
		{
			MyApp.contactForm.validate();
			MyApp.contactForm.defaultInputValues();
			MyApp.contactForm.LimpiarCampos();
		},
		
		
		
		validate : function()
		{
			$("#name, #nacionalidad").alphanumeric({allow:" -"});
			$("#phone, #movil, #horarioI, #horarioII").numeric({allow:"-"});
			$("#email").alphanumeric({allow:"-_.@"});
			
			var v = $("#formContact").validate({
				errorElement : 'span',
				onkeyup: false,
				onblur: false,
				errorClass: "invalid",
				rules: {
					name: { required: true  },
					nacionalidad: { required: true  },
					direccion: { required: true  },
					/*phone: { required: true  },*/
					movil: { required: true  },
					email: { required: true, email:true  }
				},
				messages: {
					name: { required: '<br>Ingresar nombre y apellidos'  },
					nacionalidad: { required: '<br>Ingresar nacionalidad'  },
					/*phone: { required: '<br>This field is required'  },*/
					movil: { required: '<br>Ingresar # Móvil'  },
					direccion: { required: '<br>ingresar direccion'  },
					email: { required: '<br>Ingresar email' , email:'<br>Ingresar email válido' }
				},
				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(){
				$("#mensaje").html($("#mensaje").attr("title"));
			});	
		},		
		LimpiarCampos: function()
		{ 
			$("#botonSend").click(function(){
				$('input:text').each(function (i) {
					if($(this).val()== $(this).attr("title")){
							$(this).val("");
						}	
			 	 });
				/*alert("Es una prueba");*/
			});
		}
	},	
	
	combobox : {
		init : function(){
			this.setupCombobox();
		},
		
		setupCombobox : function(){
			
			var _quickSearchComboboxLarge = null;
			var _animationType = "slide";
			var comboboxSettings = { animationSpeed: 50 };
			var options = {
					comboboxContainerClass: "comboboxContainer",
					comboboxValueContentContainerClass: "comboboxValueContainer",
					comboboxValueContentClass: "comboboxValueContent",
					comboboxDropDownClass: "comboboxDropDownContainer",
					comboboxDropDownButtonClass: "comboboxDropDownButton",
					comboboxDropDownItemClass: "comboboxItem",
					comboboxDropDownItemHoverClass: "comboboxItemHover",
					comboboxDropDownGroupItemHeaderClass: "comboboxGroupItemHeader",
					comboboxDropDownGroupItemContainerClass: "comboboxGroupItemContainer"
			};
			
			var _quickSearchComboboxLarge = $('#distrito, #tratamiento').combobox(options,{ animationType: _animationType, width:278 });
			var _quickSearchComboboxLarge = $('#horarioII').combobox(options,{ animationType: _animationType, width:150 });
			/*var _quickSearchComboboxLarge = $('#adults, #children, #room').combobox(options,{ animationType: _animationType, width:58 });*/
			
		}
	}
	
	
}
MyApp.Main.init();
