/* <![CDATA[ */	
$(document).ready(function () {

	// Any link of class .lightbox will open in the lightbox
	/*
	$("a.lightbox").fancybox({
	  'overlayOpacity': 0.7,
	  'overlayColor': '#111'
	});
	*/
	//$(".lightbox").colorbox();
	  
	//////// Scrolling from a section to another
	// Function adds the class .active to the #nav element you have clicked and removes it from others
	
	$("#nav li a").click(function(){
	  $("#nav li a").removeClass("active");		// Remove any "active" class
	  $(this).addClass("active");					// Add "active" class to selected tab	
	  return false;
	});
	
	
	$.localScroll.defaults.axis = 'y';
	$.localScroll({
	  target:  '#container-inner',
	  queue:    true,
	  margin:   true,
	  //hash:  	  true,							// Uncommenting this line adds #id-name's to the url
	  //easing:  'elasout',						// Uncommenting this line adds a easing effect at the end of the scroll
	  duration: 700
	
	});
	
	$.easing.elasout = function(x,t,b,c,d){	// This function makes the easing effect if you have uncommented easing:  'elasout',
	  var s = 1.70158;
	  var p = 0;
	  var a = c;
	  if (t == 0) return b;
	  if ((t /= d) == 1) return b + c;
	  if (!p) p = d * .3;
	  if (a < Math.abs(c)){
	  	a = c;
	  	var s = p / 4;
	  } else var s = p / (2 * Math.PI) * Math.asin(c / a);
	  return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
	};
	
	
	
	//////// Slider for the Work area ////////
	$("#slider").easySlider({
		auto: false,
		continuous: false,
		numeric: true
	});


	
	//////// Animation function for the Social items ////////
	$(function(){
		$('#social a').hover(function () {
			$('img', this).stop().animate({
				'marginLeft': 5
			},
			250);
		},
		function(){
			$('img', this).stop().animate({
				'marginLeft': 15
			},
			250);
		}).find('img').css('marginLeft', 10);	
	});
	
	
	//////// Contact Form ////////
	// sends the data filled in the contact form to the php file and shows a message
	$("#contact-form").submit(function(){
		var str = $(this).serialize();
		$.ajax({
			type: "POST", url: "include/send_mail.php", data: str,
			success: function(msg) {
				$("#formstatus").ajaxComplete(function(event, request, settings){
					if(msg == 1){
						result = '<div class="formstatusok">Your message has been sent. Thank you!</div>';
							$("#fields").hide();
					} else {
						result = '<div class="formstatuserror">Something went wrong! Maybe you have indicated a bad email address.</div>';
					}
					$(this).html(result);
				});
			}
		});
		return false;
	});

	$("#vcard a").hover(showVcardLabel, hideVcardLabel);
	$("#cv a").hover(showCvLabel, hideCvLabel);
	
	$("#em_addr").append(' ' + split_mail('cristian','pascottini','net'));

});


function showVcardLabel() {
	$("#vcard a span").show();
	$("#vcard a span").animate({ top: "-40px", opacity: 1 }, 250 );
}
function hideVcardLabel() {
	$("#vcard a span").animate({ top: "-35px", opacity: 0 }, 250 );
	setTimeout("$('#vcard a span').hide();", 250);
	$("#vcard a span").animate({ top: "-45px", }, 250 );
}
function showCvLabel() {
	$("#cv a span").show();
	$("#cv a span").animate({ top: "-40px", opacity: 1 }, 250 );
}
function hideCvLabel() {
	$("#cv a span").animate({ top: "-35px", opacity: 0 }, 250 );
	setTimeout("$('#cv a span').hide();", 250);
	$("#cv a span").animate({ top: "-45px", }, 250 );
}

function split_mail(user,domain,tld){
	var mail;
	mail = '<a href="'+'ma'+'il'+'to:'+user+'&#64;'+domain+'.'+tld+'">'+user+'&#64;'+domain+'.'+tld+'<'+'/a>';
	return mail;
}

$(function() {
	$('a[rel*=bookmark]').click(function(){
		window.open(this.href);
		return false;
	});
});

/* ]]> */	
