/* ----------------------------------------------------------- */
/* TEKSTBALLONNEN copyright 2006-2007 klaas bellemans, yaki.be */
/* all rights reserved */
/* license: 'free for non commercial* use' */
/* (*: company websites, sites (re)selling products or a site showing advertisement is a commercial site) */
/* ----------------------------------------------------------- */

//var balloonmodes = new Object();
/*
var balloonoptions = new Object();

balloonoptions.mouseMove=false;//does balloonposition gets updated constantly upon hovering; disadvantage: you can't click inside the balloon
balloonoptions.showIcon=false;//toon icoon of niet
balloonoptions.doFlip=true;//flipt tekstballon naar beneden als in bovenste helft van scherm?
balloonoptions.showTitle=true;//toon title-header of niet
balloonoptions.autoHideTitle=true;//will hide title after a few seconds
balloonoptions.fixedTitle="speech bubble script by yaki.be";//title string if you want always the same title; or false (=>first title of active region if h1,h2,h3,h4)
balloonoptions.easyClose=false;//closes very fast, or close slower by clicking on icon/close-corner/pointer
balloonoptions.activeRegionClassName="loc";
balloonoptions.markActiveRegions=true;
balloonoptions.theme="rounded-white-fake-shadow3";
balloonoptions.autoCloseBalloon=false;
balloonoptions.endFunction=false;//"setTimeout('ballonclose()',5000)"; //function to be run when textballoon is opened eg "alert('test')"	
balloonoptions.onWindowLoad = false;//"changeballooncontent('dit werkt');openAndAutoCloseBalloon(2000,5000);";
balloonoptions.welcomeMessage= "ja, zou dat niet geweldig zijn,<br />tekstballonnen op je eigen site !";
balloonoptions.basefolder="";
balloonoptions.disablebody=true;

var balloon =new Object();
balloon.up=false;
//balloon.content='leeg';
balloon.storypointer=0;
balloon.story = ["1 one-liner","2 deze welkomstekst is langer dan een lijn","3 en dan weer iets kort", "4 nog iets anders", "5 en gedaan ermee"];
balloon.direction = "under";
balloon.id="tekstballon";
balloon.where=document.getElementsByTagName('body')[0];//append...
balloon.xpos=250;//zie styles
balloon.ypos=250;//zie styles

*/
addLoadEvent(initTekstballonnen);
//window.onload = function(){initTekstballonnen();};

function initTekstballonnen(){
	loadStyles();
	createBallon();
	initBody();
	initLocations();
	//initRelativeBalloons();
	initLoadFunctions();
	showWelcomeMessage();
	doBalloonStory();
}

function showWelcomeMessage(){
	if(balloonoptions.welcomeMessage && balloonoptions.welcomeMessage != ""){
	updateLocation2();
	changeballooncontent(balloonoptions.welcomeMessage);
	setTekstballonDirection("above");
	openAndAutoCloseBalloon(500,6000);
	//thestory = ["hi","ik","ben","hier"];
	//doBalloonStory();
	}
}

function showBalloonStory(story){
balloon.story = story;
doBalloonStory();
}
function resetBalloonStory(){
balloon.story=[];
balloon.storypointer=0;
}

var doStoryTime=0;
var abortstory = false;

function doBalloonStory(){//story = array
if(balloon.story.length>0){
	updateLocation2();
	if(!abortstory){
		if(balloon.story[balloon.storypointer]){
			ballonclose();
			changeballooncontent(balloon.story[balloon.storypointer]);
			//setTekstballonDirection(balloon.direction);//
			setTimeout("ballonopen()",500);
			balloon.storypointer++;
			doStoryTime = setTimeout("doBalloonStory()",4000);
		}else{
			ballonclose();
		}
	}else{
		setTimeout("abortstory=false;",4000);
	}
}
}

function initLoadFunctions(){
	if(balloonoptions.onWindowLoad){
		eval(balloonoptions.onWindowLoad);
	}
}

function openAndAutoCloseBalloon(timetoopen,timetoclose){
	setTimeout("ballonopen();setTimeout('ballonclose()',"+timetoclose+");",timetoopen);
}

function loadStyles(){
	var link = document.createElement('link');
	var where = document.getElementsByTagName('head')[0];
	link.id="balloon_theme";
	link.href=balloonoptions.basefolder+"tekstballonnen/themes/"+balloonoptions.theme+"/ballonstyles.css";
	link.rel="stylesheet";
	where.appendChild(link);
}

function fixRBcorner(){
	if(!balloonoptions.easyClose){
		var txtballon = document.getElementById(balloon.id);
		var therbhoeken = getElementsByClassName(txtballon,"span","rb");
		therbhoeken[0].style.backgroundImage="url('"+balloonoptions.basefolder+"tekstballonnen/themes/"+balloonoptions.theme+"/cwrb-x.gif')";
	}
}


function changeTheme(atheme){
	balloonoptions.theme = atheme;
	updateTheme();
}

function updateTheme(){
	document.getElementById('balloon_theme').href=balloonoptions.basefolder+"tekstballonnen/themes/"+balloonoptions.theme+"/ballonstyles.css";
	fixRBcorner();
}

function createBallon(){
	var tekstballonwrapper = document.createElement('div');
	if(balloonoptions.fixedTitle){balloon_title = balloonoptions.fixedTitle;}else{balloon_title="";}
	balloon_msg = "message in a bubble";
	tekstballonwrapper.innerHTML = '<div id="icon"><i>speach bubble message:</i></div><div id="'+balloon.id+'" class="above"><span class="aa"></span><span class="lb"><b>'+balloon_title+'</b></span><span class="rb"></span><span class="lo"><i title="tekstballonnen by yaki.be">bubbles by <a href="http://www.yaki.be">yaki.be</a></i></span><span class="ro"></span><div class="spacetop"><div class="spacebottom"><div class="spaceleft"><div class="spaceright"><div id="text"><p>'+balloon_msg+'</p></div></div></div></div></div></div>';
	tekstballonwrapper.id = "punt";
	var where = document.getElementsByTagName('body')[0];//default
	if(balloon.where){
		where=document.getElementById(balloon.where);
	}
	where.appendChild(tekstballonwrapper);
	initBallonBehaviour();
}

/*
function createRelativeBalloon(place){
	var tekstballon = document.createElement('div');
	if(balloonoptions.fixedTitle){balloon_title = balloonoptions.fixedTitle;}else{balloon_title="";}
	balloon_msg = "message in a bubble";
	tekstballon.innerHTML = '<div id="icon"><i>speach bubble message:</i></div><div id="tekstballon" class="above"><span class="aa"></span><span class="lb"><b>'+balloon_title+'</b></span><span class="rb"></span><span class="lo"><i title="tekstballonnen by yaki.be">bubbles by <a href="http://www.yaki.be">yaki.be</a></i></span><span class="ro"></span><div class="spacetop"><div class="spacebottom"><div class="spaceleft"><div class="spaceright"><div id="text"><p>'+balloon_msg+'</p></div></div></div></div></div></div>';
	tekstballon.id = "punt";
	place.appendChild(tekstballon);
	initRelativeBallonBehaviour();
}
*/
/*
function initRelativeBallonBehaviour(){
	var hetpunt = document.getElementById('punt');
	hetpunt.style.left="10px";
	hetpunt.style.top="10px";
	var txtballon = document.getElementById('tekstballon');

	var theicon = document.getElementById('icon');
	if(balloonoptions.showIcon){theicon.style.display="block";}else{theicon.style.display="none";}
	theicon.onclick = function(){ballontoggle()};

	if(balloonoptions.showTitle){
		if(balloonoptions.autoHideTitle){
			txtballon.onmouseover=function(){showBalloonTitle();hideBalloonTitle();}
			txtballon.onmouseout=function(){hideBalloonTitle();}
		}
		else{
			var lb_vak = getElementsByClassName(document.getElementById('punt'),"span","lb");
			lb_vak[0].getElementsByTagName('b')[0].style.display="block";
		}
	}

	if(balloonoptions.easyClose){//easy closing: click balloon to close; or click icon or in a 'world' if defined
		txtballon.onclick=function(event){
			ballontoggle();
			if(event){event.cancelBubble = true;}else{window.event.cancelBubble = true;}
			}
	}else{ //click right upper corner or pointer to close; or click icon or in a 'world' if defined
		var rechtsbovenhoeken = getElementsByClassName(txtballon,"span","rb");
		rechtsbovenhoeken[0].title="close";
		rechtsbovenhoeken[0].style.cursor="pointer";
//rechtsbovenhoeken[0].style.backgroundImage="url('"+balloonoptions.basefolder+"tekstballonnen/themes/"+balloonoptions.theme+"/cwrb-x.gif')";
		rechtsbovenhoeken[0].onclick=function(){ballontoggle();};
		var aanwijzers = getElementsByClassName(txtballon,"span","aa");
		aanwijzers[0].onclick=function(){ballontoggle();};
	}
	var tekstballontext = document.getElementById('text').getElementsByTagName('p')[0];
	tekstballontext.innerHTML = balloon.content;
	setTimeout('ballonopen()',1200);
}
*/
function initBallonBehaviour(){
	var txtballon = document.getElementById(balloon.id);
	/*option: showIcon*/
	var theicon = document.getElementById('icon');
	if(balloonoptions.showIcon){theicon.style.display="block";}else{theicon.style.display="none";}
	theicon.onclick = function(){ballontoggle()};
	/*option: showTitle*/
	if(balloonoptions.showTitle){
		if(balloonoptions.autoHideTitle){
			txtballon.onmouseover=function(){window.clearTimeout(closeTitleTime);showBalloonTitle();}
			//txtballon.onmouseout=function(){hideBalloonTitle();}
		}
		else{
			var lb_vak = getElementsByClassName(document.getElementById('punt'),"span","lb");
			lb_vak[0].getElementsByTagName('b')[0].style.display="block";
		}
	}
	/*option: easyclose*/
	if(balloonoptions.easyClose){//easy closing: click balloon to close; or click icon or in a 'world' if defined
		txtballon.onclick=function(event){
			ballontoggle();
			if(event){event.cancelBubble = true;/*FF*/}else{window.event.cancelBubble = true;/*IE*/}
			}
	}else{ //click right upper corner or pointer to close; or click icon or in a 'world' if defined
		var rechtsbovenhoeken = getElementsByClassName(txtballon,"span","rb");
		rechtsbovenhoeken[0].title="close";
		rechtsbovenhoeken[0].style.cursor="pointer";
		rechtsbovenhoeken[0].style.backgroundImage="url('"+balloonoptions.basefolder+"tekstballonnen/themes/"+balloonoptions.theme+"/cwrb-x.gif')";
		rechtsbovenhoeken[0].onclick=function(){ballontoggle();};
		var aanwijzers = getElementsByClassName(txtballon,"span","aa");
		aanwijzers[0].onclick=function(){ballontoggle();};
		txtballon.onclick=function(event){
			if(event){event.cancelBubble = true;/*FF*/}else{window.event.cancelBubble = true;/*IE*/}
		};
	}
}

function initBody(){
	var tekstballontext = document.getElementById('text').getElementsByTagName('p')[0];
	/*if a WORLD-canvas is defined => separate not nested div containing messages on fixed locations upon inline sites */
	/*if(document.getElementById('world')){
		var theworld =  document.getElementById('world');	
		theworld.onclick = function(event){
				ballonclose();
				thistalksession="";
				updateLocation(event);
		        tekstballontext.innerHTML = "what do you want me to say ???";
		 };
		 //theworld.onmouseover = function(){};
	}else{*/
		var thebody =  document.getElementsByTagName('body')[0];	
		if(!balloonoptions.disablebody){
		if(!balloonoptions.mouseMove){
			thebody.onclick = function(event){
					if(!balloonoptions.mouseMove){window.clearTimeout(doStoryTime);}
					ballonclose();
					thistalksession="";
					updateLocation(event);
			        tekstballontext.innerHTML = "what do you want me to say ???";
			 };
		}else{//mouseMove
		 	thebody.onmouseover = function(){
		 			if(balloon.up){ballonclose();}
					//thistalksession="";
					//updateLocation(event);
			        //tekstballontext.innerHTML = "what do you want me to say ???";
		 	};
		}
		}
		if(balloonoptions.centerWelcome==true){
			balloon.xpos=document.body.clientWidth/2;//zie styles
			balloon.ypos=document.body.clientHeight/2-10;//zie styles
		}
	//}              
}


function initLocations(){
	var tekstballontext = document.getElementById('text').getElementsByTagName('p')[0];
	//var thelocations =  document.getElementById('locations').getElementsByTagName("div");
	var thelocations = getElementsByClassName(document,"*",balloonoptions.activeRegionClassName);
	//var thelocations = getElementsByClassName(document,"div","loc");
	for (var i=0;i<thelocations.length;i++){
		thelocations[i].onclick = function(event){
				abortstory=true;
		 //	if(!balloon.up){
				if(getElementsByClassName(this,"*","abstract")){
					//tekstballontext.innerHTML = this.getElementsByTagName('p')[0].innerHTML;
					var abstracts = getElementsByClassName(this,"*","abstract");
					/*resetBalloonStory();
					for(j=0;j<abstracts.length;j++){
						balloon.story[j]=abstracts[j].innerHTML;
					}*/
					//balloon.content = abstracts[0].innerHTML;
					changeballooncontent(abstracts[0].innerHTML);
					
					//lastclickedcontent = abstracts[0].innerHTML;
					//ballonclose();
					updateLocation(event);
					//reposition & update style ballon....
					//if(!balloon.up){
						ballonopen();
					//}
					//doBalloonStory();
					if(!balloonoptions.fixedTitle){
						var ballontitle = getElementsByClassName(document.getElementById('punt'),"span","lb");
						var titeltext = checkForTitle(this);
						ballontitle[0].getElementsByTagName('b')[0].innerHTML=titeltext;
					}
					if(balloonoptions.showTitle && balloonoptions.autoHideTitle){
						window.clearTimeout(closeTitleTime);
						showBalloonTitle();
					}
				}
		/*	}else{//if balloonup, close except different location, then open that one !!!
				if(this.getElementsByTagName('p')[0]){
					var abstracts = getElementsByClassName(this,"p","abstract");
					balloon.content = abstracts[0].innerHTML;
					if(balloon.content==lastclickedcontent){
						ballonclose();
					}else{
						tekstballontext.innerHTML = abstracts[0].innerHTML;
						lastclickedcontent = abstracts[0].innerHTML;
						//ballonclose();
						updateLocation(event);
						//reposition & update style ballon....
						ballonopen();					
					}
				}
			}
		*/
			if(event){event.cancelBubble = true;/*FF*/}else{window.event.cancelBubble = true;/*IE*/}
		 };   
		 thelocations[i].onmouseover= function(event){
			if(balloonoptions.mouseMove){
				abortstory=true;
				// MOUSEOVER SHOW BALLOON
			//	if(!balloon.up){
					if(getElementsByClassName(this,"*","abstract")){
						//tekstballontext.innerHTML = this.getElementsByTagName('p')[0].innerHTML;
						var abstracts = getElementsByClassName(this,"*","abstract");
						/*resetBalloonStory();
						for(j=0;j<abstracts.length;j++){
							balloon.story[j]=abstracts[j];
						}*/
						//balloon.content = abstracts[0].innerHTML;
						changeballooncontent(abstracts[0].innerHTML);
						//lastclickedcontent = abstracts[0].innerHTML;
						//ballonclose();
						updateLocation(event);
						//reposition & update style ballon....
						//if(!balloon.up){
							ballonopen();
						//}
						//doBalloonStory();
						if(!balloonoptions.fixedTitle){
							var ballontitle = getElementsByClassName(document.getElementById('punt'),"span","lb");
							var titeltext = checkForTitle(this);
							ballontitle[0].getElementsByTagName('b')[0].innerHTML=titeltext;
						}
						if(balloonoptions.showTitle && balloonoptions.autoHideTitle){
							window.clearTimeout(closeTitleTime);
							showBalloonTitle();
						}
					}
			/*	}else{//if balloonup, close except different location, then open that one !!!
					if(this.getElementsByTagName('p')[0]){
						var abstracts = getElementsByClassName(this,"p","abstract");
						balloon.content = abstracts[0].innerHTML;
						//if(balloon.content==lastclickedcontent){
						//	ballonclose();
						//}else{
							tekstballontext.innerHTML = abstracts[0].innerHTML;
							lastclickedcontent = abstracts[0].innerHTML;
							//ballonclose();
							updateLocation(event);
							//reposition & update style ballon....
							ballonopen();					
						//}
					}
				}
			*/
				if(event){event.cancelBubble = true;/*FF*/}else{window.event.cancelBubble = true;/*IE*/}
			}else{
				var titeltext = "click for more info";
				var temptitle = checkForTitle(this);
				if(temptitle==""){
					this.title=titeltext;
				}else{
					this.title=temptitle;
				}
				if(balloonoptions.markActiveRegions){
					activeRegionStyling = this.style.cssText; 				
					this.style.cssText=activeRegionStyling + ";background-color:rgb(245,245,245);color:black;";
				}
			}
		 }; 
		 
		 thelocations[i].onmouseout=function(){
		 	//setTimeout('delayedClose()',4000);
		 	//	ballonclose();
		 	if(balloonoptions.markActiveRegions){
					this.style.cssText=activeRegionStyling;
			}
		 };
	 }//end for
}

function checkForTitle(obj){
	var output="";
	if(obj.getElementsByTagName('h1')[0]){
		output = obj.getElementsByTagName('h1')[0].innerHTML;
	}else if(obj.getElementsByTagName('h2')[0]){
		output = obj.getElementsByTagName('h2')[0].innerHTML;
	}else if(obj.getElementsByTagName('h3')[0]){
		output = obj.getElementsByTagName('h3')[0].innerHTML;
	}else if(obj.getElementsByTagName('h4')[0]){
		output = obj.getElementsByTagName('h4')[0].innerHTML;
	}else if(obj.getElementsByTagName('h5')[0]){
		output = obj.getElementsByTagName('h5')[0].innerHTML;
	}else if(obj.getElementsByTagName('h6')[0]){
		output = obj.getElementsByTagName('h6')[0].innerHTML;
	}
	return output;
}

var activeRegionStyling;
/*
function initRelativeBalloons(){
	var tekstballontext = document.getElementById('text').getElementsByTagName('p')[0];
	
	var relatives = getElementsByClassName(document,"*","ballooning");
	for (var i=0;i<relatives.length;i++){
		relatives[i].onmouseover = function(event){
			var vgl = this.innerHTML;
			var listitems = document.getElementById("relativeballoons").getElementsByTagName('li');
			for(var j=0;j<listitems.length;j++){
				var listtitle=listitems[j].getElementsByTagName('b')[0].innerHTML;
				if (listtitle==vgl){
					if(listitems[j].getElementsByTagName('p')[0]){
						var explanation=listitems[j].getElementsByTagName('p')[0].innerHTML;	
					}
					balloon.content = explanation;
					tekstballontext.innerHTML = explanation;
					lastclickedcontent = explanation;
					updateRelativeLocation(event,this);
				}
			}
		};
	}
}
*/
//var lastclickedcontent = "leeg";

/*function delayedClose(){
	ballonclose();
}*/

function ballonclose(){
	var tballon = document.getElementById(balloon.id);
	var theicon = document.getElementById("icon");
	tballon.style.display='none';
	balloon.up=false;
	theicon.title="click to speak";
	//theicon.style.backgroundColor="red";
	theicon.style.backgroundImage="url('"+balloonoptions.basefolder+"tekstballonnen/icons/icon1h1.gif')";
}

var autoCloseTime;

function ballonopen(){
	var tballon = document.getElementById(balloon.id);
	var theicon = document.getElementById("icon");
	tballon.style.display='block';
	balloon.up=true;
	theicon.title="close speach";
	//theicon.style.backgroundColor="green";
	theicon.style.backgroundImage="url('"+balloonoptions.basefolder+"tekstballonnen/icons/icon1hbb.gif')";
	if(balloonoptions.autoCloseBalloon){
		window.clearTimeout(autoCloseTime);
		autoCloseTime = setTimeout('ballonclose()',5000);
	}
	if(balloonoptions.endFunction){
		eval(balloonoptions.endFunction);
	}
}

function ballontoggle(){
	if(balloon.up){ballonclose();}
	else{ballonopen();}
}

function toggledisplay(theid){
if (document.getElementById(theid).style.display!='block'){document.getElementById(theid).style.display='block';}
else{document.getElementById(theid).style.display='none';}
}

function updateLocation2() {
	thepoint=document.getElementById('punt');
	thepoint.style.top = balloon.ypos+"px";
	thepoint.style.left = balloon.xpos+"px";
	
	var screenh = document.body.clientHeight;
	var screenw = document.body.clientWidth;
	
	if(!balloonoptions.doFlip){
			document.getElementById(balloon.id).className='above';
	}else{
		var canvas=document.getElementsByTagName('body')[0];
		var screenposition=balloon.ypos-canvas.scrollTop;
		if(screenposition>screenh/2){//onderste helft
			document.getElementById(balloon.id).className='above';
		}else{//bovenste helft
			document.getElementById(balloon.id).className='under';
			//document.getElementById('tekstballon').className='above';
		}	
	}
	
}

function setTekstballonDirection(direction){
document.getElementById(balloon.id).className = direction;
}

/*
function updateRelativeLocation(event,obj){
	var where = document.getElementsByTagName('body')[0];
	var thediv = document.getElementById('punt');
	where.removeChild(thediv);
	createRelativeBalloon(obj);
}*/


function updateLocation(evt) {
	var screenh = document.body.clientHeight;
	var screenw = document.body.clientWidth;
	var scroll_hor = document.body.scrollLeft;
	var scroll_ver = document.body.scrollTop;
	
	/* get x, y position */
	/* begin  http://evolt.org/article/Mission_Impossible_mouse_position/17/23335/index.html  (quirksmode author PPK about events) */
	var posx = 0;
	var posy = 0;
	var e = evt || window.event; // because window.event does not exist in FF!!!
	if (e.pageX || e.pageY){//IE
		posx = e.pageX +0;
		posy = e.pageY +0;
	}
	else if (e.clientX || e.clientY){//FF
		posx = e.clientX + document.body.scrollLeft;/*20:some extra offset*/
		posy = e.clientY + document.body.scrollTop;
	}
	/* end PPK's way to get x,y position crossbrowser */
	if(balloonoptions.mouseMove){
		posx = posx +5;/*5px: some extra offset to make sure balloon does not react strangely, to remove 'flicker'-effect */
		posy = posy +5;
	}
	//posy = posy+100;//100=pointerheight;
	//posx = posx-100;
	var thepoint=document.getElementById('punt');
	
	if(posx<75){posx=75;}//
	if(posx>scroll_hor+screenw-245){posx=scroll_hor+screenw-245;}//
	
	thepoint.style.top = posy+"px";
	thepoint.style.left = posx+"px";
	balloon.xpos=posx;
	balloon.ypos=posy;
	
	
	
	if(!balloonoptions.doFlip){
			document.getElementById(balloon.id).className='above';
	}else{
		var canvas=document.getElementsByTagName('body')[0];
		var screenposition=posy-canvas.scrollTop;
		if(screenposition>screenh/2){//onderste helft
			document.getElementById(balloon.id).className='above';
		}else{//bovenste helft
			document.getElementById(balloon.id).className='under';
			//document.getElementById('tekstballon').className='above';
			/*var browsername = navigator.appName;
			var browserversion = parseInt(navigator.appVersion);
			if(browsername=="Microsoft Internet Explorer" && browserversion == 6){
				posy=posy+100;//100=pointerheight;
				posx=posx-100;//100=pointerwidth;
				thepoint.style.top = posy+"px";
				thepoint.style.left = posx+"px";
			}*/
		}
		
	}	
}
 //{}
function updatecontent(thelocation){
	var textb = document.getElementById('text').getElementsByTagName('p')[0];
	textb.innerHTML=thelocation.innerHTML;
}

function changeballooncontent(thecontent){
	var textb = document.getElementById('text').getElementsByTagName('p')[0];
	textb.innerHTML=thecontent;
}

//v3
var closeTitleTime;

function showBalloonTitle(){
	var lb_vak = getElementsByClassName(document.getElementById('punt'),"span","lb");
	var thetitle=lb_vak[0].getElementsByTagName('b')[0];
	if(thetitle.innerHTML != ""){thetitle.style.display="block";}
	if(balloonoptions.autoHideTitle){
		closeTitleTime = setTimeout('hideBalloonTitle()',4000);
	}
}

function hideBalloonTitle(){
	var lb_vak = getElementsByClassName(document.getElementById('punt'),"span","lb");
	lb_vak[0].getElementsByTagName('b')[0].style.display="none";
}

/* v2
var aborttimeout = false;
function showBalloonTitle(){
	var lb_vak = getElementsByClassName(document.getElementById('punt'),"span","lb");
	var thetitle=lb_vak[0].getElementsByTagName('b')[0];
	if(thetitle.innerHTML != ""){thetitle.style.display="block";}
	aborttimeout=true;
	setTimeout('resetTimeout()',3000);
}
function hideBalloonTitle(){
	if(aborttimeout==false){
		var lb_vak = getElementsByClassName(document.getElementById('punt'),"span","lb");
		lb_vak[0].getElementsByTagName('b')[0].style.display="none";
	}else{
		setTimeout('hideBalloonTitle()',2000);
	}
}
function resetTimeout(){
	aborttimeout=false;
}
*/
/* v1
var timeout = 0;
function showBalloonTitle(){
	var lb_vak = getElementsByClassName(document.getElementById('punt'),"span","lb");
	lb_vak[0].getElementsByTagName('b')[0].style.display="block";
	timeout =3;
	setTimeout('countdown()',1000);
}
function hideBalloonTitle(){
	if(timeout==0){
		var lb_vak = getElementsByClassName(document.getElementById('punt'),"span","lb");
		lb_vak[0].getElementsByTagName('b')[0].style.display="none";
	}else{
		setTimeout('hideBalloonTitle()',1100);
	}
}
function countdown(){
	timeout=timeout-1;
	setTimeout('countdown()',1000);
}
*/

var thehistory="";
var thistalksession="";

function sayIt(){
	var balloncontent = document.getElementById('text').getElementsByTagName('p')[0];
	var speachinput = document.getElementById('speach');
	var speaking =speachinput.value;
	tohistory = speaking+"<br>";
	thehistory = thehistory+tohistory;
	thistalksession = thistalksession + tohistory;
	balloncontent.innerHTML =thistalksession;
	//balloncontent.innerHTML =speaking;
	speachinput.value = "";
	updateLocation2();	  	  
}



/*
    getElementsByClassName
    Written by Jonathan Snook, http://www.snook.ca/jonathan
    Add-ons by Robert Nyman, http://www.robertnyman.com
*/
function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

// http://simon.incutio.com/archive/2004/05/26/addLoadEvent
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

//http://fettig.net/weblog/2006/10/09/detecting-ie7-in-javascript/
function browserVersion(){
	if(window.XMLHttpRequest){
		if(window.ActiveXObject){
			return "ie7";
		}else{
			return "other";
		}
	}else{
		return "ie6-";
	}
}
