// js handling the login procedures

// constants
var NORMAL_STATE = 4;
var REQUEST_PREFIX = './getposts.php?';
var REQUEST_PREFIX2 = './db_functions.php?';

// variables
var http = getHTTPObject(); // We create the HTTP Object
//var results = '';
var blogRollEle;


function RequestContent(query)
{
	//send request to web server to get content results ...
    http.open('POST', REQUEST_PREFIX + query + "&", true);
	// where to go
	http.onreadystatechange = handleLoading;
	http.send(null);
	
	
	
}

function RequestBlogrolls()
{
	http.open('POST', REQUEST_PREFIX2 + "&func=randblogrolls", true);
	// where to go
	http.onreadystatechange = handleLoading2;
	http.send(null);
	
}

function handleLoading2()
{
	// did the connection work?
	if (http.readyState == NORMAL_STATE) 
	{
		// split by the pipe
		results = http.responseText;
		
		//eval(results);
		
		preload = document.getElementById('blogrolls');
	
		if(preload)
		{
			//document.getElementsByTagName('center')[0].removeChild(preload);
			preload.innerHTML = results;
		}


		//ShowContent();
	}
}

function handleLoading()
{
	// did the connection work?
	if (http.readyState == NORMAL_STATE) 
	{
		// split by the pipe
		results = http.responseText;
		
		//eval(results);
		
		preload = document.getElementById('content');
	
		if(preload)
		{
			//document.getElementsByTagName('center')[0].removeChild(preload);
			preload.innerHTML = results;
		}
		
		
		if(!blogRollEle)
		{
			blogRollEle = document.getElementById('blogrollheader');
			LoadingBlogrolls();
			addEvent(blogRollEle, 'click', LoadingBlogrolls);
		}

		//ShowContent();
	}
}

