function RegisterChar()
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="phpBB3/ucp.php"
var postvar="mode=" + encodeURI( "logout" ) +
                    "&logout=" + encodeURI( "1" ) +
					"&redirect=" + encodeURI( "" );
xmlHttp.onreadystatechange=stateChanged2
xmlHttp.open("POST",url,true)
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", postvar.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(postvar);
}
function stateChanged2() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 RegisterPHPBB(username, pass, pass, email, email)
 } 
}

function LogoutPHPBB()
{
//alert ("WORKING")
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="phpBB3/ucp.php"
var postvar="mode=" + encodeURI( "logout" ) +
                    "&logout=" + encodeURI( "1" ) +
					"&redirect=" + encodeURI( "" );
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("POST",url,true)
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", postvar.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(postvar);
} 

function LoginPHPBB(username, pass, remember)
{
//alert ("WORKING")
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="phpBB3/ucp.php"
var postvar="mode=" + encodeURI( "login" ) +
                    "&username=" + encodeURI( username ) +
					"&password=" + encodeURI( pass ) +
					//"&viewonline=" + encodeURI( "false" ) +
					"autologin=" + encodeURI( remember ) +
					"&redirect=" + encodeURI( "" ) +
					"&login=" + encodeURI( "1" );
xmlHttp.onreadystatechange=URLChanged
xmlHttp.open("POST",url,true)
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", postvar.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(postvar);
//alert("finished")
} 

function RegisterPHPBB(username, pass, pass2, email, email2)
{
//alert ("WORKING" + " " + username + " " + pass + " " + pass2 + " " + email + " " + email2)
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="phpBB3/ucp.php"
var postvar="mode=" + encodeURI( "register" ) +
                    "&username=" + encodeURI( username ) +
					"&email=" + encodeURI( email ) +
					"&email_confirm=" + encodeURI( email2 ) +
					"&new_password=" + encodeURI( pass ) +
					"&password_confirm=" + encodeURI( pass2 ) +
					"&lang=" + encodeURI( "en" ) +
					"&tz=" + encodeURI( "0" ) +
					"&agreed=" + encodeURI( "true" ) +
					"&coppa=" + encodeURI( "0" ) +
					"&change_lang=" + encodeURI( "0" ) +
					"&register=" + encodeURI( "1" ) +
					"&submit=" + encodeURI( "1" ) +
					"&registercontrol=" + encodeURI( "Aq28d$72PPz" );
xmlHttp.open("POST",url,true)
//xmlHttp.onreadystatechange=Changed
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", postvar.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(postvar);
var e = document.getElementById("returns");
if (e)
{
	setTimeout(e.submit(),10000);
}
//window.location="index.php?site=CPL";
} 

function Changed() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 // alert (xmlHttp.responseText)
 document.innerHTML=xmlHttp.responseText 
 }
}

function URLChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
// alert(url.substring(1,10));
	if ( url != "" && url.substring(1,10) != "index.php")
	{
	window.location=url;
	 }
	}
}


function stateChanged() 
{ 
if (window.loginid != undefined && (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") )
 { 
 //document.innerHTML=xmlHttp.responseText 
 //alert ("CHANGED")
 LoginPHPBB(loginid, pass, remember)
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
 // In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
 var win = window.open(url,
  name,
  'width=' + w + ', height=' + h + ', ' +
  'location=no, menubar=no, ' +
  'status=no, toolbar=no, scrollbars=yes, resizable=no');
 win.resizeTo(w, h);
 win.focus();
}
// -->
