/*
 * Copyright (c) 2007, Harley Davidson Inc. All rights reserved.
 * 
 * This file contains static content (html, css, text) to be used throught the 
 * Harley-Davidson namespace. This content is seperated in order to allow for 
 * easy update of content throughout the namespace.
 * 
 * Note that each namespace/section within HD might have its own content.js 
 * file to allow for encapsulation of functionality within that namespace.
 */

/**
 * Namespace declaration
 * @static
 * @namespace HD
 */
HD.content = {};

/**
 * This is a static class that provides a single place for text to be 
 * accessed and written within the javscript for common text within HD.
 * The reasing for this is to provide easier support for i18n as well as
 * providing a single place where one can adjust text used within the 
 * script.  No js files outside of content.js files in HD should have 
 * hardcoded text that is displayed within the dom.
 *
 * @class Text
 * @static
 * @namespace HD.content
 */
/*
 * NOTE::!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 * MAKE SURE THAT ADDITIONS TO THIS ARE ALPHABETICAL BY TEXT
 */
HD.content.Text = {
	cancel              : 'Cancel',
	char_left_eval		: function(length) { return (length == 1) ? 'character left' : 'characters left'; },
	char_limit_eval		: function(length) { return (length == 1) ? 'character' : 'characters'; },
	clear				: 'Clear',
	close				: 'Close',
	defaultErrorMessage : "There was a problem with your request.<br />Please try again later.", 
	edit_note			: 'Edit Note',
	errorDialogHeader   : 'Error occurred ...',
	limit	            : 'Limit',
	loading             : 'Loading',
	next				: 'next',
	ok                  : 'Ok',
	prev				: 'prev',
	save_note			: 'Save Note',
	title_note			: 'Note',
	states: [
		{name:"Alabama",code:"AL"},
		{name:"Alaska" ,code:"AK"},
		{name:"Arizona",code:"AZ"},
		{name:"Arkansas",code:"AR"},
		{name:"California",code:"CA"},
		{name:"Colorado",code:"CO"},
		{name:"Connecticut",code:"CT"},
		{name:"Delaware",code:"DE"},
		{name:"District Of Columbia",code:"DC"},
		{name:"Florida",code:"FL"},
		{name:"Georgia",code:"GA"},
		{name:"Hawaii",code:"HI"},
		{name:"Idaho",code:"ID"},
		{name:"Illinois",code:"IL"},
		{name:"Indiana",code:"IN"},
		{name:"Iowa",code:"IA"},
		{name:"Kansas",code:"KS"},
		{name:"Kentucky",code:"KY"},
		{name:"Louisiana",code:"LA"},
		{name:"Maine",code:"ME"},
		{name:"Maryland",code:"MD"},
		{name:"Massachusetts",code:"MA"},
		{name:"Michigan",code:"MI"},
		{name:"Minnesota",code:"MN"},
		{name:"Mississippi",code:"MS"},
		{name:"Missouri",code:"MO"},
		{name:"Montana",code:"MT"},
		{name:"Nebraska",code:"NE"},
		{name:"Nevada",code:"NV"},
		{name:"New Hampshire",code:"NH"},
		{name:"New Jersey",code:"NJ"},
		{name:"New Mexico",code:"NM"},
		{name:"New York",code:"NY"},
		{name:"North Carolina",code:"NC"},
		{name:"North Dakota",code:"ND"},
		{name:"Ohio",code:"OH"},
		{name:"Oklahoma",code:"OK"},
		{name:"Oregon",code:"OR"},
		{name:"Pennsylvania",code:"PA"},
		{name:"Puerto Rico",code:"PR"},
		{name:"Rhode Island",code:"RI"},
		{name:"South Carolina",code:"SC"},
		{name:"South Dakota",code:"SD"},
		{name:"Tennessee",code:"TN"},
		{name:"Texas",code:"TX"},
		{name:"Utah",code:"UT"},
		{name:"Vermont",code:"VT"},
		{name:"Virgin Islands",code:"VI"},
		{name:"Virginia",code:"VA"},
		{name:"Washington",code:"WA"},
		{name:"West Virginia",code:"WV"},
		{name:"Wisconsin",code:"WI"},
		{name:"Wyoming",code:"WY"}
	]
};

/**
 * This is a static class that provides a single place for localized date/time
 * strings and configuration settings are stored.
 *
 * @class Date
 * @static
 * @namespace HD.content
 */
HD.content.Date = {
	/**
	 * Initializes the HD.content.Date namespace.
	 */
	init		: function() {
		// Update settings.
		this.FORMAT.CONFIG.SETTINGS.format = this.FORMAT.CONFIG.SETTINGS.format();
		this.FORMAT.CONFIG.SETTINGS.parse = this.FORMAT.CONFIG.SETTINGS.parse();
	},
	
	/**
	 * This object holds the text formatting codes for dates (both numeric and verbose)
	 * as well as a list of text formatting patterns.
	 * 
	 * @property {Object} FORMAT
	 * @constant
	 */
	FORMAT		: {
		CONFIG	: {
			// Default settings for date/time
			SETTINGS	: {
				// The delimiter is used for separating numeric dates
				delimiter		: { mask: '\\/',				string: '/' },
				// The default date format object to use (converts to actual object after init)
				format			: function() { return HD.content.Date.FORMAT.MDY; },
				// The default date format object to use for parsing (converts to actual object after init)
				parse			: function() { return HD.content.Date.FORMAT.MMDDYYYY; }
			},
			// Numeric formatting replaces the string with the numeric value
			NUMERIC		: {
				// 'mm' replaced with number
				month		: { mask: '([01]?[0-9])',		string: 'm' },
				// 'dd' replaced with number
				day			: { mask: '([0-3]?[0-9])',		string: 'd' },
				// 'yyyy' replaced with number
				year		: { mask: '([0-9]{4})',			string: 'y' }
			},
			// Verbose formatting replaces the string with the enumerated string value
			VERBOSE		: {
				// 'M' replaced with month number
				// 'MM' replaced with zero-padded month number
				// 'MMM' replaced with short month name ('Jan')
				// 'MMMM' replaced with long month name ('January')
				month		: { mask: '([0-9a-zA-Z]+?)',	string: 'M' },
				// 'D' replaced with day number
				// 'DD' replaced with zero-padded day number
				day			: { mask: '([0-3]?[0-9])',		string: 'D' },
				// 'W' replaced with 1 character weekday name ('S')
				// 'WW' replaced with short weekday name ('Su')
				// 'WWW' replaced with medium weekday name ('Sun')
				// 'WWWW' replaced with long weekday name ('Sunday')
				weekday		: { mask: '([a-zA-Z]+?)',		string: 'W' },
				// 'Y' replaced with four digit year number
				// 'YY' replaced with two digit year number
				// 'YYYY' replaced with four digit year number
				year		: { mask: '([0-9]{2,4})',		string: 'Y' }
			}
		},
		// HD internal format
		HD		: {
			mask		: function(delimiter) {
							var f = HD.content.Date.FORMAT;
							delimiter = delimiter || '-';
							return new RegExp('^' +
								f.CONFIG.VERBOSE.year.mask +
								delimiter +
								f.CONFIG.VERBOSE.month.mask +
								delimiter +
								f.CONFIG.VERBOSE.day.mask +
								'$');
						  },
			positions	: { month: 1, day: 2, year: 3 },
			string		: function(delimiter) {
							delimiter = delimiter || '-';
							return 'YYYY' + delimiter + 'MM' + delimiter + 'DD';
						  }
		},
		// Month/Year
		MY			: {
			mask		: function(delimiter) {
							var f = HD.content.Date.FORMAT;
							delimiter = delimiter || f.CONFIG.SETTINGS.delimiter.mask;
							return new RegExp('^' +
								f.CONFIG.NUMERIC.month.mask +
								delimiter +
								f.CONFIG.NUMERIC.year.mask +
								'$');
						  },
			positions	: { month: 1, year: 2 },
			string		: function(delimiter) {
							delimiter = delimiter || HD.content.Date.FORMAT.CONFIG.SETTINGS.delimiter.string;
							return 'mm' + delimiter + 'yyyy';
							}
		},
		// Month/Day/Year
		MDY			: {
			mask		: function(delimiter) {
							var f = HD.content.Date.FORMAT;
							delimiter = delimiter || f.CONFIG.SETTINGS.delimiter.mask;
							return new RegExp('^' + 
								f.CONFIG.NUMERIC.month.mask +
								delimiter +
								f.CONFIG.NUMERIC.day.mask +
								delimiter +
								f.CONFIG.NUMERIC.year.mask +
								'$');
						  },
			positions	: { month: 1, day: 2, year: 3 },
			string		: function(delimiter) {
							delimiter = delimiter || HD.content.Date.FORMAT.CONFIG.SETTINGS.delimiter.string;
							return 'mm' + delimiter + 'dd' + delimiter + 'yyyy';
							}
		},
		// Month/Day/Year (long numeric version)
		MMDDYYYY		: {
			mask		: function(delimiter) {
							var f = HD.content.Date.FORMAT;
							delimiter = delimiter || f.CONFIG.SETTINGS.delimiter.mask;
							return new RegExp('^' +
								f.CONFIG.VERBOSE.month.mask +
								delimiter +
								f.CONFIG.VERBOSE.day.mask +
								delimiter +
								f.CONFIG.VERBOSE.year.mask +
								'$');
						  },
			positions	: { month: 1, day: 2, year: 3 },
			string		: function(delimiter) {
							delimiter = delimiter || HD.content.Date.FORMAT.CONFIG.SETTINGS.delimiter.string;
							return 'MM' + delimiter + 'DD' + delimiter + 'YYYY';
							}
		},
		// Month/Day/Year (long version)
		MDYlong		: {
			mask		: function() {
							var f = HD.content.Date.FORMAT;
							return new RegExp('^' +
								f.CONFIG.VERBOSE.month.mask +
								' ' +
								f.CONFIG.VERBOSE.day.mask +
								', ' +
								f.CONFIG.VERBOSE.year.mask +
								'$');
						  },
			positions	: { month: 1, day: 2, year: 3 },
			string		: function() {
							return 'MMMM D, YYYY';
							}
							
		},
		// Weekday/Month/Day/Year (long version)
		WMDYlong	: {
			mask		: function() {
							var f = HD.content.Date.FORMAT;
							return new RegExp('^' +
								f.CONFIG.VERBOSE.weekday.mask +
								' ' +
								f.CONFIG.VERBOSE.month.mask +
								' ' +
								f.CONFIG.VERBOSE.day.mask +
								', ' +
								f.CONFIG.VERBOSE.year.mask +
								'$');
						  },
			positions	: { month: 2, day: 3, weekday: 1, year: 4 },
			string		: function() {
							return 'WWWW, MMMM D, YYYY';
							}
							
		},
		// Weekday/Month/Day/Year (short version)
		WMDYshort	: {
			mask		: function() {
							var f = HD.content.Date.FORMAT;
							return new RegExp('^' +
								f.CONFIG.VERBOSE.weekday.mask +
								' ' +
								f.CONFIG.VERBOSE.month.mask +
								' ' +
								f.CONFIG.VERBOSE.day.mask +
								', ' +
								f.CONFIG.VERBOSE.year.mask +
								'$');
						  },
			positions	: { month: 2, day: 3, weekday: 1, year: 4 },
			string		: function() {
							return 'WWW, MMM D, YYYY';
							}
		}
	},
	
	
	/**
	 * This object holds values for any reusable constants used throughout date/time.
	 * 
	 * @property {Object} CONSTANTS
	 * @constant
	 */
	CONSTANTS	: {
		/**
		 * This variable holds the number of milliseconds in a day.
		 * @property MILLISECONDS_PER_DAY
		 * @constant
		 */
		MILLISECONDS_PER_DAY	: 24 * 60 * 60 * 1000,
		/**
		 * The day of the week index to start at (0-6, 0 = Sunday)
		 * @property WEEKDAY_START
		 * @constant
		 */
		WEEKDAY_START	: 0
	},
	
	/**
	 * This object holds the text formatting for days of the week. Each element/position 
	 * in this array corresponds to the day of week and contains an object with a 1 character, 
	 * short, meduim, and long text description for that day (ex c:"S",s:"Su",m:"Sun",l: "Sunday").
	 * 
	 * @property {Array} DAYS
	 * @constant
	 */
	DAYS		: [
		{ c: 'S', s: 'Su', m: 'Sun', l: 'Sunday' },
		{ c: 'M', s: 'Mo', m: 'Mon', l: 'Monday' },
		{ c: 'T', s: 'Tu', m: 'Tue', l: 'Tuesday' },
		{ c: 'W', s: 'We', m: 'Wed', l: 'Wednesday' },
		{ c: 'T', s: 'Th', m: 'Thu', l: 'Thursday' },
		{ c: 'F', s: 'Fr', m: 'Fri', l: 'Friday' },
		{ c: 'S', s: 'Sa', m: 'Sat', l: 'Saturday' }
	],
	
	/**
	 * This object holds the text formatting for months. Each element/position in this array 
	 * corresponds to a single month and contains an object with a short text, long text 
	 * (ex s:"Jan",l:"January").
	 * 
	 * @property {Array} MONTHS
	 * @constant
	 */
	MONTHS		: [
		{ s: 'Jan', l: 'January' },
		{ s: 'Feb', l: 'February' },
		{ s: 'Mar', l: 'March' },
		{ s: 'Apr', l: 'April' },
		{ s: 'May', l: 'May' },
		{ s: 'Jun', l: 'June' },
		{ s: 'Jul', l: 'July' },
		{ s: 'Aug', l: 'August' },
		{ s: 'Sep', l: 'September' },
		{ s: 'Oct', l: 'October' },
		{ s: 'Nov', l: 'November' },
		{ s: 'Dec', l: 'December' }
	],
	
	/**
	 * This object holds references to the label text for each element of date/time.
	 * Each label text takes in an integer and returns the localized string object 
	 * (different locales sometimes have more differences than just singular and plural).
	 * 
	 * @property {Object} LABELS
	 * @constant
	 */
	LABELS : {
		year	: function(n) {
			n = Math.floor(n);
			if (n == 1)		{ return { s: 'y', m: 'yr', l: 'year' }; }
			else 			{ return { s: 'y', m: 'yrs', l: 'years' }; }
		},
		month	: function(n) {
			n = Math.floor(n);
			if (n == 1)		{ return { s: 'm', m: 'mon', l: 'month' }; }
			else 			{ return { s: 'm', m: 'mos', l: 'months' }; }
		},
		day		: function(n) {
			n = Math.floor(n);
			if (n == 1)		{ return { s: 'd', m: 'day', l: 'day' }; }
			else 			{ return { s: 'd', m: 'days', l: 'days' }; }
		},
		hour	: function(n) {
			n = Math.floor(n);
			if (n == 1)		{ return { s: 'h', m: 'hr', l: 'hour' }; }
			else 			{ return { s: 'h', m: 'hrs', l: 'hours' }; }
		},
		minute	: function(n) {
			n = Math.floor(n);
			if (n == 1)		{ return { s: 'm', m: 'min', l: 'minute' }; }
			else 			{ return { s: 'm', m: 'mins', l: 'minutes' }; }
		}
	}
};
// Initialize HD.content.Date.
HD.content.Date.init();


/**
 * This is a static class that provides a single place for URL's that are
 * used throughout HD.  No js files in HD should hardcode URL's, they should 
 * all refer to this section.
 *
 * @class URL
 * @static
 * @namespace HD.content
 */
HD.content.URL = {
	cursors : {
		grab : "/media/cursors/grab.cur",
		grabbing : "/media/cursors/grabbing.cur",
		grabTarget : "/media/cursors/target.cur"
	}
};

/**
 * This is a static class that provides a single place for html snippets
 * used throughout HD.  The reasoning for this is to make it easier
 * to adjust html based on a designer preference, provide easier support 
 * for internationalization, and provide a single place where one can 
 * adjust HTML used within any script.
 *
 * @class text
 * @static
 * @namespace HD.content
 */
HD.content.HTML = {
	errorDialog   : '<div class="wrapper"><div class="dialogErrorHeader">' + HD.content.Text.errorDialogHeader + '</div><br /><p>_ERROR_TEXT</p><br /><div style="text-align:center;"><a href="javascript:void(0)" class="btnMain" onclick="HD.ui.Dialog.hide();">' + HD.content.Text.ok + '</a></div></div>',
	confirmDialog : '<p class="confirm">_CONFIRM_TEXT</p><br />' +
					'<div style="text-align:center;">' + 
						'<a href="javascript:void(0)" class="btnMain" onclick="HD.ui.Dialog.hide();HD.ui.Dialog.confirmCallback();">' + HD.content.Text.ok + '</a>' + 
						'<a href="javascript:void(0)" class="btnMain" onclick="HD.ui.Dialog.hide();">' + HD.content.Text.cancel + '</a>' + 
					'</div>',
	noticeDialog : '<p class="notice">_NOTICE_TEXT</p><br />' +
					'<div style="text-align:center;">' + 
						'<a href="javascript:void(0)" class="btnMain" onclick="HD.ui.Dialog.hide();HD.ui.Dialog.noticeCallback();">' + HD.content.Text.ok + '</a>' + 
					'</div>'
	
};


