/* 
	loading
	no buttons
*/
mmDialog.Loading = new Class({	
	Extends: mmDialog
	, options: {
		size: { width: 240, height: 32 }
		, minSize: {width: 240, height: 32}
		, autosize: true
		, focus: true
		, closeable: false
		, classes: {
			msgContainer: 'mmDialogLoadingMessage'
		}
		, template: '<div class="rel ptb-15"><div class="row"><div class="col c1-4 tC lh-30 tM"><img src="/assets/img/ajaxloaders/loading_28.gif" class="tM"/></div><div class="col c3-4 clast lh-30"><div class="rel mmDialogLoadingMessage f-l tL  plr-5 tsb-w"></div></div></div></div>'
		
	}
	, initialize: function(msg, options){
mm.log('INFO INIT OPT:'+options);		
		this.parent(options);
		this.setupDialogElements();
		this.setDefaultContent(msg);
		this.setupDialogEvents();
	}
	, setupDialogElements: function() {
		// this.setFooter(this.buttons);
		this.setFooter(false);
	}
	, setDefaultContent:function(msg) {
		var el = this.options.template.toHTML();
		this.setContent(el);
		this.msgContainer = this.dialogBody.getElement('div.'+this.options.classes.msgContainer);
// mm.log(this.dialogBody);		
		if (msg != '') {
			this.setMessage(msg);
		}
	}	
	, setupDialogEvents:function() {
		if(this.options.focus){
			this.addEvent('show',function(){
				//
			});
		}		
	}
	, setMessage:function(msg) {				
		this.msgContainer.set('html', msg);
		this.reSize();
		this.parseContent();
		return this;
	}
	, parseContent:function() {
		if (mm.objects != undefined) {
			mm.objects.scan(this.dialogBody);
		}
	}	
	, keyDown:function(e, el) {
// mm.log('confirm keyDown el:'+el);		
		if (this.dialogTabIndex.contains(el) && e.key=='tab') {
			e.preventDefault(); 
			if (e.shift) {
				this.setFocusElement.delay(50, this, [el, true]);
			} else {
				this.setFocusElement.delay(50, this, [el, false]);				
			}
			return false;			
		}
		if (this.dialogTabIndex.contains(el) && (e.key =='space' || e.key =='enter' )) {
			e.stop();
			el.addClass('btn-active');
			el.fireEvent('click', e);
			el.removeClass.delay(500, el, 'btn-active');
		}
	}	
	, setFocusElement:function(el, back) {
// mm.log('setNextFocusElement el.id:'+el.get('id'));		
		var curPos = 0;
		var elList = [];
		elList = this.dialogTabIndex;
		curPos = elList.indexOf(el);
		if (back) {
			nextEl = elList[curPos-1] || elList.getLast() || false;			
		} else {
			nextEl = elList[curPos+1] || elList[0] || false;
		}
// mm.log('next el = '+nextEl.get('id'));				
		if (nextEl) { nextEl.focus(); }
	}
		
});

