function shopRegisterForm(form,success,response) {
	if(!success) alert("Misslyckades med att registrera användaren!");
	else {
		if(response.responseText.length>0) alert(response.responseText);
		else {
			reloadCart();
			destroyFloater();
		}
	}
}
function shopLoginForm(form,success,response) {
	if(!success) alert("Inloggningen misslyckades p.g.a. ett systemfel!");
	else {
		if(response.responseText.length>0) alert(response.responseText);
		else {
			reloadCart();
			destroyFloater();
		}
	}
}
function shopLogout() {
	new Ajax.Request("/?ma=logout_shop_user",{
		method: "get",
		onComplete: function(response) {
			document.location.href = "/";
		}
	});
}
function initShop() {
	$$("button.shop_logout_button").each(function(o) {
		if(o.id) {
			new Event.observe(o,"click",function(e) {
				new Ajax.Request("?ma=logout_shop_user",{
				 	method: "get",
				 	onComplete: function(response) {
				 		if(response.responseText.length>0) alert(response.responseText);
				 		else reloadCart();
				 	}
				});
			});
		}
	});
}
function shopToggleVat() {
    new Ajax.Request("/?ma=toggle_vat",{
        method: "get",
        onComplete: function(response) {
            document.location.href = document.location;
        }
    });
}

function shopResetPassword(form,success,response) {
	if(response.responseText.length>0) {
		destroyFloater();
		alert(response.responseText);
	} else {
		alert("Allmänt fel! Var god försök igen");
		return false;
	}
}

function shopRegisterUser(form,success,response) {
	if(response.responseText.length>0) {
		alert(response.responseText);
	} else {
		destroyFloater();
		alert("Ditt konto har nu skapats!");
	}
	return false;
}
new Event.observe(window,"load",initShop);
