if ( typeof( do_reload ) != 'undefined' ) {
	do_reload--;
}

var SocialBookmarks = new function() {
	var bm_title	= document.title;
	var bm_href	= location.href;
	
	var img_path	= '/images/bookmarks/';
	
	var sites	= $H(
		{
			wong		: $H(
				{
					'url'		: 'http://www.mister-wong.de/index.php',
					'alt_title'	: 'Mister Wong',
					'parms'		: $H(
						{
							'action'		: 'addurl',
							'bm_url'		: bm_href,
							'bm_description'	: bm_title
						}
					)
				}
			),
			delicious	: $H(
				{
					'url'		: 'http://del.icio.us/post',
					'alt_title'	: 'del.icio.us',
					'parms'		: $H(
						{
							'url'	: bm_href,
							'title'	: bm_title
						}
					)
				}
			),
			yahoo		: $H(
				{
					'url'		: 'http://myweb2.search.yahoo.com/myresults/bookmarklet',
					'alt_title'	: 'Yahoo MyWeb',
					'parms'		: $H(
						{
							't'	: bm_title,
							'u'	: bm_href
						}
					)
				}
			),
			google		: $H(
				{
					'url'		: 'http://www.google.com/bookmarks/mark',
					'alt_title'	: 'Google',
					'parms'		: $H(
						{
							'op'		: 'add',
							'hl'		: 'de',
							'bkmk'		: bm_href,
							'title'		: bm_title
						}
					)
				}
			),
			webnews		: $H(
				{
					'url'		: 'http://www.webnews.de/einstellen',
					'alt_title'	: 'Webnews',
					'parms'		: $H(
						{
							'url'	: bm_href,
							'title'	: bm_title
						}
					)
				}
			),
			yigg		: $H(
				{
					'url'		: 'http://yigg.de/neu',
					'alt_title'	: 'YiGG',
					'parms'		: $H(
						{
							'exturl'	: bm_href,
							'exttitle'	: bm_title
						}
					)
				}
			),
			linkarena	: $H(
				{
					'url'		: 'http://linkarena.com/bookmarks/addlink/',
					'alt_title'	: 'LinkARENA',
					'parms'		: $H(
						{
							'url'	: bm_href,
							'title'	: bm_title
						}
					)
				}
			)
		}
	);
	
	return {
		insert_bm	: function() {
			var args = $A( SocialBookmarks.insert_bm.arguments );
			
			var ins_into = args.shift();
			
			if ( args.length > 0 && $( ins_into ) && bm_title ) {
				args.each(
					function( elem ) {
						if ( sites.keys().include( elem ) ) {
							var site = sites.get( elem );
							
							var a = new Element(
								'a',
								{
									'title'		: 'Diese Seite zu ' + site.get( 'alt_title' ) + ' hinzufügen',
									'href'		: 'javascript:SocialBookmarks.open_bm( \'' + elem + '\' );'
								}
							);
							
							var img = new Element(
								'img',
								{
									'src'		: img_path + elem + '.gif',
									'alt'		: 'Diese Seite zu ' + site.get( 'alt_title' ) + ' hinzufügen',
									'border'	: '0'
								}
							);
							
							img.setStyle(
								{
									'width'		: '16px',
									'height'	: '16px',
									'paddingRight'	: '6px'
								}
							);
							
							a.insert( img );
							
							$( ins_into ).insert( { 'bottom' : a } );
						}
					}
				);
			}
			
		},
		open_bm	: function() {
			var args = $A( SocialBookmarks.open_bm.arguments );
			
			var arg = args.shift();
			
			if ( sites.keys().include( arg ) ) {
				var site = sites.get( arg );
				
				window.open( site.get( 'url' ) + '?' + site.get( 'parms' ).toQueryString() );
			}
		}
	};
}
