////////////////// FUNCTION INFORMATION //////////////////
//mainConstruct() handles drawing the main post area - it calls drawMain()
//	drawMain() handles the actual construction of the mainArea div and its content
//	mainFadeIn(i) handles the fade-in effect of the mainArea div

// mainConstruct
// this function contructs the standard page view of posts
function mainConstruct() {
	try {
		if (mainElement != false)
		{
			document.getElementById('mainEmpty').removeChild(mainElement);
		}
	}
	catch (e)
	{ }
		
	if (hasMainSql == true) {
	
	mainBody = document.getElementById('mainArea');
	mainDiv = document.createElement('div');
	mainDiv.id = 'main';
	
	// call the drawMain function
	//
	drawMain();
	//showPageNav();
	//mainFadeIn(0);
	
	mEmpty = document.getElementById('mainEmpty');
	mainBody.removeChild(mEmpty);
	mainBody.appendChild(mainDiv);
	
	mainElement = mainDiv;
	
	}
}

function mainFadeIn(i){
	if (i<6){
		mainDiv.className = 'showMain' + i;
		mainTimerAmt = setTimeout('mainFadeIn(' + (i+1) + ')', 100);			
	}
}

// drawMain
// this function draws the area that users can see posts in
function drawMain() {

	for (var i = 1; i <= sqllength; i = i + 6) {
	//for (var i = 1; i <= 5; i = i + 5) {
		sql = new Array();
		for (var n = 0; n <= 5; n = n + 1) {
			sql[n] = mainResults[i + n];
		}
		
		bH2 = document.createElement('h2');
			bH2S1 = document.createElement('span');
			bH2S1.innerHTML = 'Present';
		bH2.appendChild(bH2S1);
		mainDiv.appendChild(bH2);
		
		bDiv = document.createElement('div');
		bDiv.className = 'postbox';
		bDiv.id = 'body' + sql[0];
		
			bH3 = document.createElement('h3');
			bH3_text = document.createTextNode(sql[3]);
			bH3.appendChild(bH3_text);
		bDiv.appendChild(bH3);		

			bPost = document.createElement('div');
			bPost.className = 'post';
			bPost.innerHTML = sql[4];
		bDiv.appendChild(bPost);
		
			bDate = document.createElement('div');
			bDate.className = 'date';
				bDateS1 = document.createElement('span');
				bDateS1_text = document.createTextNode(' posted by ' + sql[2] + ' on ' + sql[1]);
				bDateS1.appendChild(bDateS1_text);
			bDate.appendChild(bDateS1);
				bDateS2 = document.createElement('span');
				bDateS2.id = 'show' + sql[0];
				bDateS2.className = 'comLink';
				bDateS2.innerHTML = '<a href="javascript:showId(\'' + sql[0] + '\');">comments(' + sql[5] + ')</a>';
			bDate.appendChild(bDateS2);
		bDiv.appendChild(bDate);

		bCom = document.createElement('div');
		bCom.id = 'c' + sql[0];
		bCom.className = 'commentsE';
			//bCom_text = document.createTextNode('no comments');
		//bCom.appendChild(bCom_text);
		
		mainDiv.appendChild(bDiv);
		mainDiv.appendChild(bCom);
/*		sqlBr1 = document.createElement('br');
		mainDiv.appendChild(sqlBr1); */
	}
}