
var home_url = '';
var home_dir = '';


dochref = document.location.href.substr(document.location.href.search('/')+2, 1000);
if(dochref.search('/') == -1){
	$thisurl = document.location.href.substr(0,document.location.href.search('/')+2) + dochref;
} else {
	$thisurl = document.location.href.substr(0,document.location.href.search('/')+2) + dochref.substr(0, dochref.search('/'));
}
$thisurl = $thisurl + '';

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}
}

function myXMLHttpRequest ()
{
  var xmlhttplocal;
  try {
  	xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")}
  catch (e) {
	try {
	xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")}
	catch (E) {
	  xmlhttplocal = false;
	}
  }

  if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
	try {
	  var xmlhttplocal = new XMLHttpRequest ();
	}
	catch (e) {
	  var xmlhttplocal = false;
	}
  }
  return (xmlhttplocal);
}

var mnmxmlhttp = Array ();
var xvotesString = Array ();
var mnmPrevColor = Array ();
var responsestring = Array ();
var myxmlhttp = Array ();
var responseString = new String;


function login(outputid)
{
	username = document.getElementById('login-username').value;
	password = document.getElementById('login-password').value;
	remember = document.getElementById('login-remember').checked;
	return_url = document.getElementById('login-return').value;
	
	if (xmlhttp) {
		url = home_url + "/login.php";
		content = "username=" + username + "&password=" + password + "&remember=" + remember;// + "&return=" + return_url;
		target2 = document.getElementById(outputid);
		target2.innerHTML = "please wait...";
		
		mnmxmlhttp[0] = new myXMLHttpRequest ();
		if (mnmxmlhttp)
		{
			mnmxmlhttp[0].open ("POST", url, true);
			mnmxmlhttp[0].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
	   
			mnmxmlhttp[0].send(content);
			
			mnmxmlhttp[0].onreadystatechange = function ()
			{
				if (mnmxmlhttp[0].readyState == 4)
				{
					result = mnmxmlhttp[0].responseText;
					if (result == "ok")
						document.location.href = return_url;
					else
						target2.innerHTML = result;
				}
			}
		}
	}
}

function SiteStatus(id, status)
{
	if (xmlhttp) {
		url = home_url + "/admin_sites.php";
		content = "action=status&id=" + id + "&status=" + status;
		target2 = document.getElementById("status-"+id);
		target2.innerHTML = "wait...";
		
		mnmxmlhttp[0] = new myXMLHttpRequest ();
		if (mnmxmlhttp)
		{
			mnmxmlhttp[0].open ("POST", url, true);
			mnmxmlhttp[0].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
	   
			mnmxmlhttp[0].send(content);
			
			mnmxmlhttp[0].onreadystatechange = function ()
			{
				if (mnmxmlhttp[0].readyState == 4)
				{
					result = mnmxmlhttp[0].responseText;
					if (result == "ok")
						document.location.href = return_url;
					else
						target2.innerHTML = result;
				}
			}
		}
	}
}

function SiteRemove(id)
{
	//if (confirm('Are you sure you want to remove this site?? ['+id+']'))
	//{
	if (xmlhttp) {
		url = home_url + "/admin_sites.php";
		content = "action=remove&id=" + id;
		target2 = document.getElementById("remove-"+id);
		target2.innerHTML = "wait...";
		
		mnmxmlhttp[0] = new myXMLHttpRequest ();
		if (mnmxmlhttp)
		{
			mnmxmlhttp[0].open ("POST", url, true);
			mnmxmlhttp[0].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
	   
			mnmxmlhttp[0].send(content);
			
			mnmxmlhttp[0].onreadystatechange = function ()
			{
				if (mnmxmlhttp[0].readyState == 4)
				{
					result = mnmxmlhttp[0].responseText;
					if (result == "ok")
						document.location.href = return_url;
					else
						target2.innerHTML = result;
				}
			}
		}
	}
	//}
}

function Report(id, name)
{
	if (xmlhttp) {
		url = home_url + "/report.php";
		content = "id=" + id + "&name=" + name;
		target2 = document.getElementById("report-"+id);
		target2.innerHTML = "wait...";
		
		mnmxmlhttp[0] = new myXMLHttpRequest ();
		if (mnmxmlhttp)
		{
			mnmxmlhttp[0].open ("POST", url, true);
			mnmxmlhttp[0].setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
	   
			mnmxmlhttp[0].send(content);
			
			mnmxmlhttp[0].onreadystatechange = function ()
			{
				if (mnmxmlhttp[0].readyState == 4)
				{
					result = mnmxmlhttp[0].responseText;
					if (result == "ok")
						document.location.href = return_url;
					else
						target2.innerHTML = result;
				}
			}
		}
	}
}
