function selectEntryBox()
{
	if (document.graffiti_form.newpost.value == "[type graffiti here]")
	{
		document.graffiti_form.newpost.value = "";
	}
	document.graffiti_form.postbutton.className = "graffiti_INPUT_button_enabled";
	document.graffiti_form.newpost.select();
};

function deselectEntryBox()
{
	if (document.graffiti_form.newpost.value == "" ||
		document.graffiti_form.newpost.value == "[type graffiti here]")
	{
		document.graffiti_form.newpost.value = "[type graffiti here]"
		document.graffiti_form.postbutton.className = "graffiti_INPUT_button_disabled";
	}
};

function isCodeValid()
{
	mystring = document.graffiti_form.newpost.value;
};

function isValidSearch()
{
	string = document.graffiti_form.newpost.value;
	if (string == "") return false;
	if (string == "[type graffiti here]") return false;
	return true;
};

//Execute this code on start
function initialize()
{
	document.graffiti_form.newpost.maxLength = 100;
	deselectEntryBox();
}

//Scrolling functions
var isScrollingUp = false;
var isScrollingDown = false;
var scrollDistance = 3;
var scrollTime = 10;

function startScrollingUp(obj)
{
	isScrollingUp = true;
	isScrollingDown = false;
	obj.className = "graffiti_CELL_scrollbutton_pressed";
	scrollUp();
}
function stopScrollingUp(obj)
{
	isScrollingUp = false;
	obj.className = "graffiti_CELL_scrollbutton_unpressed";
}
function startScrollingDown(obj)
{
	isScrollingDown = true;
	isScrollingUp = false;
	obj.className = "graffiti_CELL_scrollbutton_pressed";
	scrollDown();
}
function stopScrollingDown(obj)
{
	isScrollingDown = false;
	obj.className = "graffiti_CELL_scrollbutton_unpressed";
}

function scrollDown()
{
	if (!isScrollingDown) return;
	if (all_ready()) parent.graffiti_text.window.scrollBy(0, scrollDistance);
	setTimeout("scrollDown();", scrollTime);
}

function scrollUp()
{
	if (!isScrollingUp) return;
	if (all_ready()) parent.graffiti_text.window.scrollBy(0, -scrollDistance);
	setTimeout("scrollUp();", scrollTime);
}


//The help button
function helpButtonDown(obj)
{
	obj.className = "graffiti_CELL_scrollbutton_pressed";
}

function helpButtonUp(obj)
{
	obj.className = "graffiti_CELL_scrollbutton_unpressed";
	if (all_ready()) parent.graffiti_text.document.location = "graffiti_help.html";
}

function helpButtonOut(obj)
{
	obj.className = "graffiti_CELL_scrollbutton_unpressed";
}

var retrycount = 0;

//Code for the text area
function textRefreshCheck()
{
	if (!all_ready())
	{
		retrycount++;
		if (retrycount > 4) return;
		setTimeout("textRefreshCheck();", 2000);
		return;
	}

	if (window.location.search != parent.graffiti_control.document.graffiti_form.updatetime.value)
	{
		parent.graffiti_control.document.graffiti_form.updatetime.value = window.location.search;
		parent.graffiti_control.document.graffiti_form.newpost.value = "[type graffiti here]"
		parent.graffiti_control.document.graffiti_form.postbutton.className = "graffiti_INPUT_button_disabled";
	}
}

var isReady = false;

function all_ready()
{
	if (isReady) return true;
	if (	!parent ||
		!parent.graffiti_control ||
		!parent.graffiti_control.document ||
		!parent.graffiti_control.document.graffiti_form ||
		!parent.graffiti_control.document.graffiti_form.updatetime ||
		!parent.graffiti_text ||
		!parent.graffiti_text.window ||
		!parent.graffiti_text.document)
	{
		return false;
	}
	isReady = true;
	return true;
}
