//####################################################################################################################################
//	Alert
//####################################################################################################################################

function Alert()
{
	/*==========================================
		Initialisation
	==========================================*/
	
	var _self = this;
	
	this.box							= document.createElement("div");
	this.box.style.padding				= "10px";
	this.box.style.position				= "absolute";
	this.box.style.backgroundColor		= "#B2D5C4";
	this.box.style.zIndex				= "100001";
	this.box.style.border				= "solid 2px #00743D";
	this.box.style.display				= "none";
	
	this.title							= document.createElement("h2");
	this.title.style.color				= "#00743D";
	this.title.innerHTML				= "Information";
	
	this.text							= document.createElement("p");
	this.text.style.padding				= "0px";
	this.text.style.color				= "#000000";
	this.text.innerHTML					= "Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del...";
	
	this.okButton						= document.createElement("div");
	this.okButton.style.fontWeight		= "bold";
	this.okButton.style.color			= "#00743D";
	this.okButton.style.border			= "solid 2px #00743D";
	this.okButton.style.padding			= "3px";
	this.okButton.style.lineHeight		= "normal";
	this.okButton.style.width			= "100px";
	this.okButton.style.backgroundColor	= "#ffffff";
	this.okButton.style.cursor			= "pointer";
	this.okButton.style.textAlign		= "center";
	this.okButton.innerHTML				= "OK";
	
	this.cancelButton						= document.createElement("div");
	this.cancelButton.style.margin			= (window.ie6) ? "16px 18px 0px 0px" : "16px 38px 0px 0px";
	this.cancelButton.style.styleFloat		= "right";
	this.cancelButton.style.cssFloat		= "right";
	this.cancelButton.style.fontWeight		= "bold";
	this.cancelButton.style.color			= "#00743D";
	this.cancelButton.style.border			= "solid 2px #00743D";
	this.cancelButton.style.padding			= "3px";
	this.cancelButton.style.lineHeight		= "normal";
	this.cancelButton.style.width			= "100px";
	this.cancelButton.style.backgroundColor	= "#ffffff";
	this.cancelButton.style.cursor			= "pointer";
	this.cancelButton.style.textAlign		= "center";
	this.cancelButton.innerHTML				= "Abbrechen";
	
	this.imgPreloader						= document.createElement("img");
	this.imgPreloader.src					= "/pix/main/preloader.gif";
	this.imgPreloader.border				= "0";
	this.imgPreloader.alt					= "";
	this.imgPreloader.style.display			= "block";
	this.imgPreloader.style.margin				= "10px auto 0px auto";
	
	this.frame							= document.createElement("iframe");
	this.frame.style.display			= "none";
	this.frame.style.position			= "absolute";
	this.frame.frameBorder				= "0";
	this.frame.style.margin				= "0px";
	this.frame.style.padding			= "0px";
	this.frame.style.backgroundColor	= "#FFFFFF";
	this.frame.style.zIndex				= "100000";
	$(this.frame).setOpacity(0.7);
	
	this.box.appendChild(this.title);
	this.box.appendChild(this.text);
	this.box.appendChild(this.okButton);
	this.box.appendChild(this.cancelButton);
	this.box.appendChild(this.imgPreloader);
	
	var bodyContainer = ($("bodyContainer")) ? $("bodyContainer") : $(document.getElementsByTagName("BODY")[0]);
	
	bodyContainer.appendChild(this.box);
	bodyContainer.appendChild(this.frame);
	
	/*==========================================
		Methodes
	==========================================*/
	
	/*------------------------------------------
		error
	------------------------------------------*/
	
	this.error = function()
	{
		// Parameter
		// Variante 1 ("Text")
		// Variante 2 ("Titel", "Text")
		
		this.title.innerHTML			= (this.error.arguments.length > 1) ? this.error.arguments[0] : messages['title']['Ungueltige_oder_fehlende_Angaben'];
		this.text.innerHTML				= (this.error.arguments.length > 1) ? this.error.arguments[1] : this.error.arguments[0];
		this.okButton.style.margin		= "16px auto 0px auto";
		this.okButton.style.styleFloat	= "none";
		this.okButton.style.cssFloat	= "none";
		this.okButton.style.display		= "block";
		this.cancelButton.style.display	= "none";
		this.imgPreloader.style.display	= "none";
		this.box.style.width			= "300px";
		this.box.style.textAlign		= "center";
		this.box.style.display			= "block";
		this.box.style.top				= (window.getSize().size.y / 2) - (this.box.offsetHeight/2)+"px";
		this.box.style.left				= (window.getSize().size.x / 2) - (this.box.offsetWidth/2)+"px";
		
		this.setFramePosition();
		
		this.okButton.onclick = function() {
			this.parentNode.style.display = "none";
			_self.frame.style.display = "none";
		}
	}
	
	/*------------------------------------------
		info
	------------------------------------------*/
	
	this.info = function()
	{
		var e							= this.info.arguments[0];
		var show						= this.info.arguments[1];
		this.text.innerHTML				= this.info.arguments[2];
		this.okButton.style.display		= "none";
		this.cancelButton.style.display	= "none";
		this.imgPreloader.style.display	= "none";
		this.box.style.width	 		= "150px";
		
		if(show) {
			if(!e) var e = window.event;
			if(e.pageX || e.pageY) {
				var posx = e.pageX;
				var posy = e.pageY;
			}
			else if(e.clientX || e.clientY) {
				var posy = e.clientY + document.documentElement.scrollTop;
				var posx = e.clientX + document.documentElement.scrollLeft;
			}
			posx -= 185;
			posy -= 10;
			
			this.title.innerHTML = messages['title']['Information'];
			this.box.style.left = posx + "px";
			this.box.style.top = posy + "px";
			this.box.style.textAlign = "left";
			this.box.style.display = "block";
			if(window.ie6) {
				this.frame.style.left = posx + "px";
				this.frame.style.top = posy + "px";
				this.frame.style.width = this.box.offsetWidth;
				this.frame.style.height = this.box.offsetHeight;
				this.frame.style.display = "block";
			}
		}
		else { this.kill(); }
		
		this.okButton.onclick = function() { _self.kill(); }
		
	}
	
	/*------------------------------------------
		approve
	------------------------------------------*/
	
	this.approve = function()
	{
		// Parameter
		// Variante 1 ("Text")
		// Variante 2 ("Titel", "Text")
		
		this.title.innerHTML			= (this.approve.arguments.length > 2) ? this.approve.arguments[0] : messages['title']['Bitte_beachten_Sie'];
		this.text.innerHTML				= (this.approve.arguments.length > 2) ? this.approve.arguments[1] : this.approve.arguments[0];
		this.okButton.style.styleFloat	= "left";
		this.okButton.style.cssFloat 	= "left";
		this.okButton.style.margin		= (window.ie6) ? "16px 0px 0px 18px" : "16px 0px 0px 38px";
		this.okButton.style.display		= "block";
		this.cancelButton.style.display	= "block";
		this.imgPreloader.style.display	= "none";
		this.box.style.width			= "300px";
		this.box.style.textAlign		= "center";
		this.box.style.display			= "block";
		this.box.style.top				= (window.getSize().size.y / 2) - (this.box.offsetHeight/2)+"px";
		this.box.style.left				= (window.getSize().size.x / 2) - (this.box.offsetWidth/2)+"px";
		
		this.setFramePosition();
		
		this.cancelButton.onclick = function() { _self.kill(); }
		this.okButton.onclick = (this.approve.arguments.length > 2) ? this.approve.arguments[2] : this.approve.arguments[1];
	}
	
	/*------------------------------------------
		preloader
	------------------------------------------*/
	
	this.preloader = function()
	{
		// Parameter
		// Variante 1 ("Text")
		// Variante 2 ("Titel", "Text")
		
		this.title.innerHTML			= (this.preloader.arguments.length > 1) ? this.preloader.arguments[0] : messages['title']['Bitte_warten'];
		this.text.innerHTML				= (this.preloader.arguments.length > 1) ? this.preloader.arguments[1] : this.preloader.arguments[0];
		this.okButton.style.display		= "none";
		this.cancelButton.style.display	= "none";
		this.imgPreloader.style.display	= "block";
		this.box.style.width			= "300px";
		this.box.style.textAlign		= "center";
		this.box.style.display			= "block";
		this.box.style.top				= (window.getSize().size.y / 2) - (this.box.offsetHeight/2)+"px";
		this.box.style.left				= (window.getSize().size.x / 2) - (this.box.offsetWidth/2)+"px";
		
		this.setFramePosition();
	}
	
	/*------------------------------------------
		setFramePosition()
	------------------------------------------*/
	
	this.setFramePosition = function()
	{
		this.frame.style.left = "0px";
		this.frame.style.top = "0px";
		this.frame.style.width = window.getSize().size.x + "px";
		this.frame.style.height = window.getSize().size.y + "px";
		this.frame.style.display = "block";
	}
	
	this.kill = function(fromWhere)
	{		
		this.box.style.display = "none";
		this.frame.style.display = "none";
	}
	
}

var message;
window.addEvent("load",function(){ message = new Alert(); });


