var index =
{
	headerImageLoaded: false,
	latestNewsLoaded: true,
	
	runFadeIn: function(page)
	{
		page = page || '';
		//alert(page);
		
		loginCheckFunction = function(returnText,elementID)
		{
			var isLoggedIn = returnText;
			if (isLoggedIn == 'true')
			{
				//ajax.sendPostRequest('php/submits/indexSubmit.php','type=editHeaderImage','editHeaderImage');
				ajax.sendPostRequest('php/submits/indexSubmit.php','type=editLatestNews','editLatestNews');
			}
			
			ajax.sendPostRequest('php/submits/indexSubmit.php','type=loginButton','loginButton');
		}
		
		ajax.sendPostRequest('php/submits/indexSubmit.php','type=isLoggedIn','',loginCheckFunction);
		if (page == 'index') ajax.sendPostRequest('php/submits/indexSubmit.php','type=indexHeaderImage','header_image');
		else ajax.sendPostRequest('php/submits/indexSubmit.php','type=headerImage','header_image');
	},
	
	imageOnLoad: function(page)
	{
		page = page || '';
		
		var timerFunction1 = function() {animation.timer.startTimer({elementID:'header_image',effect:'fadeIn'});};
		var timerFunction2 = function() {animation.timer.startTimer({elementID:'column1',effect:'fadeIn'});};
		var timerFunction3 = function() {animation.timer.startTimer({elementID:'column2',effect:'fadeIn'});};
		var timerFunction4 = function() {animation.timer.startTimer({elementID:'column3',effect:'fadeIn'});};
		var timerFunction5 = function() {animation.timer.startTimer({elementID:'footer',effect:'fadeIn'});};
		
		setTimeout(timerFunction1,0);
		setTimeout(timerFunction2,100);
		setTimeout(timerFunction3,200);
		setTimeout(timerFunction4,300);
		setTimeout(timerFunction5,400);
	},
	
	onload: function(page)
	{
		page = page || '';
		var timerFunction2 = function() {animation.timer.startTimer({elementID:'column1',effect:'fadeIn'});};
		var timerFunction3 = function() {animation.timer.startTimer({elementID:'column2',effect:'fadeIn'});};
		var timerFunction4 = function() {animation.timer.startTimer({elementID:'column3',effect:'fadeIn'});};
		var timerFunction5 = function() {animation.timer.startTimer({elementID:'footer',effect:'fadeIn'});};
		
		setTimeout(timerFunction2,100);
		setTimeout(timerFunction3,200);
		setTimeout(timerFunction4,300);
		setTimeout(timerFunction5,400);
			
		loadElementsFunction = function(returnText,elementID)
		{
			document.getElementById(elementID).innerHTML = returnText;
			
			index.startTimer();
		}
		
		loginCheckFunction = function(returnText,elementID)
		{
			var isLoggedIn = returnText;
			if (isLoggedIn == 'true')
			{
				//ajax.sendPostRequest('php/submits/indexSubmit.php','type=editHeaderImage','editHeaderImage');
				ajax.sendPostRequest('php/submits/indexSubmit.php','type=editLatestNews','editLatestNews');
			}
			
			ajax.sendPostRequest('php/submits/indexSubmit.php','type=loginButton','loginButton');
		}
		
		if (page == 'index') ajax.sendPostRequest('php/submits/indexSubmit.php','type=indexHeaderImage','header_image',loadElementsFunction);
		else ajax.sendPostRequest('php/submits/indexSubmit.php','type=headerImage','header_image',loadElementsFunction);
		ajax.sendPostRequest('php/submits/indexSubmit.php','type=isLoggedIn','',loginCheckFunction);
	},
	
	startTimer: function()
	{
		var timerFunction1 = function() {animation.timer.startTimer({elementID:'header_image',effect:'fadeIn'});};
		setTimeout(timerFunction1,0);
	},
	
	logout: function()
	{
		var result = confirm('Are you sure you want to log out?');
		if (result)
		{
			window.location = 'login/logout.php?page=../index.html';
		}
	}
}

//index.runFadeIn('index');

