$(document).ready(function() {
	 
		  var total = $("#social img").size();
		  var count = -1;
		  
		  function go() {
			$("#social img:nth("+count+")").animate({opacity: 0.4}, {duration: 2000});
			count++;
			//alert(count+' '+total);
			if (count == total) {
			  count = 0;
			}
			$("#social img:nth("+count+")").animate({opacity: 1}, {duration: 900, complete: go});
			return false;
		  }
		  
		  go();
		  
		 
		$("#social img").mouseover(function () {
			$("#social img").css("opacity","0.4");
			$(this).css("opacity","1");
		});
		$("#social img").mouseout(function () {
			$("#social img").stop();
			$(this).css("opacity","0.4");
		});
		
		$("#social").mouseover(function () {
			$("#social img").stop();
		});
		$("#social").mouseout(function () {
		count=-1;
		go();
		});
		
		

		$.fn.emailencode = function(options) {
			var settings = jQuery.extend({
				atsign: "#2#"
			}, options);

			return this.each(function() {
				var address = $(this).attr("href");
				var formatedAddress = address.replace(settings.atsign, "@");
				//$(this).attr("href", "mailto:" + formatedAddress);
				$(this).attr("href", formatedAddress);
			});
		};
		
		$("#social ul li a").emailencode();


});