var faceprivacyimageSHARE = '/_images/design/faceprivacySHARE.jpg'
var faceprivacyimageLIKE =  '/_images/design/faceprivacy.jpg'

$(document).ready(function(){
	
		$('.faceprivacySHARE').each(function(){
			$(this).html('<img src="'+faceprivacyimageSHARE+'" style="cursor:pointer;" alt="Facebook SHARE" rel="'+$(this).html()+'" />');
		});
		$('.faceprivacySHARE img').css('opacity','0.3');
		$('.faceprivacySHARE').live("click",function(){
			
			var fburl = $(this).find('img').attr('rel')
			var fbactspan = $(this);
			var fbactspanposition = $(this).position();
			var tipleft = (fbactspanposition.left-100);
			if(tipleft < 10)
				tipleft = 15;
							
			$('.faceprivacySHAREactive div').remove();
			var otheractivesfb = $('.faceprivacySHAREactive')
			$(otheractivesfb).remove('div')
			$(otheractivesfb).addClass('faceprivacySHARE')
			$(otheractivesfb).removeClass('faceprivacySHAREactive')
			$(this).append('<div class="faceprivacytooltip" style="text-align:center;position:absolute;left:'+tipleft+'px;top:'+(fbactspanposition.top+8)+'px;background-color:#000;color:#fff;padding:5px;width:200px;font-family:Arial;font-size:11px;">Soll wirklich eine Verbindung mit mit dem externen Anbieter facebook.com aufgebaut werden? <br/>(<a target="_blank" href="/de/impressum/#Facebook">Weitere Informationen</a>)<br/><b style="cursor:pointer">Ja</b> &nbsp;&nbsp;&nbsp;&nbsp;<span style="cursor:pointer;" onclick="">Abbrechen</span></div>');
			$(this).removeClass('faceprivacySHARE');
			$(this).addClass('faceprivacySHAREactive');
			$('.faceprivacySHAREactive b').live('click',function(){
				
				var fbactspan = $(this).parent().parent();
				$(fbactspan).unbind();
				var fburl = $(fbactspan).find('img').attr('rel')

				window.open('http://www.facebook.com/sharer.php?u='+fburl, "facebookLIKE", "width=600,height=400,status=yes,scrollbars=auto,resizable=yes");		
				$('.faceprivacySHAREactive div').remove()
				$(fbactspan).removeClass('faceprivacySHAREactive');
				$(fbactspan).addClass('faceprivacySHARE');
			})
			$('.faceprivacySHAREactive span').live('click',function(){
				var fbactspan = $(this).parent().parent();
				var fburl = $(fbactspan).find('img').attr('rel')
				$('.faceprivacySHAREactive div').remove()
				$(fbactspan).removeClass('faceprivacySHAREactive');
				$(fbactspan).addClass('faceprivacySHARE');

			})
			

		});
	
	
	
	
	
		$('.faceprivacyLIKE').each(function(){
			$(this).html('<img src="'+faceprivacyimageLIKE+'" style="cursor:pointer;" alt="Facebook LIKE" rel="'+$(this).html()+'" />');
		});
		$('.faceprivacyLIKE img').css('opacity','0.3');
		$('.faceprivacyLIKE').live("click",function(){
			
			var fburl = $(this).find('img').attr('rel')
			var fbactspan = $(this);
			var fbactspanposition = $(this).position();
			var tipleft = (fbactspanposition.left-100);
			if(tipleft < 10)
				tipleft = 15;
							
			$('.faceprivacyLIKEactive div').remove();
			var otheractivesfb = $('.faceprivacyLIKEactive')
			$(otheractivesfb).remove('div')
			$(otheractivesfb).addClass('faceprivacyLIKE')
			$(otheractivesfb).removeClass('faceprivacyLIKEactive')
			$(this).append('<div class="faceprivacytooltip" style="text-align:center;position:absolute;left:'+tipleft+'px;top:'+(fbactspanposition.top+8)+'px;background-color:#000;color:#fff;padding:5px;width:200px;font-family:Arial;font-size:11px;">Soll wirklich eine Verbindung mit mit dem externen Anbieter facebook.com aufgebaut werden? <br/>(<a target="_blank" href="/de/impressum/#Facebook">Weitere Informationen</a>)<br/><b style="cursor:pointer">Ja</b> &nbsp;&nbsp;&nbsp;&nbsp;<span style="cursor:pointer;" onclick="">Abbrechen</span></div>');
			$(this).removeClass('faceprivacyLIKE');
			$(this).addClass('faceprivacyLIKEactive');
			$('.faceprivacyLIKEactive b').live('click',function(){
				
				var fbactspan = $(this).parent().parent();
				$(fbactspan).unbind();
				var fburl = $(fbactspan).find('img').attr('rel')

				fbactspan.html('<iframe src="https://www.facebook.com/plugins/like.php?href='+fburl+'" scrolling="no" frameborder="0" style="border:none; width:80px; height:30px"></iframe>');		
			})
			$('.faceprivacyLIKEactive span').live('click',function(){
				var fbactspan = $(this).parent().parent();
				var fburl = $(fbactspan).find('img').attr('rel')
				$('.faceprivacyLIKEactive div').remove()
				$(fbactspan).removeClass('faceprivacyLIKEactive');
				$(fbactspan).addClass('faceprivacyLIKE');

			})
			

		});
		

		

})
