

   function confirmBox( html_template )
   {

      this.html_template = html_template;
      this.callback_method;



      this.construct = function()
		{
			if (document.getElementById)
			{
				var _this = this;
				// window.confirm = function( txt, callback )
				window.custom_confirm = function( txt, callback )
				{
	            _this.callback_method = callback;
					_this.createCustomConfirm( txt );
				}
			}
		}



      this.createCustomConfirm = function( txt )
		{
		   if ( $('confirmModalContainer')[0] )
		   {
		      return false;
		   }

         var confirm_tpl = $.template( this.html_template );
         $('body').append( confirm_tpl , {
            'confirm_label': custom_confirm_labels.title
         ,  'confirm_message': txt
         });

         // Make sure its as tall as it needs to be to overlay all the content on the page
		   $('#confirmModalContainer')[0].style.height = document.documentElement.scrollHeight + "px";

         // Center the confirm box
			var confirmObj = $('#confirmModalContainer .alert_box')[0];
         confirmObj.style.left = (document.documentElement.scrollWidth - confirmObj.offsetWidth)/2 + "px";

		   // MSIE doesnt treat position:fixed correctly, so this compensates for positioning the confirm
		   if (typeof document.body.style.maxHeight == "undefined") {
		      confirmObj.style.top = document.documentElement.scrollTop + "px"
		   }

         var _this = this;
			$(document).keydown(function(event){
			  _this.keyDown( event );
			});
		}



      this.keyDown = function( event )
		{
			if (  typeof event != 'undefined' && event
				&& (   event.keyCode == 13 || event.keyCode == 27 // ENTER + ESCAPE
					)
				)
		   {
            $(document).unbind('keydown', function(event){
               _this.keyDown( event );
            });
            if ( $('#confirmModalContainer .alert_cancel_btn')[0] )
				{
               $('#confirmModalContainer .alert_cancel_btn')[0].focus();
				}
            this.removeCustomConfirm();
				event.stopPropagation();
			}
			return false;
		}



		this.removeCustomConfirm = function()
		{
		   $('#confirmModalContainer').remove();
			return true;
		}



      this.callCallback = function()
      {
         // this.callback_method();
			eval( this.callback_method );
			this.removeCustomConfirm();
         return true;
      }



      this.construct();
   }

