var com_url = "../../../../members/comRefresher.php";

function com_handleHttpResponse() 
{
	line = document.getElementById('comment_message').innerHTML.split(" - ");
	if (http.readyState == 4) 
	{
		if (http.responseText.indexOf('invalid') == -1) 
		{
      			results = http.responseText.split("|");
      			document.getElementById('comment_message').innerHTML = line[0] + " - " + results[0];
			if (results[1] != undefined && results[1] != "undefined" && results[1] != "")
			{			
				asd(results[1],results[2]);
			}
    		}
  	}
	else
	{
		document.getElementById('comment_message').innerHTML = line[0] +  " - Checking Database...";
	}
}

function comhandleHttpResponse() 
{
	line = document.getElementById('comment_message').innerHTML.split(" - ");
	if (http.readyState == 4) 
	{
		if (http.responseText.indexOf('invalid') == -1) 
		{
      			results = http.responseText.split("|");
      			document.getElementById('comment_message').innerHTML = line[0] + " - " + results[0];
			if (results[1] != undefined && results[1] != "undefined" && results[1] != "")
			{			
				comTimer(results[1]);
			}
    		}
  	}
	else
	{
		document.getElementById('comment_message').innerHTML = line[0] +  " - Checking Database...";
	}
}

function comTimer(page)
{
	setTimeout("comRefresh(" + page + ")",1000);
}

function asd(page)
{
	setTimeout("asdf(" + page + ")",1000);
}

function comRefresh(page)
{
	location.href = "http://www.bleachportal.net/bleach/members/comments2&topic=" + page;
	window.location = "http://www.bleachportal.net/bleach/members/comments2&topic=" + page;
}

function asdf(page,lite)
{
	location.href = "http://www.bleachportal.net/bleach/members/comments_" + page;
	window.location = "http://www.bleachportal.net/bleach/members/comments_" + page;
}

function checkComments(value,news,lite)
{
   	http.open("GET", com_url + '?com=' + value + '&news=' + news + '&lite=' + lite, true);
	http.onreadystatechange = com_handleHttpResponse;
    	http.send(null);
}


function checkCom(value,news)
{
   	http.open("GET", com_url + '?com=' + value + '&news=' + news, true);
	http.onreadystatechange = comhandleHttpResponse;
    	http.send(null);
}

function getHTTPObject() 
{
	var xmlhttp;
	/*@cc_on
  	@if (@_jscript_version >= 5)
    	try 
	{
      		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    	} 
	catch (e) 
	{
      		try 
		{
        			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      		} 
		catch (E) 
		{
        			xmlhttp = false;
      		}
    	}
  	@else
  	xmlhttp = false;
  	@end @*/
  	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
	{
    		try 
		{
      			xmlhttp = new XMLHttpRequest();
    		} 
		catch (e) 
		{
      			xmlhttp = false;
    		}
  	}
  	return xmlhttp;
}

var http = getHTTPObject();