MyApp = {
	Main : {
		init : function() 
		{
		}
	},
	home : {
		slide : function()
		{
    		$('#slide').cycle({ fx: 'fade' });
		}
	},
	opacityDivs : {
		init : function(){
			$('#textProduct').animate({opacity: 0.1});
		}
	},

	dialog : {
		init : function(){
			$.fx.speeds._default = 1000;
			$(function() {
				$( "#dialog" ).dialog({
					autoOpen: false,
					resizable: false,
					/*show: "blind",*/
					modal: true,
					hide: "explode"
				});
				
				$( ".opener" ).click(function() {
					$( "#dialog" ).dialog( "open" );
					return false;
				});
			});	
		}		
	},
	
	
	cargaImg: {			
		init : function(){
			capa = $("#contentImgProducto li a img");	
			capa.delay(500).show(1);
			capa2 = $("#textProduct");	
			capa2.delay(500).show(1);
		}
			

	},	

	Zoom : {
		init : function(){
			 $('.zoom').jloupe({ radiusLT:100, radiusRT:100, radiusRB:100, radiusLB:100, width:200, height:200, borderColor:'#f2730b', background:'none', fade:false});
		}
	},
	jcarousel : {
		init : function(){
			jQuery('#mycarousel').jcarousel();
		}
	},	
	
	contactForm : {
		init : function()
		{
			MyApp.contactForm.validate();
			MyApp.contactForm.defaultInputValues();
			MyApp.contactForm.LimpiarCampos();
		},
		validate : function()
		{
			$("#name, #comments, #lastName").alphanumeric({allow:" -"});
			$("#phone").numeric({allow:"-"});
			$("#email").alphanumeric({allow:"-_.@"});
			
			var v = $("#contactForm").validate({
				errorElement : 'span',
				onkeyup: false,
				onblur: false,
				errorClass: "invalid",
				rules: {
					name: { required: true  },
					lastName: { required: true  },
					phone: { required: true  },
					email: { required: true, email:true  },
					comments: { required: true  }
				},
				messages: {
					name: { required: 'Este campo es obligatorio'  },
					lastName: { required: 'Este campo es obligatorio'  },
					phone: { required: 'Este campo es obligatorio'  },
					email: { required: 'Este campo es obligatorio' , email:'Escriba un email v&aacute;lido' },
					comments: { 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(){
				$("#comments").html($("#comments").attr("title"));
			});	
		},		
		LimpiarCampos: function()
		{ 
			$("#botonSend").click(function(){
				$('input:text').each(function (i) {
					if($(this).val()== $(this).attr("title")){
							$(this).val("");
						}	
			 	 });
				/*alert("Es una prueba");*/
			});
		}
	},
	
	carousel:{
		init : function()
		{
		}
	},
	
	curvyCorners: {
		init : function()
		{
			settings = {
	          	tl: { radius: 80 },
	          	tr: { radius: 80 },
	          	bl: { radius: 80 },
	          	br: { radius: 80 },
	          	antiAlias: true,
	          	autoPad: true,
	          	validTags: ["img"]
      		}
		}
	},
	
	lightBox: {
		init : function()
		{
			$(function() {
				$('#gallery a').lightBox();
			});
			
		}
	},
	
	
	
	shadowbox: {
		init : function()
		{
			Shadowbox.init({
				handleOversize: "drag",
				modal: true
			});
			
		}
	},
	/*productoSlides : {
		init : function() {
			capa5 = $("#containerProductos li.addProduct");	
			capa5.hide().delay(900).fadeTo(800, 1);

		}
	},*/

	
	shadowboxAlert:{
		init: function(){
			/*$( "#contentExtensionProducto" ).live( "onClose", function() {
			  alert("Prueba"); 
			});*/
			$( "a#sb-nav-close").live("click", function() {
				
				$.ajax({
					type : "POST",
					//url	: '../../../productos/'+$("#models").val()+'/listadovisitas',
					url	: '../../../productos/verified/listadovisitas',
					cache : false,
					dataType: 'json',
					success	: function(duff) {
						/*$("a#sb-nav-close").attr("name","Hola");	*/					
						$("#containerProductos").html(duff.content);
						Shadowbox.setup();
						/*$("#productoAgregado").addClass("addProduct");*/
						/*capa5 = $("#productoAgregado");	
						capa5.hide().delay(150).fadeTo(1000, 1);*/
					}
				});
			  
			  
			  
			});			
		}
	},	
	
	tooltip:{
		init : function()
		{
			/*$(".bubbleInfo a[title]").tooltip({ 
											   offset: [10, 2],
											  effect: 'slide' });.dynamic({ bottom: { direction: 'down', bounce: true } });*/
			
			// initialize tooltip
			$("div.bubbleInfo a[title]").tooltip({
			
			   // tweak the position
			   offset: [10, 2],
			
			   // use the "slide" effect
			   effect: 'slide'
			
			// add dynamic plugin with optional configuration for bottom edge
			})


				/*$('.buble').CreateBubblePopup({
											selectable: false,
											alwaysVisible: false,
											position : 'top',
											align	 : 'center',
											
											innerHtml: $(this).find('.text_buble').html(),
		
											innerHtmlStyle: {
																color:'#000', 
																'text-align':'center'
															},
																				
											themeName: 	'all-grey',
											themePath: 	'/js/jquerybuble/jquerybubblepopup-theme'
										 
										});*/
		}
	},	
	
	scroll : {
		defaultScroll : function()
		{
			$('.scrollPane, .scrollPaneDescription, .scrollPaneContact').jScrollPane();
		}
	}
}
MyApp.Main.init();
