/**
 * @author bumz
 */
showErrorMessage = function(errorMessage){
	Ext.MessageBox.show({
		title: langlines.main_error,
		msg: errorMessage,
		buttons: Ext.MessageBox.OK,
		icon: Ext.MessageBox.ERROR
	});        
};

showInfoMessage = function(message){
	Ext.MessageBox.show({
		title: langlines.main_info,
		msg: message,
		buttons: Ext.MessageBox.OK,
		icon: Ext.MessageBox.INFO
	});        
};

showInfoMessageProc = function(message, processFn){
	Ext.MessageBox.show({
		title: langlines.main_info,
		msg: message,
		buttons: Ext.MessageBox.OK,
		'fn': processFn,
		icon: Ext.MessageBox.INFO
	});        
};

showWarningMessage = function(message){
	Ext.MessageBox.show({
		title: langlines.main_warning,
		msg: message,
		buttons: Ext.MessageBox.OK,
		icon: Ext.MessageBox.WARNING
	});        
};

confirmMessage = function(title, message, processFn){
	Ext.Msg.show({
		'title':title,
		'msg': message,
		'buttons': Ext.Msg.YESNOCANCEL,
		'fn': processFn,
		'icon': Ext.MessageBox.QUESTION
	});
};

confirmMessageYN = function(title, message, processFn){
	Ext.Msg.show({
		'title':title,
		'msg': message,
		'buttons': Ext.Msg.YESNO,
		'fn': processFn,
		'icon': Ext.MessageBox.QUESTION
	});
};

showRedirecting = function() {
	Ext.MessageBox.show({
		msg: langlines.main_redirecting,
		progressText: langlines.main_please_wait,
		width: 300,
		wait: true,
		waitConfig: {
			interval: 200
		},
		icon: 'download_icon'
	});
};

enablePreview = function() {
	Ext.select('a.icon_href').on('click', function(event, el){
		if (!Ext.get(el).win) {
			 
			Ext.get(el).win = new Ext.Window({
                layout      : 'fit',
                width       : 800,
                height      : 400,
                closeAction :'hide',
                plain       : true,
                items       : [{
					html: '<iframe border="0" height="330" width="782" src="' + Ext.get(el).dom.href + '"><iframe>'
				}],
				title		: langlines.user_preview,
                buttons: [{
                    text : langlines.main_ok,
					cls  : 'btn_lowercase',
					handler: function(){
						window_el.hide();
					}
				}]
			});
			
		}
		var window_el = Ext.get(el).win;
		Ext.get(el).win.show();
		
		return false;
	}, Ext.select('a.icon_href'), {
		preventDefault: true
	});
};

loadPageWindow = function(selector ,win_title) {
	Ext.select(selector).on('click', function(event, el){
		if (!Ext.get(el).win) {
			 
			Ext.get(el).win = new Ext.Window({
                layout      : 'fit',
                width       : 800,
                height      : 400,
                closeAction :'hide',
                plain       : true,
                items       : [{
					html: '<iframe border="0" height="330" width="782" src="' + Ext.get(el).dom.href + '"><iframe>'
				}],
				title		: win_title,
                buttons: [{
                    text : langlines.main_ok,
					cls  : 'btn_lowercase',
					handler: function(){
						window_el.hide();
					}
				}]
			});
			
		}
		var window_el = Ext.get(el).win;
		Ext.get(el).win.show();
		
		return false;
	}, Ext.select(selector), {
		preventDefault: true
	});
};

showSupportSection = function(section){
	$('#support > .support_show_hide:visible').fadeOut('slow', function(){
		$(this).hide();
		$('#' + section).fadeIn('normal', function(){
			
		});
	});
};

seralizeValues = function(form)
{
	var data = jQuery(form.dom||form).find(':input').serializeArray();
	var returnObject = {};
	
	for (var i in data) {
		if (i == 'remove' || i == 'indexOf') {
			continue;
		}
		returnObject[data[i].name] = data[i].value;
	}
	
	return returnObject;
};

processAjaxResponce = function(data) {
	if (data.status) {
		showInfoMessage(data.message);
	} else {
		showWarningMessage(data.message);
	}
};
