$(document).ready(function(){
	
	$('#logForm').submit(function(e) {

		login();
		e.preventDefault();
		
	});
	
});


function login()
{
	hideshow('loading2',1);
	error2(0);
	
	$.ajax({
		type: "POST",
		url: "submit-login.php",
		data: $('#logForm').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);
			}
			
			hideshow('loading2',0);
		}
	});

}


function hideshow(el,act)
{
	if(act) $('#'+el).css('visibility','visible');
	else $('#'+el).css('visibility','hidden');
}

function error2(act,txt)
{
	hideshow('error2',act);
	if(txt) $('#error2').html(txt);
}
