/* Realisierung target="_blank" */
function transformTargetBlankAnker() {
	$('a.target-blank').click(function() {
		window.open(this.href);
		return false;
	});
}

/* socialshareprivacy */
function loadjs(url) {
	var target = document.createElement('script');
	target.src = url;
	target.type='text/javascript';
	var anchor = document.getElementsByTagName("script")[0];
	anchor.parentNode.insertBefore(target,anchor);
};
function activateFacebook() {
	$('#tooltipFooter').remove();
	//$('#img-fb').replaceWith('<fb:like style="padding:0;margin:0;min-height:21px;" href="http%3A%2F%2Fwww.uniteddreamsofeurope.eu" layout="button_count" show_faces="false" action="recommend" send="false" font="arial"><\/fb:like>');
	$('#img-fb').replaceWith('<fb:like href="http://www.schmidtentsorgung.de" send="false" layout="button_count" colorscheme="dark" action="like" show_faces="false" font="arial"><\/fb:like>');
	window.setTimeout(function(){loadjs("http://connect.facebook.net/de_DE/all.js#xfbml=1");},500);
};

/* Tooltips */
function tooltipFooter() {
    $('.tooltipFooter').hover(function (e) {
        this.t = this.title;
        this.title = '';
		position = $(this).position();
		positionLeft = position.left;
		positionTop = position.top;
	
        $('.facebook-like').append('<p id="tooltipFooter"><span>' + this.t + '</span></p>');
        $('#tooltipFooter').css('bottom', '62px').css('left', (positionLeft - 310) + 'px' ).animate({opacity: 'show', height: 'show'}, 'fast');
    }, function () {
        this.title = this.t;
        $('#tooltipFooter').remove();
    });
};
function tooltipFooter2() {
    $('.tooltipFooter2').hover(function (e) {
        this.t = this.title;
        this.title = '';
        position = $(this).position();
		positionLeft = position.left;
		positionTop = position.top;
		
        $('.tooltipFooter2').append('<p id="tooltipFooter2"><span>' + this.t + '</span></p>');
        $('#tooltipFooter2').css('bottom', (positionTop + 20) + 'px').css('left', positionLeft + 'px' ).animate({opacity: 'show', height: 'show'}, 'fast');
    }, function () {
        this.title = this.t;
        $('#tooltipFooter2').remove();
    });
};
function tooltip() {
/*    yoff = 40;
    xoff = 10;
    $('.hasTooltips .tooltip').hover(function (e) {
        this.t = this.title;
        this.title = '';     
        $('.tooltip').append('<p id="tooltip"><span>' + this.t + '</span></p>');
        //$('#tooltip').css('top', (e.pageY - xoff) + 'px').css('left', (e.pageX + yoff) + 'px').slideDown('fast');
        $('#tooltip').css('top', (e.pageY - yoff) + 'px').css('left', (e.pageX + xoff) + 'px').animate({opacity: 'show', height: 'show'}, 'fast');
    }, function () {
        this.title = this.t;
        $('#tooltip').remove();
    });
    $('.hasTooltips .tooltip').mousemove(function (e) {
        $('#tooltip').css('top', (e.pageY - yoff) + 'px').css('left', (e.pageX + xoff) + 'px');
    });
       
    $('div#layer-body .tooltip').hover(function (e) {
        this.t = this.title;
        this.title = '';
    });
    $('div#layer-logo .tooltip').hover(function (e) {
        this.t = this.title;
        this.title = '';
    }); */
    $('.tooltip').hover(function (e) {
        this.t = this.title;
        this.title = '';
    });
};
function tooltipRight() {
/*    yoff = 40;
    xoff = 10;
    tooltipWidth = 200; 
    $('.tooltipRight').hover(function (e) {
        this.t = this.title;
        this.title = '';    
        $('.tooltipRight').append('<p id="tooltipRight"><span>' + this.t + '</span></p>');
        tooltipWidth = $('#tooltipRight').width();
        $('#tooltipRight').css('top', (e.pageY - yoff) + 'px').css('left', (e.pageX - tooltipWidth) + 'px').css('width', (tooltipWidth) + 'px').animate({opacity: 'show', height: 'show'}, 'fast');
    }, function () {
        this.title = this.t;
        $('#tooltipRight').remove();
    });
    $('.tooltipRight').mousemove(function (e) {
        $('#tooltipRight').css('top', (e.pageY - yoff) + 'px').css('left', (e.pageX - tooltipWidth) + 'px');
    });  */
    $('.tooltipRight').hover(function (e) {
        this.t = this.title;
        this.title = '';
    });
};

$(document).ready(function() {
	transformTargetBlankAnker();

	if ($(".tooltipFooter").length > 0) tooltipFooter();
    if ($(".tooltipFooter2").length > 0) tooltipFooter2();
	if ($(".tooltip").length > 0) tooltip();
    if ($(".tooltipRight").length > 0) tooltipRight();
    
    $('div.content p').addClass("hyphenate");
    
    Hyphenator.config({
    	displaytogglebox : false,
    	minwordlength : 15,
    	defaultlanguage : 'de'
    });   
    Hyphenator.run();
});

