
var lpAlert = {
	widthpx: "0",
	Width: function( value )
	{
		if ( !value )
			return widthpx;
		else
			widthpx = value + "px";
	
	},
	heightpx: "100px",
	Height: function( value )
	{
		if ( !value )
			return heightpx;
		else
			heightpx = value + "px";
	},
	borderWidth: "2px",
	Border: function( value )
	{
		if ( !value )
			return borderWidth;
		else
			borderWidth = "2px";
	},
	Show: function(windowTitle, windowText, windowType )
	{
		if( $("#lp_alert_window_bg") )
			$("#lp_alert_window_bg").remove();
		if( $("#lp_alert_window") )
			$("#lp_alert_window").remove();
			
		$("body").append('<div id="lp_alert_window_bg"></div><div id="lp_alert_window"><h3 id="lp_alert_windowTitle" class="alert"></h3><div id="lp_alert_windowContent"></div><div id="lp_alert_windowContent"></div><div id="lp_alert_windowClick"></div></div>');
		
		$("#lp_alert_windowTitle").html( windowTitle );
		$("#lp_alert_windowContent").html( windowText );
		
		if ( this.widthpx != "0" ) $("#lp_alert_window").width(this.widthpx);
		// IE FIX
		$("#lp_alert_windowTitle").width( $("#lp_alert_window").width() );
		$("#lp_alert_windowClick").width( $("#lp_alert_window").width() );
		if( !windowType ) 
			windowType = 1;
		
		switch ( windowType )
		{
			case 1: this.AppendOKButton(); break;
			case 2: this.AppendYESNOButton(); break;
			case 3: AppendInput(); break;
		}
		
		this.Position();
		
		return false;
	},
	
	Position: function()
	{
		var newWidth = $("#lp_alert_window").width();
		var newHeight = $("#lp_alert_window").height();
		
		$("#lp_alert_window").css("margin-left", "-" + parseInt((newWidth / 2), 10) + "px");
		$("#lp_alert_window").css("margin-top", "-" + parseInt((newHeight / 2), 10) + "px");
		
		var nWidth =	newWidth + 22;
		var nHeight = newHeight + 22;
		$("#lp_alert_window_bg").width(nWidth);
		$("#lp_alert_window_bg").height(nHeight);
		$("#lp_alert_window_bg").css("margin-left", "-" + parseInt((nWidth / 2) -1, 10) + "px");
		$("#lp_alert_window_bg").css("margin-top", "-" + parseInt((nHeight / 2) - 1, 10) + "px");
	},
	AppendOKButton: function()
	{
		$("#lp_alert_windowClick").append(this.OKButton);
		$("#lp_alert_okButton").html(this.OKButtonLabel);
		$("#lp_alert_okButton").click( this.OKReturn );
	},
	AppendYESNOButton: function()
	{
		$("#lp_alert_windowClick").append(this.YESButton);
		$("#lp_alert_windowClick").append(this.NOButton);
		eval('$("#lp_alert_yesButton").click(' + this.YESFunction + ');');
		$("#lp_alert_noButton").click( this.OKReturn );
	},
	OKButtonLabel: 'Ok',
	OKButton: '<button id="lp_alert_okButton" class="alert"></button>',
	YESButton: '<button id="lp_alert_yesButton" class="alert">Ja</button>&nbsp;',
	NOButton: '<button id="lp_alert_noButton" class="alert">Nein</button>',
	YESFunction: '',
	OKReturn: function() { lpAlert.MakeReturn(1)	},
	YESReturn: function() { lpAlert.MakeReturn(2) },
	NOReturn: function() { lpAlert.MakeReturn(3) },
	
	MakeReturn: function(response) 
	{
		this.CloseWindow();
	},
	CloseWindow: function()
	{
		$("#lp_alert_window").fadeOut();
		setTimeout("$('#lp_alert_window').remove()", 1000);
		$("#lp_alert_window_bg").fadeOut();
		setTimeout("$('#lp_alert_window_bg').remove()", 1000);
	}
};