// © 2011, Manojo Producciones 
// manojo.net

	//Cufon			
	Cufon.replace('h3,h4,h5,h6, .menuall, #botonmas', {fontFamily: 'League Gothic', hover: true});
	
	//Mosaic
			jQuery(function($){
				
				$('.circle').mosaic({
					opacity		:	0.8			//Opacity for overlay (0-1)
				});
				
				$('.fade').mosaic();
				
				$('.bar').mosaic({
					animation	:	'slide'		//fade or slide
				});
				
				$('.bar2').mosaic({
					animation	:	'slide'		//fade or slide
				});
				
				$('.bar3').mosaic({
					animation	:	'slide',	//fade or slide
					anchor_y	:	'top'		//Vertical anchor position
				});
				
				$('.cover').mosaic({
					animation	:	'slide',	//fade or slide
					hover_x		:	'400px'		//Horizontal position on hover
				});
				
				$('.cover2').mosaic({
					animation	:	'slide',	//fade or slide
					anchor_y	:	'top',		//Vertical anchor position
					hover_y		:	'80px'		//Vertical position on hover
				});
				
				$('.cover3').mosaic({
					animation	:	'slide',	//fade or slide
					hover_x		:	'400px',	//Horizontal position on hover
					hover_y		:	'300px'		//Vertical position on hover
				});
		    
		    });
	
	//Contact form
	$(function() {
	$('.error').hide();
	$('input.text-input, textarea#message').css({backgroundColor:"#fff"});
	$('input.text-input, textarea#message').focus(function(){
	$(this).css({backgroundColor:"#dfdfdf"});
	});
	$('input.text-input, textarea#message').blur(function(){
	$(this).css({backgroundColor:"#fff"});
	});
	
	$(".button").click(function() {
	// validate and process form
	// first hide any error messages
	$('.error').hide();
	
	var name = $("input#name").val();
	if (name == "") {
	$("label#name_error").show();
	$("input#name").focus();
	return false;
	}

	var email = $("input#email").val();
	var filter = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	//if it’s valid email
	//if(!filter(email)){
	if(!filter.test(email)){
	$("label#email_error").show();
	$("input#email").focus();
	return false;
	}
	
	//}
	//var email = $("input#email").val();
	//if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3,4})+$/.test(email)){
	//$("label#email_error").show();
	//$("input#email").focus();
	//return false;
	//}
	//var email = $("input#email").val();
	//if (email == "") {
	//$("label#email_error").show();
	//$("input#email").focus();
	//return false;
	//}
	
	var phone = $("input#phone").val();

	var message = $("textarea#message").val();
	if (message == "") {
	$("label#message_error").show();
	$("textarea#message").focus();
	return false;
	}
	
	var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&message=' + message;
	//$("#contact_form form").serialize();
	//alert (dataString);return false;
	
	$.ajax({
	type: "POST",
	url: "bin/process.php",
	data: dataString,
	success: function() {
	$('#contact_form').html("<div id='thanks-msg'></div>");
	$('#thanks-msg').html("<h5>Mensaje enviado</h5>")
	.hide()
	.fadeIn(500, function() {
	$('#thanks-msg').append("<img id='checkmark' src='imgs/check.png' />");
	});
	}
	});
	return false;
	});
	});
	//runOnLoad(function(){
	// $("input#name").select().focus();
	//});
