///////////////////////////////////////////////////////////////////
// ffxi javascript stuff
// author: justin reynard (nitsuj) - framerate@gmail.com
//
// mostly simple utilities for the ffxi linkshell point system
///////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////
// toggleRow - expand a row when clicking on it
///////////////////////////////////////////////////////////////////
function init(flag) {
	if(flag==TRUE)
		document.getElementById("messagebox").style.display='none';
	else
		document.getElementById("messagebox").style.display='yes';
}

///////////////////////////////////////////////////////////////////
// toggleRow - expand a row when clicking on it
///////////////////////////////////////////////////////////////////
function toggleRow(id) {
	request(id);
	if (document.getElementById(id+"_row").className=='message_row')
	{
		document.getElementById(id+"_row").className='message_row_full';
	}
	else 
	{
		document.getElementById(id+"_row").className='message_row';
	}
}

///////////////////////////////////////////////////////////////////
// colorOff() - resets the row to it's default color
///////////////////////////////////////////////////////////////////
function colorOff(id, oldColor) {
	document.getElementById(id+"_row").style.background=oldColor;
}

///////////////////////////////////////////////////////////////////
// colorOn() - highlight a row when mouseover
///////////////////////////////////////////////////////////////////
function colorOn(id) {
	document.getElementById(id+"_row").style.background='#FFFFCC';
}

///////////////////////////////////////////////////////////////////
// getHTTPObject() - logic behind request()
///////////////////////////////////////////////////////////////////
function getHTTPObject()
{
	if (window.ActiveXOBject)
	{
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest)
	{
		return new XMLHttpRequest();
	}
	else
	{
		alert("Your browser does not support advanced Javascript. Please upgrade to firefox 3 or IE7 or greater.");
		return null;
	}
}

///////////////////////////////////////////////////////////////////
// updateDetails() - updates the details row with the XML object
///////////////////////////////////////////////////////////////////
function updateDetails()
{
	alert(httpObject.readyState);
	if (httpObject.readyState == 4)
	{
		alert("I am now set to 4");
		document.getElementById(id+"_extra").innerHTML=httpObject.responseText;
	}
}


///////////////////////////////////////////////////////////////////
// request() - requests data from the server
///////////////////////////////////////////////////////////////////
function request(id) 
{
	httpObject = getHTTPObject();
	//alert("Passing "+id+" to request.php");
	if (httpObject != null)
	{
		httpObject.open("GET", "request.php?id="+id, true);
		httpObject.onreadystatechange = function() {
		if (httpObject.readyState == 4)
		{
			//alert("I am now set to 4");
			document.getElementById(id+"_extra").innerHTML=httpObject.responseText;
		}	
		
		}
		httpObject.send(null);
		
	}
}


///////////////////////////////////////////////////////////////////
// toggleRow - expand a row when clicking on it
///////////////////////////////////////////////////////////////////
function hidemessage() {
	document.getElementById("messagebox").style.display='none';
}
//
var httpObject = null;




