$(document).ready(function(){
						   
	$('#regForm').submit(function(e) {

		register();
		e.preventDefault();
		
	});						   
	
	$('#passForm').submit(function(e) {

		pass();
		e.preventDefault();
		
	});
	
	$('#logForm').submit(function(e) {

		login();
		e.preventDefault();
		
	});
	
	$('#changeForm').submit(function(e) {

		changepass();
		e.preventDefault();
		
	});
	
	
	
});

function register()
{
	hideshow2('loading',1);
	error2(0);
	
	$.ajax({
		type: "POST",
		url: "http://www.toonarmyblog.co.uk/submit.php",
		data: $('#regForm').serialize(),
		dataType: "json",
		success: function(msg){
			
			if(parseInt(msg.status)==1)
			{
				window.location=msg.txt;
			}
			else if(parseInt(msg.status)==0)
			{
				error2(1,msg.txt);
			}
			
			hideshow2('loading',0);
		}
	});

}






function pass()
{
	hideshow('loading2',1);
	error(0);
	
	$.ajax({
		type: "POST",
		url: "http://www.toonarmyblog.co.uk/password.php",
		data: $('#passForm').serialize(),
		dataType: "json",
		success: function(msg){
			
			if(parseInt(msg.status)==1)
			{
				window.location=msg.txt;
			}
			else if(parseInt(msg.status)==0)
			{
				error(1,msg.txt);
			}
			
			hideshow('loading2',0);
		}
	});

}

function login()
{
	hideshow3('loading3',1);
	error3(0);
	
	$.ajax({
		type: "POST",
		url: "http://www.toonarmyblog.co.uk/checklogin.php",
		data: $('#logForm').serialize(),
		dataType: "json",
		success: function(msg){
			
			if(parseInt(msg.status)==1)
			{
				window.location=msg.txt;
			}
			else if(parseInt(msg.status)==0)
			{
				error3(1,msg.txt);
			}
			
			hideshow3('loading3',0);
		}
	});

}

function changepass()
{
	hideshow4('loading4',1);
	error4(0);
	
	$.ajax({
		type: "POST",
		url: "http://www.toonarmyblog.co.uk/changepass.php",
		data: $('#changeForm').serialize(),
		dataType: "json",
		success: function(msg){
			
			if(parseInt(msg.status)==1)
			{
				window.location=msg.txt;
			}
			else if(parseInt(msg.status)==0)
			{
				error4(1,msg.txt);
			}
			
			hideshow4('loading4',0);
		}
	});

}


function hideshow(el,act)
{
	if(act) $('#'+el).css('visibility','visible');
	else $('#'+el).css('visibility','hidden');
}

function hideshow2(el,act)
{
	if(act) $('#'+el).css('visibility','visible');
	else $('#'+el).css('visibility','hidden');
}

function hideshow3(el,act)
{
	if(act) $('#'+el).css('visibility','visible');
	else $('#'+el).css('visibility','hidden');
}

function hideshow4(el,act)
{
	if(act) $('#'+el).css('visibility','visible');
	else $('#'+el).css('visibility','hidden');
}



function error(act,txt)
{
	hideshow('error',act);
	if(txt) $('#error').html(txt);
}

function error2(act,txt)
{
	hideshow2('error2',act);
	if(txt) $('#error2').html(txt);
}

function error3(act,txt)
{
	hideshow3('error3',act);
	if(txt) $('#error3').html(txt);
}

function error4(act,txt)
{
	hideshow4('error4',act);
	if(txt) $('#error4').html(txt);
}


