function getXMLHTTP() { 
		var xmlhttp=false;
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{
			try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				
			}
			catch(e){
				try{
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		return xmlhttp;
    }
    function tweet() {
	var login = document.getElementById('twit_login').value;
	var pass = document.getElementById('twit_password').value;
    var messg = document.getElementById('twit_message').value;
     if(login !== "" && pass !== "" && messg != "")
     {
	var strURL="index.php?option=com_twitter&twit_login="+login+"&twit_password="+pass+"&twit_message="+messg+"&format=ajax";
	var req = getXMLHTTP();
	if (req) {
	req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
					
					document.getElementById('tweetstatus').innerHTML=req.responseText;
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}
			}
			req.open("GET", strURL, true);
			req.send(null);
		}
	} else
    {document.getElementById('tweetstatus').innerHTML="<strong>Error posting your status to Twitter. Please retry. </strong>";
     return false;}
     }

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

