  function sayhello() {
   	hellou = document.getElementById('hellou').value;
   	nickname = document.getElementById('nickname').value;
    panda.open("GET", "/hello/upisi.php?text="+hellou+'&nickname='+nickname);
    panda.onreadystatechange = function(){rawr('ucitajkomentare');}
    panda.send(null);
   var myFx = new Fx.Tween('rawr');
//Transitions the background color of the Element from black to red:
myFx.start('background-color', '#c5c5c5', '#fff')
  }
  
  
  
function livehello() { 
 setTimeout("refreshhello()", 10000);
}

function refreshhello(){
    panda.open("GET", "/hello/refresh.php");
    panda.onreadystatechange = function(){rawr('ucitajkomentare');}
	panda.send(null);
	prikaziload(document.getElementById("loadajaxa"));
	setTimeout("shutdownhello()",10000);
}


function shutdownhello(){
var ugasiajaxic = document.getElementById("loadajaxa");
ugasiajaxic.innerHTML = "";
setTimeout("refreshhello()",10000);
}



function prikaziload(element) {
while (element.hasChildNodes()){
element.removeChild(element.lastChild);
}
var image = document.createElement("img");
image.setAttribute("src","/hello/loading.gif");
element.appendChild(image);

}


window.addEvent('domready', function() {
	var input = $('hellou'), log = $('log');
	
	// We define the highlight morph we're going to
	// use when firing an event
	var highlight = new Fx.Morph(log, {
		duration: 2500,
		link: 'cancel',
		transition: 'quad:in'
	});
	 
	// Here we start adding events to textarea.
	// Note that 'focus' and 'keyup' are native events, while 'burn'
	// is a custom one we've made
	input.addEvents({
		focus: function() {
			// When focusing, if the textarea contains value "Type here", we
			// simply clear it.
			if (input.value.contains('nickname')) input.value = '';
		},
		
		keyup: function() {
			// When user keyups we check if there are any of the magic words.
			// If yes, we fire our custom event burn with a different text for each one.
			if 	(input.value.contains('mave')) input.fireEvent('burn', 'maveeee');
			else if (input.value.contains('fuck')) input.fireEvent('burn', 'Fuck you dude :)');
			else if (input.value.contains('ass')) input.fireEvent('burn', 'Kiss my ass ');
			else if (input.value.contains('screw')) input.fireEvent('burn', 'screw you');
			// note that in case of 'delayed', we are firing the event 1 second late.
			else if (input.value.contains('delayed')) input.fireEvent('burn', "I'm a bit late!", 1000);
		},
		
		burn: function(text) {
			// When the textarea contains one of the magic words
			// we reset textarea value and set the log with text
			input.value = ''; log.set('html', text);
			
			// then we start the highlight morphing
			highlight.start({
				backgroundColor: ['#fff36f', '#fff'],
				opacity: [2, 0]
			});
		}
	});
});


