$(document).ready(function(){
	
	/**
	**		jquery.Cycle - Plugin para el slider del home
	**		Descarga: 	http://jquery.malsup.com/cycle/
	**		Archivo: 	js/jquery.cycle.all.min.js
	**/
		$('#panels').cycle({
			timeout: '5000',
			fx: 'blindX',
			pause: true,
			next: '#pnder',
			prev: '#pnizq'
		});
	
	/**
	**		Efecto "hover" para que aparezca el detalle en el slider de proyectos
	**/
		$('.panel').bind('mouseenter',function(){
			$('.txt-cont',this).fadeIn()
		}).bind('mouseleave',function(){
			$('.txt-cont',this).fadeOut();
		});
	
	/**
	**		Efecto "hover" para las fotos de la seccion about.html
	**/
		$('.photo').bind('mouseenter',function(){
			$('img',this).css('top','-195px');
		}).bind('mouseleave',function(){
			$('img',this).css('top','0');
		});
		
		/* Agrego la clase 'even' para aplicar margin: 0 a las imagenes que no necesiten margen */
		$('.photo:even').addClass('even');
	
	/**
	**		Efecto "placeholder" para los elementos de texto
	**/
		/* Agrego la clase 'idleField' a todos los input de texto */
		$('input[type="text"]').addClass("idleField");
		
		/* 
			Cuando se pone el puntero de texto en el input (evento focus), elimino la clase 'idleField y
			agrego una clase 'focusField' y si el atributo value del input es igual que el que se escribio 
			en el html, limpiamos el input.
			
			Si NO es igual (es decir, si ya el usuario escribio en este input y cambio el valor default),
			seleccionamos el texto que tenga el input para facilitar al usuario el cambio del dato.
		 */
		$('input[type="text"]').focus(function() {
			$(this).removeClass("idleField").addClass("focusField");
			if (this.value == this.defaultValue){
				this.value = '';
			}
			if(this.value != this.defaultValue){
				this.select();
			}
		});
		
		/*
			Cuando el puntero de texto salga del input (evento blur), elimino la clase focusField y agrego
			la clase idleField (como estaba originalmente). Si el input tiene un valor vacio entonces
			se regresa al valor por default (el que se escribio en el html, en el atributo value)
		*/
		$('input[type="text"]').blur(function() {
			$(this).removeClass("focusField").addClass("idleField");
			if ($.trim(this.value) == ''){
				this.value = (this.defaultValue ? this.defaultValue : '');
			}
		});
		
		$('.projtrig a.trig').tooltip({relative: true, effect: 'slide', position: 'top center'});
		
		$('#header .nav li:first-child').css('margin-right','30px');
		
		$('textarea').focus(function(){
			$(this).empty();
		});
		
		/*
		var anchoPantalla = screen.width - 18;
		
		$('#footer').width(anchoPantalla);
		$('#bot-cont').width(anchoPantalla);
		$('#bot-cont').css('background',"#DC0D3E url('../img/bot-cont-bg.png') repeat-x");
		
		$(window).resize(function(){
			$('#bot-cont').width(anchoPantalla);
			$('#bot-cont').css('background',"#DC0D3E url('../img/bot-cont-bg.png') repeat-x");
			
			$('#footer').width(anchoPantalla);
		});
		
		*/
		
		$('#bc-contact form .inp-submit, #formcontactos .inp-submit, #formjobs .inp-submit').bind('click',function(){
			if($('.humancheck').is(':checked')){
				$(this).parent().parent().submit();
				return false;
			}else{
				alert('Please, check if you are human. No bots allowed =)');
				return false;
			}
			
		});
});
