//this class stands for Messages()
/**
Methods:
	error(message)
	warning(message)
	info(message)
	uploading()
	saving()
	process(title)
	
	---------------------------
	the parameters are optional
*/
Messages=function()
{
	this.fast=500;
	this.medium=1000;
	this.slow=1500;
	this.slower=2000;
	this.crawling=3000;
	this.title="Error";
	this.html="An error occured!";
	this.load_pic="<img src=\"images/front/preloader_volum.gif\" />";
	this.msgContainer="#messageContainer";
	this.titleContainer="#messageTitle";
	this.btn="#closeMessageBtn"
	this.msgIcon="#messageIcon";
	this.popUpId="#message_pu";
	
	/**
	_________________________
	Opens the messages pop up
	*/
	this.open=function()
	{
		$(this.popUpId).center().removeClass("hidden");
		$('.coverage').css('display','block');
		$('body').addClass('coverage_background');
	}
	
	/**
	__________________________
	Closes the messages pop up
	*/
	this.close=function(delay)
	{
		if(delay) 
		{	
			setTimeout("$(\""+this.popUpId+"\").addClass(\"hidden\")",delay);
			setTimeout("$(\""+this.btn+"\").removeClass(\"hidden\")",delay);
			setTimeout("$(\""+this.msgIcon+"\").removeClass(\"hidden\")",delay);
			checkIfDelayPopUpIsOpen();
			setTimeout("$('.coverage').css('display','none')",delay);
			setTimeout("$('body').removeClass('coverage_background')",delay);
		}
		else 
		{
			$(this.popUpId).addClass("hidden");
			$(this.btn).removeClass("hidden");
			$(this.msgIcon).removeClass("hidden");
			checkIfPopUpIsOpen();
			$('.coverage').css('display','none');
			$('body').removeClass('coverage_background');
		}
	}
	
	/**
	____________________
	Pop an error message
	*/
	this.error=function(error)
	{
		$(this.titleContainer).html("Error");
		$(this.btn).removeClass("hidden");
		$(this.msgIcon).removeClass();
		$(this.msgIcon).addClass("message_icon");
		$(this.msgIcon).addClass("error_icon");
		
		if(error)
			$(this.msgContainer).html(error);
		else
			$(this.msgContainer).html(this.html);
		
		this.open();
	}
	
	/**
	_____________________
	Pop a warning message
	*/
	this.warning=function(warning)
	{
		$(this.titleContainer).html("Warning");
		$(this.btn).removeClass("hidden");
		$(this.msgIcon).removeClass();
		$(this.msgIcon).addClass("message_icon");
		$(this.msgIcon).addClass("warning_icon");
		if(warning)
			$(this.msgContainer).html(warning);
		else
			$(this.msgContainer).html(this.html);
		
		this.open();
	}
	
	/**
	__________________________
	Pop an information message
	*/
	this.info=function(info)
	{
		$(this.titleContainer).html("Info");
		$(this.msgIcon).removeClass();
		$(this.msgIcon).addClass("message_icon");
		$(this.msgIcon).addClass("info_icon");
		$(this.btn).removeClass("hidden");
		if(info)
			$(this.msgContainer).html(info);
		else
			$(this.msgContainer).html(this.html);
		
		this.open();
	}
	
	/**
	__________________________
	Pops an uploading notifier
	*/
	this.uploading=function()
	{
		$(this.titleContainer).html("Uploading");
		$(this.btn).addClass("hidden");
		$(this.msgIcon).removeClass();
		$(this.msgIcon).addClass("message_icon");
		$(this.msgIcon).addClass("process_icon");
		$(this.msgContainer).html(this.load_pic);
		
		this.open();
	}
	
	/**
	__________________________
	Pops an uploading notifier
	*/
	this.saving=function()
	{
		$(this.titleContainer).html("Saving");
		$(this.msgIcon).removeClass();
		$(this.msgIcon).addClass("message_icon");
		$(this.msgIcon).addClass("process_icon");
		$(this.btn).addClass("hidden");
		$(this.msgContainer).html(this.load_pic);
		
		this.open();
	}
	
	/**
	________________________________________
	Pops a process notifier set by the coder
	*/
	this.process=function(title)
	{
		$(this.titleContainer).html(title);
		$(this.msgIcon).removeClass();
		$(this.msgIcon).addClass("message_icon");
		$(this.msgIcon).addClass("process_icon");
		$(this.btn).addClass("hidden");
		$(this.msgContainer).html(this.load_pic);
		
		this.open();
	}
	
	/**
	________________________________________
	Pops a confirm notifier set by the coder
	*/
	this.confirm=function(q, callback)
	{
		$(this.titleContainer).html("Confirm..");
		
		$(this.msgIcon).removeClass();
		$(this.msgIcon).addClass("message_icon");
		$(this.btn).addClass("hidden");
		
		var buttons = "<br /><br /><span id='cconfirm_pu_yes' class='default_button' style='margin-right: 15px; width: 35px;'>OK</span><span id='cconfirm_pu_no' class='default_button' style='margin-left: 15px; width: 35px;'>Cancel</span>";
		
		$(this.msgContainer).html(q + buttons);
				
		this.open();
		var self = this;
		$('#cconfirm_pu_yes').click(function(){
		    if( callback ) callback(true);
		    self.close();
		});
		$('#cconfirm_pu_no').click(function(){
		    if( callback ) callback(false);
		    self.close();
		});
	}
}
