function goTo(url)
{
		
   var iframe = document.getElementById('back');
 iframe.src = url;

}

function podpowiedz(tekst)
{	
	// Ustawia podpowiedź.
	var podp = document.getElementById('podpowiedz1');
	podp.innerHTML = tekst;
	//document.getElementById('kropka1').innerHTML = '&bull; ';
}

function wybierzPodpowiedz()
{
	// Klikniecie danej podpowiedzi.
   	var podp = document.getElementById('podpowiedz1');
 	sendToBot(podp.innerHTML);
}

function pokazOpcje()
{
		
   var op = document.getElementById('opcje');
	if ("visible" === op.style.visibility)
	{
		op.style.visibility = "hidden";
	}
	else
	{
		op.style.visibility = "visible";
	}
}
function pokazPomoc()
{
		
   var op = document.getElementById('pomoc');
	if ("visible" === op.style.visibility)
	{
		op.style.visibility = "hidden";
	}
	else
	{
		op.style.visibility = "visible";
	}
}
function pokazBota()
{
		
   var op = document.getElementById('schowane');
   var bo = document.getElementById('interaction');
   var vis = document.getElementById('bot-visualisation');
   
	if ("visible" === op.style.visibility)
	{
		op.style.visibility = "hidden";
		bo.style.visibility = "visible";
		vis.style.visibility = "visible";
	}
	else
	{
		op.style.visibility = "visible";
		bo.style.visibility = "hidden";
		vis.style.visibility = "hidden";
	}
}

function getAnimation() 
{
	return document.getElementById('bot-visualisation');
			
}

function getFlashCode(path) 
{

		var text = '<object type="application/x-shockwave-flash" data="';
		text+=path;
		text+='" width=200 height=300 id="movieObject">';
		text+='<param name="movieObject" value="';
		text+=path;
		text+='" swLiveConnect="true"></param>';
		text+='</object>';

		return text;
}
function botNormal()
{
		
getAnimation().innerHTML=getFlashCode('pages/film/bot-normal.swf');
	
}

function botAction(actionFile)
{
		
getAnimation().innerHTML=getFlashCode('pages/film/'+actionFile);
	
}


function botAngry() 
{
		
		getAnimation().innerHTML=getFlashCode('pages/film/bot-zly.swf');

}

function botDontKnow() 
{
		getAnimation().innerHTML=getFlashCode('pages/film/bot-nie-wiem.swf');
}

function hideShowSwf() {
	
	var botFace=document.getElementById('bot-container');
	
	if(botFace.style.display== "none")
	{
		botFace.style.display="block";
	}
	else
	{	
		botFace.style.display= "none";
	}
}

function botToRight() {
	var divInteraction=document.getElementById('interaction');
//	var buttonhide=document.getElementById('button-hide');
//	var buttonhidediv=document.getElementById('hide-buttons');
//	var ramka=document.getElementById('ramka');
//	ramka.style.left="0px";

	divInteraction.style.right="0px";
	


}
function moveBot(x,y){

	var divInteraction=document.getElementById('interaction');
	divInteraction.style.left=x+"px";
	divInteraction.style.top=y+"px";

}

function hideShowBot() {

	var divInteraction=document.getElementById('interaction');
	var buttonhide=document.getElementById('button-hide');
	var buttonhidediv=document.getElementById('hide-buttons');
	var ramka=document.getElementById('ramka');

//	ramka
	if(divInteraction.style.display== "none") {
	divInteraction.style.display="block";
//	buttonhide.innerHTML="<";
	buttonhidediv.style.left="310px";
//		ramka.style.left="310px";
//		ramka.style.width="680px";
	}
	else
	{
	divInteraction.style.display="none";
//	buttonhide.innerHTML=">";
	buttonhidediv.style.left="0px";
//	ramka.style.left="0px";
//		ramka.style.width="1024px";
	}
}

function hideShowHistory() {

	var divHistory=document.getElementById('dialogue-history');
	
	if(divHistory.style.display== "none") {
	divHistory.style.display="block";
		
	}
	else
	{
	divHistory.style.display="none";
	
	}
}


function doZglosLink(sentence) {
    
    document.getElementById('zglos-adminowi').innerHTML='<a target="_blank" href="http://10.8.1.105/~wojtekk/inne/bot/zglos.cgi?pyt='+sentence+'">Zglos</a>';

}
var activityTimer = 0;
var timeout=240000;

function sendNoActivity() {

    sendToBot('Brak aktywnosci');
    timeout+=160000;
}

function zrobionaAktywnosc() {
    if(activityTimer) {
	window.clearTimeout(activityTimer);
	
    }
    
    activityTimer=window.setTimeout(sendNoActivity,timeout);
}

	

function playSound(soundfile){
var divSound=document.getElementById('sound-div');
divSound.innerHTML='<EMBED NAME="mySound" SRC="'+soundfile+'" LOOP="FALSE" AUTOSTART="TRUE" HIDDEN="TRUE" > </EMBED>';

}
function playText(text) {
var currentChar=0;
var finText="";
var inTag=false;
while(currentChar<text.length)
      {
	if(text[currentChar]=='<') 
	{
			inTag=true;
	}
	if(false===inTag)
		{
		if(text[currentChar]!==" "&&text[currentChar]!=".")
		{
	
		if((text[currentChar]>='a'&& text[currentChar]<='z')||(text[currentChar]>='A'&& text[currentChar]<='Z'))
			{
			finText=finText+text[currentChar];
			}
		}
	}
	if(text[currentChar]=='>') 
	{
		inTag=false;
	}

      currentChar++;
	}

	sprawdzDzwiek(finText);


}

