//ExtJs custom error message functions
//By Robert Dejesica
function showErrorMessage(str){
	Ext.MessageBox.show ({
		title: "System Error",
		msg: str,
		minWidth: 300,
		buttons: Ext.MessageBox.OK,
		icon: Ext.MessageBox.ERROR		
	})
}

function showWarningMessage(str){
	Ext.MessageBox.show ({
		title: "Warning",	
		msg: str,
		minWidth: 300,
		buttons: Ext.MessageBox.OK,
		icon: Ext.MessageBox.WARNING		
	})
}
function showInfoMessage(str){
	Ext.MessageBox.show ({
		title: "System Say's",
		msg: str,
		minWidth: 300,
		buttons: Ext.MessageBox.OK,
		icon: Ext.MessageBox.INFO		
	})
}

function getStateComboBox (oName) {
	if (typeof(oName) == "undefined") {
		oName = "state";
	}
	var stateCombo = new Ext.form.ComboBox({
		        name: oName,
		        id: oName,
		        editable: false,
				displayField: "state",
				valueField: "state",
				fieldLabel: "State",
				typeAhead: true,
				mode: "local",
				triggerAction: "all",
				emptyText:"Select State",				
				selectOnFocus:true,
				store: new Ext.data.SimpleStore({
					        fields: [
					              {name: "state"}
					        ],
					        data: [					                       
					                ["ACT"],
					                ["NSW"],
					                ["NT"],
					                ["QLD"],
					                ["SA"],
					                ["TAS"],
					                ["VIC"],
					                ["WA"]
					        ]
				        })
		 });
	stateCombo.setValue("ACT");
	return stateCombo;
}

function getCategoryComboBox (oName) {
	
	if (typeof(oName) == "undefined") {
		oName = "category1";
	}
	
	var asicDs = new Ext.data.Store({
			autoLoad: false,
		    proxy: new Ext.data.HttpProxy({
		        url: "index.php?page=common&action=getCategory",
		        method: "GET"		        
		    }),
		    reader: new Ext.data.JsonReader({
		                id: "id"
		                }, [ "id_cat", "name"]
		            ),
		    remoteSort: false
		});
		
		var asicCombo = new Ext.form.ComboBox({
			fieldLabel: 'Category',
			id: oName,
			name: oName,
			hiddenName: 'category',
			store: asicDs,
			valueField: 'id_cat',
			displayField: 'name',
			listWidth: "210",
			resizable: true,
			typeAhead: true,
			mode: 'remote',			
			triggerAction: 'all',
			emptyText: 'Please Select',
			allowBlank: false,
			selectOnFocus: true			
		});		
	asicDs.setDefaultSort("name");
	return asicCombo;

}


function getCategoryComboBoxAdmin (oName) {
	
	if (typeof(oName) == "undefined") {
		oName = "category1";
	}
	
	var asicDs = new Ext.data.Store({
			autoLoad: false,
		    proxy: new Ext.data.HttpProxy({
		        url: "../index.php?page=common&action=getCategory",
		        method: "GET"		        
		    }),
		    reader: new Ext.data.JsonReader({
		                id: "id"
		                }, [ "id_cat", "name"]
		            ),
		    remoteSort: false
		});
		
		var asicCombo = new Ext.form.ComboBox({
			fieldLabel: 'Category',
			id: oName,
			name: oName,
			hiddenName: 'category',
			store: asicDs,
			valueField: 'id_cat',
			displayField: 'name',
			listWidth: "210",
			resizable: true,
			typeAhead: true,
			mode: 'remote',			
			triggerAction: 'all',
			emptyText: 'Please Select',
			allowBlank: false,
			selectOnFocus: true			
		});		
	asicDs.setDefaultSort("name");
	return asicCombo;

}

function getCityComboBox(state) {
	if (typeof(state) == "undefined") {
		state = "ACT";
	}
	var cityDs = new Ext.data.Store({
			autoLoad: false,
		    proxy: new Ext.data.HttpProxy({
		        url: "index.php?page=common&action=getCity&state="+state,
		        method: "GET"		        
		    }),
		    reader: new Ext.data.JsonReader({
		                id: "id"
		                }, [ "post_id", "city"]
		            ),
		    remoteSort: false
		});
		
		var cityCombo = new Ext.form.ComboBox({
			fieldLabel: "City",
			id: "cities",
			name: "cities",
			hiddenName: 'city',
			store: cityDs,
			valueField: 'post_id',
			displayField: 'city',
			listWidth: "210",
			resizable: true,
			triggerAction: 'all',
			emptyText: 'Please Select',			
			allowBlank: false		
		});		
				
	return cityCombo;
}

function getMailStatCombo () {
	
	var mailCombo = new Ext.form.ComboBox({
				id: "mail_status",
		        name: "mail_status",
		        editable: false,
				displayField: "mail_status",
				valueField: "mail_status",
				fieldLabel: "Mail Status",
				typeAhead: true,
				mode: "local",
				triggerAction: "all",
				emptyText:"",
				selectOnFocus:true,
				store: new Ext.data.SimpleStore({
					    fields: [
					          {name: "mail_status"}
					    ],
					    data: [					                       
					            ["Mail Sent"],
					            ["Returned Mail"]					                        
					   ]
				})
		});
		
	return mailCombo;
}