function hideDiv(obje) {
document.getElementById(obje).style.display = "none";
}

function showDiv(obje) {
document.getElementById(obje).style.display = "block";
}


//AJAXFUNCTIONS

var nextDiv = '';
var lastMain = '?ajax';

function AjaxGET(Target,Div){
if (nextDiv==''){
nextDiv=Div;



Target=Target+"&ajax";

if (Div=="maincontent"){
lastMain = Target;
}

 var xmlHttp=null;
 try {
    xmlHttp = new XMLHttpRequest();
 } catch (e) {
    try {
       xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
 }
 xmlHttp.onreadystatechange = function() {

    if (xmlHttp.readyState == 4)
       try {

          if (xmlHttp.status == 200) {
				reci = xmlHttp.responseText;

				var i = reci.indexOf('!ax');

				if (i>-1){
				reci = reci.substr(i+3);
				}


				if (nextDiv=="comments_inner"){ CheckCommentOuter(reci.substr(0,100)); }
				document.getElementById(nextDiv).innerHTML = reci;

				if (nextDiv=="login_div"){ 
							nextDiv = '';
					if(reci.indexOf('!!lastpage!!')>1){ 
						AjaxFetchLast();
					}

				}

				nextDiv = '';
				


                
      }
       } catch (e) {
	   //alert ('Error: ' + e.description);
       }
 
 }
                

 xmlHttp.open("GET",Target); 
 xmlHttp.send(null); 
}
}



function AjaxPOST(Target,POSTTarget,Div){

if (nextDiv==''){


Target=Target+"&ajax";

if (Div=="maincontent"){
lastMain = Target;
}

nextDiv=Div;
 var xmlHttpPOST=null;
 try {
    xmlHttpPOST = new XMLHttpRequest();
 } catch (e) {
    try {
       xmlHttpPOST=new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
       xmlHttpPOST=new ActiveXObject("Microsoft.XMLHTTP");
    }
 }
 xmlHttpPOST.onreadystatechange = function() {

    if (xmlHttpPOST.readyState == 4)
       try {

          if (xmlHttpPOST.status == 200) {
		reci = xmlHttpPOST.responseText;


				var i = reci.indexOf('!ax');
				
				if (i>-1){
				reci = reci.substr(i+3);
				}

		if (nextDiv=="comments_inner"){ CheckCommentOuter(reci.substr(0,100)); }

		document.getElementById(nextDiv).innerHTML = reci;   

				if (nextDiv=="login_div"){ 
							nextDiv = '';
					if(reci.indexOf('!!lastpage!!')>1){ 
						AjaxFetchLast();
					}

				}

		nextDiv = '';






      }
       } catch (e) {
	   alert ('Error: ' + e.description);
       }
 
 }

                
xmlHttpPOST.open("POST",Target);

xmlHttpPOST.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttpPOST.setRequestHeader("Content-length", POSTTarget.length);
xmlHttpPOST.setRequestHeader("Connection", "close");

xmlHttpPOST.send(POSTTarget);

}
}

function CheckCommentOuter(txt){
if (txt.indexOf('!settoouter!')>1){
nextDiv = "comments_outer";
}
}

function AjaxFetchLast(){

 var xmlMainHttp=null;
 try {
    xmlMainHttp = new XMLHttpRequest();
 } catch (e) {
    try {
       xmlMainHttp=new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
       xmlMainHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
 }
xmlMainHttp.onreadystatechange = function() {

    if (xmlMainHttp.readyState == 4)
       try {

          if (xmlMainHttp.status == 200) {
				reci = xmlMainHttp.responseText;


				var i = reci.indexOf('!ax');
				
				if (i>0){
				reci = reci.substr(i+3);
				}

				document.getElementById('maincontent').innerHTML = reci;
				
                
      }
       } catch (e) {
	   //alert ('Error: ' + e.description);
       }
 
 }
                

xmlMainHttp.open("GET",lastMain); 
xmlMainHttp.send(null); 

}

function FP(input){
input = input.replace(/\+/g,'%2B');
return input.replace(/&/g,'%26');
}

function LoadComments(url,httppost,optdiv){

if (optdiv!=""){ 
var aDiv = optdiv;
}else{
var aDiv = 'comments_inner'; 
}
var rand_no = Math.ceil(100*Math.random());
url = '?forum&postcomment' + url + '&rnd=' + rand_no;

AjaxPOST(url,httppost,aDiv);
}
