$(document).ready(function() {
					
	$("#quoteForm").validate();	
	
	$("#twitter_update_list").tweet({
	    join_text: "auto",
	    username: "curiosidade",
	    avatar_size: null,
	    count: 1,
	    auto_join_text_default: "", 
	    auto_join_text_ed: "",
	    auto_join_text_ing: "",
	    auto_join_text_reply: "",
	    auto_join_text_url: "",
	    loading_text: "a carregar twitter..."
	});

				
	$("#name").keypress(function(e) {
		if($.trim(this.value).length <= 0) {
			$("#form_required").css("color", "#FF0000");
		}
		else {
			$("#form_required").css("color", "#B5B5B5");
		}
	});
	
	$("#message").keypress(function(e) {
		if($.trim(this.value).length <= 0) {
			$("#form_required").css("color", "#FF0000");
		}
		else {
			$("#form_required").css("color", "#B5B5B5");
		}
	});
			
	$("#email").keypress(function(e) {

		if(this.value.indexOf('@', 1) == -1 || this.value.indexOf('.', 1) == -1) {
			$(this).css("color", "#FF0000");
		}
		else {
			$(this).css("color", "#616161");
		}
	});
	
	$("#message_form").submit(function(e) {
									   
		var name = this.elements['name'].value;					
		var email = this.elements['email'].value;
		var message = this.elements['message'].value;
		
		if(email.indexOf('@', 1) == -1 || email.indexOf('.', 1) == -1){
			e.preventDefault();
			$("#email").css("color", "#FF0000");
		}
		
		if($.trim(name).length <= 0 || $.trim(email).length <= 0 || $.trim(message).length <= 0) {
			e.preventDefault();
			$("#form_required").css("color", "#FF0000");
		}

	});

			
	$("#contact_menu").live('click',function(e){
		$('html,body').animate({'scrollTop': $($(this).attr('href')).offset().top});		
		e.preventDefault();
	});
	
	/*$('#slideshow').slideshow({
		timeout: 3000,
		type: 'random'
	});*/
			
	
	// select all desired input fields and attach tooltips to them 
	$("#message_form :input[title]").tooltip({ 
	 
		// place tooltip on the right edge 
		position: "center right", 
	 
		// a little tweaking of the position 
		offset: [-4, 5], 
	 
		// use the built-in fadeIn/fadeOut effect 
		effect: "fade", 
	 
		// custom opacity setting 
		opacity: 0.7, 
	 
		// use this single tooltip element 
		tip: '.tooltip' 
	 
	});
	
});

/*function validate_form(e) {
	
	var email = this.elements['email'].value;
	
	if(email.indexOf('@', 1) == -1 || email.indexOf('.', 1) == -1) {
		e.preventDefault();
		this.elements['email'].setAttribute("className", invalid);
	}
}

window.onload = function() {
	document.forms['message_form'].onsubmit = validate_form;
}*/
