$(document).ready(function(){
	/* Dropdown */
	$("#navigation li.top-parent").hover(
		function(){
			$(this).stop().find("ul.ddown").slideDown(250);
		},
		function(){
			$(this).stop().find("ul.ddown").slideUp(250);
		}
	);
	/* On click fade */
	$("#navigation ul.ddown").click(function(){
		$(this).stop().fadeOut("slow");
	});
	
	/* Search box */
	$("input.input-search").val("Buscar Curriculums");
	$("input.input-search").focus(function(){
		inputDef=$(this).val()
		if(inputDef=='Buscar Curriculums'){
			$(this).val('');
			$(this).css('color','#5e5e5e');
		}
	});
	$("input.input-search").blur(function(){
		inputDef=$(this).val();
		if(inputDef==''){
			$(this).css('color','#ababab');
			$(this).val('Buscar Curriculums');
		}
	});

	/* Replace div#send-button with the submit button (alternative method to show it only on javascript-compatible browsers) */
	$("form#contact-form #send-button").html('<input type="submit" id="submitinput" class="input-go" value="Send it!" />');
	
	if($("#contact-form")){
		/* Contact form set-up */
		$("#contact-form").ajaxForm(function(data) {
			if (data == 1){ // success
				$("#contact-form").resetForm();
				$("p#form-success").fadeIn("slow");
				$("#contact-form #submitinput").fadeOut("fast")
			}
			else if (data==2){ // server error
				$("p#form-info").text("Error! Try again please.").fadeIn(500).fadeIn(5000).fadeout("fast");
			}
			else if (data==3){ // blank fields or invalid email
				$("p#form-info").text("Please fill correctly all necessary fields.").fadeIn(500).fadeIn(5000).fadeout("fast");
			}
		});
	}
});