

/*!
 * Globalize
 *
 * http://github.com/jquery/globalize
 *
 * Copyright Software Freedom Conservancy, Inc.
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 */

(function( window, undefined ) {

var Globalize,
	// private variables
	regexHex,
	regexInfinity,
	regexParseFloat,
	regexTrim,
	// private JavaScript utility functions
	arrayIndexOf,
	endsWith,
	extend,
	isArray,
	isFunction,
	isObject,
	startsWith,
	trim,
	truncate,
	zeroPad,
	// private Globalization utility functions
	appendPreOrPostMatch,
	expandFormat,
	formatDate,
	formatNumber,
	getTokenRegExp,
	getEra,
	getEraYear,
	parseExact,
	parseNegativePattern;

// Global variable (Globalize) or CommonJS module (globalize)
Globalize = function( cultureSelector ) {
	return new Globalize.prototype.init( cultureSelector );
};

if ( typeof require !== "undefined" &&
	typeof exports !== "undefined" &&
	typeof module !== "undefined" ) {
	// Assume CommonJS
	module.exports = Globalize;
} else {
	// Export as global variable
	window.Globalize = Globalize;
}

Globalize.cultures = {};

Globalize.prototype = {
	constructor: Globalize,
	init: function( cultureSelector ) {
		this.cultures = Globalize.cultures;
		this.cultureSelector = cultureSelector;

		return this;
	}
};
Globalize.prototype.init.prototype = Globalize.prototype;

// 1. When defining a culture, all fields are required except the ones stated as optional.
// 2. Each culture should have a ".calendars" object with at least one calendar named "standard"
//    which serves as the default calendar in use by that culture.
// 3. Each culture should have a ".calendar" object which is the current calendar being used,
//    it may be dynamically changed at any time to one of the calendars in ".calendars".
Globalize.cultures[ "default" ] = {
	// A unique name for the culture in the form <language code>-<country/region code>
	name: "en",
	// the name of the culture in the english language
	englishName: "English",
	// the name of the culture in its own language
	nativeName: "English",
	// whether the culture uses right-to-left text
	isRTL: false,
	// "language" is used for so-called "specific" cultures.
	// For example, the culture "es-CL" means "Spanish, in Chili".
	// It represents the Spanish-speaking culture as it is in Chili,
	// which might have different formatting rules or even translations
	// than Spanish in Spain. A "neutral" culture is one that is not
	// specific to a region. For example, the culture "es" is the generic
	// Spanish culture, which may be a more generalized version of the language
	// that may or may not be what a specific culture expects.
	// For a specific culture like "es-CL", the "language" field refers to the
	// neutral, generic culture information for the language it is using.
	// This is not always a simple matter of the string before the dash.
	// For example, the "zh-Hans" culture is netural (Simplified Chinese).
	// And the "zh-SG" culture is Simplified Chinese in Singapore, whose lanugage
	// field is "zh-CHS", not "zh".
	// This field should be used to navigate from a specific culture to it's
	// more general, neutral culture. If a culture is already as general as it
	// can get, the language may refer to itself.
	language: "en",
	// numberFormat defines general number formatting rules, like the digits in
	// each grouping, the group separator, and how negative numbers are displayed.
	numberFormat: {
		// [negativePattern]
		// Note, numberFormat.pattern has no "positivePattern" unlike percent and currency,
		// but is still defined as an array for consistency with them.
		//   negativePattern: one of "(n)|-n|- n|n-|n -"
		pattern: [ "-n" ],
		// number of decimal places normally shown
		decimals: 2,
		// string that separates number groups, as in 1,000,000
		",": ",",
		// string that separates a number from the fractional portion, as in 1.99
		".": ".",
		// array of numbers indicating the size of each number group.
		// TODO: more detailed description and example
		groupSizes: [ 3 ],
		// symbol used for positive numbers
		"+": "+",
		// symbol used for negative numbers
		"-": "-",
		// symbol used for NaN (Not-A-Number)
		"NaN": "NaN",
		// symbol used for Negative Infinity
		negativeInfinity: "-Infinity",
		// symbol used for Positive Infinity
		positiveInfinity: "Infinity",
		percent: {
			// [negativePattern, positivePattern]
			//   negativePattern: one of "-n %|-n%|-%n|%-n|%n-|n-%|n%-|-% n|n %-|% n-|% -n|n- %"
			//   positivePattern: one of "n %|n%|%n|% n"
			pattern: [ "-n %", "n %" ],
			// number of decimal places normally shown
			decimals: 2,
			// array of numbers indicating the size of each number group.
			// TODO: more detailed description and example
			groupSizes: [ 3 ],
			// string that separates number groups, as in 1,000,000
			",": ",",
			// string that separates a number from the fractional portion, as in 1.99
			".": ".",
			// symbol used to represent a percentage
			symbol: "%"
		},
		currency: {
			// [negativePattern, positivePattern]
			//   negativePattern: one of "($n)|-$n|$-n|$n-|(n$)|-n$|n-$|n$-|-n $|-$ n|n $-|$ n-|$ -n|n- $|($ n)|(n $)"
			//   positivePattern: one of "$n|n$|$ n|n $"
			pattern: [ "($n)", "$n" ],
			// number of decimal places normally shown
			decimals: 2,
			// array of numbers indicating the size of each number group.
			// TODO: more detailed description and example
			groupSizes: [ 3 ],
			// string that separates number groups, as in 1,000,000
			",": ",",
			// string that separates a number from the fractional portion, as in 1.99
			".": ".",
			// symbol used to represent currency
			symbol: "$"
		}
	},
	// calendars defines all the possible calendars used by this culture.
	// There should be at least one defined with name "standard", and is the default
	// calendar used by the culture.
	// A calendar contains information about how dates are formatted, information about
	// the calendar's eras, a standard set of the date formats,
	// translations for day and month names, and if the calendar is not based on the Gregorian
	// calendar, conversion functions to and from the Gregorian calendar.
	calendars: {
		standard: {
			// name that identifies the type of calendar this is
			name: "Gregorian_USEnglish",
			// separator of parts of a date (e.g. "/" in 11/05/1955)
			"/": "/",
			// separator of parts of a time (e.g. ":" in 05:44 PM)
			":": ":",
			// the first day of the week (0 = Sunday, 1 = Monday, etc)
			firstDay: 0,
			days: {
				// full day names
				names: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],
				// abbreviated day names
				namesAbbr: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
				// shortest day names
				namesShort: [ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ]
			},
			months: {
				// full month names (13 months for lunar calendards -- 13th month should be "" if not lunar)
				names: [ "Januari", "Februari", "Maret", "April", "May", "June", "July", "August", "September", "October", "November", "December", "" ],
				// abbreviated month names
				namesAbbr: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "" ]
			},
			// AM and PM designators in one of these forms:
			// The usual view, and the upper and lower case versions
			//   [ standard, lowercase, uppercase ]
			// The culture does not use AM or PM (likely all standard date formats use 24 hour time)
			//   null
			AM: [ "AM", "am", "AM" ],
			PM: [ "PM", "pm", "PM" ],
			eras: [
				// eras in reverse chronological order.
				// name: the name of the era in this culture (e.g. A.D., C.E.)
				// start: when the era starts in ticks (gregorian, gmt), null if it is the earliest supported era.
				// offset: offset in years from gregorian calendar
				{
					"name": "A.D.",
					"start": null,
					"offset": 0
				}
			],
			// when a two digit year is given, it will never be parsed as a four digit
			// year greater than this year (in the appropriate era for the culture)
			// Set it as a full year (e.g. 2029) or use an offset format starting from
			// the current year: "+19" would correspond to 2029 if the current year 2010.
			twoDigitYearMax: 2029,
			// set of predefined date and time patterns used by the culture
			// these represent the format someone in this culture would expect
			// to see given the portions of the date that are shown.
			patterns: {
				// short date pattern
				d: "M/d/yyyy",
				// long date pattern
				D: "dddd, MMMM dd, yyyy",
				// short time pattern
				t: "h:mm tt",
				// long time pattern
				T: "h:mm:ss tt",
				// long date, short time pattern
				f: "dddd, MMMM dd, yyyy h:mm tt",
				// long date, long time pattern
				F: "dddd, MMMM dd, yyyy h:mm:ss tt",
				// month/day pattern
				M: "MMMM dd",
				// month/year pattern
				Y: "yyyy MMMM",
				// S is a sortable format that does not vary by culture
				S: "yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027T\u0027HH\u0027:\u0027mm\u0027:\u0027ss"
			}
			// optional fields for each calendar:
			/*
			monthsGenitive:
				Same as months but used when the day preceeds the month.
				Omit if the culture has no genitive distinction in month names.
				For an explaination of genitive months, see http://blogs.msdn.com/michkap/archive/2004/12/25/332259.aspx
			convert:
				Allows for the support of non-gregorian based calendars. This convert object is used to
				to convert a date to and from a gregorian calendar date to handle parsing and formatting.
				The two functions:
					fromGregorian( date )
						Given the date as a parameter, return an array with parts [ year, month, day ]
						corresponding to the non-gregorian based year, month, and day for the calendar.
					toGregorian( year, month, day )
						Given the non-gregorian year, month, and day, return a new Date() object
						set to the corresponding date in the gregorian calendar.
			*/
		}
	},
	// For localized strings
	messages: {}
};

Globalize.cultures[ "default" ].calendar = Globalize.cultures[ "default" ].calendars.standard;

Globalize.cultures.en = Globalize.cultures[ "default" ];

Globalize.cultureSelector = "en";

//
// private variables
//

regexHex = /^0x[a-f0-9]+$/i;
regexInfinity = /^[+\-]?infinity$/i;
regexParseFloat = /^[+\-]?\d*\.?\d*(e[+\-]?\d+)?$/;
regexTrim = /^\s+|\s+$/g;

//
// private JavaScript utility functions
//

arrayIndexOf = function( array, item ) {
	if ( array.indexOf ) {
		return array.indexOf( item );
	}
	for ( var i = 0, length = array.length; i < length; i++ ) {
		if ( array[i] === item ) {
			return i;
		}
	}
	return -1;
};

endsWith = function( value, pattern ) {
	return value.substr( value.length - pattern.length ) === pattern;
};

extend = function() {
	var options, name, src, copy, copyIsArray, clone,
		target = arguments[0] || {},
		i = 1,
		length = arguments.length,
		deep = false;

	// Handle a deep copy situation
	if ( typeof target === "boolean" ) {
		deep = target;
		target = arguments[1] || {};
		// skip the boolean and the target
		i = 2;
	}

	// Handle case when target is a string or something (possible in deep copy)
	if ( typeof target !== "object" && !isFunction(target) ) {
		target = {};
	}

	for ( ; i < length; i++ ) {
		// Only deal with non-null/undefined values
		if ( (options = arguments[ i ]) != null ) {
			// Extend the base object
			for ( name in options ) {
				src = target[ name ];
				copy = options[ name ];

				// Prevent never-ending loop
				if ( target === copy ) {
					continue;
				}

				// Recurse if we're merging plain objects or arrays
				if ( deep && copy && ( isObject(copy) || (copyIsArray = isArray(copy)) ) ) {
					if ( copyIsArray ) {
						copyIsArray = false;
						clone = src && isArray(src) ? src : [];

					} else {
						clone = src && isObject(src) ? src : {};
					}

					// Never move original objects, clone them
					target[ name ] = extend( deep, clone, copy );

				// Don't bring in undefined values
				} else if ( copy !== undefined ) {
					target[ name ] = copy;
				}
			}
		}
	}

	// Return the modified object
	return target;
};

isArray = Array.isArray || function( obj ) {
	return Object.prototype.toString.call( obj ) === "[object Array]";
};

isFunction = function( obj ) {
	return Object.prototype.toString.call( obj ) === "[object Function]";
};

isObject = function( obj ) {
	return Object.prototype.toString.call( obj ) === "[object Object]";
};

startsWith = function( value, pattern ) {
	return value.indexOf( pattern ) === 0;
};

trim = function( value ) {
	return ( value + "" ).replace( regexTrim, "" );
};

truncate = function( value ) {
	if ( isNaN( value ) ) {
		return NaN;
	}
	return Math[ value < 0 ? "ceil" : "floor" ]( value );
};

zeroPad = function( str, count, left ) {
	var l;
	for ( l = str.length; l < count; l += 1 ) {
		str = ( left ? ("0" + str) : (str + "0") );
	}
	return str;
};

//
// private Globalization utility functions
//

appendPreOrPostMatch = function( preMatch, strings ) {
	// appends pre- and post- token match strings while removing escaped characters.
	// Returns a single quote count which is used to determine if the token occurs
	// in a string literal.
	var quoteCount = 0,
		escaped = false;
	for ( var i = 0, il = preMatch.length; i < il; i++ ) {
		var c = preMatch.charAt( i );
		switch ( c ) {
			case "\'":
				if ( escaped ) {
					strings.push( "\'" );
				}
				else {
					quoteCount++;
				}
				escaped = false;
				break;
			case "\\":
				if ( escaped ) {
					strings.push( "\\" );
				}
				escaped = !escaped;
				break;
			default:
				strings.push( c );
				escaped = false;
				break;
		}
	}
	return quoteCount;
};

expandFormat = function( cal, format ) {
	// expands unspecified or single character date formats into the full pattern.
	format = format || "F";
	var pattern,
		patterns = cal.patterns,
		len = format.length;
	if ( len === 1 ) {
		pattern = patterns[ format ];
		if ( !pattern ) {
			throw "Invalid date format string \'" + format + "\'.";
		}
		format = pattern;
	}
	else if ( len === 2 && format.charAt(0) === "%" ) {
		// %X escape format -- intended as a custom format string that is only one character, not a built-in format.
		format = format.charAt( 1 );
	}
	return format;
};

formatDate = function( value, format, culture ) {
	var cal = culture.calendar,
		convert = cal.convert,
		ret;

	if ( !format || !format.length || format === "i" ) {
		if ( culture && culture.name.length ) {
			if ( convert ) {
				// non-gregorian calendar, so we cannot use built-in toLocaleString()
				ret = formatDate( value, cal.patterns.F, culture );
			}
			else {
				var eraDate = new Date( value.getTime() ),
					era = getEra( value, cal.eras );
				eraDate.setFullYear( getEraYear(value, cal, era) );
				ret = eraDate.toLocaleString();
			}
		}
		else {
			ret = value.toString();
		}
		return ret;
	}

	var eras = cal.eras,
		sortable = format === "s";
	format = expandFormat( cal, format );

	// Start with an empty string
	ret = [];
	var hour,
		zeros = [ "0", "00", "000" ],
		foundDay,
		checkedDay,
		dayPartRegExp = /([^d]|^)(d|dd)([^d]|$)/g,
		quoteCount = 0,
		tokenRegExp = getTokenRegExp(),
		converted;

	function padZeros( num, c ) {
		var r, s = num + "";
		if ( c > 1 && s.length < c ) {
			r = ( zeros[c - 2] + s);
			return r.substr( r.length - c, c );
		}
		else {
			r = s;
		}
		return r;
	}

	function hasDay() {
		if ( foundDay || checkedDay ) {
			return foundDay;
		}
		foundDay = dayPartRegExp.test( format );
		checkedDay = true;
		return foundDay;
	}

	function getPart( date, part ) {
		if ( converted ) {
			return converted[ part ];
		}
		switch ( part ) {
			case 0:
				return date.getFullYear();
			case 1:
				return date.getMonth();
			case 2:
				return date.getDate();
			default:
				throw "Invalid part value " + part;
		}
	}

	if ( !sortable && convert ) {
		converted = convert.fromGregorian( value );
	}

	for ( ; ; ) {
		// Save the current index
		var index = tokenRegExp.lastIndex,
			// Look for the next pattern
			ar = tokenRegExp.exec( format );

		// Append the text before the pattern (or the end of the string if not found)
		var preMatch = format.slice( index, ar ? ar.index : format.length );
		quoteCount += appendPreOrPostMatch( preMatch, ret );

		if ( !ar ) {
			break;
		}

		// do not replace any matches that occur inside a string literal.
		if ( quoteCount % 2 ) {
			ret.push( ar[0] );
			continue;
		}

		var current = ar[ 0 ],
			clength = current.length;

		switch ( current ) {
			case "ddd":
				//Day of the week, as a three-letter abbreviation
			case "dddd":
				// Day of the week, using the full name
				var names = ( clength === 3 ) ? cal.days.namesAbbr : cal.days.names;
				ret.push( names[value.getDay()] );
				break;
			case "d":
				// Day of month, without leading zero for single-digit days
			case "dd":
				// Day of month, with leading zero for single-digit days
				foundDay = true;
				ret.push(
					padZeros( getPart(value, 2), clength )
				);
				break;
			case "MMM":
				// Month, as a three-letter abbreviation
			case "MMMM":
				// Month, using the full name
				var part = getPart( value, 1 );
				ret.push(
					( cal.monthsGenitive && hasDay() ) ?
					( cal.monthsGenitive[ clength === 3 ? "namesAbbr" : "names" ][ part ] ) :
					( cal.months[ clength === 3 ? "namesAbbr" : "names" ][ part ] )
				);
				break;
			case "M":
				// Month, as digits, with no leading zero for single-digit months
			case "MM":
				// Month, as digits, with leading zero for single-digit months
				ret.push(
					padZeros( getPart(value, 1) + 1, clength )
				);
				break;
			case "y":
				// Year, as two digits, but with no leading zero for years less than 10
			case "yy":
				// Year, as two digits, with leading zero for years less than 10
			case "yyyy":
				// Year represented by four full digits
				part = converted ? converted[ 0 ] : getEraYear( value, cal, getEra(value, eras), sortable );
				if ( clength < 4 ) {
					part = part % 100;
				}
				ret.push(
					padZeros( part, clength )
				);
				break;
			case "h":
				// Hours with no leading zero for single-digit hours, using 12-hour clock
			case "hh":
				// Hours with leading zero for single-digit hours, using 12-hour clock
				hour = value.getHours() % 12;
				if ( hour === 0 ) hour = 12;
				ret.push(
					padZeros( hour, clength )
				);
				break;
			case "H":
				// Hours with no leading zero for single-digit hours, using 24-hour clock
			case "HH":
				// Hours with leading zero for single-digit hours, using 24-hour clock
				ret.push(
					padZeros( value.getHours(), clength )
				);
				break;
			case "m":
				// Minutes with no leading zero for single-digit minutes
			case "mm":
				// Minutes with leading zero for single-digit minutes
				ret.push(
					padZeros( value.getMinutes(), clength )
				);
				break;
			case "s":
				// Seconds with no leading zero for single-digit seconds
			case "ss":
				// Seconds with leading zero for single-digit seconds
				ret.push(
					padZeros( value.getSeconds(), clength )
				);
				break;
			case "t":
				// One character am/pm indicator ("a" or "p")
			case "tt":
				// Multicharacter am/pm indicator
				part = value.getHours() < 12 ? ( cal.AM ? cal.AM[0] : " " ) : ( cal.PM ? cal.PM[0] : " " );
				ret.push( clength === 1 ? part.charAt(0) : part );
				break;
			case "f":
				// Deciseconds
			case "ff":
				// Centiseconds
			case "fff":
				// Milliseconds
				ret.push(
					padZeros( value.getMilliseconds(), 3 ).substr( 0, clength )
				);
				break;
			case "z":
				// Time zone offset, no leading zero
			case "zz":
				// Time zone offset with leading zero
				hour = value.getTimezoneOffset() / 60;
				ret.push(
					( hour <= 0 ? "+" : "-" ) + padZeros( Math.floor(Math.abs(hour)), clength )
				);
				break;
			case "zzz":
				// Time zone offset with leading zero
				hour = value.getTimezoneOffset() / 60;
				ret.push(
					( hour <= 0 ? "+" : "-" ) + padZeros( Math.floor(Math.abs(hour)), 2 ) +
					// Hard coded ":" separator, rather than using cal.TimeSeparator
					// Repeated here for consistency, plus ":" was already assumed in date parsing.
					":" + padZeros( Math.abs(value.getTimezoneOffset() % 60), 2 )
				);
				break;
			case "g":
			case "gg":
				if ( cal.eras ) {
					ret.push(
						cal.eras[ getEra(value, eras) ].name
					);
				}
				break;
		case "/":
			ret.push( cal["/"] );
			break;
		default:
			throw "Invalid date format pattern \'" + current + "\'.";
		}
	}
	return ret.join( "" );
};

// formatNumber
(function() {
	var expandNumber;

	expandNumber = function( number, precision, formatInfo ) {
		var groupSizes = formatInfo.groupSizes,
			curSize = groupSizes[ 0 ],
			curGroupIndex = 1,
			factor = Math.pow( 10, precision ),
			rounded = Math.round( number * factor ) / factor;

		if ( !isFinite(rounded) ) {
			rounded = number;
		}
		number = rounded;

		var numberString = number+"",
			right = "",
			split = numberString.split( /e/i ),
			exponent = split.length > 1 ? parseInt( split[1], 10 ) : 0;
		numberString = split[ 0 ];
		split = numberString.split( "." );
		numberString = split[ 0 ];
		right = split.length > 1 ? split[ 1 ] : "";

		var l;
		if ( exponent > 0 ) {
			right = zeroPad( right, exponent, false );
			numberString += right.slice( 0, exponent );
			right = right.substr( exponent );
		}
		else if ( exponent < 0 ) {
			exponent = -exponent;
			numberString = zeroPad( numberString, exponent + 1, true );
			right = numberString.slice( -exponent, numberString.length ) + right;
			numberString = numberString.slice( 0, -exponent );
		}

		if ( precision > 0 ) {
			right = formatInfo[ "." ] +
				( (right.length > precision) ? right.slice(0, precision) : zeroPad(right, precision) );
		}
		else {
			right = "";
		}

		var stringIndex = numberString.length - 1,
			sep = formatInfo[ "," ],
			ret = "";

		while ( stringIndex >= 0 ) {
			if ( curSize === 0 || curSize > stringIndex ) {
				return numberString.slice( 0, stringIndex + 1 ) + ( ret.length ? (sep + ret + right) : right );
			}
			ret = numberString.slice( stringIndex - curSize + 1, stringIndex + 1 ) + ( ret.length ? (sep + ret) : "" );

			stringIndex -= curSize;

			if ( curGroupIndex < groupSizes.length ) {
				curSize = groupSizes[ curGroupIndex ];
				curGroupIndex++;
			}
		}

		return numberString.slice( 0, stringIndex + 1 ) + sep + ret + right;
	};

	formatNumber = function( value, format, culture ) {
		if ( !isFinite(value) ) {
			if ( value === Infinity ) {
				return culture.numberFormat.positiveInfinity;
			}
			if ( value === -Infinity ) {
				return culture.numberFormat.negativeInfinity;
			}
			return culture.numberFormat.NaN;
		}
		if ( !format || format === "i" ) {
			return culture.name.length ? value.toLocaleString() : value.toString();
		}
		format = format || "D";

		var nf = culture.numberFormat,
			number = Math.abs( value ),
			precision = -1,
			pattern;
		if ( format.length > 1 ) precision = parseInt( format.slice(1), 10 );

		var current = format.charAt( 0 ).toUpperCase(),
			formatInfo;

		switch ( current ) {
			case "D":
				pattern = "n";
				number = truncate( number );
				if ( precision !== -1 ) {
					number = zeroPad( "" + number, precision, true );
				}
				if ( value < 0 ) number = "-" + number;
				break;
			case "N":
				formatInfo = nf;
				/* falls through */
			case "C":
				formatInfo = formatInfo || nf.currency;
				/* falls through */
			case "P":
				formatInfo = formatInfo || nf.percent;
				pattern = value < 0 ? formatInfo.pattern[ 0 ] : ( formatInfo.pattern[1] || "n" );
				if ( precision === -1 ) precision = formatInfo.decimals;
				number = expandNumber( number * (current === "P" ? 100 : 1), precision, formatInfo );
				break;
			default:
				throw "Bad number format specifier: " + current;
		}

		var patternParts = /n|\$|-|%/g,
			ret = "";
		for ( ; ; ) {
			var index = patternParts.lastIndex,
				ar = patternParts.exec( pattern );

			ret += pattern.slice( index, ar ? ar.index : pattern.length );

			if ( !ar ) {
				break;
			}

			switch ( ar[0] ) {
				case "n":
					ret += number;
					break;
				case "$":
					ret += nf.currency.symbol;
					break;
				case "-":
					// don't make 0 negative
					if ( /[1-9]/.test(number) ) {
						ret += nf[ "-" ];
					}
					break;
				case "%":
					ret += nf.percent.symbol;
					break;
			}
		}

		return ret;
	};

}());

getTokenRegExp = function() {
	// regular expression for matching date and time tokens in format strings.
	return (/\/|dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|hh|h|HH|H|mm|m|ss|s|tt|t|fff|ff|f|zzz|zz|z|gg|g/g);
};

getEra = function( date, eras ) {
	if ( !eras ) return 0;
	var start, ticks = date.getTime();
	for ( var i = 0, l = eras.length; i < l; i++ ) {
		start = eras[ i ].start;
		if ( start === null || ticks >= start ) {
			return i;
		}
	}
	return 0;
};

getEraYear = function( date, cal, era, sortable ) {
	var year = date.getFullYear();
	if ( !sortable && cal.eras ) {
		// convert normal gregorian year to era-shifted gregorian
		// year by subtracting the era offset
		year -= cal.eras[ era ].offset;
	}
	return year;
};

// parseExact
(function() {
	var expandYear,
		getDayIndex,
		getMonthIndex,
		getParseRegExp,
		outOfRange,
		toUpper,
		toUpperArray;

	expandYear = function( cal, year ) {
		// expands 2-digit year into 4 digits.
		if ( year < 100 ) {
			var now = new Date(),
				era = getEra( now ),
				curr = getEraYear( now, cal, era ),
				twoDigitYearMax = cal.twoDigitYearMax;
			twoDigitYearMax = typeof twoDigitYearMax === "string" ? new Date().getFullYear() % 100 + parseInt( twoDigitYearMax, 10 ) : twoDigitYearMax;
			year += curr - ( curr % 100 );
			if ( year > twoDigitYearMax ) {
				year -= 100;
			}
		}
		return year;
	};

	getDayIndex = function	( cal, value, abbr ) {
		var ret,
			days = cal.days,
			upperDays = cal._upperDays;
		if ( !upperDays ) {
			cal._upperDays = upperDays = [
				toUpperArray( days.names ),
				toUpperArray( days.namesAbbr ),
				toUpperArray( days.namesShort )
			];
		}
		value = toUpper( value );
		if ( abbr ) {
			ret = arrayIndexOf( upperDays[1], value );
			if ( ret === -1 ) {
				ret = arrayIndexOf( upperDays[2], value );
			}
		}
		else {
			ret = arrayIndexOf( upperDays[0], value );
		}
		return ret;
	};

	getMonthIndex = function( cal, value, abbr ) {
		var months = cal.months,
			monthsGen = cal.monthsGenitive || cal.months,
			upperMonths = cal._upperMonths,
			upperMonthsGen = cal._upperMonthsGen;
		if ( !upperMonths ) {
			cal._upperMonths = upperMonths = [
				toUpperArray( months.names ),
				toUpperArray( months.namesAbbr )
			];
			cal._upperMonthsGen = upperMonthsGen = [
				toUpperArray( monthsGen.names ),
				toUpperArray( monthsGen.namesAbbr )
			];
		}
		value = toUpper( value );
		var i = arrayIndexOf( abbr ? upperMonths[1] : upperMonths[0], value );
		if ( i < 0 ) {
			i = arrayIndexOf( abbr ? upperMonthsGen[1] : upperMonthsGen[0], value );
		}
		return i;
	};

	getParseRegExp = function( cal, format ) {
		// converts a format string into a regular expression with groups that
		// can be used to extract date fields from a date string.
		// check for a cached parse regex.
		var re = cal._parseRegExp;
		if ( !re ) {
			cal._parseRegExp = re = {};
		}
		else {
			var reFormat = re[ format ];
			if ( reFormat ) {
				return reFormat;
			}
		}

		// expand single digit formats, then escape regular expression characters.
		var expFormat = expandFormat( cal, format ).replace( /([\^\$\.\*\+\?\|\[\]\(\)\{\}])/g, "\\\\$1" ),
			regexp = [ "^" ],
			groups = [],
			index = 0,
			quoteCount = 0,
			tokenRegExp = getTokenRegExp(),
			match;

		// iterate through each date token found.
		while ( (match = tokenRegExp.exec(expFormat)) !== null ) {
			var preMatch = expFormat.slice( index, match.index );
			index = tokenRegExp.lastIndex;

			// don't replace any matches that occur inside a string literal.
			quoteCount += appendPreOrPostMatch( preMatch, regexp );
			if ( quoteCount % 2 ) {
				regexp.push( match[0] );
				continue;
			}

			// add a regex group for the token.
			var m = match[ 0 ],
				len = m.length,
				add;
			switch ( m ) {
				case "dddd": case "ddd":
				case "MMMM": case "MMM":
				case "gg": case "g":
					add = "(\\D+)";
					break;
				case "tt": case "t":
					add = "(\\D*)";
					break;
				case "yyyy":
				case "fff":
				case "ff":
				case "f":
					add = "(\\d{" + len + "})";
					break;
				case "dd": case "d":
				case "MM": case "M":
				case "yy": case "y":
				case "HH": case "H":
				case "hh": case "h":
				case "mm": case "m":
				case "ss": case "s":
					add = "(\\d\\d?)";
					break;
				case "zzz":
					add = "([+-]?\\d\\d?:\\d{2})";
					break;
				case "zz": case "z":
					add = "([+-]?\\d\\d?)";
					break;
				case "/":
					add = "(\\/)";
					break;
				default:
					throw "Invalid date format pattern \'" + m + "\'.";
			}
			if ( add ) {
				regexp.push( add );
			}
			groups.push( match[0] );
		}
		appendPreOrPostMatch( expFormat.slice(index), regexp );
		regexp.push( "$" );

		// allow whitespace to differ when matching formats.
		var regexpStr = regexp.join( "" ).replace( /\s+/g, "\\s+" ),
			parseRegExp = { "regExp": regexpStr, "groups": groups };

		// cache the regex for this format.
		return re[ format ] = parseRegExp;
	};

	outOfRange = function( value, low, high ) {
		return value < low || value > high;
	};

	toUpper = function( value ) {
		// "he-IL" has non-breaking space in weekday names.
		return value.split( "\u00A0" ).join( " " ).toUpperCase();
	};

	toUpperArray = function( arr ) {
		var results = [];
		for ( var i = 0, l = arr.length; i < l; i++ ) {
			results[ i ] = toUpper( arr[i] );
		}
		return results;
	};

	parseExact = function( value, format, culture ) {
		// try to parse the date string by matching against the format string
		// while using the specified culture for date field names.
		value = trim( value );
		var cal = culture.calendar,
			// convert date formats into regular expressions with groupings.
			// use the regexp to determine the input format and extract the date fields.
			parseInfo = getParseRegExp( cal, format ),
			match = new RegExp( parseInfo.regExp ).exec( value );
		if ( match === null ) {
			return null;
		}
		// found a date format that matches the input.
		var groups = parseInfo.groups,
			era = null, year = null, month = null, date = null, weekDay = null,
			hour = 0, hourOffset, min = 0, sec = 0, msec = 0, tzMinOffset = null,
			pmHour = false;
		// iterate the format groups to extract and set the date fields.
		for ( var j = 0, jl = groups.length; j < jl; j++ ) {
			var matchGroup = match[ j + 1 ];
			if ( matchGroup ) {
				var current = groups[ j ],
					clength = current.length,
					matchInt = parseInt( matchGroup, 10 );
				switch ( current ) {
					case "dd": case "d":
						// Day of month.
						date = matchInt;
						// check that date is generally in valid range, also checking overflow below.
						if ( outOfRange(date, 1, 31) ) return null;
						break;
					case "MMM": case "MMMM":
						month = getMonthIndex( cal, matchGroup, clength === 3 );
						if ( outOfRange(month, 0, 11) ) return null;
						break;
					case "M": case "MM":
						// Month.
						month = matchInt - 1;
						if ( outOfRange(month, 0, 11) ) return null;
						break;
					case "y": case "yy":
					case "yyyy":
						year = clength < 4 ? expandYear( cal, matchInt ) : matchInt;
						if ( outOfRange(year, 0, 9999) ) return null;
						break;
					case "h": case "hh":
						// Hours (12-hour clock).
						hour = matchInt;
						if ( hour === 12 ) hour = 0;
						if ( outOfRange(hour, 0, 11) ) return null;
						break;
					case "H": case "HH":
						// Hours (24-hour clock).
						hour = matchInt;
						if ( outOfRange(hour, 0, 23) ) return null;
						break;
					case "m": case "mm":
						// Minutes.
						min = matchInt;
						if ( outOfRange(min, 0, 59) ) return null;
						break;
					case "s": case "ss":
						// Seconds.
						sec = matchInt;
						if ( outOfRange(sec, 0, 59) ) return null;
						break;
					case "tt": case "t":
						// AM/PM designator.
						// see if it is standard, upper, or lower case PM. If not, ensure it is at least one of
						// the AM tokens. If not, fail the parse for this format.
						pmHour = cal.PM && ( matchGroup === cal.PM[0] || matchGroup === cal.PM[1] || matchGroup === cal.PM[2] );
						if (
							!pmHour && (
								!cal.AM || ( matchGroup !== cal.AM[0] && matchGroup !== cal.AM[1] && matchGroup !== cal.AM[2] )
							)
						) return null;
						break;
					case "f":
						// Deciseconds.
					case "ff":
						// Centiseconds.
					case "fff":
						// Milliseconds.
						msec = matchInt * Math.pow( 10, 3 - clength );
						if ( outOfRange(msec, 0, 999) ) return null;
						break;
					case "ddd":
						// Day of week.
					case "dddd":
						// Day of week.
						weekDay = getDayIndex( cal, matchGroup, clength === 3 );
						if ( outOfRange(weekDay, 0, 6) ) return null;
						break;
					case "zzz":
						// Time zone offset in +/- hours:min.
						var offsets = matchGroup.split( /:/ );
						if ( offsets.length !== 2 ) return null;
						hourOffset = parseInt( offsets[0], 10 );
						if ( outOfRange(hourOffset, -12, 13) ) return null;
						var minOffset = parseInt( offsets[1], 10 );
						if ( outOfRange(minOffset, 0, 59) ) return null;
						tzMinOffset = ( hourOffset * 60 ) + ( startsWith(matchGroup, "-") ? -minOffset : minOffset );
						break;
					case "z": case "zz":
						// Time zone offset in +/- hours.
						hourOffset = matchInt;
						if ( outOfRange(hourOffset, -12, 13) ) return null;
						tzMinOffset = hourOffset * 60;
						break;
					case "g": case "gg":
						var eraName = matchGroup;
						if ( !eraName || !cal.eras ) return null;
						eraName = trim( eraName.toLowerCase() );
						for ( var i = 0, l = cal.eras.length; i < l; i++ ) {
							if ( eraName === cal.eras[i].name.toLowerCase() ) {
								era = i;
								break;
							}
						}
						// could not find an era with that name
						if ( era === null ) return null;
						break;
				}
			}
		}
		var result = new Date(), defaultYear, convert = cal.convert;
		defaultYear = convert ? convert.fromGregorian( result )[ 0 ] : result.getFullYear();
		if ( year === null ) {
			year = defaultYear;
		}
		else if ( cal.eras ) {
			// year must be shifted to normal gregorian year
			// but not if year was not specified, its already normal gregorian
			// per the main if clause above.
			year += cal.eras[( era || 0 )].offset;
		}
		// set default day and month to 1 and January, so if unspecified, these are the defaults
		// instead of the current day/month.
		if ( month === null ) {
			month = 0;
		}
		if ( date === null ) {
			date = 1;
		}
		// now have year, month, and date, but in the culture's calendar.
		// convert to gregorian if necessary
		if ( convert ) {
			result = convert.toGregorian( year, month, date );
			// conversion failed, must be an invalid match
			if ( result === null ) return null;
		}
		else {
			// have to set year, month and date together to avoid overflow based on current date.
			result.setFullYear( year, month, date );
			// check to see if date overflowed for specified month (only checked 1-31 above).
			if ( result.getDate() !== date ) return null;
			// invalid day of week.
			if ( weekDay !== null && result.getDay() !== weekDay ) {
				return null;
			}
		}
		// if pm designator token was found make sure the hours fit the 24-hour clock.
		if ( pmHour && hour < 12 ) {
			hour += 12;
		}
		result.setHours( hour, min, sec, msec );
		if ( tzMinOffset !== null ) {
			// adjust timezone to utc before applying local offset.
			var adjustedMin = result.getMinutes() - ( tzMinOffset + result.getTimezoneOffset() );
			// Safari limits hours and minutes to the range of -127 to 127.  We need to use setHours
			// to ensure both these fields will not exceed this range.	adjustedMin will range
			// somewhere between -1440 and 1500, so we only need to split this into hours.
			result.setHours( result.getHours() + parseInt(adjustedMin / 60, 10), adjustedMin % 60 );
		}
		return result;
	};
}());

parseNegativePattern = function( value, nf, negativePattern ) {
	var neg = nf[ "-" ],
		pos = nf[ "+" ],
		ret;
	switch ( negativePattern ) {
		case "n -":
			neg = " " + neg;
			pos = " " + pos;
			/* falls through */
		case "n-":
			if ( endsWith(value, neg) ) {
				ret = [ "-", value.substr(0, value.length - neg.length) ];
			}
			else if ( endsWith(value, pos) ) {
				ret = [ "+", value.substr(0, value.length - pos.length) ];
			}
			break;
		case "- n":
			neg += " ";
			pos += " ";
			/* falls through */
		case "-n":
			if ( startsWith(value, neg) ) {
				ret = [ "-", value.substr(neg.length) ];
			}
			else if ( startsWith(value, pos) ) {
				ret = [ "+", value.substr(pos.length) ];
			}
			break;
		case "(n)":
			if ( startsWith(value, "(") && endsWith(value, ")") ) {
				ret = [ "-", value.substr(1, value.length - 2) ];
			}
			break;
	}
	return ret || [ "", value ];
};

//
// public instance functions
//

Globalize.prototype.findClosestCulture = function( cultureSelector ) {
	return Globalize.findClosestCulture.call( this, cultureSelector );
};

Globalize.prototype.format = function( value, format, cultureSelector ) {
	return Globalize.format.call( this, value, format, cultureSelector );
};

Globalize.prototype.localize = function( key, cultureSelector ) {
	return Globalize.localize.call( this, key, cultureSelector );
};

Globalize.prototype.parseInt = function( value, radix, cultureSelector ) {
	return Globalize.parseInt.call( this, value, radix, cultureSelector );
};

Globalize.prototype.parseFloat = function( value, radix, cultureSelector ) {
	return Globalize.parseFloat.call( this, value, radix, cultureSelector );
};

Globalize.prototype.culture = function( cultureSelector ) {
	return Globalize.culture.call( this, cultureSelector );
};

//
// public singleton functions
//

Globalize.addCultureInfo = function( cultureName, baseCultureName, info ) {

	var base = {},
		isNew = false;

	if ( typeof cultureName !== "string" ) {
		// cultureName argument is optional string. If not specified, assume info is first
		// and only argument. Specified info deep-extends current culture.
		info = cultureName;
		cultureName = this.culture().name;
		base = this.cultures[ cultureName ];
	} else if ( typeof baseCultureName !== "string" ) {
		// baseCultureName argument is optional string. If not specified, assume info is second
		// argument. Specified info deep-extends specified culture.
		// If specified culture does not exist, create by deep-extending default
		info = baseCultureName;
		isNew = ( this.cultures[ cultureName ] == null );
		base = this.cultures[ cultureName ] || this.cultures[ "default" ];
	} else {
		// cultureName and baseCultureName specified. Assume a new culture is being created
		// by deep-extending an specified base culture
		isNew = true;
		base = this.cultures[ baseCultureName ];
	}

	this.cultures[ cultureName ] = extend(true, {},
		base,
		info
	);
	// Make the standard calendar the current culture if it's a new culture
	if ( isNew ) {
		this.cultures[ cultureName ].calendar = this.cultures[ cultureName ].calendars.standard;
	}
};

Globalize.findClosestCulture = function( name ) {
	var match;
	if ( !name ) {
		return this.findClosestCulture( this.cultureSelector ) || this.cultures[ "default" ];
	}
	if ( typeof name === "string" ) {
		name = name.split( "," );
	}
	if ( isArray(name) ) {
		var lang,
			cultures = this.cultures,
			list = name,
			i, l = list.length,
			prioritized = [];
		for ( i = 0; i < l; i++ ) {
			name = trim( list[i] );
			var pri, parts = name.split( ";" );
			lang = trim( parts[0] );
			if ( parts.length === 1 ) {
				pri = 1;
			}
			else {
				name = trim( parts[1] );
				if ( name.indexOf("q=") === 0 ) {
					name = name.substr( 2 );
					pri = parseFloat( name );
					pri = isNaN( pri ) ? 0 : pri;
				}
				else {
					pri = 1;
				}
			}
			prioritized.push({ lang: lang, pri: pri });
		}
		prioritized.sort(function( a, b ) {
			if ( a.pri < b.pri ) {
				return 1;
			} else if ( a.pri > b.pri ) {
				return -1;
			}
			return 0;
		});
		// exact match
		for ( i = 0; i < l; i++ ) {
			lang = prioritized[ i ].lang;
			match = cultures[ lang ];
			if ( match ) {
				return match;
			}
		}

		// neutral language match
		for ( i = 0; i < l; i++ ) {
			lang = prioritized[ i ].lang;
			do {
				var index = lang.lastIndexOf( "-" );
				if ( index === -1 ) {
					break;
				}
				// strip off the last part. e.g. en-US => en
				lang = lang.substr( 0, index );
				match = cultures[ lang ];
				if ( match ) {
					return match;
				}
			}
			while ( 1 );
		}

		// last resort: match first culture using that language
		for ( i = 0; i < l; i++ ) {
			lang = prioritized[ i ].lang;
			for ( var cultureKey in cultures ) {
				var culture = cultures[ cultureKey ];
				if ( culture.language == lang ) {
					return culture;
				}
			}
		}
	}
	else if ( typeof name === "object" ) {
		return name;
	}
	return match || null;
};

Globalize.format = function( value, format, cultureSelector ) {
	var culture = this.findClosestCulture( cultureSelector );
	if ( value instanceof Date ) {
		value = formatDate( value, format, culture );
	}
	else if ( typeof value === "number" ) {
		value = formatNumber( value, format, culture );
	}
	return value;
};

Globalize.localize = function( key, cultureSelector ) {
	return this.findClosestCulture( cultureSelector ).messages[ key ] ||
		this.cultures[ "default" ].messages[ key ];
};

Globalize.parseDate = function( value, formats, culture ) {
	culture = this.findClosestCulture( culture );

	var date, prop, patterns;
	if ( formats ) {
		if ( typeof formats === "string" ) {
			formats = [ formats ];
		}
		if ( formats.length ) {
			for ( var i = 0, l = formats.length; i < l; i++ ) {
				var format = formats[ i ];
				if ( format ) {
					date = parseExact( value, format, culture );
					if ( date ) {
						break;
					}
				}
			}
		}
	} else {
		patterns = culture.calendar.patterns;
		for ( prop in patterns ) {
			date = parseExact( value, patterns[prop], culture );
			if ( date ) {
				break;
			}
		}
	}

	return date || null;
};

Globalize.parseInt = function( value, radix, cultureSelector ) {
	return truncate( Globalize.parseFloat(value, radix, cultureSelector) );
};

Globalize.parseFloat = function( value, radix, cultureSelector ) {
	// radix argument is optional
	if ( typeof radix !== "number" ) {
		cultureSelector = radix;
		radix = 10;
	}

	var culture = this.findClosestCulture( cultureSelector );
	var ret = NaN,
		nf = culture.numberFormat;

	if ( value.indexOf(culture.numberFormat.currency.symbol) > -1 ) {
		// remove currency symbol
		value = value.replace( culture.numberFormat.currency.symbol, "" );
		// replace decimal seperator
		value = value.replace( culture.numberFormat.currency["."], culture.numberFormat["."] );
	}

	//Remove percentage character from number string before parsing
	if ( value.indexOf(culture.numberFormat.percent.symbol) > -1){
		value = value.replace( culture.numberFormat.percent.symbol, "" );
	}

	// remove spaces: leading, trailing and between - and number. Used for negative currency pt-BR
	value = value.replace( / /g, "" );

	// allow infinity or hexidecimal
	if ( regexInfinity.test(value) ) {
		ret = parseFloat( value );
	}
	else if ( !radix && regexHex.test(value) ) {
		ret = parseInt( value, 16 );
	}
	else {

		// determine sign and number
		var signInfo = parseNegativePattern( value, nf, nf.pattern[0] ),
			sign = signInfo[ 0 ],
			num = signInfo[ 1 ];

		// #44 - try parsing as "(n)"
		if ( sign === "" && nf.pattern[0] !== "(n)" ) {
			signInfo = parseNegativePattern( value, nf, "(n)" );
			sign = signInfo[ 0 ];
			num = signInfo[ 1 ];
		}

		// try parsing as "-n"
		if ( sign === "" && nf.pattern[0] !== "-n" ) {
			signInfo = parseNegativePattern( value, nf, "-n" );
			sign = signInfo[ 0 ];
			num = signInfo[ 1 ];
		}

		sign = sign || "+";

		// determine exponent and number
		var exponent,
			intAndFraction,
			exponentPos = num.indexOf( "e" );
		if ( exponentPos < 0 ) exponentPos = num.indexOf( "E" );
		if ( exponentPos < 0 ) {
			intAndFraction = num;
			exponent = null;
		}
		else {
			intAndFraction = num.substr( 0, exponentPos );
			exponent = num.substr( exponentPos + 1 );
		}
		// determine decimal position
		var integer,
			fraction,
			decSep = nf[ "." ],
			decimalPos = intAndFraction.indexOf( decSep );
		if ( decimalPos < 0 ) {
			integer = intAndFraction;
			fraction = null;
		}
		else {
			integer = intAndFraction.substr( 0, decimalPos );
			fraction = intAndFraction.substr( decimalPos + decSep.length );
		}
		// handle groups (e.g. 1,000,000)
		var groupSep = nf[ "," ];
		integer = integer.split( groupSep ).join( "" );
		var altGroupSep = groupSep.replace( /\u00A0/g, " " );
		if ( groupSep !== altGroupSep ) {
			integer = integer.split( altGroupSep ).join( "" );
		}
		// build a natively parsable number string
		var p = sign + integer;
		if ( fraction !== null ) {
			p += "." + fraction;
		}
		if ( exponent !== null ) {
			// exponent itself may have a number patternd
			var expSignInfo = parseNegativePattern( exponent, nf, "-n" );
			p += "e" + ( expSignInfo[0] || "+" ) + expSignInfo[ 1 ];
		}
		if ( regexParseFloat.test(p) ) {
			ret = parseFloat( p );
		}
	}
	return ret;
};

Globalize.culture = function( cultureSelector ) {
	// setter
	if ( typeof cultureSelector !== "undefined" ) {
		this.cultureSelector = cultureSelector;
	}
	// getter
	return this.findClosestCulture( cultureSelector ) || this.cultures[ "default" ];
};

}( this ));


/*!
 * Globalize
 *
 * http://github.com/jquery/globalize
 *
 * Copyright Software Freedom Conservancy, Inc.
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 */

(function( window, undefined ) {

var Globalize,
	// private variables
	regexHex,
	regexInfinity,
	regexParseFloat,
	regexTrim,
	// private JavaScript utility functions
	arrayIndexOf,
	endsWith,
	extend,
	isArray,
	isFunction,
	isObject,
	startsWith,
	trim,
	truncate,
	zeroPad,
	// private Globalization utility functions
	appendPreOrPostMatch,
	expandFormat,
	formatDate,
	formatNumber,
	getTokenRegExp,
	getEra,
	getEraYear,
	parseExact,
	parseNegativePattern;

// Global variable (Globalize) or CommonJS module (globalize)
Globalize = function( cultureSelector ) {
	return new Globalize.prototype.init( cultureSelector );
};

if ( typeof require !== "undefined" &&
	typeof exports !== "undefined" &&
	typeof module !== "undefined" ) {
	// Assume CommonJS
	module.exports = Globalize;
} else {
	// Export as global variable
	window.Globalize = Globalize;
}

Globalize.cultures = {};

Globalize.prototype = {
	constructor: Globalize,
	init: function( cultureSelector ) {
		this.cultures = Globalize.cultures;
		this.cultureSelector = cultureSelector;

		return this;
	}
};
Globalize.prototype.init.prototype = Globalize.prototype;

// 1. When defining a culture, all fields are required except the ones stated as optional.
// 2. Each culture should have a ".calendars" object with at least one calendar named "standard"
//    which serves as the default calendar in use by that culture.
// 3. Each culture should have a ".calendar" object which is the current calendar being used,
//    it may be dynamically changed at any time to one of the calendars in ".calendars".
Globalize.cultures[ "default" ] = {
	// A unique name for the culture in the form <language code>-<country/region code>
	name: "en",
	// the name of the culture in the english language
	englishName: "English",
	// the name of the culture in its own language
	nativeName: "English",
	// whether the culture uses right-to-left text
	isRTL: false,
	// "language" is used for so-called "specific" cultures.
	// For example, the culture "es-CL" means "Spanish, in Chili".
	// It represents the Spanish-speaking culture as it is in Chili,
	// which might have different formatting rules or even translations
	// than Spanish in Spain. A "neutral" culture is one that is not
	// specific to a region. For example, the culture "es" is the generic
	// Spanish culture, which may be a more generalized version of the language
	// that may or may not be what a specific culture expects.
	// For a specific culture like "es-CL", the "language" field refers to the
	// neutral, generic culture information for the language it is using.
	// This is not always a simple matter of the string before the dash.
	// For example, the "zh-Hans" culture is netural (Simplified Chinese).
	// And the "zh-SG" culture is Simplified Chinese in Singapore, whose lanugage
	// field is "zh-CHS", not "zh".
	// This field should be used to navigate from a specific culture to it's
	// more general, neutral culture. If a culture is already as general as it
	// can get, the language may refer to itself.
	language: "en",
	// numberFormat defines general number formatting rules, like the digits in
	// each grouping, the group separator, and how negative numbers are displayed.
	numberFormat: {
		// [negativePattern]
		// Note, numberFormat.pattern has no "positivePattern" unlike percent and currency,
		// but is still defined as an array for consistency with them.
		//   negativePattern: one of "(n)|-n|- n|n-|n -"
		pattern: [ "-n" ],
		// number of decimal places normally shown
		decimals: 2,
		// string that separates number groups, as in 1,000,000
		",": ",",
		// string that separates a number from the fractional portion, as in 1.99
		".": ".",
		// array of numbers indicating the size of each number group.
		// TODO: more detailed description and example
		groupSizes: [ 3 ],
		// symbol used for positive numbers
		"+": "+",
		// symbol used for negative numbers
		"-": "-",
		// symbol used for NaN (Not-A-Number)
		"NaN": "NaN",
		// symbol used for Negative Infinity
		negativeInfinity: "-Infinity",
		// symbol used for Positive Infinity
		positiveInfinity: "Infinity",
		percent: {
			// [negativePattern, positivePattern]
			//   negativePattern: one of "-n %|-n%|-%n|%-n|%n-|n-%|n%-|-% n|n %-|% n-|% -n|n- %"
			//   positivePattern: one of "n %|n%|%n|% n"
			pattern: [ "-n %", "n %" ],
			// number of decimal places normally shown
			decimals: 2,
			// array of numbers indicating the size of each number group.
			// TODO: more detailed description and example
			groupSizes: [ 3 ],
			// string that separates number groups, as in 1,000,000
			",": ",",
			// string that separates a number from the fractional portion, as in 1.99
			".": ".",
			// symbol used to represent a percentage
			symbol: "%"
		},
		currency: {
			// [negativePattern, positivePattern]
			//   negativePattern: one of "($n)|-$n|$-n|$n-|(n$)|-n$|n-$|n$-|-n $|-$ n|n $-|$ n-|$ -n|n- $|($ n)|(n $)"
			//   positivePattern: one of "$n|n$|$ n|n $"
			pattern: [ "($n)", "$n" ],
			// number of decimal places normally shown
			decimals: 2,
			// array of numbers indicating the size of each number group.
			// TODO: more detailed description and example
			groupSizes: [ 3 ],
			// string that separates number groups, as in 1,000,000
			",": ",",
			// string that separates a number from the fractional portion, as in 1.99
			".": ".",
			// symbol used to represent currency
			symbol: "Rp."
		}
	},
	// calendars defines all the possible calendars used by this culture.
	// There should be at least one defined with name "standard", and is the default
	// calendar used by the culture.
	// A calendar contains information about how dates are formatted, information about
	// the calendar's eras, a standard set of the date formats,
	// translations for day and month names, and if the calendar is not based on the Gregorian
	// calendar, conversion functions to and from the Gregorian calendar.
	calendars: {
		standard: {
			// name that identifies the type of calendar this is
			name: "Gregorian_USEnglish",
			// separator of parts of a date (e.g. "/" in 11/05/1955)
			"/": "/",
			// separator of parts of a time (e.g. ":" in 05:44 PM)
			":": ":",
			// the first day of the week (0 = Sunday, 1 = Monday, etc)
			firstDay: 0,
			days: {
				// full day names
				names: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],
				// abbreviated day names
				namesAbbr: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
				// shortest day names
				namesShort: [ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ]
			},
			months: {
				// full month names (13 months for lunar calendards -- 13th month should be "" if not lunar)
				names: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "" ],
				// abbreviated month names
				namesAbbr: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "" ]
			},
			// AM and PM designators in one of these forms:
			// The usual view, and the upper and lower case versions
			//   [ standard, lowercase, uppercase ]
			// The culture does not use AM or PM (likely all standard date formats use 24 hour time)
			//   null
			AM: [ "AM", "am", "AM" ],
			PM: [ "PM", "pm", "PM" ],
			eras: [
				// eras in reverse chronological order.
				// name: the name of the era in this culture (e.g. A.D., C.E.)
				// start: when the era starts in ticks (gregorian, gmt), null if it is the earliest supported era.
				// offset: offset in years from gregorian calendar
				{
					"name": "A.D.",
					"start": null,
					"offset": 0
				}
			],
			// when a two digit year is given, it will never be parsed as a four digit
			// year greater than this year (in the appropriate era for the culture)
			// Set it as a full year (e.g. 2029) or use an offset format starting from
			// the current year: "+19" would correspond to 2029 if the current year 2010.
			twoDigitYearMax: 2029,
			// set of predefined date and time patterns used by the culture
			// these represent the format someone in this culture would expect
			// to see given the portions of the date that are shown.
			patterns: {
				// short date pattern
				d: "dd/MM/yyyy",
				// long date pattern
				D: "dddd, MMMM dd, yyyy",
				// short time pattern
				t: "h:mm tt",
				// long time pattern
				T: "h:mm:ss tt",
				// long date, short time pattern
				f: "dddd, MMMM dd, yyyy h:mm tt",
				// long date, long time pattern
				F: "dddd, MMMM dd, yyyy h:mm:ss tt",
				// month/day pattern
				M: "MMMM dd",
				// month/year pattern
				Y: "yyyy MMMM",
				// S is a sortable format that does not vary by culture
				S: "yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027T\u0027HH\u0027:\u0027mm\u0027:\u0027ss"
			}
			// optional fields for each calendar:
			/*
			monthsGenitive:
				Same as months but used when the day preceeds the month.
				Omit if the culture has no genitive distinction in month names.
				For an explaination of genitive months, see http://blogs.msdn.com/michkap/archive/2004/12/25/332259.aspx
			convert:
				Allows for the support of non-gregorian based calendars. This convert object is used to
				to convert a date to and from a gregorian calendar date to handle parsing and formatting.
				The two functions:
					fromGregorian( date )
						Given the date as a parameter, return an array with parts [ year, month, day ]
						corresponding to the non-gregorian based year, month, and day for the calendar.
					toGregorian( year, month, day )
						Given the non-gregorian year, month, and day, return a new Date() object
						set to the corresponding date in the gregorian calendar.
			*/
		}
	},
	// For localized strings
	messages: {}
};

Globalize.cultures[ "default" ].calendar = Globalize.cultures[ "default" ].calendars.standard;

Globalize.cultures.en = Globalize.cultures[ "default" ];

Globalize.cultureSelector = "en";

//
// private variables
//

regexHex = /^0x[a-f0-9]+$/i;
regexInfinity = /^[+\-]?infinity$/i;
regexParseFloat = /^[+\-]?\d*\.?\d*(e[+\-]?\d+)?$/;
regexTrim = /^\s+|\s+$/g;

//
// private JavaScript utility functions
//

arrayIndexOf = function( array, item ) {
	if ( array.indexOf ) {
		return array.indexOf( item );
	}
	for ( var i = 0, length = array.length; i < length; i++ ) {
		if ( array[i] === item ) {
			return i;
		}
	}
	return -1;
};

endsWith = function( value, pattern ) {
	return value.substr( value.length - pattern.length ) === pattern;
};

extend = function() {
	var options, name, src, copy, copyIsArray, clone,
		target = arguments[0] || {},
		i = 1,
		length = arguments.length,
		deep = false;

	// Handle a deep copy situation
	if ( typeof target === "boolean" ) {
		deep = target;
		target = arguments[1] || {};
		// skip the boolean and the target
		i = 2;
	}

	// Handle case when target is a string or something (possible in deep copy)
	if ( typeof target !== "object" && !isFunction(target) ) {
		target = {};
	}

	for ( ; i < length; i++ ) {
		// Only deal with non-null/undefined values
		if ( (options = arguments[ i ]) != null ) {
			// Extend the base object
			for ( name in options ) {
				src = target[ name ];
				copy = options[ name ];

				// Prevent never-ending loop
				if ( target === copy ) {
					continue;
				}

				// Recurse if we're merging plain objects or arrays
				if ( deep && copy && ( isObject(copy) || (copyIsArray = isArray(copy)) ) ) {
					if ( copyIsArray ) {
						copyIsArray = false;
						clone = src && isArray(src) ? src : [];

					} else {
						clone = src && isObject(src) ? src : {};
					}

					// Never move original objects, clone them
					target[ name ] = extend( deep, clone, copy );

				// Don't bring in undefined values
				} else if ( copy !== undefined ) {
					target[ name ] = copy;
				}
			}
		}
	}

	// Return the modified object
	return target;
};

isArray = Array.isArray || function( obj ) {
	return Object.prototype.toString.call( obj ) === "[object Array]";
};

isFunction = function( obj ) {
	return Object.prototype.toString.call( obj ) === "[object Function]";
};

isObject = function( obj ) {
	return Object.prototype.toString.call( obj ) === "[object Object]";
};

startsWith = function( value, pattern ) {
	return value.indexOf( pattern ) === 0;
};

trim = function( value ) {
	return ( value + "" ).replace( regexTrim, "" );
};

truncate = function( value ) {
	if ( isNaN( value ) ) {
		return NaN;
	}
	return Math[ value < 0 ? "ceil" : "floor" ]( value );
};

zeroPad = function( str, count, left ) {
	var l;
	for ( l = str.length; l < count; l += 1 ) {
		str = ( left ? ("0" + str) : (str + "0") );
	}
	return str;
};

//
// private Globalization utility functions
//

appendPreOrPostMatch = function( preMatch, strings ) {
	// appends pre- and post- token match strings while removing escaped characters.
	// Returns a single quote count which is used to determine if the token occurs
	// in a string literal.
	var quoteCount = 0,
		escaped = false;
	for ( var i = 0, il = preMatch.length; i < il; i++ ) {
		var c = preMatch.charAt( i );
		switch ( c ) {
			case "\'":
				if ( escaped ) {
					strings.push( "\'" );
				}
				else {
					quoteCount++;
				}
				escaped = false;
				break;
			case "\\":
				if ( escaped ) {
					strings.push( "\\" );
				}
				escaped = !escaped;
				break;
			default:
				strings.push( c );
				escaped = false;
				break;
		}
	}
	return quoteCount;
};

expandFormat = function( cal, format ) {
	// expands unspecified or single character date formats into the full pattern.
	format = format || "F";
	var pattern,
		patterns = cal.patterns,
		len = format.length;
	if ( len === 1 ) {
		pattern = patterns[ format ];
		if ( !pattern ) {
			throw "Invalid date format string \'" + format + "\'.";
		}
		format = pattern;
	}
	else if ( len === 2 && format.charAt(0) === "%" ) {
		// %X escape format -- intended as a custom format string that is only one character, not a built-in format.
		format = format.charAt( 1 );
	}
	return format;
};

formatDate = function( value, format, culture ) {
	var cal = culture.calendar,
		convert = cal.convert,
		ret;

	if ( !format || !format.length || format === "i" ) {
		if ( culture && culture.name.length ) {
			if ( convert ) {
				// non-gregorian calendar, so we cannot use built-in toLocaleString()
				ret = formatDate( value, cal.patterns.F, culture );
			}
			else {
				var eraDate = new Date( value.getTime() ),
					era = getEra( value, cal.eras );
				eraDate.setFullYear( getEraYear(value, cal, era) );
				ret = eraDate.toLocaleString();
			}
		}
		else {
			ret = value.toString();
		}
		return ret;
	}

	var eras = cal.eras,
		sortable = format === "s";
	format = expandFormat( cal, format );

	// Start with an empty string
	ret = [];
	var hour,
		zeros = [ "0", "00", "000" ],
		foundDay,
		checkedDay,
		dayPartRegExp = /([^d]|^)(d|dd)([^d]|$)/g,
		quoteCount = 0,
		tokenRegExp = getTokenRegExp(),
		converted;

	function padZeros( num, c ) {
		var r, s = num + "";
		if ( c > 1 && s.length < c ) {
			r = ( zeros[c - 2] + s);
			return r.substr( r.length - c, c );
		}
		else {
			r = s;
		}
		return r;
	}

	function hasDay() {
		if ( foundDay || checkedDay ) {
			return foundDay;
		}
		foundDay = dayPartRegExp.test( format );
		checkedDay = true;
		return foundDay;
	}

	function getPart( date, part ) {
		if ( converted ) {
			return converted[ part ];
		}
		switch ( part ) {
			case 0:
				return date.getFullYear();
			case 1:
				return date.getMonth();
			case 2:
				return date.getDate();
			default:
				throw "Invalid part value " + part;
		}
	}

	if ( !sortable && convert ) {
		converted = convert.fromGregorian( value );
	}

	for ( ; ; ) {
		// Save the current index
		var index = tokenRegExp.lastIndex,
			// Look for the next pattern
			ar = tokenRegExp.exec( format );

		// Append the text before the pattern (or the end of the string if not found)
		var preMatch = format.slice( index, ar ? ar.index : format.length );
		quoteCount += appendPreOrPostMatch( preMatch, ret );

		if ( !ar ) {
			break;
		}

		// do not replace any matches that occur inside a string literal.
		if ( quoteCount % 2 ) {
			ret.push( ar[0] );
			continue;
		}

		var current = ar[ 0 ],
			clength = current.length;

		switch ( current ) {
			case "ddd":
				//Day of the week, as a three-letter abbreviation
			case "dddd":
				// Day of the week, using the full name
				var names = ( clength === 3 ) ? cal.days.namesAbbr : cal.days.names;
				ret.push( names[value.getDay()] );
				break;
			case "d":
				// Day of month, without leading zero for single-digit days
			case "dd":
				// Day of month, with leading zero for single-digit days
				foundDay = true;
				ret.push(
					padZeros( getPart(value, 2), clength )
				);
				break;
			case "MMM":
				// Month, as a three-letter abbreviation
			case "MMMM":
				// Month, using the full name
				var part = getPart( value, 1 );
				ret.push(
					( cal.monthsGenitive && hasDay() ) ?
					( cal.monthsGenitive[ clength === 3 ? "namesAbbr" : "names" ][ part ] ) :
					( cal.months[ clength === 3 ? "namesAbbr" : "names" ][ part ] )
				);
				break;
			case "M":
				// Month, as digits, with no leading zero for single-digit months
			case "MM":
				// Month, as digits, with leading zero for single-digit months
				ret.push(
					padZeros( getPart(value, 1) + 1, clength )
				);
				break;
			case "y":
				// Year, as two digits, but with no leading zero for years less than 10
			case "yy":
				// Year, as two digits, with leading zero for years less than 10
			case "yyyy":
				// Year represented by four full digits
				part = converted ? converted[ 0 ] : getEraYear( value, cal, getEra(value, eras), sortable );
				if ( clength < 4 ) {
					part = part % 100;
				}
				ret.push(
					padZeros( part, clength )
				);
				break;
			case "h":
				// Hours with no leading zero for single-digit hours, using 12-hour clock
			case "hh":
				// Hours with leading zero for single-digit hours, using 12-hour clock
				hour = value.getHours() % 12;
				if ( hour === 0 ) hour = 12;
				ret.push(
					padZeros( hour, clength )
				);
				break;
			case "H":
				// Hours with no leading zero for single-digit hours, using 24-hour clock
			case "HH":
				// Hours with leading zero for single-digit hours, using 24-hour clock
				ret.push(
					padZeros( value.getHours(), clength )
				);
				break;
			case "m":
				// Minutes with no leading zero for single-digit minutes
			case "mm":
				// Minutes with leading zero for single-digit minutes
				ret.push(
					padZeros( value.getMinutes(), clength )
				);
				break;
			case "s":
				// Seconds with no leading zero for single-digit seconds
			case "ss":
				// Seconds with leading zero for single-digit seconds
				ret.push(
					padZeros( value.getSeconds(), clength )
				);
				break;
			case "t":
				// One character am/pm indicator ("a" or "p")
			case "tt":
				// Multicharacter am/pm indicator
				part = value.getHours() < 12 ? ( cal.AM ? cal.AM[0] : " " ) : ( cal.PM ? cal.PM[0] : " " );
				ret.push( clength === 1 ? part.charAt(0) : part );
				break;
			case "f":
				// Deciseconds
			case "ff":
				// Centiseconds
			case "fff":
				// Milliseconds
				ret.push(
					padZeros( value.getMilliseconds(), 3 ).substr( 0, clength )
				);
				break;
			case "z":
				// Time zone offset, no leading zero
			case "zz":
				// Time zone offset with leading zero
				hour = value.getTimezoneOffset() / 60;
				ret.push(
					( hour <= 0 ? "+" : "-" ) + padZeros( Math.floor(Math.abs(hour)), clength )
				);
				break;
			case "zzz":
				// Time zone offset with leading zero
				hour = value.getTimezoneOffset() / 60;
				ret.push(
					( hour <= 0 ? "+" : "-" ) + padZeros( Math.floor(Math.abs(hour)), 2 ) +
					// Hard coded ":" separator, rather than using cal.TimeSeparator
					// Repeated here for consistency, plus ":" was already assumed in date parsing.
					":" + padZeros( Math.abs(value.getTimezoneOffset() % 60), 2 )
				);
				break;
			case "g":
			case "gg":
				if ( cal.eras ) {
					ret.push(
						cal.eras[ getEra(value, eras) ].name
					);
				}
				break;
		case "/":
			ret.push( cal["/"] );
			break;
		default:
			throw "Invalid date format pattern \'" + current + "\'.";
		}
	}
	return ret.join( "" );
};

// formatNumber
(function() {
	var expandNumber;

	expandNumber = function( number, precision, formatInfo ) {
		var groupSizes = formatInfo.groupSizes,
			curSize = groupSizes[ 0 ],
			curGroupIndex = 1,
			factor = Math.pow( 10, precision ),
			rounded = Math.round( number * factor ) / factor;

		if ( !isFinite(rounded) ) {
			rounded = number;
		}
		number = rounded;

		var numberString = number+"",
			right = "",
			split = numberString.split( /e/i ),
			exponent = split.length > 1 ? parseInt( split[1], 10 ) : 0;
		numberString = split[ 0 ];
		split = numberString.split( "." );
		numberString = split[ 0 ];
		right = split.length > 1 ? split[ 1 ] : "";

		var l;
		if ( exponent > 0 ) {
			right = zeroPad( right, exponent, false );
			numberString += right.slice( 0, exponent );
			right = right.substr( exponent );
		}
		else if ( exponent < 0 ) {
			exponent = -exponent;
			numberString = zeroPad( numberString, exponent + 1, true );
			right = numberString.slice( -exponent, numberString.length ) + right;
			numberString = numberString.slice( 0, -exponent );
		}

		if ( precision > 0 ) {
			right = formatInfo[ "." ] +
				( (right.length > precision) ? right.slice(0, precision) : zeroPad(right, precision) );
		}
		else {
			right = "";
		}

		var stringIndex = numberString.length - 1,
			sep = formatInfo[ "," ],
			ret = "";

		while ( stringIndex >= 0 ) {
			if ( curSize === 0 || curSize > stringIndex ) {
				return numberString.slice( 0, stringIndex + 1 ) + ( ret.length ? (sep + ret + right) : right );
			}
			ret = numberString.slice( stringIndex - curSize + 1, stringIndex + 1 ) + ( ret.length ? (sep + ret) : "" );

			stringIndex -= curSize;

			if ( curGroupIndex < groupSizes.length ) {
				curSize = groupSizes[ curGroupIndex ];
				curGroupIndex++;
			}
		}

		return numberString.slice( 0, stringIndex + 1 ) + sep + ret + right;
	};

	formatNumber = function( value, format, culture ) {
		if ( !isFinite(value) ) {
			if ( value === Infinity ) {
				return culture.numberFormat.positiveInfinity;
			}
			if ( value === -Infinity ) {
				return culture.numberFormat.negativeInfinity;
			}
			return culture.numberFormat.NaN;
		}
		if ( !format || format === "i" ) {
			return culture.name.length ? value.toLocaleString() : value.toString();
		}
		format = format || "D";

		var nf = culture.numberFormat,
			number = Math.abs( value ),
			precision = -1,
			pattern;
		if ( format.length > 1 ) precision = parseInt( format.slice(1), 10 );

		var current = format.charAt( 0 ).toUpperCase(),
			formatInfo;

		switch ( current ) {
			case "D":
				pattern = "n";
				number = truncate( number );
				if ( precision !== -1 ) {
					number = zeroPad( "" + number, precision, true );
				}
				if ( value < 0 ) number = "-" + number;
				break;
			case "N":
				formatInfo = nf;
				/* falls through */
			case "C":
				formatInfo = formatInfo || nf.currency;
				/* falls through */
			case "P":
				formatInfo = formatInfo || nf.percent;
				pattern = value < 0 ? formatInfo.pattern[ 0 ] : ( formatInfo.pattern[1] || "n" );
				if ( precision === -1 ) precision = formatInfo.decimals;
				number = expandNumber( number * (current === "P" ? 100 : 1), precision, formatInfo );
				break;
			default:
				throw "Bad number format specifier: " + current;
		}

		var patternParts = /n|\$|-|%/g,
			ret = "";
		for ( ; ; ) {
			var index = patternParts.lastIndex,
				ar = patternParts.exec( pattern );

			ret += pattern.slice( index, ar ? ar.index : pattern.length );

			if ( !ar ) {
				break;
			}

			switch ( ar[0] ) {
				case "n":
					ret += number;
					break;
				case "$":
					ret += nf.currency.symbol;
					break;
				case "-":
					// don't make 0 negative
					if ( /[1-9]/.test(number) ) {
						ret += nf[ "-" ];
					}
					break;
				case "%":
					ret += nf.percent.symbol;
					break;
			}
		}

		return ret;
	};

}());

getTokenRegExp = function() {
	// regular expression for matching date and time tokens in format strings.
	return (/\/|dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|hh|h|HH|H|mm|m|ss|s|tt|t|fff|ff|f|zzz|zz|z|gg|g/g);
};

getEra = function( date, eras ) {
	if ( !eras ) return 0;
	var start, ticks = date.getTime();
	for ( var i = 0, l = eras.length; i < l; i++ ) {
		start = eras[ i ].start;
		if ( start === null || ticks >= start ) {
			return i;
		}
	}
	return 0;
};

getEraYear = function( date, cal, era, sortable ) {
	var year = date.getFullYear();
	if ( !sortable && cal.eras ) {
		// convert normal gregorian year to era-shifted gregorian
		// year by subtracting the era offset
		year -= cal.eras[ era ].offset;
	}
	return year;
};

// parseExact
(function() {
	var expandYear,
		getDayIndex,
		getMonthIndex,
		getParseRegExp,
		outOfRange,
		toUpper,
		toUpperArray;

	expandYear = function( cal, year ) {
		// expands 2-digit year into 4 digits.
		if ( year < 100 ) {
			var now = new Date(),
				era = getEra( now ),
				curr = getEraYear( now, cal, era ),
				twoDigitYearMax = cal.twoDigitYearMax;
			twoDigitYearMax = typeof twoDigitYearMax === "string" ? new Date().getFullYear() % 100 + parseInt( twoDigitYearMax, 10 ) : twoDigitYearMax;
			year += curr - ( curr % 100 );
			if ( year > twoDigitYearMax ) {
				year -= 100;
			}
		}
		return year;
	};

	getDayIndex = function	( cal, value, abbr ) {
		var ret,
			days = cal.days,
			upperDays = cal._upperDays;
		if ( !upperDays ) {
			cal._upperDays = upperDays = [
				toUpperArray( days.names ),
				toUpperArray( days.namesAbbr ),
				toUpperArray( days.namesShort )
			];
		}
		value = toUpper( value );
		if ( abbr ) {
			ret = arrayIndexOf( upperDays[1], value );
			if ( ret === -1 ) {
				ret = arrayIndexOf( upperDays[2], value );
			}
		}
		else {
			ret = arrayIndexOf( upperDays[0], value );
		}
		return ret;
	};

	getMonthIndex = function( cal, value, abbr ) {
		var months = cal.months,
			monthsGen = cal.monthsGenitive || cal.months,
			upperMonths = cal._upperMonths,
			upperMonthsGen = cal._upperMonthsGen;
		if ( !upperMonths ) {
			cal._upperMonths = upperMonths = [
				toUpperArray( months.names ),
				toUpperArray( months.namesAbbr )
			];
			cal._upperMonthsGen = upperMonthsGen = [
				toUpperArray( monthsGen.names ),
				toUpperArray( monthsGen.namesAbbr )
			];
		}
		value = toUpper( value );
		var i = arrayIndexOf( abbr ? upperMonths[1] : upperMonths[0], value );
		if ( i < 0 ) {
			i = arrayIndexOf( abbr ? upperMonthsGen[1] : upperMonthsGen[0], value );
		}
		return i;
	};

	getParseRegExp = function( cal, format ) {
		// converts a format string into a regular expression with groups that
		// can be used to extract date fields from a date string.
		// check for a cached parse regex.
		var re = cal._parseRegExp;
		if ( !re ) {
			cal._parseRegExp = re = {};
		}
		else {
			var reFormat = re[ format ];
			if ( reFormat ) {
				return reFormat;
			}
		}

		// expand single digit formats, then escape regular expression characters.
		var expFormat = expandFormat( cal, format ).replace( /([\^\$\.\*\+\?\|\[\]\(\)\{\}])/g, "\\\\$1" ),
			regexp = [ "^" ],
			groups = [],
			index = 0,
			quoteCount = 0,
			tokenRegExp = getTokenRegExp(),
			match;

		// iterate through each date token found.
		while ( (match = tokenRegExp.exec(expFormat)) !== null ) {
			var preMatch = expFormat.slice( index, match.index );
			index = tokenRegExp.lastIndex;

			// don't replace any matches that occur inside a string literal.
			quoteCount += appendPreOrPostMatch( preMatch, regexp );
			if ( quoteCount % 2 ) {
				regexp.push( match[0] );
				continue;
			}

			// add a regex group for the token.
			var m = match[ 0 ],
				len = m.length,
				add;
			switch ( m ) {
				case "dddd": case "ddd":
				case "MMMM": case "MMM":
				case "gg": case "g":
					add = "(\\D+)";
					break;
				case "tt": case "t":
					add = "(\\D*)";
					break;
				case "yyyy":
				case "fff":
				case "ff":
				case "f":
					add = "(\\d{" + len + "})";
					break;
				case "dd": case "d":
				case "MM": case "M":
				case "yy": case "y":
				case "HH": case "H":
				case "hh": case "h":
				case "mm": case "m":
				case "ss": case "s":
					add = "(\\d\\d?)";
					break;
				case "zzz":
					add = "([+-]?\\d\\d?:\\d{2})";
					break;
				case "zz": case "z":
					add = "([+-]?\\d\\d?)";
					break;
				case "/":
					add = "(\\/)";
					break;
				default:
					throw "Invalid date format pattern \'" + m + "\'.";
			}
			if ( add ) {
				regexp.push( add );
			}
			groups.push( match[0] );
		}
		appendPreOrPostMatch( expFormat.slice(index), regexp );
		regexp.push( "$" );

		// allow whitespace to differ when matching formats.
		var regexpStr = regexp.join( "" ).replace( /\s+/g, "\\s+" ),
			parseRegExp = { "regExp": regexpStr, "groups": groups };

		// cache the regex for this format.
		return re[ format ] = parseRegExp;
	};

	outOfRange = function( value, low, high ) {
		return value < low || value > high;
	};

	toUpper = function( value ) {
		// "he-IL" has non-breaking space in weekday names.
		return value.split( "\u00A0" ).join( " " ).toUpperCase();
	};

	toUpperArray = function( arr ) {
		var results = [];
		for ( var i = 0, l = arr.length; i < l; i++ ) {
			results[ i ] = toUpper( arr[i] );
		}
		return results;
	};

	parseExact = function( value, format, culture ) {
		// try to parse the date string by matching against the format string
		// while using the specified culture for date field names.
		value = trim( value );
		var cal = culture.calendar,
			// convert date formats into regular expressions with groupings.
			// use the regexp to determine the input format and extract the date fields.
			parseInfo = getParseRegExp( cal, format ),
			match = new RegExp( parseInfo.regExp ).exec( value );
		if ( match === null ) {
			return null;
		}
		// found a date format that matches the input.
		var groups = parseInfo.groups,
			era = null, year = null, month = null, date = null, weekDay = null,
			hour = 0, hourOffset, min = 0, sec = 0, msec = 0, tzMinOffset = null,
			pmHour = false;
		// iterate the format groups to extract and set the date fields.
		for ( var j = 0, jl = groups.length; j < jl; j++ ) {
			var matchGroup = match[ j + 1 ];
			if ( matchGroup ) {
				var current = groups[ j ],
					clength = current.length,
					matchInt = parseInt( matchGroup, 10 );
				switch ( current ) {
					case "dd": case "d":
						// Day of month.
						date = matchInt;
						// check that date is generally in valid range, also checking overflow below.
						if ( outOfRange(date, 1, 31) ) return null;
						break;
					case "MMM": case "MMMM":
						month = getMonthIndex( cal, matchGroup, clength === 3 );
						if ( outOfRange(month, 0, 11) ) return null;
						break;
					case "M": case "MM":
						// Month.
						month = matchInt - 1;
						if ( outOfRange(month, 0, 11) ) return null;
						break;
					case "y": case "yy":
					case "yyyy":
						year = clength < 4 ? expandYear( cal, matchInt ) : matchInt;
						if ( outOfRange(year, 0, 9999) ) return null;
						break;
					case "h": case "hh":
						// Hours (12-hour clock).
						hour = matchInt;
						if ( hour === 12 ) hour = 0;
						if ( outOfRange(hour, 0, 11) ) return null;
						break;
					case "H": case "HH":
						// Hours (24-hour clock).
						hour = matchInt;
						if ( outOfRange(hour, 0, 23) ) return null;
						break;
					case "m": case "mm":
						// Minutes.
						min = matchInt;
						if ( outOfRange(min, 0, 59) ) return null;
						break;
					case "s": case "ss":
						// Seconds.
						sec = matchInt;
						if ( outOfRange(sec, 0, 59) ) return null;
						break;
					case "tt": case "t":
						// AM/PM designator.
						// see if it is standard, upper, or lower case PM. If not, ensure it is at least one of
						// the AM tokens. If not, fail the parse for this format.
						pmHour = cal.PM && ( matchGroup === cal.PM[0] || matchGroup === cal.PM[1] || matchGroup === cal.PM[2] );
						if (
							!pmHour && (
								!cal.AM || ( matchGroup !== cal.AM[0] && matchGroup !== cal.AM[1] && matchGroup !== cal.AM[2] )
							)
						) return null;
						break;
					case "f":
						// Deciseconds.
					case "ff":
						// Centiseconds.
					case "fff":
						// Milliseconds.
						msec = matchInt * Math.pow( 10, 3 - clength );
						if ( outOfRange(msec, 0, 999) ) return null;
						break;
					case "ddd":
						// Day of week.
					case "dddd":
						// Day of week.
						weekDay = getDayIndex( cal, matchGroup, clength === 3 );
						if ( outOfRange(weekDay, 0, 6) ) return null;
						break;
					case "zzz":
						// Time zone offset in +/- hours:min.
						var offsets = matchGroup.split( /:/ );
						if ( offsets.length !== 2 ) return null;
						hourOffset = parseInt( offsets[0], 10 );
						if ( outOfRange(hourOffset, -12, 13) ) return null;
						var minOffset = parseInt( offsets[1], 10 );
						if ( outOfRange(minOffset, 0, 59) ) return null;
						tzMinOffset = ( hourOffset * 60 ) + ( startsWith(matchGroup, "-") ? -minOffset : minOffset );
						break;
					case "z": case "zz":
						// Time zone offset in +/- hours.
						hourOffset = matchInt;
						if ( outOfRange(hourOffset, -12, 13) ) return null;
						tzMinOffset = hourOffset * 60;
						break;
					case "g": case "gg":
						var eraName = matchGroup;
						if ( !eraName || !cal.eras ) return null;
						eraName = trim( eraName.toLowerCase() );
						for ( var i = 0, l = cal.eras.length; i < l; i++ ) {
							if ( eraName === cal.eras[i].name.toLowerCase() ) {
								era = i;
								break;
							}
						}
						// could not find an era with that name
						if ( era === null ) return null;
						break;
				}
			}
		}
		var result = new Date(), defaultYear, convert = cal.convert;
		defaultYear = convert ? convert.fromGregorian( result )[ 0 ] : result.getFullYear();
		if ( year === null ) {
			year = defaultYear;
		}
		else if ( cal.eras ) {
			// year must be shifted to normal gregorian year
			// but not if year was not specified, its already normal gregorian
			// per the main if clause above.
			year += cal.eras[( era || 0 )].offset;
		}
		// set default day and month to 1 and January, so if unspecified, these are the defaults
		// instead of the current day/month.
		if ( month === null ) {
			month = 0;
		}
		if ( date === null ) {
			date = 1;
		}
		// now have year, month, and date, but in the culture's calendar.
		// convert to gregorian if necessary
		if ( convert ) {
			result = convert.toGregorian( year, month, date );
			// conversion failed, must be an invalid match
			if ( result === null ) return null;
		}
		else {
			// have to set year, month and date together to avoid overflow based on current date.
			result.setFullYear( year, month, date );
			// check to see if date overflowed for specified month (only checked 1-31 above).
			if ( result.getDate() !== date ) return null;
			// invalid day of week.
			if ( weekDay !== null && result.getDay() !== weekDay ) {
				return null;
			}
		}
		// if pm designator token was found make sure the hours fit the 24-hour clock.
		if ( pmHour && hour < 12 ) {
			hour += 12;
		}
		result.setHours( hour, min, sec, msec );
		if ( tzMinOffset !== null ) {
			// adjust timezone to utc before applying local offset.
			var adjustedMin = result.getMinutes() - ( tzMinOffset + result.getTimezoneOffset() );
			// Safari limits hours and minutes to the range of -127 to 127.  We need to use setHours
			// to ensure both these fields will not exceed this range.	adjustedMin will range
			// somewhere between -1440 and 1500, so we only need to split this into hours.
			result.setHours( result.getHours() + parseInt(adjustedMin / 60, 10), adjustedMin % 60 );
		}
		return result;
	};
}());

parseNegativePattern = function( value, nf, negativePattern ) {
	var neg = nf[ "-" ],
		pos = nf[ "+" ],
		ret;
	switch ( negativePattern ) {
		case "n -":
			neg = " " + neg;
			pos = " " + pos;
			/* falls through */
		case "n-":
			if ( endsWith(value, neg) ) {
				ret = [ "-", value.substr(0, value.length - neg.length) ];
			}
			else if ( endsWith(value, pos) ) {
				ret = [ "+", value.substr(0, value.length - pos.length) ];
			}
			break;
		case "- n":
			neg += " ";
			pos += " ";
			/* falls through */
		case "-n":
			if ( startsWith(value, neg) ) {
				ret = [ "-", value.substr(neg.length) ];
			}
			else if ( startsWith(value, pos) ) {
				ret = [ "+", value.substr(pos.length) ];
			}
			break;
		case "(n)":
			if ( startsWith(value, "(") && endsWith(value, ")") ) {
				ret = [ "-", value.substr(1, value.length - 2) ];
			}
			break;
	}
	return ret || [ "", value ];
};

//
// public instance functions
//

Globalize.prototype.findClosestCulture = function( cultureSelector ) {
	return Globalize.findClosestCulture.call( this, cultureSelector );
};

Globalize.prototype.format = function( value, format, cultureSelector ) {
	return Globalize.format.call( this, value, format, cultureSelector );
};

Globalize.prototype.localize = function( key, cultureSelector ) {
	return Globalize.localize.call( this, key, cultureSelector );
};

Globalize.prototype.parseInt = function( value, radix, cultureSelector ) {
	return Globalize.parseInt.call( this, value, radix, cultureSelector );
};

Globalize.prototype.parseFloat = function( value, radix, cultureSelector ) {
	return Globalize.parseFloat.call( this, value, radix, cultureSelector );
};

Globalize.prototype.culture = function( cultureSelector ) {
	return Globalize.culture.call( this, cultureSelector );
};

//
// public singleton functions
//

Globalize.addCultureInfo = function( cultureName, baseCultureName, info ) {

	var base = {},
		isNew = false;

	if ( typeof cultureName !== "string" ) {
		// cultureName argument is optional string. If not specified, assume info is first
		// and only argument. Specified info deep-extends current culture.
		info = cultureName;
		cultureName = this.culture().name;
		base = this.cultures[ cultureName ];
	} else if ( typeof baseCultureName !== "string" ) {
		// baseCultureName argument is optional string. If not specified, assume info is second
		// argument. Specified info deep-extends specified culture.
		// If specified culture does not exist, create by deep-extending default
		info = baseCultureName;
		isNew = ( this.cultures[ cultureName ] == null );
		base = this.cultures[ cultureName ] || this.cultures[ "default" ];
	} else {
		// cultureName and baseCultureName specified. Assume a new culture is being created
		// by deep-extending an specified base culture
		isNew = true;
		base = this.cultures[ baseCultureName ];
	}

	this.cultures[ cultureName ] = extend(true, {},
		base,
		info
	);
	// Make the standard calendar the current culture if it's a new culture
	if ( isNew ) {
		this.cultures[ cultureName ].calendar = this.cultures[ cultureName ].calendars.standard;
	}
};

Globalize.findClosestCulture = function( name ) {
	var match;
	if ( !name ) {
		return this.findClosestCulture( this.cultureSelector ) || this.cultures[ "default" ];
	}
	if ( typeof name === "string" ) {
		name = name.split( "," );
	}
	if ( isArray(name) ) {
		var lang,
			cultures = this.cultures,
			list = name,
			i, l = list.length,
			prioritized = [];
		for ( i = 0; i < l; i++ ) {
			name = trim( list[i] );
			var pri, parts = name.split( ";" );
			lang = trim( parts[0] );
			if ( parts.length === 1 ) {
				pri = 1;
			}
			else {
				name = trim( parts[1] );
				if ( name.indexOf("q=") === 0 ) {
					name = name.substr( 2 );
					pri = parseFloat( name );
					pri = isNaN( pri ) ? 0 : pri;
				}
				else {
					pri = 1;
				}
			}
			prioritized.push({ lang: lang, pri: pri });
		}
		prioritized.sort(function( a, b ) {
			if ( a.pri < b.pri ) {
				return 1;
			} else if ( a.pri > b.pri ) {
				return -1;
			}
			return 0;
		});
		// exact match
		for ( i = 0; i < l; i++ ) {
			lang = prioritized[ i ].lang;
			match = cultures[ lang ];
			if ( match ) {
				return match;
			}
		}

		// neutral language match
		for ( i = 0; i < l; i++ ) {
			lang = prioritized[ i ].lang;
			do {
				var index = lang.lastIndexOf( "-" );
				if ( index === -1 ) {
					break;
				}
				// strip off the last part. e.g. en-US => en
				lang = lang.substr( 0, index );
				match = cultures[ lang ];
				if ( match ) {
					return match;
				}
			}
			while ( 1 );
		}

		// last resort: match first culture using that language
		for ( i = 0; i < l; i++ ) {
			lang = prioritized[ i ].lang;
			for ( var cultureKey in cultures ) {
				var culture = cultures[ cultureKey ];
				if ( culture.language == lang ) {
					return culture;
				}
			}
		}
	}
	else if ( typeof name === "object" ) {
		return name;
	}
	return match || null;
};

Globalize.format = function( value, format, cultureSelector ) {
	var culture = this.findClosestCulture( cultureSelector );
	if ( value instanceof Date ) {
		value = formatDate( value, format, culture );
	}
	else if ( typeof value === "number" ) {
		value = formatNumber( value, format, culture );
	}
	return value;
};

Globalize.localize = function( key, cultureSelector ) {
	return this.findClosestCulture( cultureSelector ).messages[ key ] ||
		this.cultures[ "default" ].messages[ key ];
};

Globalize.parseDate = function( value, formats, culture ) {
	culture = this.findClosestCulture( culture );

	var date, prop, patterns;
	if ( formats ) {
		if ( typeof formats === "string" ) {
			formats = [ formats ];
		}
		if ( formats.length ) {
			for ( var i = 0, l = formats.length; i < l; i++ ) {
				var format = formats[ i ];
				if ( format ) {
					date = parseExact( value, format, culture );
					if ( date ) {
						break;
					}
				}
			}
		}
	} else {
		patterns = culture.calendar.patterns;
		for ( prop in patterns ) {
			date = parseExact( value, patterns[prop], culture );
			if ( date ) {
				break;
			}
		}
	}

	return date || null;
};

Globalize.parseInt = function( value, radix, cultureSelector ) {
	return truncate( Globalize.parseFloat(value, radix, cultureSelector) );
};

Globalize.parseFloat = function( value, radix, cultureSelector ) {
	// radix argument is optional
	if ( typeof radix !== "number" ) {
		cultureSelector = radix;
		radix = 10;
	}

	var culture = this.findClosestCulture( cultureSelector );
	var ret = NaN,
		nf = culture.numberFormat;

	if ( value.indexOf(culture.numberFormat.currency.symbol) > -1 ) {
		// remove currency symbol
		value = value.replace( culture.numberFormat.currency.symbol, "" );
		// replace decimal seperator
		value = value.replace( culture.numberFormat.currency["."], culture.numberFormat["."] );
	}

	//Remove percentage character from number string before parsing
	if ( value.indexOf(culture.numberFormat.percent.symbol) > -1){
		value = value.replace( culture.numberFormat.percent.symbol, "" );
	}

	// remove spaces: leading, trailing and between - and number. Used for negative currency pt-BR
	value = value.replace( / /g, "" );

	// allow infinity or hexidecimal
	if ( regexInfinity.test(value) ) {
		ret = parseFloat( value );
	}
	else if ( !radix && regexHex.test(value) ) {
		ret = parseInt( value, 16 );
	}
	else {

		// determine sign and number
		var signInfo = parseNegativePattern( value, nf, nf.pattern[0] ),
			sign = signInfo[ 0 ],
			num = signInfo[ 1 ];

		// #44 - try parsing as "(n)"
		if ( sign === "" && nf.pattern[0] !== "(n)" ) {
			signInfo = parseNegativePattern( value, nf, "(n)" );
			sign = signInfo[ 0 ];
			num = signInfo[ 1 ];
		}

		// try parsing as "-n"
		if ( sign === "" && nf.pattern[0] !== "-n" ) {
			signInfo = parseNegativePattern( value, nf, "-n" );
			sign = signInfo[ 0 ];
			num = signInfo[ 1 ];
		}

		sign = sign || "+";

		// determine exponent and number
		var exponent,
			intAndFraction,
			exponentPos = num.indexOf( "e" );
		if ( exponentPos < 0 ) exponentPos = num.indexOf( "E" );
		if ( exponentPos < 0 ) {
			intAndFraction = num;
			exponent = null;
		}
		else {
			intAndFraction = num.substr( 0, exponentPos );
			exponent = num.substr( exponentPos + 1 );
		}
		// determine decimal position
		var integer,
			fraction,
			decSep = nf[ "." ],
			decimalPos = intAndFraction.indexOf( decSep );
		if ( decimalPos < 0 ) {
			integer = intAndFraction;
			fraction = null;
		}
		else {
			integer = intAndFraction.substr( 0, decimalPos );
			fraction = intAndFraction.substr( decimalPos + decSep.length );
		}
		// handle groups (e.g. 1,000,000)
		var groupSep = nf[ "," ];
		integer = integer.split( groupSep ).join( "" );
		var altGroupSep = groupSep.replace( /\u00A0/g, " " );
		if ( groupSep !== altGroupSep ) {
			integer = integer.split( altGroupSep ).join( "" );
		}
		// build a natively parsable number string
		var p = sign + integer;
		if ( fraction !== null ) {
			p += "." + fraction;
		}
		if ( exponent !== null ) {
			// exponent itself may have a number patternd
			var expSignInfo = parseNegativePattern( exponent, nf, "-n" );
			p += "e" + ( expSignInfo[0] || "+" ) + expSignInfo[ 1 ];
		}
		if ( regexParseFloat.test(p) ) {
			ret = parseFloat( p );
		}
	}
	return ret;
};

Globalize.culture = function( cultureSelector ) {
	// setter
	if ( typeof cultureSelector !== "undefined" ) {
		this.cultureSelector = cultureSelector;
	}
	// getter
	return this.findClosestCulture( cultureSelector ) || this.cultures[ "default" ];
};

}( this ));


/*
jQWidgets v3.0.3 (2013-Oct-01)
Copyright (c) 2011-2013 jQWidgets.
License: http://jqwidgets.com/license/
*/

(function(a){a.jqx=a.jqx||{};a.jqx.define=function(b,c,d){b[c]=function(){if(this.baseType){this.base=new b[this.baseType]();this.base.defineInstance()}this.defineInstance()};b[c].prototype.defineInstance=function(){};b[c].prototype.base=null;b[c].prototype.baseType=undefined;if(d&&b[d]){b[c].prototype.baseType=d}};a.jqx.invoke=function(e,d){if(d.length==0){return}var f=typeof(d)==Array||d.length>0?d[0]:d;var c=typeof(d)==Array||d.length>1?Array.prototype.slice.call(d,1):a({}).toArray();while(e[f]==undefined&&e.base!=null){e=e.base}if(e[f]!=undefined&&a.isFunction(e[f])){return e[f].apply(e,c)}if(typeof f=="string"){var b=f.toLowerCase();if(e[b]!=undefined&&a.isFunction(e[b])){return e[b].apply(e,c)}}return};a.jqx.hasProperty=function(c,b){if(typeof(b)=="object"){for(var e in b){var d=c;while(d){if(d.hasOwnProperty(e)){return true}if(d.hasOwnProperty(e.toLowerCase())){return true}d=d.base}return false}}else{while(c){if(c.hasOwnProperty(b)){return true}if(c.hasOwnProperty(b.toLowerCase())){return true}c=c.base}}return false};a.jqx.hasFunction=function(e,d){if(d.length==0){return false}if(e==undefined){return false}var f=typeof(d)==Array||d.length>0?d[0]:d;var c=typeof(d)==Array||d.length>1?Array.prototype.slice.call(d,1):{};while(e[f]==undefined&&e.base!=null){e=e.base}if(e[f]&&a.isFunction(e[f])){return true}if(typeof f=="string"){var b=f.toLowerCase();if(e[b]&&a.isFunction(e[b])){return true}}return false};a.jqx.isPropertySetter=function(c,b){if(b.length==1&&typeof(b[0])=="object"){return true}if(b.length==2&&typeof(b[0])=="string"&&!a.jqx.hasFunction(c,b)){return true}return false};a.jqx.validatePropertySetter=function(f,d,b){if(!a.jqx.propertySetterValidation){return true}if(d.length==1&&typeof(d[0])=="object"){for(var e in d[0]){var g=f;while(!g.hasOwnProperty(e)&&g.base){g=g.base}if(!g||!g.hasOwnProperty(e)){if(!b){var c=g.hasOwnProperty(e.toString().toLowerCase());if(!c){throw"Invalid property: "+e}else{return true}}return false}}return true}if(d.length!=2){if(!b){throw"Invalid property: "+d.length>=0?d[0]:""}return false}while(!f.hasOwnProperty(d[0])&&f.base){f=f.base}if(!f||!f.hasOwnProperty(d[0])){if(!b){throw"Invalid property: "+d[0]}return false}return true};a.jqx.set=function(c,b){if(b.length==1&&typeof(b[0])=="object"){a.each(b[0],function(d,e){var f=c;while(!f.hasOwnProperty(d)&&f.base!=null){f=f.base}if(f.hasOwnProperty(d)){a.jqx.setvalueraiseevent(f,d,e)}else{if(f.hasOwnProperty(d.toLowerCase())){a.jqx.setvalueraiseevent(f,d.toLowerCase(),e)}else{if(a.jqx.propertySetterValidation){throw"jqxCore: invalid property '"+d+"'"}}}})}else{if(b.length==2){while(!c.hasOwnProperty(b[0])&&c.base){c=c.base}if(c.hasOwnProperty(b[0])){a.jqx.setvalueraiseevent(c,b[0],b[1])}else{if(c.hasOwnProperty(b[0].toLowerCase())){a.jqx.setvalueraiseevent(c,b[0].toLowerCase(),b[1])}else{if(a.jqx.propertySetterValidation){throw"jqxCore: invalid property '"+b[0]+"'"}}}}}};a.jqx.setvalueraiseevent=function(c,d,e){var b=c[d];c[d]=e;if(!c.isInitialized){return}if(c.propertyChangedHandler!=undefined){c.propertyChangedHandler(c,d,b,e)}if(c.propertyChangeMap!=undefined&&c.propertyChangeMap[d]!=undefined){c.propertyChangeMap[d](c,d,b,e)}};a.jqx.get=function(e,d){if(d==undefined||d==null){return undefined}if(e.propertyMap){var c=e.propertyMap(d);if(c!=null){return c}}if(e.hasOwnProperty(d)){return e[d]}if(e.hasOwnProperty(d.toLowerCase())){return e[d.toLowerCase()]}var b=undefined;if(typeof(d)==Array){if(d.length!=1){return undefined}b=d[0]}else{if(typeof(d)=="string"){b=d}}while(!e.hasOwnProperty(b)&&e.base){e=e.base}if(e){return e[b]}return undefined};a.jqx.serialize=function(e){var b="";if(a.isArray(e)){b="[";for(var d=0;d<e.length;d++){if(d>0){b+=", "}b+=a.jqx.serialize(e[d])}b+="]"}else{if(typeof(e)=="object"){b="{";var c=0;for(var d in e){if(c++>0){b+=", "}b+=d+": "+a.jqx.serialize(e[d])}b+="}"}else{b=e.toString()}}return b};a.jqx.propertySetterValidation=true;a.jqx.jqxWidgetProxy=function(g,c,b){var d=a(c);var f=a.data(c,g);if(f==undefined){return undefined}var e=f.instance;if(a.jqx.hasFunction(e,b)){return a.jqx.invoke(e,b)}if(a.jqx.isPropertySetter(e,b)){if(a.jqx.validatePropertySetter(e,b)){a.jqx.set(e,b);return undefined}}else{if(typeof(b)=="object"&&b.length==0){return}else{if(typeof(b)=="object"&&b.length==1&&a.jqx.hasProperty(e,b[0])){return a.jqx.get(e,b[0])}else{if(typeof(b)=="string"&&a.jqx.hasProperty(e,b[0])){return a.jqx.get(e,b)}}}}throw"jqxCore: Invalid parameter '"+a.jqx.serialize(b)+"' does not exist.";return undefined};a.jqx.jqxWidget=function(b,d,j){var c=false;try{jqxArgs=Array.prototype.slice.call(j,0)}catch(h){jqxArgs=""}try{c=window.MSApp!=undefined}catch(h){}var g=b;var f="";if(d){f="_"+d}a.jqx.define(a.jqx,"_"+g,f);a.fn[g]=function(){var e=Array.prototype.slice.call(arguments,0);var k=null;if(e.length==0||(e.length==1&&typeof(e[0])=="object")){if(this.length==0){if(this.selector){throw new Error("Invalid jQuery Selector - "+this.selector+"! Please, check whether the used ID or CSS Class name is correct.")}else{throw new Error("Invalid jQuery Selector! Please, check whether the used ID or CSS Class name is correct.")}}return this.each(function(){var o=a(this);var n=this;var q=a.data(n,g);if(q==null){q={};q.element=n;q.host=o;q.instance=new a.jqx["_"+g]();if(n.id==""){n.id=a.jqx.utilities.createId()}q.instance.get=q.instance.set=q.instance.call=function(){var r=Array.prototype.slice.call(arguments,0);return a.jqx.jqxWidgetProxy(g,n,r)};a.data(n,g,q);a.data(n,"jqxWidget",q.instance);var p=new Array();var l=q.instance;while(l){l.isInitialized=false;p.push(l);l=l.base}p.reverse();p[0].theme="";a.jqx.jqxWidgetProxy(g,this,e);for(var m in p){l=p[m];if(m==0){l.host=o;l.element=n;l.WinJS=c}if(l!=undefined){if(l.createInstance!=null){if(c){MSApp.execUnsafeLocalFunction(function(){l.createInstance(e)})}else{l.createInstance(e)}}}}for(var m in p){if(p[m]!=undefined){p[m].isInitialized=true}}if(c){MSApp.execUnsafeLocalFunction(function(){q.instance.refresh(true)})}else{q.instance.refresh(true)}k=this}else{a.jqx.jqxWidgetProxy(g,this,e)}})}else{if(this.length==0){if(this.selector){throw new Error("Invalid jQuery Selector - "+this.selector+"! Please, check whether the used ID or CSS Class name is correct.")}else{throw new Error("Invalid jQuery Selector! Please, check whether the used ID or CSS Class name is correct.")}}this.each(function(){var l=a.jqx.jqxWidgetProxy(g,this,e);if(k==null){k=l}})}return k};try{a.extend(a.jqx["_"+g].prototype,Array.prototype.slice.call(j,0)[0])}catch(h){}a.extend(a.jqx["_"+g].prototype,{toThemeProperty:function(e,k){if(this.theme==""){return e}if(k!=null&&k){return e+"-"+this.theme}return e+" "+e+"-"+this.theme}});a.jqx["_"+g].prototype.refresh=function(){if(this.base){this.base.refresh()}};a.jqx["_"+g].prototype.createInstance=function(){};a.jqx["_"+g].prototype.propertyChangeMap={};a.jqx["_"+g].prototype.addHandler=function(m,k,e,l){switch(k){case"mousewheel":if(window.addEventListener){if(a.jqx.browser.mozilla){m[0].addEventListener("DOMMouseScroll",e,false)}else{m[0].addEventListener("mousewheel",e,false)}return false}break;case"mousemove":if(window.addEventListener&&!l){m[0].addEventListener("mousemove",e,false);return false}break}if(l==undefined||l==null){if(m.on){m.on(k,e)}else{m.bind(k,e)}}else{if(m.on){m.on(k,l,e)}else{m.bind(k,l,e)}}};a.jqx["_"+g].prototype.removeHandler=function(l,k,e){switch(k){case"mousewheel":if(window.removeEventListener){if(a.jqx.browser.mozilla){l[0].removeEventListener("DOMMouseScroll",e,false)}else{l[0].removeEventListener("mousewheel",e,false)}return false}break;case"mousemove":if(e){if(window.removeEventListener){l[0].removeEventListener("mousemove",e,false)}}break}if(k==undefined){if(l.off){l.off()}else{l.unbind()}return}if(e==undefined){if(l.off){l.off(k)}else{l.unbind(k)}}else{if(l.off){l.off(k,e)}else{l.unbind(k,e)}}}};a.jqx.utilities=a.jqx.utilities||{};a.extend(a.jqx.utilities,{scrollBarSize:15,touchScrollBarSize:10,createId:function(){var b=function(){return(((1+Math.random())*65536)|0).toString(16).substring(1)};return"jqxWidget"+b()+b()},setTheme:function(f,g,e){if(typeof e==="undefined"){return}var h=e[0].className.split(" "),b=[],j=[],d=e.children();for(var c=0;c<h.length;c+=1){if(h[c].indexOf(f)>=0){if(f.length>0){b.push(h[c]);j.push(h[c].replace(f,g))}else{j.push(h[c]+"-"+g)}}}this._removeOldClasses(b,e);this._addNewClasses(j,e);for(var c=0;c<d.length;c+=1){this.setTheme(f,g,a(d[c]))}},_removeOldClasses:function(d,c){for(var b=0;b<d.length;b+=1){c.removeClass(d[b])}},_addNewClasses:function(d,c){for(var b=0;b<d.length;b+=1){c.addClass(d[b])}},getOffset:function(b){var d=a.jqx.mobile.getLeftPos(b[0]);var c=a.jqx.mobile.getTopPos(b[0]);return{top:c,left:d}},resize:function(d,m,l,k){if(k===undefined){k=true}var g=-1;var f=this;var c=function(o){if(!f.hiddenWidgets){return -1}var p=-1;for(var n=0;n<f.hiddenWidgets.length;n++){if(o.id){if(f.hiddenWidgets[n].id==o.id){p=n;break}}else{if(f.hiddenWidgets[n].id==o[0].id){p=n;break}}}return p};if(this.resizeHandlers){for(var e=0;e<this.resizeHandlers.length;e++){if(d.id){if(this.resizeHandlers[e].id==d.id){g=e;break}}else{if(this.resizeHandlers[e].id==d[0].id){g=e;break}}}if(l===true){if(g!=-1){this.resizeHandlers.splice(g,1)}if(this.resizeHandlers.length==0){var j=a(window);if(j.off){j.off("resize.jqx");j.off("orientationchange.jqx");j.off("orientationchanged.jqx")}else{j.unbind("resize.jqx");j.unbind("orientationchange.jqx");j.unbind("orientationchanged.jqx")}this.resizeHandlers=null}var b=c(d);if(b!=-1&&this.hiddenWidgets){this.hiddenWidgets.splice(b,1)}return}}else{if(l===true){var b=c(d);if(b!=-1&&this.hiddenWidgets){this.hiddenWidgets.splice(b,1)}return}}var f=this;var h=function(n,o){if(!f.resizeHandlers){return}var p=function(t,r){var s=t.widget.parents().length;var q=r.widget.parents().length;try{if(s<q){return -1}if(s>q){return 1}}catch(u){var v=u}return 0};f.hiddenWidgets=new Array();f.resizeHandlers.sort(p);a.each(f.resizeHandlers,function(s,v){var u=this.widget.data();if(!u){return true}if(!u.jqxWidget){return true}var t=u.jqxWidget.width;var q=u.jqxWidget.height;var r=false;if(t!=null&&t.toString().indexOf("%")!=-1){r=true}if(q!=null&&q.toString().indexOf("%")!=-1){r=true}if(a.jqx.isHidden(this.widget)){if(c(this.widget)===-1){f.hiddenWidgets.push(this)}}else{if(n===undefined||n!==true){if(r){this.callback(o);if(f.hiddenWidgets.indexOf(this)>=0){f.hiddenWidgets.splice(f.hiddenWidgets.indexOf(this),1)}}}}});if(f.hiddenWidgets.length>0){f.hiddenWidgets.sort(p);if(f.__resizeInterval){clearInterval(f.__resizeInterval)}f.__resizeInterval=setInterval(function(){var q=false;var r=new Array();a.each(f.hiddenWidgets,function(s,t){if(a.jqx.isHidden(this.widget)){q=true;r.push(this)}else{this.callback(o)}});f.hiddenWidgets=r;if(!q){clearInterval(f.__resizeInterval)}},100)}};if(!this.resizeHandlers){this.resizeHandlers=new Array();var j=a(window);if(j.on){j.on("resize.jqx",function(n){h(null,"resize")});j.on("orientationchange.jqx",function(n){h(null,"orientationchange")});j.on("orientationchanged.jqx",function(n){h(null,"orientationchange")})}else{j.bind("resize.jqx",function(n){h(null,"orientationchange")});j.bind("orientationchange.jqx",function(n){h(null,"orientationchange")});j.bind("orientationchanged.jqx",function(n){h(null,"orientationchange")})}}if(k){if(g===-1){this.resizeHandlers.push({id:d[0].id,widget:d,callback:m})}}if(a.jqx.isHidden(d)&&k===true){h(true)}},html:function(c,d){if(!a(c).on){return a(c).html(d)}try{return jQuery.access(c,function(s){var f=c[0]||{},m=0,j=c.length;if(s===undefined){return f.nodeType===1?f.innerHTML.replace(rinlinejQuery,""):undefined}var r=/<(?:script|style|link)/i,n="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",h=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,p=/<([\w:]+)/,g=/<(?:script|object|embed|option|style)/i,k=new RegExp("<(?:"+n+")[\\s/>]","i"),q=/^\s+/,t={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};if(typeof s==="string"&&!r.test(s)&&(jQuery.support.htmlSerialize||!k.test(s))&&(jQuery.support.leadingWhitespace||!q.test(s))&&!t[(p.exec(s)||["",""])[1].toLowerCase()]){s=s.replace(h,"<$1></$2>");try{for(;m<j;m++){f=this[m]||{};if(f.nodeType===1){jQuery.cleanData(f.getElementsByTagName("*"));f.innerHTML=s}}f=0}catch(o){}}if(f){c.empty().append(s)}},null,d,arguments.length)}catch(b){return a(c).html(d)}},hasTransform:function(d){var c="";c=d.css("transform");if(c==""||c=="none"){c=d.parents().css("transform");if(c==""||c=="none"){var b=a.jqx.utilities.getBrowser();if(b.browser=="msie"){c=d.css("-ms-transform");if(c==""||c=="none"){c=d.parents().css("-ms-transform")}}else{if(b.browser=="chrome"){c=d.css("-webkit-transform");if(c==""||c=="none"){c=d.parents().css("-webkit-transform")}}else{if(b.browser=="opera"){c=d.css("-o-transform");if(c==""||c=="none"){c=d.parents().css("-o-transform")}}else{if(b.browser=="mozilla"){c=d.css("-moz-transform");if(c==""||c=="none"){c=d.parents().css("-moz-transform")}}}}}}else{return c!=""&&c!="none"}}if(c==""||c=="none"){c=a(document.body).css("transform")}return c!=""&&c!="none"&&c!=null},getBrowser:function(){var c=navigator.userAgent.toLowerCase();var b=/(chrome)[ \/]([\w.]+)/.exec(c)||/(webkit)[ \/]([\w.]+)/.exec(c)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(c)||/(msie) ([\w.]+)/.exec(c)||c.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(c)||[];var d={browser:b[1]||"",version:b[2]||"0"};d[b[1]]=b[1];return d}});a.jqx.browser=a.jqx.utilities.getBrowser();a.jqx.isHidden=function(d){try{var b=d[0].offsetWidth,e=d[0].offsetHeight;if(b===0||e===0){return true}else{return false}}catch(c){return false}};a.jqx.ariaEnabled=true;a.jqx.aria=function(c,e,d){if(!a.jqx.ariaEnabled){return}if(e==undefined){a.each(c.aria,function(g,h){var k=!c.base?c.host.attr(g):c.base.host.attr(g);if(k!=undefined&&!a.isFunction(k)){var j=k;switch(h.type){case"number":j=new Number(k);if(isNaN(j)){j=k}break;case"boolean":j=k=="true"?true:false;break;case"date":j=new Date(k);if(j=="Invalid Date"||isNaN(j)){j=k}break}c[h.name]=j}else{var k=c[h.name];if(a.isFunction(k)){k=c[h.name]()}if(k==undefined){k=""}try{!c.base?c.host.attr(g,k.toString()):c.base.host.attr(g,k.toString())}catch(f){}}})}else{try{if(c.host){if(!c.base){if(c.host){if(c.element.setAttribute){c.element.setAttribute(e,d.toString())}else{c.host.attr(e,d.toString())}}else{c.attr(e,d.toString())}}else{if(c.base.host){c.base.host.attr(e,d.toString())}else{c.attr(e,d.toString())}}}else{if(c.setAttribute){c.setAttribute(e,d.toString())}}}catch(b){}}};if(!Array.prototype.indexOf){Array.prototype.indexOf=function(c){var b=this.length;var d=Number(arguments[1])||0;d=(d<0)?Math.ceil(d):Math.floor(d);if(d<0){d+=b}for(;d<b;d++){if(d in this&&this[d]===c){return d}}return -1}}a.jqx.mobile=a.jqx.mobile||{};a.jqx.position=function(b){var e=parseInt(b.pageX);var d=parseInt(b.pageY);if(a.jqx.mobile.isTouchDevice()){var c=a.jqx.mobile.getTouches(b);var f=c[0];e=parseInt(f.pageX);d=parseInt(f.pageY)}return{left:e,top:d}};a.extend(a.jqx.mobile,{_touchListener:function(h,f){var b=function(j,l){var k=document.createEvent("MouseEvents");k.initMouseEvent(j,l.bubbles,l.cancelable,l.view,l.detail,l.screenX,l.screenY,l.clientX,l.clientY,l.ctrlKey,l.altKey,l.shiftKey,l.metaKey,l.button,l.relatedTarget);k._pageX=l.pageX;k._pageY=l.pageY;return k};var g={mousedown:"touchstart",mouseup:"touchend",mousemove:"touchmove"};var d=b(g[h.type],h);h.target.dispatchEvent(d);var c=h.target["on"+g[h.type]];if(typeof c==="function"){c(h)}},setMobileSimulator:function(c,e){if(this.isTouchDevice()){return}this.simulatetouches=true;if(e==false){this.simulatetouches=false}var d={mousedown:"touchstart",mouseup:"touchend",mousemove:"touchmove"};var b=this;if(window.addEventListener){var f=function(){for(var g in d){if(c.addEventListener){c.removeEventListener(g,b._touchListener);c.addEventListener(g,b._touchListener,false)}}};if(a.jqx.browser.msie){f()}else{f()}}},isTouchDevice:function(){if(this.touchDevice!=undefined){return this.touchDevice}var b="Browser CodeName: "+navigator.appCodeName+"";b+="Browser Name: "+navigator.appName+"";b+="Browser Version: "+navigator.appVersion+"";b+="Platform: "+navigator.platform+"";b+="User-agent header: "+navigator.userAgent+"";if(b.indexOf("Android")!=-1){return true}if(b.indexOf("IEMobile")!=-1){return true}if(b.indexOf("Windows Phone")!=-1){return true}if(b.indexOf("WPDesktop")!=-1){return true}if(b.indexOf("ZuneWP7")!=-1){return true}if(b.indexOf("BlackBerry")!=-1&&b.indexOf("Mobile Safari")!=-1){return true}if(b.indexOf("ipod")!=-1){return true}if(b.indexOf("nokia")!=-1||b.indexOf("Nokia")!=-1){return true}if(b.indexOf("Chrome/17")!=-1){return false}if(b.indexOf("CrOS")!=-1){return false}if(b.indexOf("Opera")!=-1&&b.indexOf("Mobi")==-1&&b.indexOf("Mini")==-1&&b.indexOf("Platform: Win")!=-1){return false}if(b.indexOf("Opera")!=-1&&b.indexOf("Mobi")!=-1&&b.indexOf("Opera Mobi")!=-1){return true}var c={ios:"i(?:Pad|Phone|Pod)(?:.*)CPU(?: iPhone)? OS ",android:"(Android |HTC_|Silk/)",blackberry:"BlackBerry(?:.*)Version/",rimTablet:"RIM Tablet OS ",webos:"(?:webOS|hpwOS)/",bada:"Bada/"};try{if(this.touchDevice!=undefined){return this.touchDevice}this.touchDevice=false;for(i in c){if(c.hasOwnProperty(i)){prefix=c[i];match=b.match(new RegExp("(?:"+prefix+")([^\\s;]+)"));if(match){if(i.toString()=="blackberry"){this.touchDevice=false;return false}this.touchDevice=true;return true}}}if(navigator.platform.toLowerCase().indexOf("win")!=-1){this.touchDevice=false;return false}document.createEvent("TouchEvent");this.touchDevice=true;return this.touchDevice}catch(d){this.touchDevice=false;return false}},getLeftPos:function(b){var c=b.offsetLeft;while((b=b.offsetParent)!=null){if(b.tagName!="HTML"){c+=b.offsetLeft;if(document.all){c+=b.clientLeft}}}return c},getTopPos:function(c){var e=c.offsetTop;var b=a(c).coord();while((c=c.offsetParent)!=null){if(c.tagName!="HTML"){e+=(c.offsetTop-c.scrollTop);if(document.all){e+=c.clientTop}}}var d=navigator.userAgent.toLowerCase();var f=(d.indexOf("windows phone")!=-1||d.indexOf("WPDesktop")!=-1||d.indexOf("ZuneWP7")!=-1||d.indexOf("msie 9")!=-1||d.indexOf("msie 11")!=-1||d.indexOf("msie 10")!=-1)&&d.indexOf("touch")!=-1;if(f){return b.top}if(this.isSafariMobileBrowser()){if(this.isSafari4MobileBrowser()&&this.isIPadSafariMobileBrowser()){return e}if(d.indexOf("version/7")!=-1){return b.top}e=e+a(window).scrollTop()}return e},isChromeMobileBrowser:function(){var c=navigator.userAgent.toLowerCase();var b=c.indexOf("android")!=-1;return b},isOperaMiniMobileBrowser:function(){var c=navigator.userAgent.toLowerCase();var b=c.indexOf("opera mini")!=-1||c.indexOf("opera mobi")!=-1;return b},isOperaMiniBrowser:function(){var c=navigator.userAgent.toLowerCase();var b=c.indexOf("opera mini")!=-1;return b},isNewSafariMobileBrowser:function(){var c=navigator.userAgent.toLowerCase();var b=c.indexOf("ipad")!=-1||c.indexOf("iphone")!=-1||c.indexOf("ipod")!=-1;b=b&&(c.indexOf("version/5")!=-1);return b},isSafari4MobileBrowser:function(){var c=navigator.userAgent.toLowerCase();var b=c.indexOf("ipad")!=-1||c.indexOf("iphone")!=-1||c.indexOf("ipod")!=-1;b=b&&(c.indexOf("version/4")!=-1);return b},isWindowsPhone:function(){var c=navigator.userAgent.toLowerCase();var b=(c.indexOf("windows phone")!=-1||c.indexOf("WPDesktop")!=-1||c.indexOf("ZuneWP7")!=-1||c.indexOf("msie 9")!=-1||c.indexOf("msie 11")!=-1||c.indexOf("msie 10")!=-1)&&c.indexOf("touch")!=-1;return b},isSafariMobileBrowser:function(){var c=navigator.userAgent.toLowerCase();var b=c.indexOf("ipad")!=-1||c.indexOf("iphone")!=-1||c.indexOf("ipod")!=-1;return b},isIPadSafariMobileBrowser:function(){var c=navigator.userAgent.toLowerCase();var b=c.indexOf("ipad")!=-1;return b},isMobileBrowser:function(){var c=navigator.userAgent.toLowerCase();var b=c.indexOf("ipad")!=-1||c.indexOf("iphone")!=-1||c.indexOf("android")!=-1;return b},getTouches:function(b){if(b.originalEvent){if(b.originalEvent.touches&&b.originalEvent.touches.length){return b.originalEvent.touches}else{if(b.originalEvent.changedTouches&&b.originalEvent.changedTouches.length){return b.originalEvent.changedTouches}}}if(!b.touches){b.touches=new Array();b.touches[0]=b.originalEvent!=undefined?b.originalEvent:b;if(b.originalEvent!=undefined&&b.pageX){b.touches[0]=b}if(b.type=="mousemove"){b.touches[0]=b}}return b.touches},getTouchEventName:function(b){if(this.isWindowsPhone()){if(b.toLowerCase().indexOf("start")!=-1){return"MSPointerDown"}if(b.toLowerCase().indexOf("move")!=-1){return"MSPointerMove"}if(b.toLowerCase().indexOf("end")!=-1){return"MSPointerUp"}}else{return b}},dispatchMouseEvent:function(b,f,d){if(this.simulatetouches){return}var c=document.createEvent("MouseEvent");c.initMouseEvent(b,true,true,f.view,1,f.screenX,f.screenY,f.clientX,f.clientY,false,false,false,false,0,null);if(d!=null){d.dispatchEvent(c)}},getRootNode:function(b){while(b.nodeType!==1){b=b.parentNode}return b},setTouchScroll:function(b,c){if(!this.enableScrolling){this.enableScrolling=[]}this.enableScrolling[c]=b},touchScroll:function(d,y,g,D,b,k){if(d==null){return}var B=this;var t=0;var j=0;var l=0;var u=0;var m=0;var n=0;if(!this.scrolling){this.scrolling=[]}this.scrolling[D]=false;var h=false;var q=a(d);var v=["select","input","textarea"];var c=0;var e=0;if(!this.enableScrolling){this.enableScrolling=[]}this.enableScrolling[D]=true;var D=D;var C=this.getTouchEventName("touchstart")+".touchScroll";var p=this.getTouchEventName("touchend")+".touchScroll";var A=this.getTouchEventName("touchmove")+".touchScroll";var c=function(E){if(!B.enableScrolling[D]){return true}if(a.inArray(E.target.tagName.toLowerCase(),v)!==-1){return}var F=B.getTouches(E);var G=F[0];if(F.length==1){B.dispatchMouseEvent("mousedown",G,B.getRootNode(G.target))}h=false;j=G.pageY;m=G.pageX;if(B.simulatetouches){j=G._pageY;m=G._pageX}B.scrolling[D]=true;t=0;u=0;return true};if(q.on){q.on(C,c)}else{q.bind(C,c)}var x=function(J){if(!B.enableScrolling[D]){return true}if(!B.scrolling[D]){return true}var L=B.getTouches(J);if(L.length>1){return true}var H=L[0].pageY;var I=L[0].pageX;if(B.simulatetouches){H=L[0]._pageY;I=L[0]._pageX}var E=H-j;var F=I-m;e=H;touchHorizontalEnd=I;l=E-t;n=F-u;h=true;t=E;u=F;g(-n*1,-l*1,F,E,J);var G=b!=null?b[0].style.display!="none":true;var K=k!=null?k[0].style.display!="none":true;if(G||K){if((n!==0&&G)||(l!==0&&K)){J.preventDefault();J.stopPropagation();if(J.preventManipulation){J.preventManipulation()}return false}}};if(q.on){q.on(A,x)}else{q.bind(A,x)}if(this.simulatetouches){var o=a(window).on!=undefined||a(window).bind;var z=function(E){B.scrolling[D]=false};a(window).on!=undefined?a(document).on("mouseup.touchScroll",z):a(document).bind("mouseup.touchScroll",z);if(window.frameElement){if(window.top!=null){var r=function(E){B.scrolling[D]=false};if(window.top.document){a(window.top.document).on?a(window.top.document).on("mouseup",r):a(window.top.document).bind("mouseup",r)}}}var s=a(document).on!=undefined||a(document).bind;var w=function(E){if(!B.scrolling[D]){return true}B.scrolling[D]=false;var G=B.getTouches(E)[0],F=B.getRootNode(G.target);B.dispatchMouseEvent("mouseup",G,F);B.dispatchMouseEvent("click",G,F)};a(document).on!=undefined?a(document).on("touchend",w):a(document).bind("touchend",w)}var f=function(E){if(!B.enableScrolling[D]){return true}var G=B.getTouches(E)[0];if(!B.scrolling[D]){return true}B.scrolling[D]=false;if(h){B.dispatchMouseEvent("mouseup",G,F)}else{var G=B.getTouches(E)[0],F=B.getRootNode(G.target);B.dispatchMouseEvent("mouseup",G,F);B.dispatchMouseEvent("click",G,F);return true}};q.on?q.on(p+" touchcancel.touchScroll",f):q.bind(p+" touchcancel.touchScroll",f)}});a.jqx.cookie=a.jqx.cookie||{};a.extend(a.jqx.cookie,{cookie:function(e,f,c){if(arguments.length>1&&String(f)!=="[object Object]"){c=jQuery.extend({},c);if(f===null||f===undefined){c.expires=-1}if(typeof c.expires==="number"){var h=c.expires,d=c.expires=new Date();d.setDate(d.getDate()+h)}f=String(f);return(document.cookie=[encodeURIComponent(e),"=",c.raw?f:encodeURIComponent(f),c.expires?"; expires="+c.expires.toUTCString():"",c.path?"; path="+c.path:"",c.domain?"; domain="+c.domain:"",c.secure?"; secure":""].join(""))}c=f||{};var b,g=c.raw?function(j){return j}:decodeURIComponent;return(b=new RegExp("(?:^|; )"+encodeURIComponent(e)+"=([^;]*)").exec(document.cookie))?g(b[1]):null}});a.jqx.string=a.jqx.string||{};a.extend(a.jqx.string,{replace:function(f,d,e){if(d===e){return this}var b=f;var c=b.indexOf(d);while(c!=-1){b=b.replace(d,e);c=b.indexOf(d)}return b},contains:function(b,c){if(b==null||c==null){return false}return b.indexOf(c)!=-1},containsIgnoreCase:function(b,c){if(b==null||c==null){return false}return b.toUpperCase().indexOf(c.toUpperCase())!=-1},equals:function(b,c){if(b==null||c==null){return false}b=this.normalize(b);if(c.length==b.length){return b.slice(0,c.length)==c}return false},equalsIgnoreCase:function(b,c){if(b==null||c==null){return false}b=this.normalize(b);if(c.length==b.length){return b.toUpperCase().slice(0,c.length)==c.toUpperCase()}return false},startsWith:function(b,c){if(b==null||c==null){return false}return b.slice(0,c.length)==c},startsWithIgnoreCase:function(b,c){if(b==null||c==null){return false}return b.toUpperCase().slice(0,c.length)==c.toUpperCase()},normalize:function(b){if(b.charCodeAt(b.length-1)==65279){b=b.substring(0,b.length-1)}return b},endsWith:function(b,c){if(b==null||c==null){return false}b=this.normalize(b);return b.slice(-c.length)==c},endsWithIgnoreCase:function(b,c){if(b==null||c==null){return false}b=this.normalize(b);return b.toUpperCase().slice(-c.length)==c.toUpperCase()}});a.extend(jQuery.easing,{easeOutBack:function(f,g,e,k,j,h){if(h==undefined){h=1.70158}return k*((g=g/j-1)*g*((h+1)*g+h)+1)+e},easeInQuad:function(f,g,e,j,h){return j*(g/=h)*g+e},easeInOutCirc:function(f,g,e,j,h){if((g/=h/2)<1){return -j/2*(Math.sqrt(1-g*g)-1)+e}return j/2*(Math.sqrt(1-(g-=2)*g)+1)+e},easeInOutSine:function(f,g,e,j,h){return -j/2*(Math.cos(Math.PI*g/h)-1)+e},easeInCubic:function(f,g,e,j,h){return j*(g/=h)*g*g+e},easeOutCubic:function(f,g,e,j,h){return j*((g=g/h-1)*g*g+1)+e},easeInOutCubic:function(f,g,e,j,h){if((g/=h/2)<1){return j/2*g*g*g+e}return j/2*((g-=2)*g*g+2)+e},easeInSine:function(f,g,e,j,h){return -j*Math.cos(g/h*(Math.PI/2))+j+e},easeOutSine:function(f,g,e,j,h){return j*Math.sin(g/h*(Math.PI/2))+e},easeInOutSine:function(f,g,e,j,h){return -j/2*(Math.cos(Math.PI*g/h)-1)+e}})})(jQuery);(function(b){b.extend(jQuery.event.special,{close:{noBubble:true},open:{noBubble:true},expand:{noBubble:true},collapse:{noBubble:true},tabclick:{noBubble:true},selected:{noBubble:true},expanded:{noBubble:true},collapsed:{noBubble:true},valuechanged:{noBubble:true},expandedItem:{noBubble:true},collapsedItem:{noBubble:true},expandingItem:{noBubble:true},collapsingItem:{noBubble:true}});b.fn.extend({ischildof:function(f){var d=b(this).parents().get();for(var c=0;c<d.length;c++){if(typeof f!="string"){var e=d[c];if(f!==undefined){if(e==f[0]){return true}}}else{if(f!==undefined){if(b(d[c]).is(f)){return true}}}}return false}});var a=this.originalVal=b.fn.val;b.fn.val=function(d){if(typeof d=="undefined"){if(b(this).hasClass("jqx-widget")){var c=b(this).data().jqxWidget;if(c&&c.val){return c.val()}}return a.call(this)}else{if(b(this).hasClass("jqx-widget")){var c=b(this).data().jqxWidget;if(c&&c.val){if(arguments.length!=2){return c.val(d)}else{return c.val(d,arguments[1])}}}return a.call(this,d)}};b.fn.coord=function(o){var e,k,j={top:0,left:0},f=this[0],m=f&&f.ownerDocument;if(!m){return}e=m.documentElement;if(!jQuery.contains(e,f)){return j}if(typeof f.getBoundingClientRect!==undefined){j=f.getBoundingClientRect()}var d=function(p){return jQuery.isWindow(p)?p:p.nodeType===9?p.defaultView||p.parentWindow:false};k=d(m);var h=0;var c=0;var g=navigator.userAgent.toLowerCase();var n=g.indexOf("ipad")!=-1||g.indexOf("iphone")!=-1;if(n){h=2}if(true==o){if(b(document.body).css("position")!="static"){var l=b(document.body).coord();h=-l.left;c=-l.top}}return{top:c+j.top+(k.pageYOffset||e.scrollTop)-(e.clientTop||0),left:h+j.left+(k.pageXOffset||e.scrollLeft)-(e.clientLeft||0)}}})(jQuery);

/*
jQWidgets v3.0.3 (2013-Oct-01)
Copyright (c) 2011-2013 jQWidgets.
License: http://jqwidgets.com/license/
*/

(function(a){a.jqx.cssroundedcorners=function(b){var c={all:"jqx-rc-all",top:"jqx-rc-t",bottom:"jqx-rc-b",left:"jqx-rc-l",right:"jqx-rc-r","top-right":"jqx-rc-tr","top-left":"jqx-rc-tl","bottom-right":"jqx-rc-br","bottom-left":"jqx-rc-bl"};for(prop in c){if(!c.hasOwnProperty(prop)){continue}if(b==prop){return c[prop]}}};a.jqx.jqxWidget("jqxButton","",{});a.extend(a.jqx._jqxButton.prototype,{defineInstance:function(){this.cursor="arrow";this.roundedCorners="all";this.disabled=false;this.height=null;this.width=null;this.overrideTheme=false;this.enableHover=true;this.rtl=false;this._ariaDisabled=false;this.aria={"aria-disabled":{name:"disabled",type:"boolean"}}},createInstance:function(d){var b=this;this._setSize();if(!this._ariaDisabled){this.host.attr("role","button")}if(!this.overrideTheme){this.host.addClass(this.toThemeProperty(a.jqx.cssroundedcorners(this.roundedCorners)));this.host.addClass(this.toThemeProperty("jqx-button"));this.host.addClass(this.toThemeProperty("jqx-widget"))}this.isTouchDevice=a.jqx.mobile.isTouchDevice();if(!this._ariaDisabled){a.jqx.aria(this)}if(this.cursor!="arrow"){if(!this.disabled){this.host.css({cursor:this.cursor})}else{this.host.css({cursor:"arrow"})}}this.addHandler(this.host,"mouseenter mouseleave mousedown focus blur",function(g){switch(g.type){case"mouseenter":if(!this.isTouchDevice){if(!b.disabled&&b.enableHover){b.isMouseOver=true;b.refresh()}}break;case"mouseleave":if(!this.isTouchDevice){if(!b.disabled&&b.enableHover){b.isMouseOver=false;b.refresh()}}break;case"mousedown":if(!b.disabled){b.isPressed=true;b.refresh()}break;case"focus":if(!b.disabled){b.isFocused=true;b.refresh()}break;case"blur":if(!b.disabled){b.isFocused=false;b.refresh()}break}});this.mouseupfunc=function(g){if(!b.disabled){b.isPressed=false;b.refresh()}};this.addHandler(a(document),"mouseup.button"+this.element.id,this.mouseupfunc);try{if(document.referrer!=""||window.frameElement){if(window.top!=null&&window.top!=window.self){var f="";if(window.parent&&document.referrer){f=document.referrer}if(f.indexOf(document.location.host)!=-1){var e=function(g){b.isPressed=false;b.refresh()};if(window.top.document){this.addHandler(a(window.top.document),"mouseup",e)}}}}}catch(c){}this.propertyChangeMap.roundedCorners=function(g,i,h,j){g.refresh()};this.propertyChangeMap.width=function(g,i,h,j){g._setSize();g.refresh()};this.propertyChangeMap.height=function(g,i,h,j){g._setSize();g.refresh()};this.propertyChangeMap.disabled=function(g,i,h,j){if(h!=j){g.host[0].disabled=j;g.refresh();if(!j){g.host.css({cursor:g.cursor})}else{g.host.css({cursor:"arrow"})}a.jqx.aria(g,"aria-disabled",g.disabled)}};this.propertyChangeMap.rtl=function(g,i,h,j){if(h!=j){g.refresh()}};this.propertyChangeMap.theme=function(g,i,h,j){g.host.removeClass();g.host.addClass(g.toThemeProperty("jqx-button"));g.host.addClass(g.toThemeProperty("jqx-widget"));if(!g.overrideTheme){g.host.addClass(g.toThemeProperty(a.jqx.cssroundedcorners(g.roundedCorners)))}g._oldCSSCurrent=null;g.refresh()}},val:function(){var b=this.host.find("input");if(b.length>0){if(arguments.length==0||typeof(value)=="object"){return b.val()}b.val(value);this.refresh();return b.val()}if(arguments.length==0||typeof(value)=="object"){return this.element.value}this.element.value=arguments[0];this.refresh()},_setSize:function(){if(this.width!=null&&(this.width.toString().indexOf("px")!=-1||this.width.toString().indexOf("%")!=-1)){this.host.css("width",this.width)}else{if(this.width!=undefined&&!isNaN(this.width)){this.host.css("width",this.width)}}if(this.height!=null&&(this.height.toString().indexOf("px")!=-1||this.height.toString().indexOf("%")!=-1)){this.host.css("height",parseInt(this.height)+2)}else{if(this.height!=undefined&&!isNaN(this.height)){this.host.css("height",parseInt(this.height)+2)}}},_removeHandlers:function(){this.removeHandler(this.host,"selectstart");this.removeHandler(this.host,"click");this.removeHandler(this.host,"focus");this.removeHandler(this.host,"blur");this.removeHandler(this.host,"mouseenter");this.removeHandler(this.host,"mouseleave");this.removeHandler(this.host,"mousedown");this.removeHandler(a(document),"mouseup.button"+this.element.id,this.mouseupfunc);this.mouseupfunc=null;delete this.mouseupfunc},focus:function(){this.host.focus()},destroy:function(){this._removeHandlers();this.host.removeClass();this.host.removeData();this.host.remove();delete this.set;delete this.get;delete this.call},render:function(){this.refresh()},refresh:function(){if(this.overrideTheme){return}var d=this.toThemeProperty("jqx-fill-state-focus");var h=this.toThemeProperty("jqx-fill-state-disabled");var b=this.toThemeProperty("jqx-fill-state-normal");var g=this.toThemeProperty("jqx-fill-state-hover");var e=this.toThemeProperty("jqx-fill-state-pressed");var f=this.toThemeProperty("jqx-fill-state-pressed");var c="";this.host[0].disabled=this.disabled;if(this.disabled){c=h}else{if(this.isMouseOver&&!this.isTouchDevice){if(this.isPressed){c=f}else{c=g}}else{if(this.isPressed){c=e}else{c=b}}}if(this.isFocused){c+=" "+d}if(c!=this._oldCSSCurrent){if(this._oldCSSCurrent){this.host.removeClass(this._oldCSSCurrent)}this.host.addClass(c);this._oldCSSCurrent=c}if(this.rtl){this.host.addClass(this.toThemeProperty("jqx-rtl"));this.host.css("direction","rtl")}}});a.jqx.jqxWidget("jqxLinkButton","",{});a.extend(a.jqx._jqxLinkButton.prototype,{defineInstance:function(){this.disabled=false;this.height=null;this.width=null;this.rtl=false;this.href=null},createInstance:function(d){var c=this;this.host.onselectstart=function(){return false};this.host.attr("role","button");var b=this.height||this.host.height();var e=this.width||this.host.width();this.href=this.host.attr("href");this.target=this.host.attr("target");this.content=this.host.text();this.element.innerHTML="";this.host.append("<input type='button' class='jqx-wrapper'/>");var f=this.host.find("input");f.addClass(this.toThemeProperty("jqx-reset"));f.width(e);f.height(b);f.val(this.content);this.host.find("tr").addClass(this.toThemeProperty("jqx-reset"));this.host.find("td").addClass(this.toThemeProperty("jqx-reset"));this.host.find("tbody").addClass(this.toThemeProperty("jqx-reset"));this.host.css("color","inherit");this.host.addClass(this.toThemeProperty("jqx-link"));f.css({width:e});f.css({height:b});var g=d==undefined?{}:d[0]||{};f.jqxButton(g);if(this.disabled){this.host[0].disabled=true}this.propertyChangeMap.disabled=function(h,j,i,k){c.host[0].disabled=k};this.addHandler(f,"click",function(h){if(!this.disabled){c.onclick(h)}return false})},onclick:function(b){if(this.target!=null){window.open(this.href,this.target)}else{window.location=this.href}}});a.jqx.jqxWidget("jqxRepeatButton","jqxButton",{});a.extend(a.jqx._jqxRepeatButton.prototype,{defineInstance:function(){this.delay=50},createInstance:function(e){var c=this;var d=a.jqx.mobile.isTouchDevice();var b=!d?"mouseup."+this.base.element.id:"touchend."+this.base.element.id;var f=!d?"mousedown."+this.base.element.id:"touchstart."+this.base.element.id;this.addHandler(a(document),b,function(g){if(c.timeout!=null){clearTimeout(c.timeout);c.timeout=null;c.refresh()}if(c.timer!=undefined){clearInterval(c.timer);c.timer=null;c.refresh()}});this.addHandler(this.base.host,f,function(g){if(c.timer!=null){clearInterval(c.timer)}c.timeout=setTimeout(function(){clearInterval(c.timer);c.timer=setInterval(function(h){c.ontimer(h)},c.delay)},150)});this.mousemovefunc=function(g){if(!d){if(g.which==0){if(c.timer!=null){clearInterval(c.timer);c.timer=null}}}};this.addHandler(this.base.host,"mousemove",this.mousemovefunc)},destroy:function(){var c=a.jqx.mobile.isTouchDevice();var b=!c?"mouseup."+this.base.element.id:"touchend."+this.base.element.id;var d=!c?"mousedown."+this.base.element.id:"touchstart."+this.base.element.id;this.removeHandler(this.base.host,"mousemove",this.mousemovefunc);this.removeHandler(this.base.host,d);this.removeHandler(a(document),b);this.timer=null;delete this.mousemovefunc;delete this.timer;this.base.destroy();delete this},stop:function(){clearInterval(this.timer);this.timer=null},ontimer:function(b){var b=new jQuery.Event("click");if(this.base!=null&&this.base.host!=null){this.base.host.trigger(b)}}});a.jqx.jqxWidget("jqxToggleButton","jqxButton",{});a.extend(a.jqx._jqxToggleButton.prototype,{defineInstance:function(){this.toggled=false;this.aria={"aria-checked":{name:"toggled",type:"boolean"},"aria-disabled":{name:"disabled",type:"boolean"}}},createInstance:function(c){var b=this;this.base.overrideTheme=true;this.isTouchDevice=a.jqx.mobile.isTouchDevice();a.jqx.aria(this);this.propertyChangeMap.toggled=function(d,f,e,g){d.refresh()};this.propertyChangeMap.disabled=function(d,f,e,g){b.base.disabled=g;d.refresh()};this.addHandler(this.base.host,"click",function(d){if(!b.base.disabled){b.toggle()}});if(!this.isTouchDevice){this.addHandler(this.base.host,"mouseenter",function(d){if(!b.base.disabled){b.refresh()}});this.addHandler(this.base.host,"mouseleave",function(d){if(!b.base.disabled){b.refresh()}})}this.addHandler(this.base.host,"mousedown",function(d){if(!b.base.disabled){b.refresh()}});this.addHandler(a(document),"mouseup",function(d){if(!b.base.disabled){b.refresh()}})},_removeHandlers:function(){this.removeHandler(this.base.host,"click");this.removeHandler(this.base.host,"mouseenter");this.removeHandler(this.base.host,"mouseleave");this.removeHandler(this.base.host,"mousedown");this.removeHandler(a(document),"mouseup")},toggle:function(){this.toggled=!this.toggled;this.refresh();a.jqx.aria(this,"aria-checked",this.toggled)},unCheck:function(){this.toggled=false;this.refresh()},check:function(){this.toggled=true;this.refresh()},refresh:function(){var g=this.base.toThemeProperty("jqx-fill-state-disabled");var b=this.base.toThemeProperty("jqx-fill-state-normal");var f=this.base.toThemeProperty("jqx-fill-state-hover");var d=this.base.toThemeProperty("jqx-fill-state-pressed");var e=this.base.toThemeProperty("jqx-fill-state-pressed");var c="";this.base.host[0].disabled=this.base.disabled;if(this.base.disabled){c=g}else{if(this.base.isMouseOver&&!this.isTouchDevice){if(this.base.isPressed||this.toggled){c=e}else{c=f}}else{if(this.base.isPressed||this.toggled){c=d}else{c=b}}}if(this.base.host.hasClass(g)&&g!=c){this.base.host.removeClass(g)}if(this.base.host.hasClass(b)&&b!=c){this.base.host.removeClass(b)}if(this.base.host.hasClass(f)&&f!=c){this.base.host.removeClass(f)}if(this.base.host.hasClass(d)&&d!=c){this.base.host.removeClass(d)}if(this.base.host.hasClass(e)&&e!=c){this.base.host.removeClass(e)}if(!this.base.host.hasClass(c)){this.base.host.addClass(c)}}})})(jQuery);

/*
jQWidgets v3.0.3 (2013-Oct-01)
Copyright (c) 2011-2013 jQWidgets.
License: http://jqwidgets.com/license/
*/

(function(a){a.jqx.jqxWidget("jqxNumberInput","",{});a.extend(a.jqx._jqxNumberInput.prototype,{defineInstance:function(){this.value=null;this.decimal=0;this.min=-99999999;this.max=99999999;this.width=null;this.validationMessage="Invalid value";this.height=50;this.textAlign="right";this.readOnly=false;this.promptChar="_";this.decimalDigits=2;this.decimalSeparator=".";this.groupSeparator=",";this.groupSize=3;this.symbol="";this.symbolPosition="left";this.digits=8;this.negative=false;this.negativeSymbol="-";this.disabled=false;this.inputMode="advanced";this.spinButtons=false;this.spinButtonsWidth=18;this.spinButtonsStep=1;this.autoValidate=true;this.spinMode="advanced";this.touchMode="auto";this.rtl=false;this.events=["valuechanged","textchanged","mousedown","mouseup","keydown","keyup","keypress","change"];this.aria={"aria-valuenow":{name:"decimal",type:"number"},"aria-valuemin":{name:"min",type:"number"},"aria-valuemax":{name:"max",type:"number"},"aria-disabled":{name:"disabled",type:"boolean"}};this.invalidArgumentExceptions=["invalid argument exception"]},createInstance:function(b){var c=this.host.attr("value");if(c!=undefined){this.decimal=c}if(this.value!=null){this.decimal=this.value}this.render()},_doTouchHandling:function(){var e=this;var g=e.savedValue;if(!e.parsing){e.parsing=true}if(e.parsing){if(e.numberInput.val()&&e.numberInput.val().indexOf("-")==0){e.setvalue("negative",true)}else{e.setvalue("negative",false)}var f=e.numberInput.val();for(var c=0;c<f.length-1;c++){var d=f.substring(c,c+1);if(isNaN(parseFloat(d))&&d!=e.symbol&&d!="%"&&d!="$"&&d!="."&&d!=","&&d!="-"){e.numberInput[0].value=g;e.parsing=false;return}}e.ValueString=e.GetValueString(e.numberInput.val(),e.decimalSeparator,e.decimalSeparator!="");e.ValueString=new Number(e.ValueString).toFixed(e.decimalDigits);e._parseDecimalInSimpleMode();e.decimal=e.ValueString;var b=e.getvalue("negative");if(b){e.decimal="-"+e.ValueString}e.parsing=false}},render:function(){this.host.attr({role:"spinbutton"});this.host.attr("data-role","input");a.jqx.aria(this);a.jqx.aria(this,"aria-multiline",false);var f=this;a.jqx.utilities.resize(this.host,function(){f._render()});if(this.officeMode||(this.theme&&this.theme.indexOf("office")!=-1)){if(this.spinButtonsWidth==18){this.spinButtonsWidth=15}}if(a.jqx.mobile.isTouchDevice()||this.touchMode===true){this.inputMode="textbox";this.spinMode="simple"}if(this.decimalSeparator==""){this.decimalSeparator=" "}this.host.addClass(this.toThemeProperty("jqx-input"));this.host.addClass(this.toThemeProperty("jqx-rc-all"));this.host.addClass(this.toThemeProperty("jqx-widget"));this.host.addClass(this.toThemeProperty("jqx-widget-content"));this.host.addClass(this.toThemeProperty("jqx-numberinput"));if(this.spinButtons){this._spinButtons()}else{this.numberInput=a("<input autocomplete='off' type='textarea'/>").appendTo(this.host);this.numberInput.addClass(this.toThemeProperty("jqx-input-content"));this.numberInput.addClass(this.toThemeProperty("jqx-widget-content"))}var d=this.host.attr("name");if(!d){d=this.element.id}this.numberInput.attr("name",d);if(a.jqx.mobile.isTouchDevice()||this.touchMode===true||this.inputMode=="textbox"){var f=this;f.savedValue="";this.addHandler(this.numberInput,"focus",function(){f.savedValue=f.numberInput[0].value});this.addHandler(this.numberInput,"change",function(){f._doTouchHandling()})}var h=a.data(this.host[0],"jqxNumberInput");h.jqxNumberInput=this;var f=this;this.removeHandler(this.host,"loadContent");this.addHandler(this.host,"loadContent",function(n){f._render()});if(this.host.parents("form").length>0){this.removeHandler(this.host.parents("form"),"loadContent");this.addHandler(this.host.parents("form"),"reset",function(){setTimeout(function(){f.setDecimal(0)},10)})}this.propertyChangeMap.disabled=function(n,q,o,r){if(r){n.numberInput.addClass(c.toThemeProperty("jqx-input-disabled"));n.numberInput.attr("disabled",true)}else{n.host.removeClass(c.toThemeProperty("jqx-input-disabled"));n.numberInput.attr("disabled",false)}if(n.spinButtons&&n.host.jqxRepeatButton){n.upbutton.jqxRepeatButton({disabled:r});n.downbutton.jqxRepeatButton({disabled:r})}};if(this.disabled){this.numberInput.addClass(this.toThemeProperty("jqx-input-disabled"));this.numberInput.attr("disabled",true);this.host.addClass(this.toThemeProperty("jqx-fill-state-disabled"))}this.selectedText="";this.decimalSeparatorPosition=-1;var l=this.element.id;var e=this.element;var c=this;this.oldValue=this._value();this.items=new Array();var g=this.value;var b=this.decimal;this._initializeLiterals();this._render();this.setDecimal(b);var f=this;setTimeout(function(){f._render(false)},100);this._addHandlers()},refresh:function(b){if(!b){this._render()}},wheel:function(d,c){var e=0;if(!d){d=window.event}if(d.originalEvent&&d.originalEvent.wheelDelta){d.wheelDelta=d.originalEvent.wheelDelta}if(d.wheelDelta){e=d.wheelDelta/120}else{if(d.detail){e=-d.detail/3}}if(e){var b=c._handleDelta(e);if(d.preventDefault){d.preventDefault()}if(d.originalEvent!=null){d.originalEvent.mouseHandled=true}if(d.stopPropagation!=undefined){d.stopPropagation()}if(b){b=false;d.returnValue=b;return b}else{return false}}if(d.preventDefault){d.preventDefault()}d.returnValue=false},_handleDelta:function(b){if(b<0){this.spinDown()}else{this.spinUp()}return true},_addHandlers:function(){var b=this;this.addHandler(this.numberInput,"mousedown",function(d){return b._raiseEvent(2,d)});this._mousewheelfunc=this._mousewheelfunc||function(d){if(!b.editcell){b.wheel(d,b);return false}};this.removeHandler(this.host,"mousewheel",this._mousewheelfunc);this.addHandler(this.host,"mousewheel",this._mousewheelfunc);var c="";this.addHandler(this.numberInput,"focus",function(d){a.data(b.numberInput,"selectionstart",b._selection().start);b.host.addClass(b.toThemeProperty("jqx-fill-state-focus"));if(b.spincontainer){b.spincontainer.addClass(b.toThemeProperty("jqx-numberinput-focus"))}c=b.numberInput.val()});this.addHandler(this.numberInput,"blur",function(e){if(b.inputMode=="simple"){b._exitSimpleInputMode(e,b,false,c)}if(b.autoValidate){var f=parseFloat(b.decimal);var d=b.getvalue("negative");if(d&&b.decimal>0){f=-parseFloat(b.decimal)}if(f>b.max){b._disableSetSelection=true;b.setDecimal(b.max);b._disableSetSelection=false}if(f<b.min){b._disableSetSelection=true;b.setDecimal(b.min);b._disableSetSelection=false}}b.host.removeClass(b.toThemeProperty("jqx-fill-state-focus"));if(b.spincontainer){b.spincontainer.removeClass(b.toThemeProperty("jqx-numberinput-focus"))}if(b.numberInput.val()!=c){b._raiseEvent(7,e);a.jqx.aria(b,"aria-valuenow",b.decimal);b.element.value=b.decimal}return true});this.addHandler(this.numberInput,"mouseup",function(d){return b._raiseEvent(3,d)});this.addHandler(this.numberInput,"keydown",function(d){return b._raiseEvent(4,d)});this.addHandler(this.numberInput,"keyup",function(d){return b._raiseEvent(5,d)});this.addHandler(this.numberInput,"keypress",function(d){return b._raiseEvent(6,d)})},focus:function(){try{this.numberInput.focus()}catch(b){}},_removeHandlers:function(){var b=this;this.removeHandler(this.numberInput,"mousedown");var c=a.jqx.mobile.isOperaMiniMobileBrowser();if(c){this.removeHandler(a(document),"click."+this.element.id,b._exitSimpleInputMode,b)}this.removeHandler(this.numberInput,"focus");this.removeHandler(this.numberInput,"blur");this.removeHandler(this.numberInput,"mouseup");this.removeHandler(this.numberInput,"keydown");this.removeHandler(this.numberInput,"keyup");this.removeHandler(this.numberInput,"keypress")},_spinButtons:function(){if(this.host.jqxRepeatButton){if(!this.numberInput){this.numberInput=a("<input autocomplete='off' style='position: relative; float: left;' type='textarea'/>");this.numberInput.appendTo(this.host);this.numberInput.addClass(this.toThemeProperty("jqx-input-content"));this.numberInput.addClass(this.toThemeProperty("jqx-widget-content"))}else{this.numberInput.css("float","left")}if(this.spincontainer){if(this.upbutton){this.upbutton.jqxRepeatButton("destroy")}if(this.downbutton){this.downbutton.jqxRepeatButton("destroy")}this.spincontainer.remove()}this.spincontainer=a('<div style="float: right; height: 100%; overflow: hidden; position: relative;"></div>');if(this.rtl){this.spincontainer.css("float","right");this.numberInput.css("float","right")}this.host.append(this.spincontainer);this.upbutton=a('<div style="overflow: hidden; padding: 0px; margin-left: -1px; position: relative;"><div></div></div>');this.spincontainer.append(this.upbutton);this.upbutton.jqxRepeatButton({overrideTheme:true,disabled:this.disabled,roundedCorners:"top-right"});this.downbutton=a('<div style="overflow: hidden; padding: 0px; margin-left: -1px; position: relative;"><div></div></div>');this.spincontainer.append(this.downbutton);this.downbutton.jqxRepeatButton({overrideTheme:true,disabled:this.disabled,roundedCorners:"bottom-right"});var d=this;this.downbutton.addClass(this.toThemeProperty("jqx-fill-state-normal"));this.upbutton.addClass(this.toThemeProperty("jqx-fill-state-normal"));this.upbutton.addClass(this.toThemeProperty("jqx-rc-tr"));this.downbutton.addClass(this.toThemeProperty("jqx-rc-br"));this.addHandler(this.downbutton,"mouseup",function(e){if(!d.disabled){d.downbutton.removeClass(d.toThemeProperty("jqx-fill-state-pressed"));d._downArrow.removeClass(d.toThemeProperty("jqx-icon-arrow-down-selected"))}});this.addHandler(this.upbutton,"mouseup",function(e){if(!d.disabled){d.upbutton.removeClass(d.toThemeProperty("jqx-fill-state-pressed"));d._upArrow.removeClass(d.toThemeProperty("jqx-icon-arrow-up-selected"))}});this.removeHandler(a(document),"mouseup."+this.element.id);this.addHandler(a(document),"mouseup."+this.element.id,function(e){d.upbutton.removeClass(d.toThemeProperty("jqx-fill-state-pressed"));d._upArrow.removeClass(d.toThemeProperty("jqx-icon-arrow-up-selected"));d.downbutton.removeClass(d.toThemeProperty("jqx-fill-state-pressed"));d._downArrow.removeClass(d.toThemeProperty("jqx-icon-arrow-down-selected"))});this.addHandler(this.downbutton,"mousedown",function(e){if(!d.disabled){if(a.jqx.browser.msie&&a.jqx.browser.version<9){d._inputSelection=d._selection()}d.downbutton.addClass(d.toThemeProperty("jqx-fill-state-pressed"));d._downArrow.addClass(d.toThemeProperty("jqx-icon-arrow-down-selected"));e.preventDefault();e.stopPropagation();return false}});this.addHandler(this.upbutton,"mousedown",function(e){if(!d.disabled){if(a.jqx.browser.msie&&a.jqx.browser.version<9){d._inputSelection=d._selection()}d.upbutton.addClass(d.toThemeProperty("jqx-fill-state-pressed"));d._upArrow.addClass(d.toThemeProperty("jqx-icon-arrow-up-selected"));e.preventDefault();e.stopPropagation();return false}});this.addHandler(this.upbutton,"mouseenter",function(e){d.upbutton.addClass(d.toThemeProperty("jqx-fill-state-hover"));d._upArrow.addClass(d.toThemeProperty("jqx-icon-arrow-up-hover"))});this.addHandler(this.upbutton,"mouseleave",function(e){d.upbutton.removeClass(d.toThemeProperty("jqx-fill-state-hover"));d._upArrow.removeClass(d.toThemeProperty("jqx-icon-arrow-up-hover"))});this.addHandler(this.downbutton,"mouseenter",function(e){d.downbutton.addClass(d.toThemeProperty("jqx-fill-state-hover"));d._downArrow.addClass(d.toThemeProperty("jqx-icon-arrow-down-hover"))});this.addHandler(this.downbutton,"mouseleave",function(e){d.downbutton.removeClass(d.toThemeProperty("jqx-fill-state-hover"));d._downArrow.removeClass(d.toThemeProperty("jqx-icon-arrow-down-hover"))});this.upbutton.css("border-width","0px");this.downbutton.css("border-width","0px");if(this.disabled){this.upbutton[0].disabled=true;this.downbutton[0].disabled=true}else{this.upbutton[0].disabled=false;this.downbutton[0].disabled=false}this.spincontainer.addClass(this.toThemeProperty("jqx-input"));this.spincontainer.addClass(this.toThemeProperty("jqx-rc-r"));this.spincontainer.css("border-width","0px");if(!this.rtl){this.spincontainer.css("border-left-width","1px")}else{this.spincontainer.css("border-right-width","1px")}this._upArrow=this.upbutton.find("div");this._downArrow=this.downbutton.find("div");this._upArrow.addClass(this.toThemeProperty("jqx-icon-arrow-up"));this._downArrow.addClass(this.toThemeProperty("jqx-icon-arrow-down"));this._upArrow.addClass(this.toThemeProperty("jqx-input-icon"));this._downArrow.addClass(this.toThemeProperty("jqx-input-icon"));var d=this;this._upArrow.hover(function(){if(!d.disabled){d._upArrow.addClass(d.toThemeProperty("jqx-icon-arrow-up-hover"))}},function(){d._upArrow.removeClass(d.toThemeProperty("jqx-icon-arrow-up-hover"))});this._downArrow.hover(function(){if(!d.disabled){d._downArrow.addClass(d.toThemeProperty("jqx-icon-arrow-down-hover"))}},function(){d._downArrow.removeClass(d.toThemeProperty("jqx-icon-arrow-down-hover"))});var b=a.jqx.mobile.isTouchDevice();var c="click";if(b){c=a.jqx.mobile.getTouchEventName("touchstart")}this.addHandler(this.downbutton,c,function(e){if(!b){if(d._selection().start==0){d._setSelectionStart(d.numberInput.val().length)}if(a.jqx.browser.msie&&a.jqx.browser.version<9){d._setSelectionStart(d._inputSelection.start)}}else{e.preventDefault();e.stopPropagation()}d.spinDown();return false});this.addHandler(this.upbutton,c,function(e){if(!b){if(d._selection().start==0){d._setSelectionStart(d.numberInput.val().length)}if(a.jqx.browser.msie&&a.jqx.browser.version<9){d._setSelectionStart(d._inputSelection.start)}}else{e.preventDefault();e.stopPropagation()}d.spinUp();return false})}else{throw new Error("jqxNumberInput: Missing reference to jqxbuttons.js.")}},spinDown:function(){var o=this;if(o.spinMode=="none"){return}var b=this.getvalue("negative");var t=b?-1:0;if(a.jqx.mobile.isTouchDevice()||this.inputMode=="textbox"){o._doTouchHandling()}if(!o.disabled){var r=this._selection();var q=this.decimal;var l=this.getDecimal();if(l<this.min){l=this.min;this.setDecimal(this.min);this._setSelectionStart(r.start);this.spinDown();return}else{if(l>this.max){l=this.max;this.setDecimal(this.max);this._setSelectionStart(r.start);this.spinDown();return}}if(o.spinButtonsStep<0){o.spinButtonsStep=1}var d=parseInt(o.decimal)+o.spinButtonsStep;d=d.toString().length;var f=t+d<=o.digits;if(o.spinMode!="advanced"){if(l-o.spinButtonsStep>=o.min&&f){var v=1;for(g=0;g<o.decimalDigits;g++){v=v*10}var e=(v*l)-(v*o.spinButtonsStep);e=e/v;e=this._parseDecimalValueToEditorValue(e);o.setDecimal(e)}}else{var s=this._getspindecimal();var n=this._getSeparatorPosition();var l=parseFloat(s.decimal);if(o.spinButtonsStep<0){o.spinButtonsStep=1}var d=parseInt(l)+o.spinButtonsStep;d=d.toString().length;var f=t+d<=o.digits;var v=1;var c=s.decimal.indexOf(".");if(c!=-1){var h=s.decimal.length-c-1;var v=1;for(var g=0;g<h;g++){v=v*10}l-=new Number(o.spinButtonsStep/v);l=l.toFixed(h);var c=l.toString().indexOf(".");if(c==-1){l=l.toString()+"."}var u=l.toString()+s.afterdecimal;u=new Number(u);u=u.toFixed(o.decimalDigits);if(u>=o.min){u=this._parseDecimalValueToEditorValue(u);o.setDecimal(u)}}else{if(l-o.spinButtonsStep>=o.min&&f){var e=(v*l)-(v*o.spinButtonsStep);e=e/v;var u=e.toString()+s.afterdecimal;if(u>=o.min){u=this._parseDecimalValueToEditorValue(u);o.setDecimal(u)}}}}if(u==undefined||this.inputMode!="simple"){this._setSelectionStart(r.start);o.savedValue=o.numberInput[0].value;return}u=this.decimal.toString();var b=this.getvalue("negative");if(t==0&&b){this._setSelectionStart(r.start+1)}else{if((u!=undefined&&(q==undefined||q.toString().length==u.length))){this._setSelectionStart(r.start)}else{if(b){this._setSelectionStart(r.start+1)}else{this._setSelectionStart(r.start-1)}}}}},_getspindecimal:function(){var q=this._selection();var r="";var n=this._getSeparatorPosition();var t=this._getVisibleItems();var e=this._getHiddenPrefixCount();var s=this.numberInput.val();if(this.numberInput.val().length==q.start&&q.length==0){this._setSelection(q.start,q.start+1);q=this._selection()}var l=this.inputMode!="advanced";for(var c=0;c<q.start;c++){if(l){var o=s.substring(c,c+1);var h=(!isNaN(parseInt(o)));if(h){r+=o}if(o==this.decimalSeparator){r+=o}continue}if(t[c].canEdit&&t[c].character!=this.promptChar){r+=t[c].character}else{if(!t[c].canEdit&&this.decimalSeparatorPosition!=-1&&t[c]==t[this.decimalSeparatorPosition-e]){if(r.length==0){r="0"}r+=t[c].character}}}var g="";for(var c=q.start;c<t.length;c++){if(l){var o=s.substring(c,c+1);var h=(!isNaN(parseInt(o)));if(h){g+=o}if(o==this.decimalSeparator){g+=o}continue}if(t[c].canEdit&&t[c].character!=this.promptChar){g+=t[c].character}else{if(!t[c].canEdit&&this.decimalSeparatorPosition!=-1&&t[c]==t[this.decimalSeparatorPosition-e]){g+=t[c].character}}}var b=this.getvalue("negative");var f=b?"-"+this._parseDecimalValue(r).toString():this._parseDecimalValue(r).toString();return{decimal:f,afterdecimal:this._parseDecimalValue(g)}},_parseDecimalValue:function(c){if(this.decimalSeparator!="."){var d=c.toString().indexOf(this.decimalSeparator);if(d>=0){var b=c.toString().substring(0,d)+"."+c.toString().substring(d+1);return b}}return c},_parseDecimalValueToEditorValue:function(c){if(this.decimalSeparator!="."){var d=c.toString().indexOf(".");if(d>=0){var b=c.toString().substring(0,d)+this.decimalSeparator+c.toString().substring(d+1);return b}}return c},spinUp:function(){var q=this;if(q.spinMode=="none"){return}if(a.jqx.mobile.isTouchDevice()||this.inputMode=="textbox"){q._doTouchHandling()}var b=this.getvalue("negative");var u=b?-1:0;if(!q.disabled){var s=this._selection();var r=q.decimal;var n=q.getDecimal();if(n<this.min){n=this.min;this.setDecimal(this.min);this._setSelectionStart(s.start);this.spinUp();return}else{if(n>this.max){n=this.max;this.setDecimal(this.max);this._setSelectionStart(s.start);this.spinUp();return}}if(q.spinButtonsStep<0){q.spinButtonsStep=1}var d=parseInt(q.decimal)+q.spinButtonsStep;d=d.toString().length;var g=u+d<=q.digits;if(q.spinMode!="advanced"){if(n+q.spinButtonsStep<=q.max&&g){var w=1;for(var l=0;l<q.decimalDigits;l++){w=w*10}var f=(w*n)+(w*q.spinButtonsStep);f=f/w;f=this._parseDecimalValueToEditorValue(f);q.setDecimal(f)}}else{var t=this._getspindecimal();var o=this._getSeparatorPosition();var n=parseFloat(t.decimal);if(q.spinButtonsStep<0){q.spinButtonsStep=1}var d=parseInt(n)+q.spinButtonsStep;d=d.toString().length;var g=u+d<=q.digits;var w=1;var c=t.decimal.indexOf(".");if(c!=-1){var h=t.decimal.length-c-1;var w=1;for(var l=0;l<h;l++){w=w*10}n+=new Number(q.spinButtonsStep/w);n=n.toFixed(h);var c=n.toString().indexOf(".");if(c==-1){n=n.toString()+"."}var v=n.toString()+t.afterdecimal;v=new Number(v);v=v.toFixed(q.decimalDigits);var e=new Number(v).toFixed(q.decimalDigits);if(e<=q.max){v=this._parseDecimalValueToEditorValue(v);q.setDecimal(v)}else{v=undefined}}else{if(n+q.spinButtonsStep<=q.max&&g){var f=(w*n)+(w*q.spinButtonsStep);f=f/w;var v=f.toString()+t.afterdecimal;var e=new Number(v).toFixed(q.decimalDigits);if(e<=q.max){v=this._parseDecimalValueToEditorValue(v);if(b&&v.indexOf("-")==-1){if(t.decimal!="-0"){v="-"+v}}q.setDecimal(v)}else{v=undefined}}}}if(v==undefined||this.inputMode!="simple"){this._setSelectionStart(s.start);q.savedValue=q.numberInput[0].value;return}v=this.decimal.toString();var b=this.getvalue("negative");if(u==-1&&!b){this._setSelectionStart(-1+s.start)}else{if((v!=undefined&&(r==undefined||r.toString().length==v.length))){this._setSelectionStart(s.start)}else{if(b){this._setSelectionStart(-1+s.start)}else{this._setSelectionStart(1+s.start)}}}}},_exitSimpleInputMode:function(b,o,h,d){if(o==undefined){o=b.data}if(o==null){return}if(h==undefined){if(b.target!=null&&o.element!=null){if((b.target.id!=undefined&&b.target.id.toString().length>0&&o.host.find("#"+b.target.id).length>0)||b.target==o.element){return}}var f=o.host.offset();var e=f.left;var g=f.top;var c=o.host.width();var n=o.host.height();var q=a(b.target).offset();if(q.left>=e&&q.left<=e+c){if(q.top>=g&&q.top<=g+n){return}}}if(a.jqx.mobile.isOperaMiniBrowser()){o.numberInput.attr("readonly",true)}if(o.disabled||o.readOnly){return}var l=a.data(o.numberInput,"simpleInputMode");if(l==null){return}a.data(o.numberInput,"simpleInputMode",null);this._parseDecimalInSimpleMode();return false},_getDecimalInSimpleMode:function(){var d=this.decimal;if(this.decimalSeparator!="."){var b=d.toString().indexOf(this.decimalSeparator);if(b>0){var c=d.toString().substring(0,b);var d=c+"."+d.toString().substring(b+1)}}return d},_parseDecimalInSimpleMode:function(d){var o=this;var b=o.getvalue("negative");var e=this.ValueString;if(e==undefined){e=this.GetValueString(this.numberInput.val(),this.decimalSeparator,this.decimalSeparator!="")}if(this.decimalSeparator!="."){var g=e.toString().indexOf(".");if(g>0){var f=e.toString().substring(0,g);var c=f+this.decimalSeparator+e.toString().substring(g+1);e=c}}var h=b?"-":"";if(this.symbolPosition=="left"){h+=this.symbol}var l=this.digits%this.groupSize;if(l==0){l=this.groupSize}var n=e.toString();h+=n;if(this.symbolPosition=="right"){h+=this.symbol}if(d!=false){o.numberInput.val(h)}},_enterSimpleInputMode:function(f,d){if(d==undefined){d=f.data}var e=this._selection();if(d==null){return}var c=d.getvalue("negative");var b=d.decimal;if(c){if(b>0){b=-b}}d.numberInput.val(b);a.data(d.numberInput,"simpleInputMode",true);if(a.jqx.mobile.isOperaMiniBrowser()){d.numberInput.attr("readonly",false)}this._parseDecimalInSimpleMode();this._setSelectionStart(e.start)},setvalue:function(b,c){if(this[b]!=undefined){if(b=="decimal"){this._setDecimal(c)}else{this[b]=c;this.propertyChangedHandler(this,b,c,c)}}},getvalue:function(b){if(b=="decimal"){if(this.negative!=undefined&&this.negative==true){return -Math.abs(this[b])}}if(b in this){return this[b]}return null},_getString:function(){var c="";for(var b=0;b<this.items.length;b++){var d=this.items[b].character;c+=d}return c},_literal:function(d,b,c,e){return{character:d,regex:b,canEdit:c,isSeparator:e}},_initializeLiterals:function(){if(this.inputMode=="textbox"){return}var h=0;var e=this.negativeSymbol.length;for(var d=0;d<e;d++){var g=this.negativeSymbol.substring(d,d+1);var n="";var b=false;var o=null;if(this.negative){o=this._literal(g,n,b,false)}else{o=this._literal("",n,b,false)}this.items[h]=o;h++}var c=this.symbol.length;if(this.symbolPosition=="left"){for(d=0;d<c;d++){var g=this.symbol.substring(d,d+1);var n="";var b=false;var o=this._literal(g,n,b,false);this.items[h]=o;h++}}var f=this.digits%this.groupSize;if(f==0){f=this.groupSize}for(var d=0;d<this.digits;d++){var g=this.promptChar;var n="\\d";var b=true;var o=this._literal(g,n,b,false);this.items[h]=o;h++;if(d<this.digits-1&&this.groupSeparator!=undefined&&this.groupSeparator.length>0){f--;if(f==0){f=this.groupSize;var l=this._literal(this.groupSeparator,"",false,false);this.items[h]=l;h++}}else{if(d==this.digits-1){o.character=0}}}this.decimalSeparatorPosition=-1;if(this.decimalDigits!=undefined&&this.decimalDigits>0){var g=this.decimalSeparator;if(g.length==0){g="."}var o=this._literal(g,"",false,true);this.items[h]=o;this.decimalSeparatorPosition=h;h++;for(var d=0;d<this.decimalDigits;d++){var r=0;var n="\\d";var q=this._literal(r,n,true,false);this.items[h]=q;h++}}if(this.symbolPosition=="right"){for(var d=0;d<c;d++){var g=this.symbol.substring(d,d+1);var n="";var b=false;var o=this._literal(g,n,b);this.items[h]=o;h++}}},_match:function(c,b){var d=new RegExp(b,"i");return d.test(c)},_raiseEvent:function(f,w){var v=this.events[f];var n={};n.owner=this;if(this.host.css("display")=="none"){return true}var u=w.charCode?w.charCode:w.keyCode?w.keyCode:0;var x=true;var t=this.readOnly;var o=this;if(f==3||f==2){if(!this.disabled){if(this.inputMode!="simple"&&this.inputMode!="textbox"){this._handleMouse(w)}else{return true}}}if(f==0){var d=this.getvalue("decimal");if((this.max<d)||(this.min>d)){this.host.addClass(this.toThemeProperty("jqx-input-invalid"))}else{this.host.removeClass(this.toThemeProperty("jqx-input-invalid"));this.host.addClass(this.toThemeProperty("jqx-input"));this.host.addClass(this.toThemeProperty("jqx-rc-all"))}}var c=new jQuery.Event(v);c.owner=this;n.value=this.getvalue("decimal");n.text=this.numberInput.val();c.args=n;x=this.host.trigger(c);var o=this;if(this.inputMode=="textbox"){return x}if(this.inputMode!="simple"){if(f==4){if(t||this.disabled){return false}x=o._handleKeyDown(w,u)}else{if(f==5){if(t||this.disabled){x=false}}else{if(f==6){if(t||this.disabled){return false}x=o._handleKeyPress(w,u)}}}}else{if(f==4||f==5||f==6){if(a.jqx.mobile.isTouchDevice()||this.touchMode===true){return true}if(t||this.disabled){return false}var g=String.fromCharCode(u);var q=parseInt(g);var h=true;if(!w.ctrlKey&&!w.shiftKey){if(u>=65&&u<=90){h=false}}if(f==6&&a.jqx.browser.opera!=undefined){if(u==8){return false}}if(h){if(f==4){h=o._handleSimpleKeyDown(w,u)}if(u==189||u==45||u==109||u==173){var s=o._selection();if(f==4){var b=o.getvalue("negative");if(b==false){o.setvalue("negative",true)}else{o.setvalue("negative",false)}o._parseDecimalInSimpleMode();o._setSelectionStart(s.start);h=false}}if(!a.jqx.browser.msie){var l=w;if((l.ctrlKey&&u==99)||(l.ctrlKey&&u==67)||(l.ctrlKey&&u==122)||(l.ctrlKey&&u==90)||(l.ctrlKey&&u==118)||(l.ctrlKey&&u==86)||(l.shiftKey&&u==45)){if(f==6&&a.jqx.browser.webkit){o._handleSimpleKeyDown(w,u)}return false}}if((w.ctrlKey&&u==97)||(w.ctrlKey&&u==65)){return true}if(f==6&&h){var r=this._isSpecialKey(u);return r}}return h}}return x},GetSelectionInValue:function(h,g,f,e){var c=0;for(i=0;i<g.length;i++){if(i>=h){break}var d=g.substring(i,i+1);var b=(!isNaN(parseInt(d)));if(b||(e&&g.substring(i,i+1)==f)){c++}}return c},GetSelectionLengthInValue:function(g,h,f,e){var c=0;for(i=0;i<f.length;i++){if(i>=g+h){break}var d=f.substring(i,i+1);var b=(!isNaN(parseInt(d)));if(h>0&&i>=g&&b||(i>=g&&f[i].toString()==e)){c++}}return c},GetInsertTypeByPositionInValue:function(e,g,h,f){var c="before";var b=this.GetValueString(h,g,f);var d=this.GetDigitsToSeparator(0,b,g);if(e>d){c="after"}return c},RemoveRange:function(f,e,q,g,w,b){var h=this.digits;var r=f;var x=e;var c=0;var s=this.decimal;var B=this._selection();var q=this.numberInput.val();var g=this.decimalSeparator;var l=g!="";if(x==0&&this.ValueString.length<this.decimalPossibleChars-1){return c}var y=this.GetSeparatorPositionInText(g,q);if(!w){y=this.GetSeparatorPositionInText(g,q)}if(y<0&&!l&&q.length>1){y=q.length}if(y==-1){y=q.length}var d=l?1:0;if(e<2&&b==true){var A=this.ValueString.length-this.decimalDigits-d;if((A)==h&&f+e<y){x++}}var n="";for(var v=0;v<q.length;v++){if(v<r||v>=r+x){n+=q.substring(v,v+1);continue}else{var u=q.substring(v,v+1);if(u==g){n+=g;continue}else{var u=q.substring(v,v+1);if(v>y){n+="0";continue}}}var u=q.substring(v,v+1);var t=(!isNaN(parseInt(u)));if(t){c++}}if(n.length==0){n="0"}if(w){this.numberInput.val(n)}else{this.ValueString=n}var o=n.substring(0,1);if(o==g&&isNaN(parseInt(o))){var z="0"+n;n=z}this.ValueString=this.GetValueString(n,g,l);this.decimal=this.ValueString;this._parseDecimalInSimpleMode();this._setSelectionStart(r);return c},InsertDigit:function(v,B){if(typeof this.digits!="number"){this.digits=parseInt(this.digits)}if(typeof this.decimalDigits!="number"){this.decimalDigits=parseInt(this.decimalDigits)}var l=1+this.digits;var C=this._selection();var q=this.getvalue("negative");var d=false;if(C.start==0&&this.symbol!=""&&this.symbolPosition=="left"){this._setSelectionStart(C.start+1);C=this._selection();d=true}if((q&&d)||(q&&!d&&C.start==0)){this._setSelectionStart(C.start+1);C=this._selection()}var z=this.numberInput.val().substring(C.start,C.start+1);var s=this.numberInput.val();var g=this.decimalSeparator;var n=g!=""&&this.decimalDigits>0;if(z==this.symbol&&this.symbolPosition=="right"){if(this.decimalDigits==0){this.ValueString=this.GetValueString(s,g,n);if(this.ValueString.length>=l){return}}else{return}}this.ValueString=this.GetValueString(s,g,n);var y=this.ValueString;if(this.decimalDigits>0&&B>=y.length){B=y.length-1}var t="";if(B<y.length){t=y.substring(B,B+1)}var h=false;var A=false;var e=this.GetInsertTypeByPositionInValue(B,g,s,n);if(e=="after"){h=true}var b=n?1:0;if(t!=g&&(this.ValueString.length-this.decimalDigits-b)>=l-1){h=true}var u=false;var w=n?1:0;if(!h&&this.ValueString&&this.ValueString.length>=this.digits+this.decimalDigits+w){return}if(h&&t!=g){if(u){B++}var r=y.substring(0,B);if(r.length==y.length){if(this.ValueString.length>=this.digits+this.decimalDigits+w){return}}var x=v;var c="";if(B+1<y.length){c=y.substring(B+1)}var o=r+x+c;this.ValueString=o}else{var r=y.substring(0,B);var x=v;var c=y.substring(B);var o=r+x+c;if(y.substring(0,1)=="0"){o=x+y.substring(1);if(t==g){this._setSelectionStart(C.start-1);C=this._selection()}}this.ValueString=o}if(q){this.decimal=-this.ValueString}else{this.decimal=this.ValueString}this._parseDecimalInSimpleMode();var f=C.start;f+=1;this._setSelectionStart(f);this.value=this.decimal;this._raiseEvent(0,this.value);this._raiseEvent(1,this.numberInput.val())},GetStringToSeparator:function(h,f,e){var d="";var b=f;var g=this.GetSeparatorPositionInText(f,h);var c=h.subString(0,g);d=this.GetValueString(c,f,e);return d},GetSeparatorPositionInText:function(c,d){var b=-1;for(i=0;i<d.length;i++){if(d.substring(i,i+1)==c){b=i;break}}return b},GetValueString:function(h,g,f){var d="";for(var c=0;c<h.length;c++){var e=h.substring(c,c+1);var b=(!isNaN(parseInt(e)));if(b){d+=e}if(e==g){d+=g}}return d},Backspace:function(){var d=this._selection();var e=this._selection();var f=this.numberInput.val();if(d.start==0&&d.length==0){return}this.isBackSpace=true;var c=f.substring[d.start,d.start+1];var b=(!isNaN(parseInt(c)));if(d.start>0&&d.length==0){this._setSelectionStart(d.start-1);var d=this._selection()}this.Delete();this._setSelectionStart(e.start-1);this.isBackSpace=false},Delete:function(c){var e=this._selection();var g=this.numberInput.val();var f=e.start;var h=e.length;h=Math.max(h,1);this.ValueString=this.GetValueString(g,this.decimalSeparator,this.decimalSeparator!="");this.RemoveRange(e.start,h,this.ValueString,".",false);var d=this.ValueString.substring(0,1);var b=(!isNaN(parseInt(d)));if(!b){this.ValueString="0"+this.ValueString}this.decimal=this.ValueString;this._parseDecimalInSimpleMode();this._setSelectionStart(f);this.value=this.decimal;this._raiseEvent(0,this.value);this._raiseEvent(1,this.numberInput.val())},insertsimple:function(d){var l=this._selection();var n=this.numberInput.val();if(l.start==n.length&&this.decimalDigits>0){return}var b=this.decimal;var g=this.decimalSeparator;this.ValueString=this.GetValueString(n,g,g!="");var h=this.GetSelectionInValue(l.start,n,g,g!="");var e=this.GetSelectionLengthInValue(l.start,l.length,n,g);var f=this.GetDigitsToSeparator(0,this.ValueString,g);var c=false;if(this.decimalDigits>0&&h>=this.ValueString.length){h--}this.RemoveRange(l.start,e,this.ValueString,g,false,true);this.InsertDigit(d,h,l)},GetDigitsToSeparator:function(c,b,d){if(d==undefined){d="."}if(b.indexOf(d)<0){return b.length}for(i=0;i<b.length;i++){if(b.substring(i,i+1)==d){c=i;break}}return c},_handleSimpleKeyDown:function(h,t){var s=this._selection();if(s.start>=0&&s.start<this.items.length){var c=String.fromCharCode(t)}if(this.rtl&&t==37){var b=h.shiftKey;var d=b?1:0;if(b){this._setSelection(s.start+1-d,s.start+s.length+1)}else{this._setSelection(s.start+1-d,s.start+1)}return false}else{if(this.rtl&&t==39){var b=h.shiftKey;var d=b?1:0;if(b){this._setSelection(s.start-1,s.length+d+s.start-1)}else{this._setSelection(s.start-1,s.start-1)}return false}}if(t==8){this.Backspace();return false}if(t==190||t==110){var g=this.GetSeparatorPositionInText(this.decimalSeparator,this.numberInput.val());this._setSelectionStart(g+1);return false}if(t==188){var r=this.numberInput.val();for(f=s.start;f<r.length;f++){if(r[f]==this.groupSeparator){this._setSelectionStart(1+f);break}}return false}if((h.ctrlKey&&t==99)||(h.ctrlKey&&t==67)){var s=this._selection();var u="";var q=this.numberInput.val();if(s.start>0||s.length>0){for(var f=s.start;f<s.end;f++){u+=q.substring(f,f+1)}}if(a.jqx.browser.msie){window.clipboardData.setData("Text",u)}this.savedText=u;return false}if((h.ctrlKey&&t==122)||(h.ctrlKey&&t==90)){return false}if((h.ctrlKey&&t==118)||(h.ctrlKey&&t==86)||(h.shiftKey&&t==45)){if(this.savedText!=null&&this.savedText.length>0){for(var f=0;f<this.savedText.length;f++){var n=parseInt(this.savedText.substring(f,f+1));if(!isNaN(n)){this.insertsimple(n)}}}return false}var c=String.fromCharCode(t);var n=parseInt(c);if(t>=96&&t<=105){n=t-96;t=t-48}if(!isNaN(n)){var l=this;this.insertsimple(n);return false}if(t==46){this.Delete();return false}if(t==38){this.spinUp();return false}else{if(t==40){this.spinDown();return false}}var o=this._isSpecialKey(t);if(!a.jqx.browser.mozilla){return true}return o},_getEditRange:function(){var c=0;var b=0;for(i=0;i<this.items.length;i++){if(this.items[i].canEdit){c=i;break}}for(i=this.items.length-1;i>=0;i--){if(this.items[i].canEdit){b=i;break}}return{start:c,end:b}},_getVisibleItems:function(){var b=new Array();var c=0;for(i=0;i<this.items.length;i++){if(this.items[i].character.toString().length>0){b[c]=this.items[i];c++}}return b},_hasEmptyVisibleItems:function(){var b=this._getVisibleItems();for(i=0;i<b.length;i++){if(b[i].canEdit&&b[i].character==this.promptChar){return true}}return false},_getFirstVisibleNonEmptyIndex:function(){var b=this._getVisibleItems();for(i=0;i<b.length;i++){if(b[i].canEdit&&b[i].character!=this.promptChar){return i}}},_handleMouse:function(f,b){var d=this._selection();if(d.length<=1){var c=this._getFirstVisibleNonEmptyIndex();if(d.start<c){this._setSelectionStart(c)}}},_insertKey:function(l){this.numberInput[0].focus();var d=String.fromCharCode(l);var e=parseInt(d);if(isNaN(e)){return}var q=0;for(i=0;i<this.items.length;i++){if(this.items[i].character.length==0){q++}}var g=this._selection();var b=this;if(g.start>=0&&g.start<=this.items.length){var f=false;var h=this._getFirstVisibleNonEmptyIndex();if(g.start<h&&g.length==0){if(!isNaN(d)||d==" "){this._setSelectionStart(h);g=this._selection()}}var c=this._getFirstEditableItemIndex();var o=this._getLastEditableItemIndex();var n=this._getVisibleItems();a.each(n,function(x,B){if(g.start>x&&x!=n.length-1){return}var E=n[x];if(x>o){E=n[o]}if(isNaN(d)||d==" "){return}if(!E.canEdit){return}var A=b._getSeparatorPosition();if(b._match(d,E.regex)){if(!f&&g.length>0){for(j=g.start+q;j<g.end+q;j++){if(b.items[j].canEdit){if(j>A){b.items[j].character="0"}else{b.items[j].character=b.promptChar}}}var D=b._getString();f=true}var A=b._getSeparatorPosition();var y=b._hasEmptyVisibleItems();if(g.start<=A&&y){var v=x;if(b.decimalSeparatorPosition==-1&&g.start==A){v=x+1}var u="";for(p=0;p<v;p++){if(n[p].canEdit&&n[p].character!=b.promptChar){u+=n[p].character}}u+=d;var w=b.decimal<1?1:0;if(g.start==A&&b.decimalSeparatorPosition!=-1){u+=b.decimalSeparator;w=0}for(p=v+w;p<n.length;p++){if(n[p].character==b.decimalSeparator&&n[p].isSeparator){u+=n[p].character}else{if(n[p].canEdit&&n[p].character!=b.promptChar){u+=n[p].character}}}if(b.decimalSeparator!="."){u=b._parseDecimalValue(u)}u=parseFloat(u).toString();u=new Number(u);u=u.toFixed(b.decimalDigits);if(b.decimalSeparator!="."){u=b._parseDecimalValueToEditorValue(u)}b.setvalue("decimal",u);var D=b._getString();if(g.end<A){b._setSelectionStart(g.end+w)}else{b._setSelectionStart(g.end)}if(g.length>=1){b._setSelectionStart(g.end)}if(g.length==b.numberInput.val().length){var r=b._moveCaretToDecimalSeparator();var C=b.decimalSeparatorPosition>=0?1:0;b._setSelectionStart(r-C)}}else{if(g.start<A||g.start>A){if(b.numberInput.val().length==g.start&&b.decimalSeparatorPosition!=-1){return false}else{if(b.numberInput.val().length==g.start&&b.decimalSeparatorPosition==-1&&!y){return false}}var u="";var s=false;for(p=0;p<x;p++){if(n[p].canEdit&&n[p].character!=b.promptChar){u+=n[p].character}if(n[p].character==b.decimalSeparator&&n[p].isSeparator){u+=n[p].character;s=true}}u+=d;var w=b.decimal<1?1:0;if(!s&&g.start==A-1){u+=b.decimalSeparator;s=true}for(p=x+1;p<n.length;p++){if(!s&&n[p].character==b.decimalSeparator&&n[p].isSeparator){u+=n[p].character}else{if(n[p].canEdit&&n[p].character!=b.promptChar){u+=n[p].character}}}b.setvalue("decimal",u);var D=b._getString();if(b.decimalSeparatorPosition<0&&E==n[o]){b._setSelectionStart(x);return false}var z=D.indexOf(b.symbol);var t=!b.getvalue("negative")?0:1;if(z<=t){z=D.length}if(g.start<z){b._setSelectionStart(x+1)}else{b._setSelectionStart(x)}if(g.length>=1){}if(g.length==b.numberInput.val().length){var r=b._moveCaretToDecimalSeparator();b._setSelectionStart(r-1)}}}return false}})}},_handleKeyPress:function(h,d){var f=this._selection();var b=this;if((h.ctrlKey&&d==97)||(h.ctrlKey&&d==65)){return true}if(d==8){if(f.start>0){b._setSelectionStart(f.start)}return false}if(d==46){if(f.start<this.items.length){b._setSelectionStart(f.start)}return false}if(d==45||d==173||d==109||d==189){var c=this.getvalue("negative");if(c==false){this.setvalue("negative",true)}else{this.setvalue("negative",false)}}if(a.jqx.browser.msie){this._insertKey(d)}var g=this._isSpecialKey(d);return g},_deleteSelectedText:function(){var d=this._selection();var c="";var f=this._getSeparatorPosition();var b=this._getVisibleItems();var e=this._getHiddenPrefixCount();if(this.numberInput.val().length==d.start&&d.length==0){this._setSelection(d.start,d.start+1);d=this._selection()}for(i=0;i<d.start;i++){if(b[i].canEdit&&b[i].character!=this.promptChar){c+=b[i].character}else{if(!b[i].canEdit&&this.decimalSeparatorPosition!=-1&&b[i]==b[this.decimalSeparatorPosition-e]){if(c.length==0){c="0"}c+=b[i].character}}}for(i=d.start;i<d.end;i++){if(i>f&&this.decimalSeparatorPosition!=-1){if(b[i].canEdit&&b[i].character!=this.promptChar){c+="0"}}else{if(!b[i].canEdit&&this.decimalSeparatorPosition!=-1&&b[i]==b[this.decimalSeparatorPosition-e]){if(c.length==0){c="0"}c+=b[i].character}}}for(i=d.end;i<b.length;i++){if(b[i].canEdit&&b[i].character!=this.promptChar){c+=b[i].character}else{if(!b[i].canEdit&&this.decimalSeparatorPosition!=-1&&b[i]==b[this.decimalSeparatorPosition-e]){if(c.length==0){c="0"}c+=b[i].character}}}this.setvalue("decimal",c);return d.length>0},_restoreInitialState:function(){var b=parseInt(this.decimalDigits);if(b>0){b+=2}for(k=this.items.length-1;k>this.items.length-1-b;k--){if(this.items[k].canEdit&&this.items[k].character==this.promptChar){this.items[k].character=0}}},clear:function(){this.setDecimal(0)},clearDecimal:function(){if(this.inputMode=="textbox"){this.numberInput.val();return}for(var b=0;b<this.items.length;b++){if(this.items[b].canEdit){this.items[b].character=this.promptChar}}this._restoreInitialState()},_saveSelectedText:function(){var c=this._selection();var d="";var b=this._getVisibleItems();if(c.start>0||c.length>0){for(i=c.start;i<c.end;i++){if(b[i].canEdit&&b[i].character!=this.promptChar){d+=b[i].character}else{if(b[i].isSeparator){d+=b[i].character}}}}if(a.jqx.browser.msie){window.clipboardData.setData("Text",d)}return d},_pasteSelectedText:function(){var f=this._selection();var h="";var c=0;this.selectedText=a.data(document.body,"jqxSelection");if(window.clipboardData){var d=window.clipboardData.getData("Text");if(d!=this.selectedText&&d.length>0){this.selectedText=window.clipboardData.getData("Text");if(this.selectedText==null||this.selectedText==undefined){return}}}var e=f.start;var n=this._getVisibleItems();if(this.selectedText!=null){for(var l=0;l<this.selectedText.length;l++){var b=parseInt(this.selectedText[l]);if(!isNaN(b)){var g=48+b;this._insertKey(g)}}}},_getHiddenPrefixCount:function(){var b=0;if(!this.negative){b++}if(this.symbolPosition=="left"){for(i=0;i<this.symbol.length;i++){if(this.symbol.substring(i,i+1)==""){b++}}}return b},_getEditableItem:function(){var b=this._selection();for(i=0;i<this.items.length;i++){if(i<b.start){if(this.items[i].canEdit&&this.items[i].character!=this.promptChar){return this.items[i]}}}return null},_getEditableItems:function(){var c=new Array();var b=0;for(i=0;i<this.items.length;i++){if(this.items[i].canEdit){c[b]=this.items[i];b++}}return c},_getValidSelectionStart:function(b){for(i=this.items.length-1;i>=0;i--){if(this.items[i].canEdit&&this.items[i].character!=this.promptChar){return i}}return -1},_getEditableItemIndex:function(c){var e=this._selection();var f=this._getHiddenPrefixCount();var b=this._getVisibleItems();var d=e.start;var g=-1;for(i=0;i<d;i++){if(i<b.length&&b[i].canEdit){g=i+f}}if(g==-1&&e.length>0){d=e.end;for(i=0;i<d;i++){if(i<b.length&&b[i].canEdit){g=i+f;break}}}return g},_getEditableItemByIndex:function(b){for(k=0;k<this.items.length;k++){if(k>b){if(this.items[k].canEdit&&this.items[k].character!=this.promptChar){return k}}}return -1},_getFirstEditableItemIndex:function(){var b=this._getVisibleItems();for(m=0;m<b.length;m++){if(b[m].character!=this.promptChar&&b[m].canEdit&&b[m].character!="0"){return m}}return -1},_getLastEditableItemIndex:function(){var b=this._getVisibleItems();for(m=b.length-1;m>=0;m--){if(b[m].character!=this.promptChar&&b[m].canEdit){return m}}return -1},_moveCaretToDecimalSeparator:function(){for(i=this.items.length-1;i>=0;i--){if(this.items[i].character==this.decimalSeparator&&this.items[i].isSeparator){if(!this.negative){this._setSelectionStart(i);return i}else{this._setSelectionStart(i+1);return i}break}}return this.numberInput.val().length},_handleBackspace:function(){var e=this._selection();var f=this._getHiddenPrefixCount();var b=this._getEditableItemIndex()-f;if(b>=0){if(e.length==0&&b!=-1){this._setSelection(b,b+1)}var g=e.start>this._getSeparatorPosition()+1&&this.decimalSeparatorPosition>0;if(g){e=this._selection()}var d=this._deleteSelectedText();if(e.length<1||g){this._setSelectionStart(e.start)}else{if(e.length>=1){this._setSelectionStart(e.end)}}if(e.length==this.numberInput.val().length){var c=this._moveCaretToDecimalSeparator();this._setSelectionStart(c-1)}}else{this._setSelectionStart(e.start)}},_handleKeyDown:function(f,q){var o=this._selection();if(this.rtl&&q==37){var b=f.shiftKey;var d=b?1:0;if(b){this._setSelection(o.start+1-d,o.start+o.length+1)}else{this._setSelection(o.start+1-d,o.start+1)}return false}else{if(this.rtl&&q==39){var b=f.shiftKey;var d=b?1:0;if(b){this._setSelection(o.start-1,o.length+d+o.start-1)}else{this._setSelection(o.start-1,o.start-1)}return false}}if((f.ctrlKey&&q==97)||(f.ctrlKey&&q==65)){return true}if((f.ctrlKey&&q==120)||(f.ctrlKey&&q==88)){this.selectedText=this._saveSelectedText(f);a.data(document.body,"jqxSelection",this.selectedText);this._handleBackspace();return false}if((f.ctrlKey&&q==99)||(f.ctrlKey&&q==67)){this.selectedText=this._saveSelectedText(f);a.data(document.body,"jqxSelection",this.selectedText);return false}if((f.ctrlKey&&q==122)||(f.ctrlKey&&q==90)){return false}if((f.ctrlKey&&q==118)||(f.ctrlKey&&q==86)||(f.shiftKey&&q==45)){this._pasteSelectedText();return false}if(o.start>=0&&o.start<this.items.length){var c=String.fromCharCode(q);var s=this.items[o.start]}if(q==8){this._handleBackspace();return false}if(q==190||q==110){this._moveCaretToDecimalSeparator();return false}if(q==188){var n=this.numberInput.val();for(i=o.start;i<n.length;i++){if(n[i]==this.groupSeparator){this._setSelectionStart(1+i);break}}return false}if(a.jqx.browser.msie==null){var c=String.fromCharCode(q);var h=parseInt(c);if(q>=96&&q<=105){h=q-96;q=q-48}if(!isNaN(h)){var g=this;g._insertKey(q);return false}}if(q==46){var r=this._getVisibleItems();if(o.start<r.length){var d=r[o.start].canEdit==false?2:1;if(o.length==0){this._setSelection(o.start+d,o.start+d+o.length)}this._handleBackspace();if(new Number(this.decimal)<1||o.start>this._getSeparatorPosition()){this._setSelectionStart(o.end+d)}else{if(o.start+1<this.decimalSeparatorPosition){this._setSelectionStart(o.end+d)}}}return false}if(q==38){this.spinUp();return false}else{if(q==40){this.spinDown();return false}}var l=this._isSpecialKey(q);if(!a.jqx.browser.mozilla){return true}return l},_isSpecialKey:function(b){if(b!=8&&b!=9&&b!=13&&b!=35&&b!=36&&b!=37&&b!=39&&b!=27&&b!=46){return false}return true},_selection:function(){try{if("selectionStart" in this.numberInput[0]){var g=this.numberInput[0];var h=g.selectionEnd-g.selectionStart;return{start:g.selectionStart,end:g.selectionEnd,length:h,text:g.value}}else{var d=document.selection.createRange();if(d==null){return{start:0,end:g.value.length,length:0}}var c=this.numberInput[0].createTextRange();var f=c.duplicate();c.moveToBookmark(d.getBookmark());f.setEndPoint("EndToStart",c);var h=d.text.length;return{start:f.text.length,end:f.text.length+d.text.length,length:h,text:d.text}}}catch(b){return{start:0,end:0,length:0}}},_setSelection:function(f,b){if(this._disableSetSelection==true){return}var e=a.jqx.mobile.isTouchDevice();if(e||this.touchMode==true){return}try{if("selectionStart" in this.numberInput[0]){this.numberInput[0].focus();this.numberInput[0].setSelectionRange(f,b)}else{var c=this.numberInput[0].createTextRange();c.collapse(true);c.moveEnd("character",b);c.moveStart("character",f);c.select()}}catch(d){}},_setSelectionStart:function(b){this._setSelection(b,b);a.data(this.numberInput,"selectionstart",b)},_render:function(f){var c=parseInt(this.host.css("border-left-width"));var h=parseInt(this.host.css("border-left-width"));var g=parseInt(this.host.css("border-left-width"));var d=parseInt(this.host.css("border-left-width"));this.numberInput.css("padding-top","0px");this.numberInput.css("padding-bottom","0px");this.host.height(this.height);this.host.width(this.width);var e=this.host.width();var o=this.host.height();this.numberInput.css({"border-left-width":0,"border-right-width":0,"border-bottom-width":0,"border-top-width":0});this.numberInput.css("text-align",this.textAlign);var q=this.numberInput.css("font-size");this.numberInput.css("height",parseInt(q)+4+"px");this.numberInput.css("width",e-2);var n=o-2*g-parseInt(q)-2;if(isNaN(n)){n=0}if(n<0){n=0}if(this.spinButtons&&this.spincontainer){e-=parseInt(this.spinButtonsWidth-2);var l=a.jqx.mobile.isTouchDevice();if(!l&&this.touchMode!==true){this.spincontainer.width(this.spinButtonsWidth);this.upbutton.width(this.spinButtonsWidth+2);this.downbutton.width(this.spinButtonsWidth+2);this.upbutton.height("50%");this.downbutton.height("50%");this.spincontainer.width(this.spinButtonsWidth)}else{this.spincontainer.width(2*(this.spinButtonsWidth));e-=this.spinButtonsWidth;this.upbutton.height("100%");this.downbutton.height("100%");this.downbutton.css("float","left");this.upbutton.css("float","right");this.upbutton.width(this.spinButtonsWidth);this.downbutton.width(1+this.spinButtonsWidth)}this._upArrow.height("100%");this._downArrow.height("100%");this.numberInput.css("width",e-6);this.numberInput.css("margin-right","2px")}var b=n/2;if(a.jqx.browser.msie&&a.jqx.browser.version<8){b=n/4}this.numberInput.css("padding-left","0px");this.numberInput.css("padding-right","0px");this.numberInput.css("padding-top",Math.round(b)+"px");this.numberInput.css("padding-bottom",Math.round(b)+"px");if(f==undefined||f==true){this.numberInput.val(this._getString());if(this.inputMode!="advanced"){this._parseDecimalInSimpleMode()}}},destroy:function(){this._removeHandlers();this.host.remove()},inputValue:function(b){if(b===undefined){return this._value()}this.propertyChangedHandler(this,"value",this._value,b);this._refreshValue();return this},_value:function(){var b=this.numberInput.val();return b},val:function(b){if(b!=undefined&&typeof b!="object"){this.setDecimal(b)}else{return this.getDecimal()}},getDecimal:function(){if(this.inputMode=="simple"){this._parseDecimalInSimpleMode(false);this.decimal=this._getDecimalInSimpleMode(this.decimal)}if(this.decimal==""){return 0}var b=this.getvalue("negative");if(b&&this.decimal>0){return -parseFloat(this.decimal)}return parseFloat(this.decimal)},setDecimal:function(d){var b=d;if(this.decimalSeparator!="."){d=d.toString();var f=d.indexOf(".");if(f!=-1){var c=d.substring(0,f);var e=d.substring(f+1);d=c+this.decimalSeparator+e}if(d<0){this.setvalue("negative",true)}else{this.setvalue("negative",false)}this._setDecimal(d)}else{if(d<0){this.setvalue("negative",true)}else{this.setvalue("negative",false)}this._setDecimal(Math.abs(d))}if(b==null){this.numberInput.val("")}},_setDecimal:function(r){if(r==null||r==undefined){r=0}if(r.toString().indexOf("e")!=-1){r=0}this.clearDecimal();var s=r.toString();var t="";var b="";var d=true;if(s.length==0){s="0"}for(var g=0;g<s.length;g++){if(s.substring(g,g+1)==this.decimalSeparator){d=false;continue}if(d){t+=s.substring(g,g+1)}else{b+=s.substring(g,g+1)}}if(t.length>0){t=parseFloat(t).toString()}var o=this.digits;if(o<t.length){t=t.substr(0,o)}var f=0;var q=this._getSeparatorPosition();var n=this._getHiddenPrefixCount();q=q+n;for(var g=q;g>=0;g--){if(g<this.items.length&&this.items[g].canEdit){if(f<t.length){this.items[g].character=t.substring(t.length-f-1,t.length-f);f++}}}f=0;for(var g=q;g<this.items.length;g++){if(this.items[g].canEdit){if(f<b.length){this.items[g].character=b.substring(f,f+1);f++}}}this._refreshValue();if(this.decimalSeparator=="."){this.ValueString=new Number(r).toFixed(this.decimalDigits)}else{var l=r.toString().indexOf(this.decimalSeparator);if(l>0){var h=r.toString().substring(0,l);var e=h+"."+r.toString().substring(l+1);this.ValueString=new Number(e).toFixed(this.decimalDigits)}else{this.ValueString=new Number(r).toFixed(this.decimalDigits)}}if(this.inputMode!="advanced"){this._parseDecimalInSimpleMode();this._raiseEvent(1,this.ValueString)}if(this.inputMode=="textbox"){this.decimal=this.ValueString;var c=this.getvalue("negative");if(c){this.decimal="-"+this.ValueString}}var r=this.val();if(r<this.min||r>this.max){this.host.addClass("jqx-input-invalid")}else{this.host.removeClass("jqx-input-invalid")}},_getSeparatorPosition:function(){var b=this._getHiddenPrefixCount();if(this.decimalSeparatorPosition>0){return this.decimalSeparatorPosition-b}return this.items.length-b},_setTheme:function(){this.host.removeClass();this.host.addClass(this.toThemeProperty("jqx-input"));this.host.addClass(this.toThemeProperty("jqx-rc-all"));this.host.addClass(this.toThemeProperty("jqx-widget"));this.host.addClass(this.toThemeProperty("jqx-widget-content"));this.host.addClass(this.toThemeProperty("jqx-numberinput"));if(this.spinButtons){this.downbutton.removeClass();this.upbutton.removeClass();this.downbutton.addClass(this.toThemeProperty("jqx-scrollbar-button-state-normal"));this.upbutton.addClass(this.toThemeProperty("jqx-scrollbar-button-state-normal"));this._upArrow.removeClass();this._downArrow.removeClass();this._upArrow.addClass(this.toThemeProperty("jqx-icon-arrow-up"));this._downArrow.addClass(this.toThemeProperty("jqx-icon-arrow-down"))}this.numberInput.removeClass();this.numberInput.addClass(this.toThemeProperty("jqx-input-content"))},propertyChangedHandler:function(c,d,g,f){if(d=="digits"||d=="groupSize"||d=="decimalDigits"){if(f<0){throw new Exception(this.invalidArgumentExceptions[0])}}if(d==="theme"){a.jqx.utilities.setTheme(g,f,c.host)}if(d=="digits"){if(f!=g){c.digits=parseInt(f)}}if(d=="min"||d=="max"){a.jqx.aria(c,"aria-value"+d,f.toString());c._refreshValue()}if(d=="decimalDigits"){if(f!=g){c.decimalDigits=parseInt(f)}}if(d=="decimalSeparator"||d=="digits"||d=="symbol"||d=="symbolPosition"||d=="groupSize"||d=="groupSeparator"||d=="decimalDigits"||d=="negativeSymbol"){var b=c.decimal;if(d=="decimalSeparator"&&f==""){f=" "}if(g!=f){var e=c._selection();c.items=new Array();c._initializeLiterals();c.value=c._getString();c._refreshValue();c._setDecimal(b)}}if(d=="rtl"){if(c.rtl){if(c.spincontainer){c.spincontainer.css("float","right");c.spincontainer.css("border-right-width","1px")}c.numberInput.css("float","right")}else{if(c.spincontainer){c.spincontainer.css("float","right");c.spincontainer.css("border-right-width","1px")}c.numberInput.css("float","left")}}if(d=="spinButtons"){if(c.spincontainer){if(!f){c.spincontainer.css("display","none")}else{c.spincontainer.css("display","block")}c._render()}else{c._spinButtons()}}if(d==="touchMode"){c.inputMode="textbox";c.spinMode="simple";c.render()}if(d=="negative"&&c.inputMode=="advanced"){var e=c._selection();var h=0;if(f){c.items[0].character=c.negativeSymbol[0];h=1}else{c.items[0].character="";h=-1}c._refreshValue();if(c.isInitialized){c._setSelection(e.start+h,e.end+h)}}if(d=="decimal"){c.value=f;c.setDecimal(f)}if(d==="value"){c.value=f;c.setDecimal(f);c._raiseEvent(1,f)}if(d=="textAlign"){c.textAlign=f;c._render()}if(d=="disabled"){c.numberInput.attr("disabled",f);if(c.disabled){c.host.addClass(c.toThemeProperty("jqx-fill-state-disabled"))}else{c.host.removeClass(c.toThemeProperty("jqx-fill-state-disabled"))}a.jqx.aria(c,"aria-disabled",f.toString())}if(d=="readOnly"){c.readOnly=f}if(d=="promptChar"){for(i=0;i<c.items.length;i++){if(c.items[i].character==c.promptChar){c.items[i].character=f}}c.promptChar=f}if(d=="width"){c.width=f;c._render()}else{if(d=="height"){c.height=f;c._render()}}},_value:function(){var b=this.value;return b},_refreshValue:function(){var g=this.value;var b=0;if(this.inputMode==="textbox"){return}this.value=this._getString();g=this.value;var f="";for(var c=0;c<this.items.length;c++){var e=this.items[c];if(e.canEdit&&e.character!=this.promptChar){f+=e.character}if(c==this.decimalSeparatorPosition){f+="."}}this.decimal=f;var d=false;if(this.oldValue!==g){this.oldValue=g;this._raiseEvent(0,g);d=true}if(this.inputMode!="simple"){this.numberInput.val(g);if(d){this._raiseEvent(1,g)}}if(g==null){this.numberInput.val("")}}})})(jQuery);