function postTweet(tweet) {
r = document.getElementById('twitresult');
p = document.getElementById('twitprogress');
p.style.display = "block";
twitstatus =  document.getElementById(tweet).value;

page = baseURL+"js/post_twitter.php?twitter_status="+twitstatus;
var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function() {
response = ajaxRequest.responseText;
if(ajaxRequest.readyState == 4){
p.style.display = "none";
r.innerHTML = "Post tweeted!";
r.setAttribute("class", "tweet_confirm");
r.className = "tweet_confirm";
}
}
	ajaxRequest.open("GET", page, true);
	ajaxRequest.send(null); 

}


function tweet(username, password, tweet) {
r = document.getElementById('twitresult');
p = document.getElementById('twitprogress');
p.style.display = "block";
twitter_username =  document.getElementById(username).value;
twitter_password = document.getElementById(password).value;
twitstatus =  document.getElementById(tweet).value;

page = baseURL+"js/api.php?twitter_username="+twitter_username+"&twitter_password="+twitter_password+"&twitstatus="+twitstatus;
var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function() {
response = ajaxRequest.responseText;
if(ajaxRequest.readyState == 4){
check = response.indexOf("created_at");
p.style.display = "none";
if (check > -1) {//worked
r.innerHTML = "Tweeted to <a href='http://twitter.com/"+twitter_username+"' target='_parent'>"+twitter_username+"</a>";
r.setAttribute("class", "tweet_confirm");
r.className = "tweet_confirm";
} else {
auth = response.indexOf("Could not authenticate you");
if (auth > -1) {
r.innerHTML = 'Could not login to twitter. Please check your details in <a href="'+baseURL+'account">Account</a>';
r.setAttribute("class", "tweet_error");
r.className = "tweet_error";
} else {
r.innerHTML = "Whoops something went wrong!";
r.setAttribute("class", "tweet_error");
r.className = "tweet_error";
}
}
}
}
	ajaxRequest.open("GET", page, true);
	ajaxRequest.send(null); 

}