function checkUpdate(lastAdded)
{
	url = "com.spiff.member.S_M_AJAXWallUpdate?l="+lastAdded+"&rD="+(new Date().getTime() % 100000);
//alert("URL:"+lastAdded);
	ajaxSend(url, ajaxWallUpdate, null, null, true);
}

function ajaxWallUpdate(ajaxRequest, id1, id2)
{
	if(ajaxRequest.responseText=='')
	{
		return;
	}

	i = ajaxRequest.responseText.indexOf(" ");
	t = ajaxRequest.responseText.substring(0, i);
	html = ajaxRequest.responseText.substring(i+1);
	ss = window.document.getElementById("statuses");
	el = document.createElement("span");
	el.innerHTML = html;
	ss.insertBefore(el, ss.childNodes[0]);

	clearInterval(wallInt);
	wallInt = setInterval ( 'checkUpdate('+t+')', 10000);
	window.document.getElementById("update-wall-text-input").disabled = false;
	//disableLayer("updatingStatus");
}


function showUpdating()
{
	enableLayer("updatingStatus");
	window.document.getElementById("update-wall-text-input").disabled = true;
	//setTimeout('disableLayer("updatingStatus")', 10000);
	setTimeout('window.document.getElementById("update-wall-text-input").disabled = false; disableLayer("updatingStatus")', 10000);
	
	window.document.getElementById("update-wall-text-input").style.height = "40px";
}



function pullFBStatus()
{
	url = "com.spiff.fb.S_FB_GetStatus?rD="+(new Date().getTime() % 100000);
//alert("URL:"+lastAdded);
	ajaxSend(url, ajaxFBStatus, null, null, true);
}
function pullTwitterStatus()
{
	url = "com.spiff.twitter.S_TW_PullTweet?rD="+(new Date().getTime() % 100000);
//alert("URL:"+lastAdded);
	ajaxSend(url, ajaxFBStatus, null, null, true);
}


function addComment(form, commentID)
{
	form.sub.disabled = true;
//alert(form);
	if(form.c.value=='')
	{
		return;
	}
	doPull('com.spiff.member.S_M_AJAXWall?'+getFormValues(form,null), commentID);
	pullBalance();
}


function ajaxFBStatus(ajaxRequest, id1, id2)
{
	if(ajaxRequest.responseText=='')
	{
		return;
	}

	window.document.getElementById("update-wall-text-input").value=ajaxRequest.responseText;
}


function deleteStatus(id)
{
	if(confirm("Are you sure you want to delete this?"))
	{
		//clearInterval(wallInt);
		doPull("com.spiff.member.S_M_AJAXWall?v=y&a=d&sID="+id, "statuses");
	}
}


function pullWall(time, uid)
{
	if(uid==-1)
	{
		doPull("com.spiff.member.S_M_AJAXWall?v=y&st="+time, "statuses");
	}
	else
	{
		doPull("com.spiff.member.S_M_AJAXWall?v=y&st="+time+"&uid="+uid, "statuses");
	}
}


var isBig=false;
function checkLength()
{
	if(isBig)
	{
		return;
	}
	
	txt = window.document.getElementById("update-wall-text-input").value;
	if(txt.length<100)
	{
		return;
	}
	
	window.document.getElementById("update-wall-text-input").style.height = "300px";
	isBig = true;
}



function addStatus()
{
	str = window.document.getElementById('update-wall-text-input').value;
	if(str.length<1000)
	{
		doPullPost('com.spiff.member.S_M_AJAXWall', getFormValuesPost(window.document.sForm,null),'tempStatusHolder'); 
		window.document.getElementById('update-wall-text-input').value=''; 
		showUpdating();
	}
	else
	{
		window.document.getElementById('red').value='y'; 
		window.document.sForm.submit();
	}
}