function urlencode(str)	
{
	str1 = '';
	str2 = str;
	while (str1 != str2)
	{
		str1 = str2;
		str2 = str2.replace('¸','%B8');
		str2 = str2.replace('é','%E9');
		str2 = str2.replace('ö','%F6');
		str2 = str2.replace('ó','%F3');
		str2 = str2.replace('ê','%EA');
		str2 = str2.replace('å','%E5');
		str2 = str2.replace('í','%ED');
		str2 = str2.replace('ã','%E3');
		str2 = str2.replace('ø','%F8');
		str2 = str2.replace('ù','%F9');
		str2 = str2.replace('ç','%E7');
		str2 = str2.replace('õ','%F5');  
		str2 = str2.replace('ú','%FA');
		str2 = str2.replace('ý','%FD');
		str2 = str2.replace('æ','%E6');
		str2 = str2.replace('ä','%E4');
		str2 = str2.replace('ë','%EB');
		str2 = str2.replace('î','%EE');
		str2 = str2.replace('ð','%F0');
		str2 = str2.replace('ï','%EF');
		str2 = str2.replace('à','%E0');
		str2 = str2.replace('â','%E2');
		str2 = str2.replace('û','%FB');
		str2 = str2.replace('ô','%F4');
		str2 = str2.replace('ÿ','%FF');
		str2 = str2.replace('÷','%F7');
		str2 = str2.replace('ñ','%F1');
		str2 = str2.replace('ì','%EC');
		str2 = str2.replace('è','%E8');
		str2 = str2.replace('ò','%F2');
		str2 = str2.replace('ü','%FC');
		str2 = str2.replace('á','%E1');
		str2 = str2.replace('þ','%FE');
		
		str2 = str2.replace('¨','%A8');
		str2 = str2.replace('É','%C9');
		str2 = str2.replace('Ö','%D6');
		str2 = str2.replace('Ó','%D3');
		str2 = str2.replace('Ê','%CA');
		str2 = str2.replace('Å','%C5');
		str2 = str2.replace('Í','%CD');
		str2 = str2.replace('Ã','%C3');
		str2 = str2.replace('Ø','%D8');
		str2 = str2.replace('Ù','%D9');
		str2 = str2.replace('Ç','%C7');
		str2 = str2.replace('Õ','%D5');  
		str2 = str2.replace('Ú','%DA');
		str2 = str2.replace('Ý','%DD');
		str2 = str2.replace('Æ','%C6');
		str2 = str2.replace('Ä','%C4');
		str2 = str2.replace('Ë','%CB');
		str2 = str2.replace('Î','%CE');
		str2 = str2.replace('Ð','%D0');
		str2 = str2.replace('Ï','%CF');
		str2 = str2.replace('À','%C0');
		str2 = str2.replace('Â','%C2');
		str2 = str2.replace('Û','%DB');
		str2 = str2.replace('Ô','%D4');
		str2 = str2.replace('ß','%DF');
		str2 = str2.replace('×','%D7');
		str2 = str2.replace('Ñ','%D1');
		str2 = str2.replace('Ì','%CC');
		str2 = str2.replace('È','%C8');
		str2 = str2.replace('Ò','%D2');
		str2 = str2.replace('Ü','%DC');
		str2 = str2.replace('Á','%C1');
		str2 = str2.replace('Þ','%DE');

	}
	
	return str1;
}
	
function addshout()
{
	var newmsg;
	msg = document.shoutform.shouttext.value;

	
	newmsg = '';
	while (newmsg !== msg)
	{	
		newmsg = msg.replace('<','&lt;');
		msg = newmsg.replace('<','&lt;');
		newmsg = msg.replace('>','&gt;');
		msg = newmsg.replace('>','&gt;');
	}

	newmsg = '';
	while (newmsg !== msg)
	{	
		newmsg = msg.replace('?','xxxx');
		msg = newmsg.replace('?','xxxx');
		newmsg = msg.replace('&','yyyy');
		msg = newmsg.replace('&','yyyy');
	//	newmsg = msg.replace("'","\'");
	//	msg = newmsg.replace("'","\'");
	//	newmsg = msg.replace('"','\"');
	//	msg = newmsg.replace('"','\"');
		
		
	}	
	newmsg = '';
		while (newmsg !== msg)
	{	
		newmsg = msg.replace('\n','<br/>');
		msg = newmsg.replace('\n','<br/>');
	}
		
	document.getElementById('shouttext').value = '';
	
	if ((xmlHttp.readyState == 4)||(xmlHttp.readyState == 0))
	{

		//msg = Utf8.encode(msg);
	//	a = msg.charCodeAt(0);
		msg = urlencode(msg);
	
		sendtext = "addshout.php?msg="+msg+"&username=<?php echo $username ?>&password=<?php echo $password ?>";
		
		xmlHttp.open("GET",sendtext,false);
		//xmlHttp.onreadystatechange = ResponseShout;
		xmlHttp.send(null);
		
	}
	
	//document.getElementById('shoutdiv').innerHTML = msg+'<br/><br/>'+document.getElementById('shoutdiv').innerHTML;
	
}

