var root_map;

function root(root) {
	root_map = root;
	
	$('#user, #pass').bind('keypress', function(e) {
        if(e.keyCode==13){
               login();
        }
	});
	
	$("#login").click(function() {
		login();
	});
}

function login() {
	$("#login").hide();
	$("#logLader").show();
	
	$.ajax({
		type: "POST",
		url: root_map + "ajax/inlog.php",
		data: "username=" + $("#user").val() + "&password=" + $("#pass").val(),
		success: function(response){
			if(response == "error 1") {
				alert("wachtwoord incorrect");
				$("#login").show();
				$("#logLader").hide();
			} else if(response == "error 2") {
				alert("account bestaat niet");
				$("#login").show();
				$("#logLader").hide();
			} else {
				document.getElementsByName("inlogform")[0].submit();
				//window.location.href = root_map + "index.php";
			}
		}
	});
	
	/*
	//extra
	$.ajax({
		type: "POST",
		url: root_map + "../index.php",
		data: "Submit=Login&lang=dutch&f41df6de68c8d07e2bd53a4e2c815215=1&message=0&op2=login&option=login&username=" + $("#user").val() + "&passwd=" + $("#pass").val(),
		success: function(response2){
			
		}
	});*/
}

function herlaadAccount() {
	$.ajax({
		type: "POST",
		url: root_map + "content/winkelmandje.php",
		data: "root=" + root_map,
		success: function(response){
			$(".account").html(response);	
		}
	});
}