		$(document).ready(function() {
			
			$('#slideshow').corner("8px");		
				
			$('#slideshow ul').cycle({            
				timeout: 5000,  // milliseconds between slide transitions (0 to disable auto advance)            
				fx:      'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...                        
				pager:   '#pager',  // selector for element to use as pager container            
				pause:   0,	  // true to enable "pause on hover"            
				pauseOnPagerHover: 0 // true to pause when hovering over pager link	
			});		
				
			$('.ksecciones').hide();
						
			$('#klink_home').click(function () { 		
				$('.ksecciones').hide();		
				$('#ksec_inicio').fadeIn();
			});
			$('#klink_homelogo').click(function () { 		
				$('.ksecciones').hide();		
				$('#ksec_inicio').fadeIn();
			});
				
			$('#klink_que-hacemos').click(function () { 		
				$('.ksecciones').hide();
				$('#ksec_que-hacemos').fadeIn();    
			});
					
			$('.klink_clientes').click(function () { 		
				$('.ksecciones').hide();		
				$('#ksec_clientes').fadeIn();    
			});
					
			//contacto, final abajo	
			$('#klink_contacto').click(function (e) {			
				$('html, body').animate({scrollTop: $("body").attr("scrollHeight")}, 800);		
			});
			//contacto, final abajo	
			$('#klink_contacto_home').click(function (e) {			
				$('html, body').animate({scrollTop: $("body").attr("scrollHeight")}, 800);		
			});
					
			//Volver arriba	
			$('#klink_totop').click(function (e) {			
				$('html, body').animate({scrollTop: 0}, 800);		
				return false;
			});		
					
			//Veamos si estamos partiendo en una seccion especifica (segun el anchor en la URL)	
			//Si no, iniciamos en el home	
			var elanchor = location.href.split('#!/');	
			if (elanchor.length > 1) {		
				//Si vamos al contacto, cargamos el home primero, de ahi bajamos		
				if (elanchor[1] == 'contacto') {
					$('#ksec_inicio').show();			
					$('html, body').animate({scrollTop: $("body").attr("scrollHeight")}, 800);
				} else {		
					//Seccion normal, simplemente la mostramos			
					$('#ksec_'+elanchor[1]).fadeIn();		
				}
			} else {		
				//No hubo un anchor especifico, vamos al home		
				$('#ksec_inicio').show();
			}
				
			//Formulario de Contacto, validacion JS
			$("#contactFormWidget").validationEngine({promptPosition : "topRight", scroll: false});
			
			//Luego del click
			$(".button").click(function() {

				var name = $("input#checkingWidget").val();
				var lename = $("input#contactNameWidget").val();
				var email = $("input#emailWidget").val();
				var themsg = $("textarea#commentsTextWidget").val();
				
				if(lename == "" || email == "" || themsg == "") {
					alert('Debes completar todos los campos para poder contactanos usando el formulario.\nVamos, intentalo otra vez por favor. El formulario no muerde ;)');
					return false;
				} else {
					$("#contacto_submitbutton").hide();
					$("#facebook").show('fast', function() {
						$(".loadingImgWidgetFt").fadeIn();
					});
				
					var themsgenc = encodeURIComponent(themsg);
					var dataString = 'lename='+ lename + '&email=' + email + '&themsg=' + themsgenc + '&name=' + name;
         
					$.ajax({
						type: "POST",
						url: templatedirectory+"/kmail_process.php",
						data: dataString,
						success: function() {
							$('#contact-form-widget').html("<div id='message'></div>");
							$('#message').html("<p><img id='checkmark' src='"+templatedirectory+"/images/okidoky.png' alt='' /><br /></p>").append("<p><br />Tu mensaje fue enviado correctamente.</p><p>Nos pondremos en contacto ASAP.</p><p><br />¡Gracias! ;)</p>").hide().fadeIn(1500, function() {
							$('#message').append("");
							});
						}
					});
					return false;
				}
      				
			});
					
		});


