//var linSection = 'main';
var linSection = 1;

function wblur(blurId) {
	blurMe = document.getElementById(blurId);
	blurMe.blur();
}

function resetLinTitles() {
	if ( document.getElementById('mainArea') ) {
		mArea = document.getElementById('mainArea');
		while( mArea.hasChildNodes() ) {
			mArea.removeChild( mArea.lastChild ); 
		}
	}
	else if (	document.getElementById('galArea') ) {
		mArea = document.getElementById('galArea');
		while( mArea.hasChildNodes() ) {
			mArea.removeChild( mArea.lastChild );
		}
	}
/*	else if ( document.getElementById('linuxArea') ) {
		mArea = document.getElementById('linuxArea');
		while( mArea.hasChildNodes() ) {
			mArea.removeChild( mArea.lastChild );
		}
	} */
	if (	document.getElementById('titleArea') ){
		tArea = document.getElementById('titleArea');
		while( tArea.hasChildNodes() ) {
			tArea.removeChild( tArea.lastChild );
		}
	}
	else if (document.getElementById('titleAreaE') ){
		tArea = document.getElementById('titleAreaE');
		while( tArea.hasChildNodes() ) {
			tArea.removeChild( tArea.lastChild );
		}
	}
/*	else if ( document.getElementById('linuxTitle') ){
		tArea = document.getElementById('linuxTitle');
		while( tArea.hasChildNodes() ) {
			tArea.removeChild( tArea.lastChild );
		}
	} */
	if ( document.getElementById('bottomArea') ) {
		bArea = document.getElementById('bottomArea');
	}
/*	else if ( document.getElementById('bottomAreaE') ) {
		bArea = document.getElementById('bottomAreaE');
	} */
}

function viewLinux() {
	wblur('linux');
	var homeID = document.getElementById('home');
	var picsID = document.getElementById('pics');
	var linuxID = document.getElementById('linux');
	var projectsID = document.getElementById('projects');
	try {
		resetLinTitles();
		mArea.id = 'mainArea';
		tArea.id = 'titleArea';
		//bArea.id = 'bottomArea';
		bArea.className = 'container';
		homeID.className = '';
		picsID.className = '';
		linuxID.className = 'selected';
		projectsID.className = '';
	}
	catch (e)
	{ }
	
	l0 = '';
	linsqllength = '';
	linHasSql = false;
	
	addMainEmpty = document.createElement('div');
	addMainEmpty.id = 'main'
	
	mArea.appendChild(addMainEmpty);
	linConstruct(linSection);
	//linstr = '?task=showlin&tid=' + linSection;
	//sqlQuery('wlib-js/sqlquery3.php', linstr, handleLinux, 'GET', 'linux');
	
	//linTitleConstruct();
	lin2str = '?task=showlin';
	sqlQuery('wlib-js/sqlquery3.php', lin2str, handleLinTitles, 'GET', 'linuxNav');
}

function viewHome() {
	wblur('home');
	var homeID = document.getElementById('home');
	var picsID = document.getElementById('pics');
	var linuxID = document.getElementById('linux');
	var projectsID = document.getElementById('projects');
	try {
		resetLinTitles();
		tArea.id = 'titleArea';
		mArea.id = 'mainArea';
		//bArea.id = 'bottomArea';
		bArea.className = 'container';
		homeID.className = 'selected';
		picsID.className = '';
		linuxID.className = '';
		projectsID.className = '';
	}
	catch (e)
	{ }

	numPost = 5;
	numPage = 0;
	numPost2 = 5;
	
	mEmpty = document.createElement('div');
	mEmpty.id = 'mainEmpty';
	mArea.appendChild(mEmpty);
	//mainSql();
	poststr = '?task=showpost';
	sqlQuery('wlib-js/sqlquery3.php', poststr, mainHttpGetSql, 'GET', 'main');
	
	tEmpty = document.createElement('div');
	tEmpty.id = 'titleEmpty';
	tArea.appendChild(tEmpty);
	//titleSql();
	p1 = numPage + 1;
	titlestr = '?task=showpost&p=' + p1;
	sqlQuery('wlib-js/sqlquery3.php', titlestr, titleHttpGetSql, 'GET', 'title');
}

function showGal() {
	wblur('pics');
	var homeID = document.getElementById('home');
	var picsID = document.getElementById('pics');
	var linuxID = document.getElementById('linux');
	var projectsID = document.getElementById('projects');
	try {
		resetLinTitles();
		mArea.id = 'galArea';
		tArea.id = 'titleAreaE';
		//bArea.id = 'bottomArea';
		bArea.className = 'containerE';
		homeID.className = '';
		picsID.className = 'selected';
		linuxID.className = '';
		projectsID.className = '';
	}
	catch (e)
	{ }
	
	r0 = '';
	sqllength = '';
	hasSql = false;
	
	addMainEmpty = document.createElement('div');
	addMainEmpty.id = 'galleryList'
	
	mArea.appendChild(addMainEmpty);
	//constructor();
	//galstr = '?task=galleries&numPost=' + galNumPost + '&numPage=' + galNumPage;
	galstr = '?task=galleries';
	sqlQuery('wlib-js/gallery.php', galstr, handleQuery, 'GET', 'gallery');
}

function showGal2(galId) {
	var homeID = document.getElementById('home');
	var picsID = document.getElementById('pics');
	var linuxID = document.getElementById('linux');
	var projectsID = document.getElementById('projects');
	try {
		resetLinTitles();
		mArea.id = 'galArea';
		tArea.id = 'titleAreaE';
		//bArea.id = 'bottomArea';
		bArea.className = 'containerE';
		homeID.className = '';
		picsID.className = 'selected';
		linuxID.className = '';
		projectsID.className = '';
	}
	catch (e)
	{ }
	
	r0 = '';
	sqllength = '';
	hasSql = false;
	
	addMainEmpty = document.createElement('div');
	addMainEmpty.id = 'galleryList'
	
	mArea.appendChild(addMainEmpty);
	constructGal(galId);
}

function viewProj() {
	wblur('projects');
	var homeID = document.getElementById('home');
	var picsID = document.getElementById('pics');
	var linuxID = document.getElementById('linux');
	var projectsID = document.getElementById('projects');
	try {
		resetLinTitles();
		mArea.id = 'mainArea';
		tArea.id = 'titleArea';
		//bArea.id = 'bottomArea';
		bArea.className = 'container';
		homeID.className = '';
		picsID.className = '';
		linuxID.className = '';
		projectsID.className = 'selected';
	}
	catch (e)
	{ }
	
	//r0 = '';
	//sqllength = '';
	//hasSql = false;
	
	addMainEmpty = document.createElement('div');
	addMainEmpty.id = 'mainEmpty'
	addMainE_txt = document.createTextNode('This will be the projects area');
	addMainEmpty.appendChild(addMainE_txt);
	
	mArea.appendChild(addMainEmpty);
	//constructor();
	//galstr = '?task=galleries&numPost=' + galNumPost + '&numPage=' + galNumPage;
	//galstr = '?task=galleries';
	//sqlQuery('wlib-js/gallery.php', galstr, handleQuery, 'GET', 'gallery');
}