/**
 * This is the SDMS entry point.
 * 
 * @author Reece Garrett
 * @date 7. May 2008
 * 
 * Ext JS Library 2.1 Copyright(c) 2006-2008, Ext JS, LLC. licensing@extjs.com
 * Ext JS Library 2.1 Copyright(c) 2006-2008, Ext JS, LLC. licensing@extjs.com
 * 
 * http://extjs.com/license
 */

//Ext.Ajax.disableCaching = false;
//Ext.BLANK_IMAGE_URL = 'http://oz.co.pierce.wa.us/ExtJS/2.2/resources/images/default/s.gif';
//Ext.QuickTips.init();

// turn on validation errors beside the field globally
Ext.form.Field.prototype.msgTarget = 'qtip';

/**
 * During the construction of SDMSApp Ext.onReady is called which in turn
 * initialized the entire application.
 */
//SDMSApp = new Ext.app.App({
//	init : function() {
		// Set up custom validators for SDMS
		Ext.apply(Ext.form.VTypes, {
			// Email: This is an override of the existing extJs Vtype.
			'emailRE' : /(^[a-z]{1}([a-z0-9]){1,6}$|^[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,4}$)/,
			'email' : function(v) {
				return this.emailRE.test(v);
			},
			// Bargain Unit
			'bargainUnitMask': /[0-9a-zA-Z]/,
			'bargainUnitRE'	 : /[0-9a-zA-Z]/,
			'bargainUnitText': "This field is up to two characters and contains letters and numbers.",
			'bargainUnit'	 : function(v) {
				return this.bargainUnitRE.test(v);
			},
			// Job Class
			'jobClassMask': /[0-9]/, // 999999
			'jobClassRE'	 : /[0-9]/, // 999999999
			'jobClassText': "This field is up to six characters and contains numbers only.",
			'jobClass'	 : function(v) {
				return this.jobClassRE.test(v);
			},
						// Names
			'namesMask' : /[a-z_\-'\s]/i,     // allow letters, '_', '-' ,singlequote and space  
			'nameRE' : /^[a-zA-Z_\-'\s]+$/,  
			'namesText' : "This field should only contain letters, \_ ,-,spaces and '",
			'names' : function(v) {
				return this.nameRE.test(v);
			},			

			// Social security number
			'ssnMask' : /[0-9]/i,
			'ssnRE' : /^[\d]{9}$/, // 999999999
			'ssn' : function(v) {
				return this.ssnRE.test(v);
			},
			'ssnText' : 'This field should be a SSN in the format "999999999"',

			// Phone number
			'phoneRE' : /^(([\d]{10,15})|((\d{3}-\d{3}-\d{4})(\s?(x\d{1,5}))?))$/,
			//'phoneRE' : /^(([\d]{10,15})|((\d{3}-\d{3}-\d{4})\s?(x\d{1,5}|DC\d{1,5})?))$/,		
			'phone' : function(v) {
				return this.phoneRE.test(v);
			},
			'phoneMask' : /[\s\d-xDC]/,
			'phoneText' : 'This phone number should be all numbers or with dashes and x',
			
			// Zip code
			//'zipcodeRE' : /^\d{5}$/,  //99999 
			'zipcodeRE' : /^(([\d]{5})|([\d]{9})|([\d]{5}-[\d]{4}))$/,  //99999 or 99999-9999		
			'zipcode' : function(v) { 					
				return this.zipcodeRE.test(v);
			},	
			'zipcodeMask' : /[\d-]/,
			'zipcodeText' : 'Not a valid zipcode. Must be in the format of 99999 or 99999-9999',	
			
			//City       
			'cityRE' :/^[A-Z]{1}[a-zA-Z-]+\s?([A-Z]{1}[a-zA-Z]+)?$/,  //1st letter Cap, allow hypen, optional 2nd word with Cap		
			'city' : function(v) { 					
				return this.cityRE.test(v);
			},	
			//'cityMask' : /[-]/,
			'cityText' : 'Not a valid city. Must be mixed case, hypen is allowed.'	
		});
//	}
	//,

	/**
	 * Implementation of template method that returns all the modules used for
	 * the SDMS app. The benefit of encapsulating the modules in this manner is
	 * that one can restrict modules based on some criteria (perhaps security)
	 * just by manipulating this method. See ./App.js for more info.
	 * 
	 * @return {Array of Ext.app.Module}
	 */
//	getModules : function() {
//		// restrict modules based on some criteria (security) in this method
//		return [new SDMS.PersonnelEntry, new SDMS.PersonnelSearch,
//				new SDMS.PersonnelManager]
//	}
//});

