function ajaxFunction(){
	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;
			}
		}
	}
	return ajaxRequest;
}

function newPost(direct) {
	var action="";
	var where="";
	action = direct;
	
	if (action=='post') {
		where = "posttextarea";
	} else if (action=='blast') {
		where = "postsmsbararea";
	}
	
	//Get variables
	var post=encodeURIComponent(document.getElementById(where).value);
	var sid=encodeURIComponent(document.getElementById("sid").value);
	var uid=encodeURIComponent(document.getElementById("uid").value);
	var type=encodeURIComponent(document.getElementById("type").value);
	
	ajaxRequestPost = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestPost.onreadystatechange = function(){
		if(ajaxRequestPost.readyState == 4){
			//prependElement('display', ajaxRequest.responseText);
			//document.getElementById('newLivePosts').innerHTML = ajaxRequestPost.responseText;
			$('#sandbox').prepend(ajaxRequestPost.responseText);
			confirmShowPosts(sid);
			removeElement("sandbox", "old_update");
		}
	}
	
	var params="post="+post+"&sid="+sid+"&uid="+uid+"&type="+type+"&action="+action;
	
	ajaxRequestPost.open("POST", "./pieces/backend/flowerGarden.php", true);
	//Send the proper header information along with the request
	ajaxRequestPost.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestPost.setRequestHeader("Content-length", params.length);
	ajaxRequestPost.setRequestHeader("Connection", "close");
	ajaxRequestPost.send(params); 
	
}

function newQuestion(type) {
	
	//Get variables
	var sid = encodeURIComponent(document.getElementById("sid").value);
	
	var question = '';
	if (type==31) {
		question = encodeURIComponent(document.getElementById("tfquestionbox").value); 
	} else if (type==32) {
		question = encodeURIComponent(document.getElementById("mcquestionbox").value);
	} else if (type==33) {
		question = encodeURIComponent(document.getElementById("gquestionbox").value);
	}
	
	var option1 = encodeURIComponent(document.getElementById("mcoption1").value);
	var option2 = encodeURIComponent(document.getElementById("mcoption2").value);
	var option3 = encodeURIComponent(document.getElementById("mcoption3").value);
	var option4 = encodeURIComponent(document.getElementById("mcoption4").value);
	var option5 = encodeURIComponent(document.getElementById("mcoption5").value);
	var option6 = encodeURIComponent(document.getElementById("mcoption6").value);
	
	ajaxQuestion = ajaxFunction();
	ajaxQuestion.onreadystatechange = function(){
		if(ajaxQuestion.readyState == 4){
			//prependElement('display', ajaxQuestion.responseText);
			//document.getElementById('newLivePosts').innerHTML = ajaxQuestion.responseText;
			
			$('#sandbox').prepend(ajaxQuestion.responseText);
			confirmShowPosts(sid);
			removeElement("sandbox", "old_update");
		}
	}
	
	var params="loop_id="+sid+"&question="+question+"&question_type="+type+"&option1="+option1+"&option2="+option2+"&option3="+option3+"&option4="+option4+"&option5="+option5+"&option6="+option6;
	
	ajaxQuestion.open("POST", "./pieces/backend/postQuestion.php", true);
	//Send the proper header information along with the request
	ajaxQuestion.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxQuestion.setRequestHeader("Content-length", params.length);
	ajaxQuestion.setRequestHeader("Connection", "close");
	ajaxQuestion.send(params); 
	
}

function answerQuestion(post_id, family, answer) {
	
	var innerid = post_id+'3030';
	
	ajaxQuestion = ajaxFunction();
	ajaxQuestion.onreadystatechange = function(){
		if(ajaxQuestion.readyState == 4){
			//prependElement('display', ajaxQuestion.responseText);
			document.getElementById(innerid).innerHTML = ajaxQuestion.responseText;
			//$('#sandbox').prepend(ajaxQuestion.responseText);
			//confirmShowPosts(sid);
			//removeElement("sandbox", "old_update");
		}
	}
	
	var params = "family="+family+"&post_id="+post_id+"&answer="+answer;
	
	ajaxQuestion.open("POST", "./pieces/backend/answerQuestions.php", true);
	//Send the proper header information along with the request
	ajaxQuestion.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxQuestion.setRequestHeader("Content-length", params.length);
	ajaxQuestion.setRequestHeader("Connection", "close");
	ajaxQuestion.send(params); 
	
}

function newComment(display_id) {
	var action="";
	ajaxRequestComment = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestComment.onreadystatechange = function(){
		if(ajaxRequestComment.readyState == 4){
			//prependElement('display', ajaxRequestComment.responseText);
			//document.getElementById('display').innerHTML = ajaxRequestComment.responseText;
			$('#'+display_id).append(ajaxRequestComment.responseText);
		}
	}
	//Get variables
	var post=encodeURIComponent(document.getElementById(display_id+"00").value);
	var spid=encodeURIComponent(document.getElementById(display_id+"01").value);
	var opid=encodeURIComponent(document.getElementById(display_id+"02").value);
	var pnid=encodeURIComponent(document.getElementById(display_id+"03").value);
	var upid=encodeURIComponent(document.getElementById(display_id+"04").value);
	var location=encodeURIComponent(document.getElementById(display_id+"05").value);
	var params="post="+post+"&spid="+spid+"&opid="+opid+"&pnid="+pnid+"&upid="+upid+"&location="+location+"&action="+action;
	
	ajaxRequestComment.open("POST", "./pieces/backend/gardenBees.php", true);
	//Send the proper header information along with the request
	ajaxRequestComment.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestComment.setRequestHeader("Content-length", params.length);
	ajaxRequestComment.setRequestHeader("Connection", "close");
	ajaxRequestComment.send(params); 
}

function newMessage() {
	var action="";
	ajaxRequestThree = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestThree.onreadystatechange = function(){
		if(ajaxRequestThree.readyState == 4){
			//prependElement('display', ajaxRequest.responseText);
			//document.getElementById('display').innerHTML = ajaxRequest.responseText;
			$('#conversationSandbox').prepend(ajaxRequestThree.responseText);
		}
	}
	//Get variables
	var post=encodeURIComponent(document.getElementById("message").value);
	var to=encodeURIComponent(document.getElementById("to").value);
	var from=encodeURIComponent(document.getElementById("from").value);
	var conversation_id=encodeURIComponent(document.getElementById("cid").value);
	var submitted=encodeURIComponent(document.getElementById("submitted").value);
	var params="post="+post+"&to="+to+"&from="+from+"&cid="+conversation_id+"&submitted="+submitted;
	
	ajaxRequestThree.open("POST", "./pieces/backend/hummingbird.php", true);
	//Send the proper header information along with the request
	ajaxRequestThree.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestThree.setRequestHeader("Content-length", params.length);
	ajaxRequestThree.setRequestHeader("Connection", "close");
	ajaxRequestThree.send(params); 
}

function updateMessages(mid) {
	ajaxRequestTwo = ajaxFunction();
	ajaxRequestTwo.onreadystatechange = function(){
		if(ajaxRequestTwo.readyState == 4){
			//prependElement('display', ajaxRequest.responseText);
			//document.getElementById('display').innerHTML = ajaxRequest.responseText;
			$('#conversationSandbox').prepend(ajaxRequestTwo.responseText);
			var nmid=encodeURIComponent(document.getElementById("f_m_id").innerHTML);
			if (parseInt(nmid)>parseInt(mid)) {
				mid = nmid;
			}
			setTimeout('updateMessages(\''+mid+'\')', 3000);
		}
	}
	var conversation_id=encodeURIComponent(document.getElementById("cid").value);
	var params="cid="+conversation_id+"&mid="+mid;
	
	ajaxRequestTwo.open("POST", "./pieces/backend/hummingbird.php", true);
	//Send the proper header information along with the request
	ajaxRequestTwo.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestTwo.setRequestHeader("Content-length", params.length);
	ajaxRequestTwo.setRequestHeader("Connection", "close");
	ajaxRequestTwo.send(params); 
}

function newLike(display_id) {
	var action="";
	ajaxRequestLike = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestLike.onreadystatechange = function(){
		if(ajaxRequestLike.readyState == 4){
			//prependElement('display', ajaxRequestLike.responseText);
			//document.getElementById('display').innerHTML = ajaxRequestLike.responseText;
			//$('#'+display_id+"11").append(ajaxRequestLike.responseText);
			document.getElementById(display_id+"11").innerHTML = ajaxRequestLike.responseText;
		}
	}
	
	//Get variables
	var spid=encodeURIComponent(document.getElementById(display_id+"9999901").value);
	var opid=encodeURIComponent(document.getElementById(display_id+"9999902").value);
	var pnid=encodeURIComponent(document.getElementById(display_id+"9999903").value);
	var upid=encodeURIComponent(document.getElementById(display_id+"9999904").value);
	var params="spid="+spid+"&opid="+opid+"&pnid="+pnid+"&upid="+upid+"&action="+action;
	
	ajaxRequestLike.open("POST", "./pieces/backend/pickingStrawberries.php", true);
	//Send the proper header information along with the request
	ajaxRequestLike.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestLike.setRequestHeader("Content-length", params.length);
	ajaxRequestLike.setRequestHeader("Connection", "close");
	ajaxRequestLike.send(params); 
}

function deletePost(action, action_id) {
	
	var divid = action_id+"0001000";
	
	ajaxRequestLike = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestLike.onreadystatechange = function(){
		if(ajaxRequestLike.readyState == 4 && ajaxRequestLike.responseText!='NOCHANGE'){
			//prependElement('display', ajaxRequestLike.responseText);
			//document.getElementById('display').innerHTML = ajaxRequestLike.responseText;
			//$('#'+display_id+"11").append(ajaxRequestLike.responseText);
			document.getElementById(divid).innerHTML = ajaxRequestLike.responseText;
		}
	}
	
	//Get variables
	var params="action="+action+"&action_id="+action_id;
	
	ajaxRequestLike.open("POST", "./pieces/backend/deletePost.php", true);
	//Send the proper header information along with the request
	ajaxRequestLike.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestLike.setRequestHeader("Content-length", params.length);
	ajaxRequestLike.setRequestHeader("Connection", "close");
	ajaxRequestLike.send(params); 
}

function changeName() {
	var action="";
	ajaxRequestChange = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestChange.onreadystatechange = function(){
		if(ajaxRequestChange.readyState == 4 && ajaxRequestChange.status==200 && ajaxRequestChange.responseText.length>1){
			//prependElement('display', ajaxRequestLike.responseText);
			//document.getElementById('display').innerHTML = ajaxRequestLike.responseText;
			//$('#'+display_id+"11").append(ajaxRequestLike.responseText);
			document.getElementById('changeNameBox').innerHTML = ajaxRequestChange.responseText;
		}
	}
	
	//Get variables
	var first_name=encodeURIComponent(document.getElementById("first_name").value);
	var middle_name=encodeURIComponent(document.getElementById("middle_name").value);
	var last_name=encodeURIComponent(document.getElementById("last_name").value);
	var params="first_name="+first_name+"&middle_name="+middle_name+"&last_name="+last_name;
	
	ajaxRequestChange.open("POST", "./pieces/backend/changeinfo.php", true);
	//Send the proper header information along with the request
	ajaxRequestChange.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestChange.setRequestHeader("Content-length", params.length);
	ajaxRequestChange.setRequestHeader("Connection", "close");
	ajaxRequestChange.send(params); 
}

function changeEmail(email_id, action) {
	ajaxRequestChange = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestChange.onreadystatechange = function(){
		if(ajaxRequestChange.readyState == 4 && ajaxRequestChange.status==200 && ajaxRequestChange.responseText.length>1){
			//prependElement('display', ajaxRequestLike.responseText);
			//document.getElementById('display').innerHTML = ajaxRequestLike.responseText;
			//$('#'+display_id+"11").append(ajaxRequestLike.responseText);
			document.getElementById('changeEmailBox').innerHTML = ajaxRequestChange.responseText;
		}
	}
	
	//Get variables
	var email=encodeURIComponent(document.getElementById(email_id).value);
	var newemail=encodeURIComponent(document.getElementById("addNewEmail").value);
	var params="action="+action+"&email_id="+email_id+"&email="+email;
	
	ajaxRequestChange.open("POST", "./pieces/backend/changeinfo.php", true);
	//Send the proper header information along with the request
	ajaxRequestChange.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestChange.setRequestHeader("Content-length", params.length);
	ajaxRequestChange.setRequestHeader("Connection", "close");
	ajaxRequestChange.send(params); 
}

function verifyEmail(email_id) {
	
	var divid='22'+email_id+'22';
	
	ajaxRequestChange = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestChange.onreadystatechange = function(){
		if(ajaxRequestChange.readyState == 4 && ajaxRequestChange.status==200 && ajaxRequestChange.responseText.length>1){
			//prependElement('display', ajaxRequestLike.responseText);
			//document.getElementById('display').innerHTML = ajaxRequestLike.responseText;
			//$('#'+display_id+"11").append(ajaxRequestLike.responseText);
			document.getElementById(divid).innerHTML = ajaxRequestChange.responseText;
		}
	}
	
	//Get variables
	var params="email_id="+email_id;
	
	ajaxRequestChange.open("POST", "./pieces/backend/sendVerifyEmail.php", true);
	//Send the proper header information along with the request
	ajaxRequestChange.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestChange.setRequestHeader("Content-length", params.length);
	ajaxRequestChange.setRequestHeader("Connection", "close");
	ajaxRequestChange.send(params); 
}

function changeLoopNotification(action, divid, action_id) {
	ajaxNotification = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxNotification.onreadystatechange = function(){
		if(ajaxNotification.readyState == 4 && ajaxNotification.status==200 && ajaxNotification.responseText.length>1){
			//prependElement('display', ajaxNotification.responseText);
			//document.getElementById('display').innerHTML = ajaxNotification.responseText;
			//$('#'+display_id+"11").append(ajaxNotification.responseText);
			document.getElementById(divid).innerHTML = ajaxNotification.responseText;
		}
	}
	
	//Get variables
	var params="notification_type="+action+"&loop_id="+action_id+"&follow_id="+action_id;
	
	ajaxNotification.open("POST", "./pieces/backend/changeNotification.php", true);
	//Send the proper header information along with the request
	ajaxNotification.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxNotification.setRequestHeader("Content-length", params.length);
	ajaxNotification.setRequestHeader("Connection", "close");
	ajaxNotification.send(params); 
}

function changeReplyNotification(action, post_id, update_id) {
	var divid = '';
	if (post_id>0) {
		divid=post_id+"112233";
	} else if(update_id>0) {
		divid="112233"+update_id;
	}
	ajaxNotification = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxNotification.onreadystatechange = function(){
		if(ajaxNotification.readyState == 4 && ajaxNotification.status==200 && ajaxNotification.responseText.length>1){
			//prependElement('display', ajaxNotification.responseText);
			//document.getElementById('display').innerHTML = ajaxNotification.responseText;
			//$('#'+display_id+"11").append(ajaxNotification.responseText);
			document.getElementById(divid).innerHTML = ajaxNotification.responseText;
		}
	}
	
	//Get variables
	var params="notification_type="+action+"&post_id="+post_id+"&update_id="+update_id;
	
	ajaxNotification.open("POST", "./pieces/backend/changeNotification.php", true);
	//Send the proper header information along with the request
	ajaxNotification.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxNotification.setRequestHeader("Content-length", params.length);
	ajaxNotification.setRequestHeader("Connection", "close");
	ajaxNotification.send(params); 
}

function changeDefaultNotification() {
	var divid = 'notificationSetting';
	
	ajaxNotification = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxNotification.onreadystatechange = function(){
		if(ajaxNotification.readyState == 4 && ajaxNotification.status==200 && ajaxNotification.responseText.length>1){
			//prependElement('display', ajaxNotification.responseText);
			//document.getElementById('display').innerHTML = ajaxNotification.responseText;
			//$('#'+display_id+"11").append(ajaxNotification.responseText);
			document.getElementById(divid).innerHTML = ajaxNotification.responseText;
		}
	}
	
	//Get variables
	var params="notification_type=comment_default";
	
	ajaxNotification.open("POST", "./pieces/backend/changeNotification.php", true);
	//Send the proper header information along with the request
	ajaxNotification.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxNotification.setRequestHeader("Content-length", params.length);
	ajaxNotification.setRequestHeader("Connection", "close");
	ajaxNotification.send(params); 
}

function changeAllNotifications(divid, notification_type, set_to) {
	
	ajaxNotification = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxNotification.onreadystatechange = function(){
		if(ajaxNotification.readyState == 4 && ajaxNotification.status==200 && ajaxNotification.responseText.length>1){
			//prependElement('display', ajaxNotification.responseText);
			//document.getElementById('display').innerHTML = ajaxNotification.responseText;
			//$('#'+display_id+"11").append(ajaxNotification.responseText);
			document.getElementById(divid).innerHTML = ajaxNotification.responseText;
		}
	}
	
	//Get variables
	var params="notification_type="+notification_type+"&set_to="+set_to;
	
	ajaxNotification.open("POST", "./pieces/backend/changeNotification.php", true);
	//Send the proper header information along with the request
	ajaxNotification.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxNotification.setRequestHeader("Content-length", params.length);
	ajaxNotification.setRequestHeader("Connection", "close");
	ajaxNotification.send(params); 
}

function newEmail() {
	ajaxRequestChange = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestChange.onreadystatechange = function(){
		if(ajaxRequestChange.readyState == 4 && ajaxRequestChange.status==200 && ajaxRequestChange.responseText.length>1){
			//prependElement('display', ajaxRequestLike.responseText);
			//document.getElementById('display').innerHTML = ajaxRequestLike.responseText;
			//$('#'+display_id+"11").append(ajaxRequestLike.responseText);
			document.getElementById('changeEmailBox').innerHTML = ajaxRequestChange.responseText;
		}
	}
	
	//Get variables
	var newemail=encodeURIComponent(document.getElementById("addNewEmail").value);
	var params="newemail="+newemail;
	
	ajaxRequestChange.open("POST", "./pieces/backend/changeinfo.php", true);
	//Send the proper header information along with the request
	ajaxRequestChange.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestChange.setRequestHeader("Content-length", params.length);
	ajaxRequestChange.setRequestHeader("Connection", "close");
	ajaxRequestChange.send(params); 
}

function changeNumber() {
	var action="";
	ajaxRequestChange = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestChange.onreadystatechange = function(){
		if(ajaxRequestChange.readyState == 4 && ajaxRequestChange.status==200 && ajaxRequestChange.responseText.length>1){
			//prependElement('display', ajaxRequestLike.responseText);
			//document.getElementById('display').innerHTML = ajaxRequestLike.responseText;
			//$('#'+display_id+"11").append(ajaxRequestLike.responseText);
			document.getElementById('changeNumberBox').innerHTML = ajaxRequestChange.responseText;
		}
	}
	
	//Get variables
	var mobile_number=encodeURIComponent(document.getElementById("mobile_number").value);
	var params="mobile_number="+mobile_number;
	
	ajaxRequestChange.open("POST", "./pieces/backend/changeinfo.php", true);
	//Send the proper header information along with the request
	ajaxRequestChange.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestChange.setRequestHeader("Content-length", params.length);
	ajaxRequestChange.setRequestHeader("Connection", "close");
	ajaxRequestChange.send(params); 
}

function changePassword() {
	var action="";
	ajaxRequestChange = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestChange.onreadystatechange = function(){
		if(ajaxRequestChange.readyState == 4){
			//prependElement('display', ajaxRequest.responseText);
			//document.getElementById('display').innerHTML = ajaxRequest.responseText;
			document.getElementById('passwordMessage').innerHTML = ajaxRequestChange.responseText;
		}
	}
	//Get variables
	var password=encodeURIComponent(document.getElementById("password").value);
	var password1=encodeURIComponent(document.getElementById("password1").value);
	var password2=encodeURIComponent(document.getElementById("password2").value);
	var params="password="+password+"&password1="+password1+"&password2="+password2;
	
	ajaxRequestChange.open("POST", "./pieces/backend/changeinfo.php", true);
	//Send the proper header information along with the request
	ajaxRequestChange.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestChange.setRequestHeader("Content-length", params.length);
	ajaxRequestChange.setRequestHeader("Connection", "close");
	ajaxRequestChange.send(params); 
}

function updateSharing(action, sid) {
	ajaxRequestChange = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestChange.onreadystatechange = function(){
		if(ajaxRequestChange.readyState == 4 && ajaxRequestChange.responseText.length>1){
			//prependElement('display', ajaxRequest.responseText);
			//document.getElementById('display').innerHTML = ajaxRequest.responseText;
			document.getElementById('shareWithBox').innerHTML = ajaxRequestChange.responseText;
		}
	}
	//Get variables
	var params="action="+action+"&sid="+sid;
	
	ajaxRequestChange.open("POST", "./pieces/backend/changeSecurity.php", true);
	//Send the proper header information along with the request
	ajaxRequestChange.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestChange.setRequestHeader("Content-length", params.length);
	ajaxRequestChange.setRequestHeader("Connection", "close");
	ajaxRequestChange.send(params); 
}

function updateBio() {
	ajaxRequestChange = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestChange.onreadystatechange = function(){
		if(ajaxRequestChange.readyState == 4 && ajaxRequestChange.responseText.length>1){
			//prependElement('display', ajaxRequest.responseText);
			//document.getElementById('display').innerHTML = ajaxRequest.responseText;
			document.getElementById('changeBio').innerHTML = ajaxRequestChange.responseText;
		}
	}
	//Get variables
	var bio = encodeURIComponent(document.getElementById("bioFieldInput").value);
	var params="bio="+bio;
	
	ajaxRequestChange.open("POST", "./pieces/backend/changeinfo.php", true);
	//Send the proper header information along with the request
	ajaxRequestChange.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestChange.setRequestHeader("Content-length", params.length);
	ajaxRequestChange.setRequestHeader("Connection", "close");
	ajaxRequestChange.send(params); 
}

function changeNetworkInfo(action) {
	
	var id = action+"name";
	var id_s = action+"_name";
	//Get variables
	var handle=encodeURIComponent(document.getElementById(id_s).value);
	
	ajaxRequestNet = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestNet.onreadystatechange = function(){
		if(ajaxRequestNet.readyState == 4){
			document.getElementById(id).innerHTML = ajaxRequestNet.responseText;
		}
	}
	
	var params="action="+action+"&handle="+handle;
	
	ajaxRequestNet.open("POST", "./pieces/backend/editNetworkInfo.php", true);
	//Send the proper header information along with the request
	ajaxRequestNet.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestNet.setRequestHeader("Content-length", params.length);
	ajaxRequestNet.setRequestHeader("Connection", "close");
	ajaxRequestNet.send(params); 
	
}

function earlyAccess() {
	ajaxRequestChange = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestChange.onreadystatechange = function(){
		if(ajaxRequestChange.readyState == 4 && ajaxRequestChange.responseText.length>1){
			//prependElement('display', ajaxRequest.responseText);
			//document.getElementById('display').innerHTML = ajaxRequest.responseText;
			document.getElementById('signupwrapper').innerHTML = ajaxRequestChange.responseText;
		}
	}
	//Get variables
	var email = encodeURIComponent(document.getElementById("earlyAccessEmail").value);
	var params="email="+email;
	
	ajaxRequestChange.open("POST", "./pieces/backend/earlyAccessSubmit.php", true);
	//Send the proper header information along with the request
	ajaxRequestChange.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestChange.setRequestHeader("Content-length", params.length);
	ajaxRequestChange.setRequestHeader("Connection", "close");
	ajaxRequestChange.send(params); 
}

function showMore(location, group_id, page_id) {
	
	ajaxShowMore = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxShowMore.onreadystatechange = function(){
		if(ajaxShowMore.readyState == 4 && ajaxShowMore.status==200){
			//document.getElementById('changeNameBox').innerHTML = ajaxShowMore.responseText;
			removeElement('sandbox','playbox');
			$('#sandbox').append(ajaxShowMore.responseText);
		}
	}
	
	//Set variable
	var params="location="+location+"&group_id="+group_id+"&page_id="+page_id;
	
	ajaxShowMore.open("POST", "./pieces/backend/showMore.php", true);
	//Send the proper header information along with the request
	ajaxShowMore.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxShowMore.setRequestHeader("Content-length", params.length);
	ajaxShowMore.setRequestHeader("Connection", "close");
	ajaxShowMore.send(params); 
}

function showMoreMsg(location, lid, page_id) {
	
	ajaxShowMore = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxShowMore.onreadystatechange = function(){
		if(ajaxShowMore.readyState == 4 && ajaxShowMore.status==200){
			//document.getElementById('changeNameBox').innerHTML = ajaxShowMore.responseText;
			removeElement('sandbox','playbox');
			$('#sandbox').append(ajaxShowMore.responseText);
		}
	}
	
	//Set variable
	var params="location="+location+"&lid="+lid+"&page_id="+page_id;
	
	ajaxShowMore.open("POST", "./pieces/backend/showMore.php", true);
	//Send the proper header information along with the request
	ajaxShowMore.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxShowMore.setRequestHeader("Content-length", params.length);
	ajaxShowMore.setRequestHeader("Connection", "close");
	ajaxShowMore.send(params); 
}

function newAlbum() {
	
	ajaxShowMore = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxShowMore.onreadystatechange = function(){
		if(ajaxShowMore.readyState == 4 && ajaxShowMore.status==200){
			$('#albums').append(ajaxShowMore.responseText);
			//var sub = ajaxShowMore.responseText.substring(7,0);
			//if (sub=="http://") {
			//	window.location=ajaxShowMore.responseText;
			//} else {
			//	document.getElementById('newAlbum').innerHTML = ajaxShowMore.responseText;
			//}
		}
	}
	
	//Set variable
	var loop_id=encodeURIComponent(document.getElementById('albLip').value);
	var name=encodeURIComponent(document.getElementById('albName').value);
	var params="loop_id="+loop_id+"&name="+name;
	
	ajaxShowMore.open("POST", "./pieces/backend/pictures/newAlbum.php", true);
	//Send the proper header information along with the request
	ajaxShowMore.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxShowMore.setRequestHeader("Content-length", params.length);
	ajaxShowMore.setRequestHeader("Connection", "close");
	ajaxShowMore.send(params); 
}

function isEnterPressed(e){
	var keycode=null;
	if (e!=null){
	        if (window.event!=undefined){
	                if (window.event.keyCode) keycode = window.event.keyCode;
	                else if (window.event.charCode) keycode = window.event.charCode;
	        }else{
	                keycode = e.keyCode;
	        }
	}
	return (keycode == 13);
}

function eraseText(id, t) {
	document.getElementById(id).value = "";
	t.rows = 1;
}

function displayDate()
{
document.getElementById("demo").innerHTML=Date();
}

function toggleDiv(divid){
  if(document.getElementById(divid).style.display == 'none'){
    document.getElementById(divid).style.display = 'block';
  }else{
    document.getElementById(divid).style.display = 'none';
  }
}

function blockDiv(divid){
	  if(document.getElementById(divid).style.display == 'none'){
	    document.getElementById(divid).style.display = 'block';
	  }
}

function noneDiv(divid){
	  if(document.getElementById(divid).style.display == 'block'){
	    document.getElementById(divid).style.display = 'none';
	  }
}

function toggleQuestions(divid) {
	document.getElementById('tfquestion').style.display = 'none';
	document.getElementById('mcquestion').style.display = 'none';
	document.getElementById(divid).style.display = 'block';
}

function showForm() {
    document.getElementById('moreInfo').style.display = 'block';
}

function toggleAnyDisplay(toggleid) {
    if (document.getElementById(toggleid).style.display == 'block') {
    	document.getElementById(toggleid).style.display = 'none';
    } else if (document.getElementById(toggleid).style.display == 'none') {
    	document.getElementById(toggleid).style.display = 'block';
    }
}

function sz(t) {
	a = t.value.split('\n');
	b=1;
	for (x=0;x < a.length; x++) { 
		if (a[x].length >= t.cols) b+= Math.floor(a[x].length/t.cols);
	}
	b+= a.length;
	if (b > t.rows) {
		t.rows = b-1;
	}
}

function togglePostBar(barid){
	if(barid=='text'){
		document.getElementById("posttextbar").style.display = 'block';
		document.getElementById("postimagebar").style.display = 'none';
		document.getElementById("postsmsbar").style.display= 'none';
		document.getElementById("postquestionbar").style.display= 'none';
		document.getElementById("topLinePoint").innerHTML = '<img width="450" height="8" src="./site_images/postbar_lines/thought.png" />';
	} else if(barid=='image'){
		document.getElementById("postimagebar").style.display = 'block';
		document.getElementById("posttextbar").style.display = 'none';
		document.getElementById("postsmsbar").style.display= 'none';
		document.getElementById("postquestionbar").style.display= 'none';
		document.getElementById("topLinePoint").innerHTML = '<img width="450" height="8" src="./site_images/postbar_lines/photo.png" />';
	} else if(barid=='sms'){
		document.getElementById("postsmsbar").style.display= 'block';
		document.getElementById("posttextbar").style.display = 'none';
		document.getElementById("postimagebar").style.display = 'none';
		document.getElementById("postquestionbar").style.display= 'none';
		document.getElementById("topLinePoint").innerHTML = '<img width="450" height="8" src="./site_images/postbar_lines/sms.png" />';
	} else if(barid=='question'){
		document.getElementById("postsmsbar").style.display= 'none';
		document.getElementById("posttextbar").style.display = 'none';
		document.getElementById("postimagebar").style.display = 'none';
		document.getElementById("postquestionbar").style.display= 'block';
		document.getElementById("topLinePoint").innerHTML = '<img width="450" height="8" src="./site_images/postbar_lines/question.png" />';
	}
}

function updateSidebar() {
	ajaxRequestSidebar = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestSidebar.onreadystatechange = function(){
		if(ajaxRequestSidebar.readyState == 4 && ajaxRequestSidebar.status==200 && ajaxRequestSidebar.responseText.length>2){
			//prependElement('display', ajaxRequestSidebar.responseText);
			//document.getElementById('display').innerHTML = ajaxRequestSidebar.responseText;
			$('.sideBar').html(ajaxRequestSidebar.responseText);
		}
	}
	
	var params="true=1";
	ajaxRequestSidebar.open("POST", "./pieces/backend/nike.php", true);
	//Send the proper header information along with the request
	ajaxRequestSidebar.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestSidebar.setRequestHeader("Content-length", params.length);
	ajaxRequestSidebar.setRequestHeader("Connection", "close");
	ajaxRequestSidebar.send(params); 
	setTimeout('updateSidebar()', 8000);
}

function updateLivePosts(location,group_id,page_id) {
	
	var loop_id=parseInt(group_id);
	
	ajaxRequestTwo = ajaxFunction();
	ajaxRequestTwo.onreadystatechange = function(){
		if(ajaxRequestTwo.readyState == 4){
			//prependElement('display', ajaxRequest.responseText);
			document.getElementById('newLivePosts').innerHTML = ajaxRequestTwo.responseText;
			//$('#newLivePosts').prepend(ajaxRequestTwo.responseText);
		}
	}

	var params="location="+location+"&loop_id="+loop_id+"&page_id="+page_id;
	var inside_function = function(){updateLivePosts(location, group_id, page_id);};
	
	ajaxRequestTwo.open("POST", "./pieces/backend/livePosts.php", true);
	//Send the proper header information along with the request
	ajaxRequestTwo.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestTwo.setRequestHeader("Content-length", params.length);
	ajaxRequestTwo.setRequestHeader("Connection", "close");
	ajaxRequestTwo.send(params); 
	setTimeout(inside_function, 8000);
}

function changeId(obj,change_to) {
	try {
		document.getElementById(obj).id = change_to;
	} catch (e) {}
}

function clearEl(id) {
	try {
		document.getElementById(id).innerHTML = "";
	} catch (e) {}
}

function confirmShowPosts(group_id) {
	changeId('newLivePosts','old_update');
	
	//var thisBarLine = group_id+"8"+group_id;
	//changeId(barline, 'old_line');
	//changeId(thisBarLine, barLine);
	
	ajaxRequestChange = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestChange.onreadystatechange = function(){
		if(ajaxRequestChange.readyState == 4 && ajaxRequestChange.responseText.length>1){
			//prependElement('display', ajaxRequest.responseText);
			//document.getElementById('display').innerHTML = ajaxRequest.responseText;
			//document.getElementById('changeBio').innerHTML = ajaxRequestChange.responseText;
			$('#sandbox').prepend(ajaxRequestChange.responseText);
		}
	}
	//Get variables
	var params="group_id="+group_id;
	
	ajaxRequestChange.open("POST", "./pieces/backend/confirmShowLivePosts.php", true);
	//Send the proper header information along with the request
	ajaxRequestChange.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestChange.setRequestHeader("Content-length", params.length);
	ajaxRequestChange.setRequestHeader("Connection", "close");
	ajaxRequestChange.send(params); 
}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

function removeElement(parentDiv, childDiv){
    if (childDiv == parentDiv) {
         return false;
    }
    else if (document.getElementById(childDiv)) {     
         var child = document.getElementById(childDiv);
         var parent = document.getElementById(parentDiv);
         parent.removeChild(child);
    }
    else {
         return false;
    }
}

function preloader(src) {
	heavyImage = new Image(); 
	heavyImage.src = src;
}

function sendCode() {
	
	ajaxRequestChange = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestChange.onreadystatechange = function(){
		if(ajaxRequestChange.readyState == 4 && ajaxRequestChange.responseText.length>1){
			document.getElementById('codeSent').innerHTML = ajaxRequestChange.responseText;
		}
	}
	//Get variables
	var params="sendCode=true";
	
	ajaxRequestChange.open("POST", "./pieces/backend/sendCode.php", true);
	//Send the proper header information along with the request
	ajaxRequestChange.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestChange.setRequestHeader("Content-length", params.length);
	ajaxRequestChange.setRequestHeader("Connection", "close");
	ajaxRequestChange.send(params); 
	
}

function checkInput(divid, type) {
	
	var inner = divid+"11";
	
	ajaxRequestChange = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestChange.onreadystatechange = function(){
		if(ajaxRequestChange.readyState == 4 && ajaxRequestChange.responseText.length>1){
			document.getElementById(inner).innerHTML = ajaxRequestChange.responseText;
		}
	}
	//Get variables
	var string2='';
	if (type=='password2') {
		var inside2 = divid+"11";
		string2=encodeURIComponent(document.getElementById(inside2).value);
		divid=divid-1;
	}
	var inside1 = divid+"11";
	var string=encodeURIComponent(document.getElementById(inside1).value);
	var params="type="+type+"&string="+string+"&string2="+string2;
	
	ajaxRequestChange.open("POST", "./pieces/backend/checkInput.php", true);
	//Send the proper header information along with the request
	ajaxRequestChange.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestChange.setRequestHeader("Content-length", params.length);
	ajaxRequestChange.setRequestHeader("Connection", "close");
	ajaxRequestChange.send(params); 
	
}

function notifInfo(sid) {
	
	ajaxRequestChange = ajaxFunction();
	// Create a function that will receive data sent from the server
	ajaxRequestChange.onreadystatechange = function(){
		if(ajaxRequestChange.readyState == 4 && ajaxRequestChange.responseText.length>1){
			document.getElementById("notifpanel").innerHTML = ajaxRequestChange.responseText;
		}
	}
	//Get variables
	var params="sid="+sid;
	
	ajaxRequestChange.open("POST", "./pieces/backend/notifications.php", true);
	//Send the proper header information along with the request
	ajaxRequestChange.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxRequestChange.setRequestHeader("Content-length", params.length);
	ajaxRequestChange.setRequestHeader("Connection", "close");
	ajaxRequestChange.send(params); 
	
}

function showPic (id) {
	
	document.getElementById(id).src=id.title;
	return false;
	
}
