function addSubmitButtonHoverClass() {
	if(!Browser.Engine.trident) {
		// bei IE schaut der Effekt nicht gut aus..
		$$("input.submit").each(function(item) {
			item.addEvents({
				"mouseenter": function() {
					this.addClass("submit_hover");
				},
				"mouseleave": function() {
					this.removeClass("submit_hover");
				}
			});	
		});
	}	
}

function autoLogin(user,pw,feUserPid,el,successMessage) {
	new Request({
		"url": "/index.php?eID=tx_snidesigner_pi1&cmd=checkLogin&rootPage=1&logintype=login&user="+user+"&pass="+pw+"&pid="+feUserPid+"&permalogin=1",
		"onSuccess": function(respJson) {
	        respJson = JSON.decode(respJson);
			if(respJson.success) {
				$(el).set("text",successMessage);
			}
		}
	}).send();
}

var AutoLogin = new Class({
	Implements: [Events,Options],
	options: {
		user: "",
		password: "",
		feUserPid: 0,
		permalogin: true,
		feUserCatiUid: 0
	},
	onLoginSuccess: function() {},
	onLoginFailure: function() {},
	initialize: function(options) {
		this.setOptions(options);
		if(this.options.permalogin) {
			var permaLogin = "&permalogin=1";
		}
		else {
			var permaLogin = "";
		}
		new Request({
			"url": "/index.php?eID=tx_snidesigner_pi1&cmd=checkLogin&rootPage=1&logintype=login&user="+this.options.user+"&pass="+this.options.password+"&pid="+this.options.feUserPid+permaLogin,
			"onSuccess": function(respJson) {
				respJson = JSON.decode(respJson);
				if(respJson.success) {
					this.fireEvent("onLoginSuccess", [this.options.feUserCatUid]);
				}
				else {
					this.fireEvent("onLoginFailure");
				}
			}.bind(this)
		}).send();
	}
});

