function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
} 

function createRequestObject() {
	var xmlhttp;
	try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
  catch(e) {
    try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
    catch(f) { xmlhttp=null; }
  }
  if(!xmlhttp&&typeof XMLHttpRequest!="undefined") {
  	xmlhttp=new XMLHttpRequest();
  }
	return  xmlhttp;
}




function shoutRequest(){
	http=createRequestObject();
	
	
	var txtshout = document.getElementById('txtshout');
	stripHTML(txtshout);
	if(txtshout.value.trim() == 'TYPE YOUR SHOUT HERE!' || txtshout.value.trim() == ''){
		alert("Please type your shout");
		return;
	}
	
	
	
	document.getElementById('ajxLoader_Shout').style.display="";
	
	http.open('POST',  'index.php?section=shoutbox&action=shout');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = __handleShout;
	http.send('txtshout='+txtshout.value);
}

 	
function __handleShout(){ 
  if((http.readyState == 4)&&(http.status == 200)){
	  document.getElementById('ajxLoader_Shout').style.display="none";
		var response = http.responseText;
		var splitResponse = response.split("|");
		var obj = document.getElementById('shouts');
		if(splitResponse[0] == 1){
			//alert("You have just shouted and your shout has been posted");
			obj.style.top = "0px";
			document.getElementById('txtshout').value = '';
			obj.innerHTML = splitResponse[1];
		}else if(splitResponse[0] == 2 || splitResponse[0] == 0 ){
			alert(splitResponse[1]);
		}else if(splitResponse[0] == 3){
			document.getElementById('txtshout').value = '';
			alert(splitResponse[1]);
		}
	}
}

function clearShoutBox(obj){
	if(obj.value = 'TYPE YOUR SHOUT HERE!'){
		obj.value = '';
	}
}


String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function stripHTML(){
	var re= /<\S[^><]*>/g
	for (i=0; i<arguments.length; i++)
		arguments[i].value=arguments[i].value.replace(re, "")
}