// © 2008-2011, FaniaMartinez.com 

	//Cufon			
	Cufon.replace('h1,h2,h3,h4,h5,h6, .principal, .inside, #servicios', { fontFamily: 'Amaranth', hover: true});
	
	//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("<h3>¡gracias!</h3>")
	.hide()
	.fadeIn(500, function() {
	$('#thanks-msg').append("<img id='checkmark' src='imgs/check.png' />");
	});
	}
	});
	return false;
	});
	});
	//runOnLoad(function(){
	// $("input#name").select().focus();
	//});
	
	//Fancybox
	$(document).ready(function() {
		$("a.single_image").fancybox({
			'overlayShow'	: true,
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	600, 
			'speedOut'		:	200,
			'titlePosition'	: 'inside',
			//'overlayColor'		: '#000',
			//'overlayOpacity'	: 0.9
		});	
		$("#galeria-edg").click(function() {
		$.fancybox([
			'imgs/proyectos/web-edg.jpg',
			'imgs/proyectos/web-edg2.jpg',			
				], {
				'padding'		: 10,
				'overlayShow'	: true,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'type'			: 'image',
				'changeFade'	: 0,
				'speedIn'		: 600, 
				'speedOut'		: 200,
				'title'   		: 'Sitio web para Escuela de Graduados de la UNITEC',
				'titlePosition'	: 'inside',
				'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
		    return '<span>Imagen ' +  (currentIndex + 1) + ' de ' + currentArray.length + ' | ' + title + '</span>';}
				});
		});
		$("#galeria-trip").click(function() {
		$.fancybox([
			'imgs/proyectos/trip-edg.jpg',
			'imgs/proyectos/trip-edg2.jpg',			
				], {
				'padding'		: 10,
				'overlayShow'	: true,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'type'			: 'image',
				'changeFade'	: 0,
				'speedIn'		: 600, 
				'speedOut'		: 200,
				'title'   		: 'Trípticos informativos para Escuela de Graduados (Posgrados)',
				'titlePosition'	: 'inside',
				'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
		    return '<span>Imagen ' +  (currentIndex + 1) + ' de ' + currentArray.length + ' | ' + title + '</span>';}
				});
		});
		$("#galeria-pi").click(function() {
		$.fancybox([
			'imgs/proyectos/web-proginternacionales.jpg',
			'imgs/proyectos/web-proginternacionales2.jpg',
			'imgs/proyectos/web-proginternacionales3.jpg',
				], {
				'padding'		: 10,
				'overlayShow'	: true,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic',
				'type'			: 'image',
				'changeFade'	: 0,
				'speedIn'		: 600, 
				'speedOut'		: 200,
				'title'   		: 'Sitio web para Programas Internacionales de la UNITEC',
				'titlePosition'	: 'inside',
				'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
		    return '<span>Imagen ' +  (currentIndex + 1) + ' de ' + currentArray.length + ' | ' + title + '</span>';}
				});
		});
	});			

	//Twitter API
	twttr.anywhere(onAnywhereLoad);
		function onAnywhereLoad(twitter) {
		twitter.linkifyUsers();
		};
		//function onAnywhereLoad(twitter) {
		//twitter('#follow-FaniaYamil').followButton("FaniaYamil");
		//};
