<script type="text/javascript">
	/**
	 * @description : constructor;
	 */

	function MailBoxArchive()
	{
		// call the parent constructor ;
		this.constructor();
		this.sErrorMessage	 = '__select_messages__';
		this.sSurecaption	 = '__are_you_sure__';

		this.sResponceBlock	 = 'mail_archives_box';
		this.sPageParameters = '?ajax_mode=true&contacts_mode=' + sContacts_mode; 
		this.sPageReceiver	 = '__current_page__' + this.sPageParameters ;

		// redefinition `deleteMessages` from the base function; 

		/**
		 * @description : function will move all selected messages into trash ;
		 * @param		: sContainer (string) - contain name of section where jquery will find it ;
		 * @param		: sCallbackFunction (string) - callback function that will return answer from server side;
		 * @return		: Html presentation data ;
		 */

		this.deleteMessages = function(sContainer, sCallbackFunction )
		{
			var sMessagesId = '';
			var iValue		= '';
			var _this = this;
			var bRelocate = false;

			var oCheckBoxes = $("." + sContainer + " input:checkbox:enabled[checked]").each(function(){
				iValue = $(this).attr('value').replace(/[a-z]{1,}/i, '');
				if ( iValue ) 
				{
					sMessagesId += iValue + ',';
					if (  iValue == iMessageId )
						bRelocate = true;
				}	
			});

			if ( sMessagesId )
			{
				if ( confirm(this.sSurecaption) )
				{
					var sPageUrl = this.sPageReceiver + '&messages=' + sMessagesId 
													  + '&callback_function=' + sCallbackFunction
													  + '&messageID=' + iMessageId;
													  + this.ExtendedParameters;

					$('#'+this.sResponceBlock).load(sPageUrl, {'action' : 'delete'}, function(){
						if (bRelocate) {
							_this.relocateInbox();	
						}
					});
				}
			}
			else
				alert(this.sErrorMessage);
		}

		/**
		 * @description : function will get paginated page ;
		 * @param		: iPage (integer) number of needed page ;
		 * @return		: Html presentation data;
		 */

		this.getPaginatePage  = function(iPage)
		{
			var _this = this;
			sPageUrl = '__current_page__?ajax_mode=true&action=archives_paginate&contacts_mode=' 
								+ sContacts_mode + '&contacts_page=' + iPage + '&messageID=' + iMessageId;

			getHtmlData( this.sResponceBlock, sPageUrl,  function(){
			} );
		}
	}

	// create the object;
	MailBoxArchive.prototype = MailBox.prototype;

	// add some function to the object ;

	/**
	 * @description : function will relocate current page ;
	 */

	MailBoxArchive.prototype.relocateInbox = function()
	{
		window.location.href = '__current_page__';
	}

	/**
	 * @description : function will select function name form received data;
	 */

	MailBoxArchive.prototype.selectFunction = function( sValue )
	{
		switch(sValue)
		{
			case 'delete' :
				this.deleteMessages('contacts_container', 'genArchiveMessages');
			break;
			case 'spam' :
				this.spamMessages('contacts_container');
			break;
		}
	}
</script>
<div class="top_settings_block">
	<div class="left_section">
		__select_all__ : <input type="checkbox" onclick="javascript: if ( typeof oMailBoxArchive != 'undefined' ) { (this.checked) ? oMailBoxArchive.selectCheckBoxes(true, 'contacts_container') : oMailBoxArchive.selectCheckBoxes(false, 'contacts_container') }"/>
		&nbsp;
		<select onchange="javascript: if ( typeof oMailBoxArchive != 'undefined' ) { oMailBoxArchive.selectFunction(this.value); } ">
			<option></option>
			<option value="delete">__delete_messages__</option>
			<option value="spam">__spam_messages__</option>
		</select>
	</div>
	<div class="clear_both"></div>
</div>
<div id="mail_archives_box">
	__messages_rows__
</div>