$(document).ready(function()
{
    $("#login_fr").click(function (event){
	
        event.preventDefault(); 
     
    	$.post("includes/php/mod.login.php", $("#login-form").serialize(),
  			  function(data){
                              console.log(data);
                      
				if(data['result']=='ok'){
					if(!data['customer'] || !parseInt(data['customer'])) {
                                                //The user logging in is stored in the db.  Direct them to the railcar map.
						//tb_show('', 'includes/php/modal_change_place_admin_fr.php?height=205&width=400&username='+data['username']+'&password='+data['password'], null);
                                                window.location.href = '/admin/fr/railcartrace.html';
					} else {
                                                //The user logging in is a customer, direct them to the customer dashboard.
						window.location.href = '/admin/fr/dashboard.html';
					}
  			    }
		    	else
		    	{
					document.getElementById('login-form').submit();
		    	} 
  			  },"json");
    });
	
	$("#login_en").click(function (event){
	
        event.preventDefault(); 

    	$.post("includes/php/mod.login.php", $("#login-form").serialize(),
                function(data){
                        if(data['result']=='ok'){
			    	if(!data['customer'] || !parseInt(data['customer'])) {
						//tb_show('', 'includes/php/modal_change_place_admin_en.php?height=205&width=400&username='+data['username']+'&password='+data['password'], null);
						window.location.href = '/admin/en/railcartrace.html';
					} else {
						window.location.href = '/admin/en/dashboard.html';
					}
  			    }
		    	else
		    	{
					document.getElementById('login-form').submit();
		    	} 
  			  },"json");
    });
});
