if (parent.frames.length > 0) 
{
parent.location.href = location.href;
}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}

function checkexistsusername(essay)
{
if (window.XMLHttpRequest) {xhr = new XMLHttpRequest();}
else if (window.ActiveXObject) {xhr = new ActiveXObject("Microsoft.XMLHTTP");}

essay=encodeURIComponent(essay);
xhr.open("POST","http://www.Print-On-Demand.info/checkusername.html", true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xhr.send(essay);
xhr.onreadystatechange=function()
	{
	if (xhr.readyState==4)
		{
		if (xhr.status==200)
		{
		if (xhr.responseText==1) {document.getElementById("exists").innerHTML="Username already exists<br> - please select another";document.getElementById("newusername").style.background="#FF9999"} else {document.getElementById("exists").innerHTML="";document.getElementById("newusername").style.background="white"}
		}
		}
	}
}

function checkexistsfilename(essay, presentfn)
{
if (window.XMLHttpRequest) {xhr = new XMLHttpRequest();}
else if (window.ActiveXObject) {xhr = new ActiveXObject("Microsoft.XMLHTTP");}

essay=encodeURIComponent(essay);
xhr.open("POST","http://www.Print-On-Demand.info/checkfilename.html", true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
xhr.send(essay);
xhr.onreadystatechange=function()
	{
	if (xhr.readyState==4)
		{
		if (xhr.status==200)
		{
		if (xhr.responseText==1) {document.getElementById("exists").innerHTML="Filename already exists - please select another";document.getElementById("newusername").style.background="#FF9999"} else {document.getElementById("exists").innerHTML="";document.getElementById("newusername").style.background="white"}
		}
		}
	}
}
