var mainResults;
var titleResults;
var linking = '';
var reloadPost = false;
var numPost = 5;
var numPage = 0;
var numPost2 = 5;

////////////////// FUNCTION INFORMATION //////////////////
//viewHome() is for reloading the homepage, uses mainSql() to get the data <--> viewHome is being moved to www_thoughtbitnav.js
//mainSql() is for the initial page load - loaded from body.onload event - grabs the most recent post
//	mainHttpGetSql() is for parsing the mainSql() results into an array (mainResults[i])
//reViewHome(pId) is the function that starts the loading of a specific post, and uses reloadPostSql to get the data
//	reloadPostSql(pId) is for loading a specific post as linked from titleNav (and soon the calendar)
//		mainReHttpGetSql() is for parsing reloadPostSql() results into an array (mainResults[i])
//reloadPostNum() seems to be an orphaned function...

function mainHttpGetSql() {
	// if there haven't been any errors
	if (sqlHttp['main'].readyState == NORMAL_STATE) {
		mainResults = '';
		// split the days by the divider #!#
		mainResults = sqlHttp['main'].responseText.split('#');
		
		sqllength = mainResults.length - 2;

		hasMainSql = true;
	
		mainConstruct();
	}
}

function reViewHome(pId) {
	refId = 'title' + pId;
	wblur(refId);
	var mainArea = document.getElementById('mainArea');
	try {
		while( mainArea.hasChildNodes() ) {
			mainArea.removeChild( mainArea.lastChild ); 
		}
	}
	catch (e)
	{ }
	
	mainEmpty = document.createElement('div');
	mainEmpty.id = 'mainEmpty';
	mainArea.appendChild(mainEmpty);
	
	poststr = '?task=showpost&tid=' + pId;
	sqlQuery('wlib-js/sqlquery3.php', poststr, mainHttpGetSql, 'GET', 'main');
	//reloadPostSql(pId);
}

function reloadPostNum(newNum,newPage) {

	numPage = newPage;
	numPost = newNum;
	//}
	hasMainSql = false;
	
	//results2 = '';
	mainResults = '';
	//linking.value = '';
//	usernameP.value = ''
	//loginBody = document.getElementById('testB');
	//removeDiv = document.getElementById('testC');
	
	loginBody = document.getElementById('mainArea');
	removeDiv = document.getElementById('main');
	
	addMainEmpty = document.createElement('div');
	addMainEmpty.id = 'mainEmpty';
	
	loginBody.removeChild(removeDiv);
	//loginBody.appendChild(addP);
	loginBody.appendChild(addMainEmpty);
//	alert('hit!');
	//mainSql();
	poststr = '?task=showpost';
	sqlQuery('wlib-js/sqlquery3.php', poststr, mainHttpGetSql, 'GET', 'main');
}
