var xmlHttp;
var thisForum;
var goOffset;
var thisID;
var tempText="Loading..."

function forumChanged() { 
document.getElementById('updateForum').innerHTML = "&nbsp;<p>&nbsp;<p>&nbsp;<p><center><img src='/forum/resource/graphics/loader.gif'><p>&nbsp;<p>&nbsp;<p></center>"
if (xmlHttp.readyState==4)
{ 
if (xmlHttp.status == 200) {
document.getElementById("updateForum").innerHTML=xmlHttp.responseText;
         } else {
            ////alert('There was a problem with the request.');
         }
		 }
}

function quoteChanged() { 
//document.getElementById('updateForum').innerHTML = "&nbsp;<p>&nbsp;<p>&nbsp;<p><center><img src='/forum/resource/graphics/loader.gif'><p>&nbsp;<p>&nbsp;<p></center>"
if (xmlHttp.readyState==4)
{ 
if (xmlHttp.status == 200) {
setButton2('quote');
document.getElementById("fPost").value=xmlHttp.responseText;
setTimeout("tempTextNow()",500);
         } else {
            ////alert('There was a problem with the request.');
         }
		 }
}

//function tempTextNow(){
//document.getElementById("fpost").value=tempText;
//}

function editChanged() { 
//document.getElementById('updateForum').innerHTML = "&nbsp;<p>&nbsp;<p>&nbsp;<p><center><img src='/forum/resource/graphics/loader.gif'><p>&nbsp;<p>&nbsp;<p></center>"
if (xmlHttp.readyState==4)
{ 
if (xmlHttp.status == 200) {
var thisText=xmlHttp.responseText;
if(thisText=="thisisafailure"){
openAlert('Alert','You are not the original owner of this post and so may not perform any edit');
return;
}else{
document.getElementById("fSubject").value=thisText;
setEdit2();
}
         } else {
            ////alert('There was a problem with the request.');
         }
		 }
}

function editChanged2() { 
//document.getElementById('updateForum').innerHTML = "&nbsp;<p>&nbsp;<p>&nbsp;<p><center><img src='/forum/resource/graphics/loader.gif'><p>&nbsp;<p>&nbsp;<p></center>"
if (xmlHttp.readyState==4)
{ 
if (xmlHttp.status == 200) {
var thisText=xmlHttp.responseText;
document.getElementById("fPost").value=thisText;
setButton2('Edit');
         } else {
            ////alert('There was a problem with the request.');
         }
		 }
}

function forumChanged2(){
document.getElementById('updateForum').innerHTML = "&nbsp;<p>&nbsp;<p>&nbsp;<p><center><img src='/forum/resource/graphics/loader.gif'><p>&nbsp;<p>&nbsp;<p></center>"
      if (xmlHttp.readyState == 4) {	  
         if (xmlHttp.status == 200) {
          document.getElementById('updateForum').innerHTML = "&nbsp;<p>&nbsp;<p>&nbsp;<p align=center>Thank you, your new topic has been posted.<br><br><a href=javascript:openForum(" + thisForum + "); class=pButton2>Click here to return to the forum</a>&nbsp;<p>&nbsp;<p>&nbsp;<p>&nbsp;<p>&nbsp;<p>"
         } else {
		 //alert(xmlHttp.responseText);
            ////alert('There was a problem with the request.');
         }
      }     
   }

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

 
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return true;
    }
  }
return false;
}


function openForum(obj,obj2){
if(obj2=="undefined"){
goOffset=0;
}else{
goOffset=obj2;
}
topMe();
var thisLot="forum=" +obj;
thisLot=thisLot+"&offset=" + obj2;


var url="/forum/resource/working/openForum.asp";
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  }
//document.location.href=url+"?"+thisLot;
xmlHttp.onreadystatechange = forumChanged;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function openPost(obj,obj2,obj3){

topMe();
var thisLot="forum=" +obj;
var thisLot=thisLot+"&id=" +obj2 + "&offset=" + obj3;
thisLot=thisLot+"&offset2=" + goOffset;

var url="/forum/resource/working/openPost.asp";

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  }
//document.location.href=url+"?"+thisLot;
xmlHttp.onreadystatechange = forumChanged;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
}

function topMe(){
document.location.href="#top"
}

function chooseIcon(obj){
document.formForum.fIcon.value=obj;
document.getElementById('fIconDiv').src="/forum/resource/icons/" + obj + ".jpg";
}
   
function addEmo(obj){
var tcache = document.formForum.fPost.value;
document.formForum.fPost.value = tcache + " ["+ obj + "] ";
document.formForum.fPost.focus();
}

function reviewMe(){
alert("am reviewing");
}

function postMe(){
if (getCookie('interact')) {

var iChars = "@<>";

for (var i = 0; i < document.formForum.fSubject.value.length; i++) {
  	if (iChars.indexOf(document.formForum.fSubject.value.charAt(i)) != -1) 
  	{
openAlert('Alert','Subject contains invalid characters: @ < >');
return;
}
}
for (var i = 0; i < document.formForum.fPost.value.length; i++) {
  	if (iChars.indexOf(document.formForum.fPost.value.charAt(i)) != -1) 
  	{
openAlert('Alert','Post contains invalid characters: @ < >');
return;
}
}

var thisLot;
thisLot = "fSubject=" + encodeURIComponent(document.formForum.fSubject.value);
thisLot = thisLot + "&fForum=" + encodeURIComponent(document.formForum.fForum.value);
thisLot = thisLot + "&fPost=" + encodeURIComponent(document.formForum.fPost.value);

if(document.formForum.fReplyTo){
thisLot = thisLot + "&fReplyTo=" + encodeURIComponent(document.formForum.fReplyTo.value);
}
else{
thisLot = thisLot + "&fReplyTo=0";
}

if(document.formForum.fIcon){
thisLot = thisLot + "&fIcon=" + encodeURIComponent(document.formForum.fIcon.value);
}
else{
thisLot = thisLot + "&fIcon=star";
}

if(document.formForum.fSubject.value==""){
openAlert('Subject','The subject field cannot be blank');
return;
}

if(document.formForum.fPost.value==""){
openAlert('Post','The post field cannot be blank');
return;
}

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
//alert(thisLot);
var url="/forum/resource/working/postTopicDo.asp";
//document.location.href=url+"?"+thisLot; 
thisForum=document.formForum.fForum.value;
xmlHttp.onreadystatechange = forumChanged2;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
} else {
openAlert('Information','To post new topics or reply to existing topics, you must be a registered member of Interact. If you are not a registered member, please look at the how to join page for full information.<br><br>If you are already registered and have activated your account, please log-in using [ log-in ] from the menu at the top of this page. If you are both a registered user with an activated account and are logged in, please enable your computer to accept cookies. Each time you log-in, we place a cookie on your computer that expires within 24 hours or if you log-out');
}

}

function setQuote(obj){
thisLot = "id="+obj;

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
//alert(thisLot);
var url="/forum/resource/working/getQuoteDo.asp";
//document.location.href=url+"?"+thisLot; 
xmlHttp.onreadystatechange = quoteChanged;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);

}

function setEdit(obj){
thisLot = "id="+obj;
thisID=obj;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
//alert(thisLot);
var url="/forum/resource/working/getEditDo.asp";
//document.location.href=url+"?"+thisLot; 
xmlHttp.onreadystatechange = editChanged;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);

}

function setEdit2(){
thisLot = "id="+thisID;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
//alert(thisLot);
var url="/forum/resource/working/getEditDo2.asp";
//document.location.href=url+"?"+thisLot; 
xmlHttp.onreadystatechange = editChanged2;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);

}

function editMe(){
if (getCookie('interact')) {

var iChars = "@<>";

for (var i = 0; i < document.formForum.fSubject.value.length; i++) {
  	if (iChars.indexOf(document.formForum.fSubject.value.charAt(i)) != -1) 
  	{
openAlert('Alert','Subject contains invalid characters: @ < >');
return;
}
}
for (var i = 0; i < document.formForum.fPost.value.length; i++) {
  	if (iChars.indexOf(document.formForum.fPost.value.charAt(i)) != -1) 
  	{
openAlert('Alert','Post contains invalid characters: @ < >');
return;
}
}

if(document.formForum.fSubject.value==""){
openAlert('Subject','The subject field cannot be blank');
return;
}

if(document.formForum.fPost.value==""){
openAlert('Post','The post field cannot be blank');
return;
}

thisLot = "id="+thisID;
thisLot = thisLot + "&fSubject=" + encodeURIComponent(document.formForum.fSubject.value);
thisLot = thisLot + "&fForum=" + encodeURIComponent(document.formForum.fForum.value);
thisLot = thisLot + "&fPost=" + encodeURIComponent(document.formForum.fPost.value);

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!");
  return;
  } 
//alert(thisLot);
var url="/forum/resource/working/postEditDo.asp";
//document.location.href=url+"?"+thisLot; 
thisForum=document.formForum.fForum.value;
xmlHttp.onreadystatechange = forumChanged2;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
} else {
openAlert('Information','To post new topics or reply to existing topics, you must be a registered member of Interact. If you are not a registered member, please look at the how to join page for full information.<br><br>If you are already registered and have activated your account, please log-in using [ log-in ] from the menu at the top of this page. <br><br>If you are both a registered user with an activated account and are logged in, please enable your computer to accept cookies. <br><br>Each time you log-in, we place a cookie on your computer that expires within 24 hours or if you log-out');
}
}

function setButton(obj){
if(document.getElementById("newtopic").style.display=='none'){
openDiv('newtopic');
}else{
//
}
document.formForum.fSubject.value="";
document.formForum.fPost.value="";
document.getElementById("popText").innerHTML=obj;
document.getElementById("updateButton").href="javascript:postMe();";
document.getElementById("updateButtonText").innerHTML="Post Now";
}

function setButton2(obj){
if(document.getElementById("newtopic").style.display=='none'){
openDiv('newtopic');
}else{
//
}
if(obj=="Edit"){
document.getElementById("updateButton").href="javascript:editMe();";
document.getElementById("updateButtonText").innerHTML="Update Now";
//document.getElementById("fSubject").disabled;
}else{
document.getElementById("updateButton").href="javascript:postMe();";
document.getElementById("updateButtonText").innerHTML="Post Now";
}
document.getElementById("popText").innerHTML=obj;
}


function viewForumProfile(obj){
if(getCookie('interact'))
{
document.getElementById('divThis2').style.display='';
document.getElementById('apDiv12').style.display='';
document.body.scroll="no";
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/community/resource/working/forumProfile.asp";
url=url+"?id="+obj + "&$=" +new Date().getTime();
//document.location.href=url;
xmlHttp.onreadystatechange=displayAlert2;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} else {
openAlert('Member Profiles','To view a member profile, you must be a registered member of Interact. If you are not a registered member, please look at the how to join page for full information.<br><br>If you are already registered and have activated your account, please log-in using [ log-in ] from the menu at the top of this page. <br><br>If you are both a registered user with an activated account and are logged in, please enable your computer to accept cookies. <br><br>Each time you log-in, we place a cookie on your computer that expires within 24 hours or if you log-out');
}
}



function sendForumMessage(obj){
if(getCookie('interact'))
{
document.getElementById('divThis2').style.display='';
document.getElementById('apDiv12').style.display='';
document.body.scroll="no";
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/community/resource/working/forumMessage.asp";
url=url+"?id="+obj + "&$=" +new Date().getTime();
//document.location.href=url;
xmlHttp.onreadystatechange=displayAlert2;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} else {
openAlert('Send a Message','To send a message from the forum, you must be a registered member of Interact. If you are not a registered member, please look at the how to join page for full information.<br><br>If you are already registered and have activated your account, please log-in using [ log-in ] from the menu at the top of this page. <br><br>If you are both a registered user with an activated account and are logged in, please enable your computer to accept cookies. <br><br>Each time you log-in, we place a cookie on your computer that expires within 24 hours or if you log-out');
}
}

function sendTeacherMessage(obj){
if(getCookie('interact'))
{
document.getElementById('divThis2').style.display='';
document.getElementById('apDiv12').style.display='';
document.body.scroll="no";
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/community/resource/working/forumMessage2.asp";
url=url+"?id="+obj + "&$=" +new Date().getTime();
//document.location.href=url;
xmlHttp.onreadystatechange=displayAlert2;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} else {
openAlert('Send a Message','To send a message from the forum, you must be a registered member of Interact. If you are not a registered member, please look at the how to join page for full information.<br><br>If you are already registered and have activated your account, please log-in using [ log-in ] from the menu at the top of this page. <br><br>If you are both a registered user with an activated account and are logged in, please enable your computer to accept cookies. <br><br>Each time you log-in, we place a cookie on your computer that expires within 24 hours or if you log-out');
}
}

function displayAlert2(){ 
document.getElementById("newsHere2").innerHTML="<br/><br/><br/><br/><center><img src=/forum/resource/graphics/loader.gif></center>";
if (xmlHttp.readyState==4)
{ 
document.getElementById("newsHere2").innerHTML=xmlHttp.responseText;
//resetAll();
}
else {
document.getElementById("newsHere2").innerHTML="<br/><br/><br/><br/><center><img src=/forum/resource/graphics/loader.gif></center>";
}
}

function closeAlert2(){
document.getElementById('divThis2').style.display='none';
document.getElementById('apDiv12').style.display='none';
document.body.scroll="yes";
}

function previewMe(){
if(getCookie('interact'))
{
var thisLot = "fSubject=" + encodeURIComponent(document.formForum.fSubject.value);
thisLot = thisLot + "&fPost=" + encodeURIComponent(document.formForum.fPost.value);
document.getElementById('divThis2').style.display='';
document.getElementById('apDiv12').style.display='';
document.body.scroll="no";
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/forum/resource/working/previewMessage.asp";
//url=url+"?id="+obj + "&$=" +new Date().getTime();
//document.location.href=url;
xmlHttp.onreadystatechange=displayAlert2;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", thisLot.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(thisLot);
} else {
openAlert('Send a Message','To send a message from the forum, you must be a registered member of Interact. If you are not a registered member, please look at the how to join page for full information.<br><br>If you are already registered and have activated your account, please log-in using [ log-in ] from the menu at the top of this page. <br><br>If you are both a registered user with an activated account and are logged in, please enable your computer to accept cookies. <br><br>Each time you log-in, we place a cookie on your computer that expires within 24 hours or if you log-out');
}
}

function whySmile(){
openAlert('Adding Smilies','You can add smilies throughout your post simply by clicking on any below the post box.<br><br>Because we do not allow HTML code within our forum, you will see the name of the smiley surround by square brackets. When your post is viewed, the correct smiley appears within the message.<br><br>You can manually add smilies at any time by using the brackets and correct name within your post txt.');
}

function whyIcon(){
openAlert('Topic Icons','You can add a topic icon to your post to represent the subject content.<br><br>Simply click on the icon you wish to use and you will see it appear in the highlighted box.<br><br>When your topic is shown in the forum, the icon you chose will appear alongside.');
}


function reportPost(obj){
if (confirm('\n\nYou are about to report this post and member for alleged breach of Terms and Conditions or abuse\n\nTo continue, click [OK]')) {
var url="/forum/resource/working/postAbuse.asp?id=" + obj;
document.location.href=url;
return;
}else{
alert("You have chosen not to report this post at this time");
}
}
