$(document).ready(function(){
	
	/**
	 * Facebook
	 */
	$(".fb, .facebook").click(function() {
		var url = encodeURIComponent(String(window.location));
		var title = encodeURIComponent(String(document.title));
		
		$(this).attr('target', '_blank');
		$(this).attr('href', 'http://www.facebook.com/sharer.php?u=' + url + '&t=' + title);  
	});
	$(".fb, .facebook, #face").click(function() {
		if (this.href.lastIndexOf('facebook.com') == -1) {
			var url = encodeURIComponent(this.href);
			var title = encodeURIComponent(this.title);
			
			$(this).attr('target', '_blank');
			$(this).attr('href', 'http://www.facebook.com/sharer.php?u=' + url + '&t=' + title);
		}
	});
	
	
	/**
	 * Twitter
	 */
	$(".tt, .twitter, #twit").click(function() {
		var url = String(window.location);
		var status = encodeURIComponent($(this).attr('rel') + " " + url);
		
		$(this).attr('target', '_blank');
		$(this).attr('href', 'http://twitter.com/?status=' + status);  
	});
	$(".tt, .twitter, #twit").click(function() {
		if (this.href.lastIndexOf('twitter.com') == -1) {
			var url = this.href;
			var status = encodeURIComponent($(this).attr('rel') + " " + url);
			
			$(this).attr('target', '_blank');
			$(this).attr('href', 'http://twitter.com/?status=' + status);
		}
	});

});
