// TEXT COUNTER SCRIPT FOR DISCUSS BOXES
// Original:  Ronnie T. Moore -- Web Site:  The JavaScript Source
// Dynamic 'fix' by: Nannette Thacker -- Web Site: http://www.shiningstar.net
// This script and many more are available free online at The JavaScript Source!! http://javascript.internet.com -->
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}

function doLogin()
{
	var screenname=document.getElementById('screenname').value;
	var password=document.getElementById('password').value;
	if (screenname=="" && password=="")
	{
		alert("Screenname or password are empty!");
	}
	else
	{
		var x;
		try
		{
			x=new XMLHttpRequest();
		}
		catch(e)
		{
			try
			{
				x=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e)
			{
				try
				{
					x=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e)
				{
					alert("Your browser does not support AJAX!");
				}
			}
		}
		x.onreadystatechange=function()
		{
			if (x.readyState==4)
			{
				if (x.responseText=="1")
				{
					alert ("You are logged in!");
					var sPath = window.location.pathname;
					var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
					if (sPage!='register.php')
					{
						window.location.reload(true);
					}
				}
				else if (x.responseText=="2")
				{
					alert("Login incorrect!");
				}
			}
		}
		var a="login.php?screenname="+screenname+"&password="+password;
		x.open("GET",a,true); 
		x.send(null);
	}
}

function logout()
{
	var x;
	try
	{
		x=new XMLHttpRequest();
	}
	catch(e)
	{
		try
		{
			x=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				x=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your browser does not support AJAX!");
			}
		}
	}
	x.onreadystatechange=function()
	{
		if (x.readyState==4)
		{
			alert ("You are logged out!");
			window.location="index.php";
		}
	}
	var a="logout.php";
	x.open("GET",a,true);
	x.send(null);
}

// POPUP SCRIPT FOR BIG POPUPS
var popUpWin=0;
function BigpopUp(URLStr)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=800,left=100,top=100,screenX=100,screenY=100');
}

