


var bubbleActiveWithId='';
var bubbleIsVisible=false;
var bubbletimeout;
var bubblePosDeltaX=0;
var bubblePosDeltaY=0;

function bubblestartTimeout(){if(bubbleIsVisible==true){bubbletimeout=window.setTimeout("closeBubble()",1300);}}
function bubblestopTimeout(){window.clearTimeout(bubbletimeout)}

function setImage(directionString, _where){
	var retObj = new Object();
	switch(directionString){
		case "top"			:retObj.imgSrc="http://i.friendscout24.de/datingr5/img/rps/7/9/6/4.png";			retObj.height="6px";break;
		case "top_left"		:retObj.imgSrc="http://i.friendscout24.de/datingr5/img/rps/7/9/6/5.png";		retObj.height="15px";break;
		case "top_right"	:retObj.imgSrc="http://i.friendscout24.de/datingr5/img/rps/7/9/6/6.png";	retObj.height="15px";break;
		case "bottom"		:retObj.imgSrc="http://i.friendscout24.de/datingr5/img/rps/7/9/6/0.png";		retObj.height="11px";break;
		case "bottom_left"	:retObj.imgSrc="http://i.friendscout24.de/datingr5/img/rps/7/9/6/1.png";	retObj.height="19px";break;
		case "bottom_right"	:retObj.imgSrc="http://i.friendscout24.de/datingr5/img/rps/7/9/6/2.png";	retObj.height="19px";break;
		default				:alert('false bubbleObj.getImage() - call');
	}
	document.getElementById('hb_'+_where).innerHTML="";
	document.getElementById('hb_'+_where).innerHTML="<img class='png' src='"+retObj.imgSrc+"' style='width:246px;height:"+retObj.height+"' />";
	retObj=null;
}

function morph(where, to){
	where=where=='top'?where:'bottom';
	to=to=='left'?to:'right';
	setImage(where+'_'+to, where);
	where=where=='top'?'bottom':'top';
	setImage(where, where);
}
function show(yCord, xCord){
	document.getElementById('bubblecontainer').style.top=yCord;
	document.getElementById('bubblecontainer').style.left=xCord;
	document.getElementById('bubblecontainer').style.visibility='visible';
	bubbleIsVisible=true;
}
function closeBubble(){
	if(document.getElementById('bubblecontainer').style.visibility=='visible'){
		document.getElementById('bubblecontainer').style.visibility='hidden';
		bubbleIsVisible=false;
		bubbleActiveWithId='';
	}
}

function getBubble(e){
	bubblestopTimeout();
	try{
		e = e || window.event || null;
		var target = e.target || e.srcElement || null;
		if(target.nodeName=="IMG"){target=target.parentNode;}
		if(target.nodeType==3){target=target.parentNode;}
		if(e.type.toLowerCase()=="mouseover"){
			this.style.cursor="default";
			target.style.cursor="default";
		}
		if(bubbleActiveWithId!=target.id)
		{
			bubbleActiveWithId=target.id;
			var mainwrapper = document.getElementById("mainwrapperA") || document.getElementById("mainwrapperB") || document.getElementById('centerwrapper').firstChild;
			try{
				var posX = e.pageX+parseInt(document.getElementById('content').pageXOffset)-parseInt(getStyle(mainwrapper,'left'))-parseInt(document.getElementById('centerwrapper').offsetLeft) || e.clientX+parseInt(document.getElementById('content').scrollLeft)-parseInt(getStyle(mainwrapper,'left'))-parseInt(document.getElementById('centerwrapper').offsetLeft);
				var posY = e.pageY+parseInt(document.getElementById('content').pageYOffset)-parseInt(getStyle(mainwrapper,'top')) || e.clientY+parseInt(document.getElementById('content').scrollTop)-parseInt(getStyle(mainwrapper,'top'));
			}catch(error){_log.info(eDebug.getMessage(error));
				var posX = e.pageX-parseInt(getStyle(document.getElementsByTagName('body')[0].firstChild,'left')) || e.clientX-parseInt(getStyle(document.getElementsByTagName('body')[0].firstChild,'left'));
				var posY = e.pageY-parseInt(getStyle(document.getElementsByTagName('body')[0].firstChild,'top'))  || e.clientY-parseInt(getStyle(document.getElementsByTagName('body')[0].firstChild,'top'));
			}
			bubbledata.cb_getPublisherBubble(returnGetBubble, posX+bubblePosDeltaX, posY+bubblePosDeltaY, target.id, target.rel);
		}
		target=null;
		e=null;
	}catch(e){}
	return true;
}

function returnGetBubble(_obj){
	try{
		var targetElementPresenceCheck=document.getElementById(_obj.targetId);
		targetElementPresenceCheck=null;
		var dyn='';
		if(_obj.titleText){
			dyn+='<h1>'+_obj.titleText+'</h1>';
			dyn+='<div class="hr"></div>';	
		}
		if(_obj.image)dyn+='<div class="center"><img src="'+_obj.image+'" border="0"></div>';
		if(_obj.mainText)dyn+=''+_obj.mainText+'';
		if(dyn != '')
		{
			document.getElementById('bubblehelpdyncontent').innerHTML=dyn;
			var newY=parseInt(_obj.posY)-parseInt(getDimensions('bubblecontainer').height);
			var newX=parseInt(_obj.posX);
			
			var change=new Array('bottom','left');
			if(newY < 0 || _obj.image){
				change[0]='top';
				newY=parseInt(_obj.posY);
			}
			if(newX > getDimensions('bubblecontainer').width){
				change[1]='right';
				newX-=(getDimensions('bubblecontainer').width-4);
			}
			morph(change[0], change[1]);
			show(newY+'px', newX+'px');
		}
	}catch(error){}
	
}