$(function() {
    $('#q').keypress(function(e){
      if(e.which == 13){
       $('form#searchform').submit();
       e.preventDefault();       
       return false;
       }
    });
	/* Copyright (c) 2010 Christian Pfeiffer (christian.pfeiffer.k@gmail.com || http://www.fancydesign.de) Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. */ 
	$.fn.share = function(options) {
		var defaults = {			
			url: 			window.location,								// url of social bookmark, default is current url, use 'http://www.example.com' for individual url	
			title:			$('title').html(),								// title of social bookmark, default is window title, use 'example' for individual title	
			description: 	$('meta[name=description]').attr("content"),	// description of social bookmark, default is <meta>-description, use 'example' for individual description							
			tags:			$('meta[name=keywords]').attr("content"),		// tags of social bookmark, default is <meta>-keywords, use 'example' for individual tags
			services:		['all'], 										// 'all' for [all] services, or ['facebook', 'delicious', ..] for specific services	
			img_size:		16,												// width and height of <img>-tag (px)
			img_alt: 		'$service',										// alt-text of <img>-tag, $service will be replaced by the name of the service
			a_target:		'_blank',										// target-attribute of <a>-tag
			a_title:		'share on $service'								// title-attribute of <a>-tag, $service will be replaced by the name of the service							
   		};			
   		var options = $.extend(defaults, options);			
   		return this.each(function() {			
			var target = $(this);			
			var services = {
				digg:		['http://digg.com/submit?phase=2&url=' + options.url + '&title=' + options.title, 'left:-36px;'],				
				myspace:	['http://www.myspace.com/Modules/PostTo/Pages/?l=2&u=' + options.url + '&t=' + options.title, 'left:-216px;'],
				linkedin:	['http://www.linkedin.com/shareArticle?mini=true&url=' + options.url + '&title=' + options.title + '&source=&summary=' + options.description, 'left:-180px;'],				
				yahoo:		['http://bookmarks.yahoo.com/toolbar/savebm?u=' + options.url + '&t=' + options.title + "&d=" + options.description, 'left:-324px;'],
				google:		['http://www.google.com/bookmarks/mark?op=add&bkmk=' + options.url + '&title=' + options.title + '&labels=' + options.tags + '&annotation=' + options.description, 'left:-144px;'],
				stumbleupon:['http://www.stumbleupon.com/submit?url=' + options.url + '&title=' + options.title, 'left:-252px;'],				
				delicious: 	['http://del.icio.us/post?url=' + options.url + '&title=' + options.title + '&tags=' + options.tags + '&notes=' + options.description, 'left:0;'],
				twitter:	['http://twitter.com/home?status=' + options.title + ':+' + options.url, 'left:-288px;'],
				facebook:	['http://www.facebook.com/sharer.php?u=' + escape(options.url) + '&t=' + options.title, 'left:-108px;'],
				email:		['mailto:Your Friend?subject=' + options.title + '&body=' + options.url , 'left: -72px;']
			}
			if(options.services == "all") { 
				options.services = new Array();
			    for(n in services) options.services.push(n);					    			    
			}		
			$.each(options.services, function(index, service) { 				
				if(services[service] != undefined) {
					var content = '<h4><a rel="nofollow" href="' + services[service][0] + '"';
					if(options.target != "") content += ' target="' + options.a_target + '"';
					if(options.title != "") content += ' title="' + (options.a_title).replace(/\$service/g, this) + '"';
					content += '><img style="margin-left:1px;'+services[service][1]+'" width="' + options.img_size + '" height="' + options.img_size + '" border="0" src="http://c685847.r47.cf2.rackcdn.com/share-sprites.png"';  
					if(options.alt != "") content += ' alt="' + (options.img_alt).replace(/\$service/g, this) + '"';						
					content += ' /></a></h4>';
					if(service == 'digg') target.append('<h4 style="width:24px;margin:0 .1em"><g:plusone size="small" count="false"></g:plusone></h4>');
					target.append(content);					
				}
			});
  		});
 	};
 	$('.sharethis').share();    
});



