if (typeof (Telerik) == "undefined")
{
	Telerik = {};
}
if (Telerik.DateParsing == null)
{
	Telerik.DateParsing = {};
}

var dp = Telerik.DateParsing;

with(dp)
{
    dp.DateEvaluator = function(formatInfo)
	    {
		    this.Buckets = [null, null, null];
		    if (formatInfo != null)
		    {
			    this.Slots = formatInfo.DateSlots;
			    this.ShortYearCenturyEnd = formatInfo.ShortYearCenturyEnd;
		    }
		    else
		    {
			    this.Slots = 
				    {
					    Year: 2, Month: 0, Day: 1
				    };
			    this.ShortYearCenturyEnd = 2029;
		    }
	    }
    	
    	DateEvaluator.ParseDecimalInt = function(text)
	    {
			return parseInt(text, 10);
	    }
	    
	    DateEvaluator.prototype = 
	    {
		    Distribute: function(originalTokens)
		    {
		        var tokens = originalTokens.slice(0, originalTokens.length);
			    while (tokens.length > 0)
			    {
				    var token = tokens.shift();
    				
				    if (this.IsYear(token))
				    {
					    if (this.Buckets[this.Slots.Year] != null)
					    {
						    var oldYearToken = this.Buckets[this.Slots.Year];
						    
						    if (this.IsYear(oldYearToken))
						        throw new DateParseException();
						    
						    tokens.unshift(oldYearToken);
						}
    						
					    this.Buckets[this.Slots.Year] = token;
    					
					    var day = this.Buckets[this.Slots.Day];
					    if (day != null)
					    {
						    this.Buckets[this.Slots.Day] = null;
						    tokens.unshift(day);
					    }
				    }
				    else if(this.IsMonth(token))
				    {
					    if (this.Buckets[this.Slots.Month] != null)
						    tokens.unshift(this.Buckets[this.Slots.Month]);
    						
					    this.Buckets[this.Slots.Month] = token;
    					
					    var day = this.Buckets[this.Slots.Day];
					    if (day != null)
					    {
						    this.Buckets[this.Slots.Day] = null;
						    tokens.unshift(day);
					    }
				    }
				    else
				    {
					    var firstAvailablePosition = this.GetFirstAvailablePosition(token, this.Buckets);
					    if (typeof(firstAvailablePosition) != "undefined")
					    {
					        this.Buckets[firstAvailablePosition] = token;
					    }
                        else if (token.Type == "NUMBER" && this.Buckets[this.Slots.Month] == null && this.Buckets[this.Slots.Day] != null)
                        {
                            var oldDayToken = this.Buckets[this.Slots.Day];
                            if (oldDayToken.Value <= 12)
                            {
                                this.Buckets[this.Slots.Day] = token;
                                this.Buckets[this.Slots.Month] = oldDayToken;
                            }
                        }				    
				    }
			    }
		    },
    		
		    TransformShortYear: function(year)
		    {
			    if (year < 100)
			    {
				    var centuryEnd = this.ShortYearCenturyEnd;
				    var centuryStart = centuryEnd - 99;
    				
				    var lastTwoDigits = centuryStart % 100;
				    var delta = year - lastTwoDigits;
				    if (delta < 0)
					    delta += 100;
    					
				    return centuryStart + delta;
			    }
			    else
			    {
				    return year;
			    }
		    },
    		
		    GetYear: function()
		    {
			    var yearToken = this.Buckets[this.Slots.Year];
			    if (yearToken != null)
			    {
				    var yearValue = this.TransformShortYear(DateEvaluator.ParseDecimalInt(yearToken.Value));
				    return yearValue;
			    }
			    else
			    {
				    return null;
			    }
		    },
    		
		    GetMonth: function()
		    {
			    if (this.IsYearDaySpecialCase())
			    {
				    return null;
			    }
			    else
			    {
				    return this.GetMonthIndex();
			    }
		    },
    		
		    GetMonthIndex: function()
		    {
			    var monthToken = this.Buckets[this.Slots.Month];
			    if (monthToken != null)
			    {
				    if (monthToken.Type == "MONTHNAME")
				    {
					    return monthToken.GetMonthIndex();
				    }
				    else if (monthToken.Type == "NUMBER")
				    {
					    return DateEvaluator.ParseDecimalInt(monthToken.Value) - 1;
				    }
			    }
			    else
			    {
				    return null;
			    }
		    },
    		
		    GetDay: function()
		    {
			    if (this.IsYearDaySpecialCase())
			    {
				    var monthToken = this.Buckets[this.Slots.Month];
				    return DateEvaluator.ParseDecimalInt(monthToken.Value);
			    }
			    else
			    {	
				    var dayToken = this.Buckets[this.Slots.Day];
				    if (dayToken != null)
				    {
					    return DateEvaluator.ParseDecimalInt(dayToken.Value);
				    }
				    else
				    {
					    return null;
				    }
			    }
		    },
    		
		    //mimicking Outlook's behavior: four digit number and another number 
		    //must be interpreted as YEAR DAY
		    IsYearDaySpecialCase: function()
		    {
			    var dayToken = this.Buckets[this.Slots.Day];
			    var yearToken = this.Buckets[this.Slots.Year];
			    var monthToken = this.Buckets[this.Slots.Month];
    			
			    return (yearToken != null && this.IsYear(yearToken) && 
				    monthToken != null && monthToken.Type == "NUMBER" && 
				    dayToken == null);
		    },
    		
		    IsYear: function(token)
		    {
			    if (token.Type == "NUMBER")
			    {
				    var value = DateEvaluator.ParseDecimalInt(token.Value);
				    return (value > 31 && value <= 9999);
			    }
			    else
			    {
				    return false;
			    }
		    },
    		
		    IsMonth: function(token)
		    {
			    return token.Type == "MONTHNAME";
		    },
		    
		    GetFirstAvailablePosition: function(token, buckets)
		    {
			    for (var i = 0; i < buckets.length; i++)
			    {	
				    if (i == this.Slots.Month && token.Type == "NUMBER")
				    {
					    var value = DateEvaluator.ParseDecimalInt(token.Value);
					    if (value > 12)
					    {
						    continue;
						}
				    }
    				
				    if (buckets[i] == null)
					    return i;
			    }
		    },
		    
		    NumericSpecialCase: function(tokens)
		    {
		        for (var i=0; i < tokens.length; i++)
				{
				    if (tokens[i].Type != "NUMBER")
				        return false;
				}
				
	            var dayToken = this.Buckets[this.Slots.Day];
			    var yearToken = this.Buckets[this.Slots.Year];
			    var monthToken = this.Buckets[this.Slots.Month];
			 
			    var emptyBuckets = 0;
			    if (!dayToken)
			        emptyBuckets++;
			    if (!yearToken)
			        emptyBuckets++;
			    if (!monthToken)
			        emptyBuckets++;
			        
			    return (tokens.length + emptyBuckets != this.Buckets.length);				
		    },
		    
		    GetDate: function(tokens, date)
		    {
		        var result = DateEntry.CloneDate(date);
		        
	            this.Distribute(tokens);
	            
	            if (this.NumericSpecialCase(tokens))
	            {
	                throw new DateParseException();
	            }   
		        
		        var year = this.GetYear();
	            if (year != null)
	            {
		            result.setFullYear(year);
	            }
	            
	            var month = this.GetMonth();
	            if (month != null)
	            {
		            result.setMonth(month);
	            }
	            
	            var day = this.GetDay();
	            if (day != null)
	            {
		            var originalMonth = result.getMonth();
		            result.setDate(day)
		            if (result.getMonth() != originalMonth)
		            {
			            result.setMonth(originalMonth);
			            var calendar = new DatePickerGregorianCalendar();
			            var daysInMonth = calendar.GetDaysInMonth(result);
			            result.setDate(daysInMonth);
		            }
	            }
        		
	            return result;
		    },
		    
		    GetDateFromSingleEntry: function(token, date)
		    {
		        var result = DateEntry.CloneDate(date);
		        
        		if (token.Type == "MONTHNAME")
        		{
        			result.setMonth(token.GetMonthIndex());
        		}
        		else if (token.Type == "WEEKDAYNAME")
        		{
        			var currentIndex = date.getDay();
        			var nextIndex = token.GetWeekDayIndex();
        			var delta = (7 - currentIndex + nextIndex) % 7;
        			result.setDate(result.getDate() + delta);
        		}
        		else if (this.IsYear(token))
        		{
        		    var yearValue = this.TransformShortYear(DateEvaluator.ParseDecimalInt(token.Value));
        			result.setFullYear(yearValue);
        		}
        		else if (token.Type == "NUMBER")
        		{
        			var value = DateEvaluator.ParseDecimalInt(token.Value);
        			if (value > 10000)
        				throw new DateParseException();
        				
        			result.setDate(value);
        			if (result.getMonth() != date.getMonth() || result.getYear() != date.getYear())
        				throw new DateParseException();
        		}
        		else
        		{
        			throw new DateParseException();
        		}
        		
        		return result;
		    }
	    }
};function DatePickerGregorianCalendar ()
{
	
}

DatePickerGregorianCalendar.prototype.GetYearDaysCount = function (dateObject)
{
    var year = dateObject.getFullYear();
    return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) ? 366 : 365;	
}

DatePickerGregorianCalendar.prototype.DaysInMonths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

DatePickerGregorianCalendar.prototype.GetDaysInMonth = function (dateObject)
{
    if (this.GetYearDaysCount(dateObject) == 366 && dateObject.getMonth() == 1)
    {
        return 29;
    }
    return this.DaysInMonths[dateObject.getMonth()];
};if (typeof (Telerik) == "undefined")
{
	Telerik = {};
}
if (Telerik.DateParsing == null)
{
	Telerik.DateParsing = {};
}

Telerik.DateParsing.DateTimeFormatInfo = function(data)
{	
	this.DayNames							= data.DayNames;
	this.AbbreviatedDayNames				= data.AbbreviatedDayNames;
	this.MonthNames							= data.MonthNames;
	this.AbbreviatedMonthNames				= data.AbbreviatedMonthNames;
	
	this.AMDesignator						= data.AMDesignator;
	this.PMDesignator						= data.PMDesignator;
	this.DateSeparator						= data.DateSeparator;
	this.TimeSeparator						= data.TimeSeparator;
	this.FirstDayOfWeek                     = data.FirstDayOfWeek;
	this.DateSlots                          = data.DateSlots;
	this.ShortYearCenturyEnd                = data.ShortYearCenturyEnd;
}

Telerik.DateParsing.DateTimeFormatInfo.prototype.LeadZero = function(x)
{
    return (x < 0 || x > 9 ? "" : "0") + x;
}
// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
// Field        | Full Form          | Short Form
// -------------+--------------------+-----------------------
// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)
// Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
//              | MMMM (full)        |
// Day of Month | dd (2 digits)      | d (1 or 2 digits)
// Day of Week  | EE (name - dddd)   | E (abbr - ddd)
// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)
// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)
// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)
// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)
// Minute       | mm (2 digits)      | m (1 or 2 digits)
// Second       | ss (2 digits)      | s (1 or 2 digits)
// AM/PM        | tt (2 digits)      | t (1 or 2 digits)
Telerik.DateParsing.DateTimeFormatInfo.prototype.FormatDate = function(date,format)
{
    if (!date)
    {
        return ""; //EmptyDate
    }
	format = format+"";
	format = format.replace(/%/ig, "");
	
	var result="";
	var i_format=0;
	var c="";
	var token="";
	
	var y = "" + date.getFullYear();
	//var M = date.getMonth();
	var M = date.getMonth() + 1;
	var d = date.getDate();	
	var E = date.getDay();
	var H = date.getHours();
	var m = date.getMinutes();
	var s = date.getSeconds();	
	
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4)
	{
	    y=""+(y-0+1900);
	}
	var WithoutCentury = y.substring(2,4);
	var IslessThan10 = 0 + WithoutCentury;
	if (IslessThan10<0) 
	{
	    value["y"]=""+ WithoutCentury.substring(1,2);
	}
	else
	{
	    value["y"]=""+ WithoutCentury;
	}
	value["yyyy"]=y;
	value["yy"]=WithoutCentury;
	value["M"]=M;
	value["MM"]=this.LeadZero(M);
	value["MMM"]= this.AbbreviatedMonthNames[M-1];
	value["MMMM"]= this.MonthNames[M-1];
	value["d"]=d;
	value["dd"]=this.LeadZero(d);
	value["dddd"]= this.DayNames[E];
	value["ddd"]= this.AbbreviatedDayNames[E];
	value["H"]=H;
	value["HH"]=this.LeadZero(H);
	if (H==0)
	{
	    value["h"]=12;
	}
	else if (H>12)
	{
	    value["h"]=H-12;
	}
	else 
	{
	    value["h"]=H;
	}
	value["hh"]=this.LeadZero(value["h"]);
	if (H > 11) 
	{ 
	    value["tt"]="PM";
	    value["t"]="P"; 
	}
	else 
	{ 
	    value["tt"]="AM"; 
	    value["t"]="A";
	}
	value["m"]=m;
	value["mm"]=this.LeadZero(m);
	value["s"]=s;
	value["ss"]=this.LeadZero(s);
	while (i_format < format.length) 
	{
		c = format.charAt(i_format);
		token = "";
		
		if (format.charAt(i_format) == "'")
		{
			//skip the opening ' marker
			i_format++;
		
			while((format.charAt(i_format) != "'"))
			{
				token += format.charAt(i_format);
				i_format++;
			}
			
			//skip the closing ' marker
			i_format++;
			
			result += token;
			continue;
		}
		
		while ((format.charAt(i_format) == c) && (i_format < format.length)) 
		{
			token += format.charAt(i_format++);
		}
		
		if (value[token] != null) 
		{ 
		    result += value[token]; 
		}
		else
		{ 
		    result += token; 
		}
	}
	return result;
};if (typeof (Telerik) == "undefined")
{
	Telerik = {};
}
if (Telerik.DateParsing == null)
{
	Telerik.DateParsing = {};
}

var dp = Telerik.DateParsing;
with (dp)
{
	dp.DateTimeLexer = function(dateTimeFormatInfo)
	{
	    this.DateTimeFormatInfo = dateTimeFormatInfo;
	}
	
	DateTimeLexer.LetterMatcher = new RegExp("[\u0041-\u005a\u0061-\u007a\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u021f\u0222-\u0233\u0250-\u02ad\u02b0-\u02b8\u02bb-\u02c1\u02d0\u02d1\u02e0-\u02e4\u02ee\u037a\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03ce\u03d0-\u03d7\u03da-\u03f3\u0400-\u0481\u048c-\u04c4\u04c7\u04c8\u04cb\u04cc\u04d0-\u04f5\u04f8\u04f9\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0621-\u063a\u0640-\u064a\u0671-\u06d3\u06d5\u06e5\u06e6\u06fa-\u06fc\u0710\u0712-\u072c\u0780-\u07a5\u0905-\u0939\u093d\u0950\u0958-\u0961\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8b\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b36-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb5\u0bb7-\u0bb9\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cde\u0ce0\u0ce1\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d60\u0d61\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc\u0edd\u0f00\u0f40-\u0f47\u0f49-\u0f6a\u0f88-\u0f8b\u1000-\u1021\u1023-\u1027\u1029\u102a\u1050-\u1055\u10a0-\u10c5\u10d0-\u10f6\u1100-\u1159\u115f-\u11a2\u11a8-\u11f9\u1200-\u1206\u1208-\u1246\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1286\u1288\u128a-\u128d\u1290-\u12ae\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12ce\u12d0-\u12d6\u12d8-\u12ee\u12f0-\u130e\u1310\u1312-\u1315\u1318-\u131e\u1320-\u1346\u1348-\u135a\u13a0-\u13f4\u1401-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u1780-\u17b3\u1820-\u1877\u1880-\u18a8\u1e00-\u1e9b\u1ea0-\u1ef9\u1f00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u207f\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2131\u2133-\u2139\u3005\u3006\u3031-\u3035\u3041-\u3094\u309d\u309e\u30a1-\u30fa\u30fc-\u30fe\u3105-\u312c\u3131-\u318e\u31a0-\u31b7\u3400-\u4db5\u4e00-\u9fa5\ua000-\ua48c\uac00-\ud7a3\uf900-\ufa2d\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe72\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc][\u0300-\u034e\u0360-\u0362\u0483-\u0486\u0488\u0489\u0591-\u05a1\u05a3-\u05b9\u05bb-\u05bd\u05bf\u05c1\u05c2\u05c4\u064b-\u0655\u0670\u06d6-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u0901-\u0903\u093c\u093e-\u094d\u0951-\u0954\u0962\u0963\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u0a02\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a70\u0a71\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0b01-\u0b03\u0b3c\u0b3e-\u0b43\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b82\u0b83\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c82\u0c83\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0d02\u0d03\u0d3e-\u0d43\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102c-\u1032\u1036-\u1039\u1056-\u1059\u17b4-\u17d3\u18a9\u20d0-\u20e3\u302a-\u302f\u3099\u309a\ufb1e\ufe20-\ufe23]?");
	DateTimeLexer.DigitMatcher = new RegExp("[0-9]");
	
	DateTimeLexer.prototype =
	{
		GetTokens: function(inputString)
		{
			this.Values = [];
			this.Characters = inputString.split("");
			this.Current = 0;
			
			var timeSeparator = this.DateTimeFormatInfo.TimeSeparator;

			while (this.Current < this.Characters.length)
			{
				var number = this.ReadCharacters(this.IsNumber);
				if (number.length > 0)
				{
					this.Values.push(number);
				}
				
				var word = this.ReadCharacters(this.IsLetter);
				if (word.length > 0)
				{
					if (word.length > 1)
						this.Values.push(word);
				}
				
				var separator = this.ReadCharacters(this.IsSeparator);
				if (separator.length > 0)
				{
					if (separator.toLowerCase() == timeSeparator.toLowerCase())
					{
						this.Values.push(separator);
					}
				}
			}
			
			return this.CreateTokens(this.Values);
		},
		
		IsNumber: function(character)
		{
			return character.match(DateTimeLexer.DigitMatcher);
		},
		
		IsLetter: function(character)
		{
			return character.match(DateTimeLexer.LetterMatcher);
		},
		
		IsSeparator: function(character)
		{
			return !this.IsNumber(character) && !this.IsLetter(character);
		},
		
		ReadCharacters: function(condition)
		{
			var result = [];
			while(this.Current < this.Characters.length)
			{
				var character = this.Characters[this.Current];
				if (condition.call(this, character))
				{
					result.push(character);
					this.Current++;
				}
				else
				{
					break;
				}
			}
			return result.join("");
		},
		
		CreateTokens: function(inputs)
		{
			var result = [];
			for (var i = 0; i < inputs.length; i++)
			{
				var tokenClasses = [NumberToken, MonthNameToken, WeekDayNameToken, TimeSeparatorToken, AMPMToken];
				for (var j = 0; j < tokenClasses.length; j++)
				{
					var tokenClass = tokenClasses[j];
					var token = tokenClass.Create(inputs[i], this.DateTimeFormatInfo);
					if (token != null)
					{
						result.push(token);
						break;
					}
				}
			}
			return result;
		}
	}
	
	//inspired by Yahoo UI
	//inheritance sequence:
	// 1. fully declare base class prototype
	// 2. declare the subclass constructor
	// 3. call Extend(subclass, baseclass)
	dp.Extend = function(subClass, baseClass)
	{
		var F = function() {};
		F.prototype = baseClass.prototype;
		subClass.prototype = new F();
		subClass.prototype.constructor = subClass;
		subClass.base = baseClass.prototype;
		if (baseClass.prototype.constructor == Object.prototype.constructor)
		{
			baseClass.prototype.constructor = baseClass;
		}
	}
	    
	
	dp.Token = function(type, value)
	{	
		this.Type = type;
		this.Value = value;
	}
	
	Token.prototype = 
	{
		toString: function()
		{
			return this.Value;
		}
	}
	
	Token.FindIndex = function(array, target)
	{
		if (target.length < 3)
			return -1;
			
		for (var i = 0; i < array.length; i++)
		{
			if (array[i].toLowerCase().indexOf(target) == 0)
				return i;
		}
		return -1;
	}

	dp.NumberToken = function(value)
	{
		Telerik.DateParsing.NumberToken.base.constructor.call(this, "NUMBER", value);
	}
	
	Extend(NumberToken, Token);

	dp.MonthNameToken = function(value, dateTimeFormatInfo)
	{   
		Telerik.DateParsing.MonthNameToken.base.constructor.call(this, "MONTHNAME", value);
		this.DateTimeFormatInfo = dateTimeFormatInfo;
	}
	
	Extend(MonthNameToken, Token);
	
	MonthNameToken.prototype.GetMonthIndex = function()
	{
		var index = Token.FindIndex(this.DateTimeFormatInfo.MonthNames, this.Value)
		if (index >= 0)
			return index;
		else
			return Token.FindIndex(this.DateTimeFormatInfo.AbbreviatedMonthNames, this.Value)
	}

	dp.WeekDayNameToken = function(value, dateTimeFormatInfo)
	{
		Telerik.DateParsing.WeekDayNameToken.base.constructor.call(this, "WEEKDAYNAME", value);
		this.DateTimeFormatInfo = dateTimeFormatInfo;
	}
	
	Extend(WeekDayNameToken, Token);
	
	WeekDayNameToken.prototype.GetWeekDayIndex = function()
	{
		var index = Token.FindIndex(this.DateTimeFormatInfo.DayNames, this.Value)
		if (index >= 0)
			return index;
		else
			return Token.FindIndex(this.DateTimeFormatInfo.AbbreviatedDayNames, this.Value);
	}
	
	NumberToken.Create = function(input)
    {
        var number = parseInt(input);
        if (!isNaN(number))
        {
            return new NumberToken(input);
        }
        
        return null;
    }
    
    MonthNameToken.Create = function(input, dateTimeFormatInfo)
    {
		if (!input)
			return null;
		
		var normalizedInput = input.toLowerCase();	
		var index = Token.FindIndex(dateTimeFormatInfo.MonthNames, normalizedInput)
		if (index < 0)
			index = Token.FindIndex(dateTimeFormatInfo.AbbreviatedMonthNames, normalizedInput)
			
		if (index >= 0)
			return new MonthNameToken(normalizedInput, dateTimeFormatInfo);
		else
			return null;
    }
    
    WeekDayNameToken.Create = function(input, dateTimeFormatInfo)
    {
		if (!input)
			return null;
			
		var normalizedInput = input.toLowerCase();	
		var index = Token.FindIndex(dateTimeFormatInfo.DayNames, normalizedInput)
		if (index < 0)
			index = Token.FindIndex(dateTimeFormatInfo.AbbreviatedDayNames, normalizedInput)
			
        if (index >= 0)
            return new WeekDayNameToken(normalizedInput, dateTimeFormatInfo);
        else
			return null;
        
        return null;
    }
    
    dp.TimeSeparatorToken = function(value)
	{
		Telerik.DateParsing.TimeSeparatorToken.base.constructor.call(this, "TIMESEPARATOR", value);
	}
	
	Extend(TimeSeparatorToken, Token);
	
	TimeSeparatorToken.Create = function(input, dateTimeFormatInfo)
	{
		if (input == dateTimeFormatInfo.TimeSeparator)
		{
			return new TimeSeparatorToken(input);
		}
	}
	
	dp.AMPMToken = function(value, isPM)
	{
		Telerik.DateParsing.AMPMToken.base.constructor.call(this, "AMPM", value);
		this.IsPM = isPM;
	}
	
	Extend(AMPMToken, Token);
	
	
	AMPMToken.Create = function(input, dateTimeFormatInfo)
	{
		var normalizedInput = input.toLowerCase();
		var isAM = (normalizedInput == dateTimeFormatInfo.AMDesignator.toLowerCase());
		var isPM = (normalizedInput == dateTimeFormatInfo.PMDesignator.toLowerCase());
		if (isAM || isPM)
		{
			return new AMPMToken(normalizedInput, isPM);
		}
	}
};if (typeof (Telerik) == "undefined")
{
	Telerik = {};
}
if (Telerik.DateParsing == null)
{
	Telerik.DateParsing = {};
}

var dp = Telerik.DateParsing;

with (dp)
{
	dp.DateTimeParser = function(timeInputOnly)
	{  
		this.TimeInputOnly = timeInputOnly;
	}
	
	DateTimeParser.prototype = 
	{
		CurrentIs: function(tokenType)
		{
			return (this.CurrentToken() != null &&
					this.CurrentToken().Type == tokenType);
		},
		
		NextIs: function(tokenType)
		{
			return (this.NextToken() != null &&
					this.NextToken().Type == tokenType);
		},
		
		CurrentToken: function()
		{
			return this.Tokens[this.CurrentTokenIndex];
		},
		
		NextToken: function()
		{
			return this.Tokens[this.CurrentTokenIndex + 1];
		},
		
		StepForward: function(step)
		{
			this.CurrentTokenIndex += step;
		},
		
		StepBack: function(step)
		{
			this.CurrentTokenIndex -= step;
		},
		
		Parse: function(tokens)
		{
			this.Tokens = tokens;
			this.CurrentTokenIndex = 0
			
			var date = this.ParseDate();
			
			var time = this.ParseTime();
			if (date == null && time == null)
			{
				throw new DateParseException();
			}
			
			if (time != null)
			{	
				var dateTime = new DateTimeEntry();
				dateTime.Date = date || new EmptyDateEntry();
				dateTime.Time = time;
				
				return dateTime;
			}
			else
			{
				return date;
			}
		},
		
		ParseDate: function()
		{
			if (this.TimeInputOnly)
			{
				return new EmptyDateEntry();
			}
			
			var result = this.Triplet()
			
			if (result == null)
				result = this.Pair();
				
			if (result == null)
				result = this.Month();
			if (result == null)
				result = this.Number();
			if (result == null)
				result = this.WeekDay()
				
			return result;
		},
		
		ParseTime: function()
		{
			var result = this.TimeTriplet();
			if (result == null)
				result = this.TimePair();
			if (result == null)
				result = this.AMPMTimeNumber();
			if (result == null)
				result = this.TimeNumber();
				
			return result;
		},
		
		TimeTriplet: function()
		{
			var result = null;
			var createTime = function(first, second)
			{
				return new TimeEntry(first.Tokens.concat(second.Tokens));
			}
			
			result = this.MatchTwoRules(this.TimeNumber, this.TimePair, createTime);
			
			return result;
		},
		
		TimePair: function()
		{
			var result = null;
			var createTime = function(first, second)
			{
				return new TimeEntry(first.Tokens.concat(second.Tokens));
			}
			
			result = this.MatchTwoRules(this.TimeNumber, this.AMPMTimeNumber, createTime);
			if (result == null)
				result = this.MatchTwoRules(this.TimeNumber, this.TimeNumber, createTime);
			
			return result;
		},
		
		TimeNumber: function()
		{
			if (this.CurrentIs("NUMBER") && !this.NextIs("AMPM"))
			{	
				var result = new TimeEntry([this.CurrentToken()]);
				if (this.NextIs("TIMESEPARATOR"))
					this.StepForward(2);
				else
					this.StepForward(1);
				
				return result;
			}
		},
		
		AMPMTimeNumber: function()
		{
			if (this.CurrentIs("NUMBER") && this.NextIs("AMPM"))
			{	
				var result = new TimeEntry([this.CurrentToken(), this.NextToken()]);
				this.StepForward(2);
				
				return result;
			}
		},
		
		Triplet: function()
		{	
			var result = this.PairAndNumber();
			if (result == null)
				result = this.NumberAndPair();
				
			return result;
		},
		
		Pair: function()
		{
			var result = null;
			var createPair = function(first, second)
			{
				return new PairEntry(first.Token, second.Token);
			}
			
			result = this.MatchTwoRules(this.Number, this.Number, createPair);
			if (result == null)
				result = this.MatchTwoRules(this.Number, this.Month, createPair);
			if (result == null)
				result = this.MatchTwoRules(this.Month, this.Number, createPair);
			return result;
		},
		
		PairAndNumber: function()
		{
			var createTriplet = function(first, second)
			{
				return new TripletEntry(first.First, first.Second, second.Token);
			}	
			return this.MatchTwoRules(this.Pair, this.Number, createTriplet);
		},
		
		NumberAndPair: function()
		{
			var createTriplet = function(first, second)
			{
				return new TripletEntry(first.Token, second.First, second.Second);
			}	
			return this.MatchTwoRules(this.Number, this.Pair, createTriplet);
		},
		
		WeekDayAndPair: function()
		{
			var getPair = function(first, second)
			{
				return second;
			}
			return this.MatchTwoRules(this.WeekDay, this.Pair, getPair);
		},
		
		MatchTwoRules: function(firstRule, secondRule, onSuccess)
		{
			var savedCurrentToken = this.CurrentTokenIndex;
			
			var first = firstRule.call(this);
			var second = null;
			
			if (first != null)
			{
				second = secondRule.call(this);
				if (second != null)
				{
					return onSuccess(first, second)
				}
			}
			
			this.CurrentTokenIndex = savedCurrentToken;
		},
		
		Month: function()
		{
			if (this.CurrentIs("MONTHNAME"))
			{
				var result = new SingleEntry(this.CurrentToken());
				this.StepForward(1);
				
				return result;
			}
			else if (this.CurrentIs("WEEKDAYNAME"))
			{
				this.StepForward(1);
				var result = this.Month();
				if (result == null)
					this.StepBack(1);
				return result;
			}
		},
		
		WeekDay: function()
		{
			if (this.CurrentIs("WEEKDAYNAME"))
			{
				var result = new SingleEntry(this.CurrentToken());
				this.StepForward(1);
				return result;
			}
		},
		
		Number: function()
		{
			if (this.NextIs("TIMESEPARATOR"))
				return null;
				
			if (this.CurrentIs("NUMBER"))
			{
				var result = new SingleEntry(this.CurrentToken());
				this.StepForward(1);
				
				return result;
			}
			else if (this.CurrentIs("WEEKDAYNAME"))
			{
				this.StepForward(1);
				var result = this.Number();
				if (result == null)
					this.StepBack(1);
				return result;
			}
		}
	}
	
	dp.DateEntry = function(type)
	{
		this.Type = type;
	}
	
	DateEntry.CloneDate = function (date)
	{   
		return new Date(date.getFullYear(), 
						date.getMonth(), 
						date.getDate(), 
						date.getHours(), 
						date.getMinutes(), 
						date.getSeconds(),
						0);
	}
	
	DateEntry.prototype = 
	{
		Evaluate: function(date)
		{
			throw new Error("must override");
		}
	};

	dp.PairEntry = function(firstToken, secondToken)
	{
		Telerik.DateParsing.PairEntry.base.constructor.call(this, "DATEPAIR");
		
		this.First = firstToken;
		this.Second = secondToken;
	}
	
	Extend(PairEntry, DateEntry);
	
	PairEntry.prototype.Evaluate = function(date, dateFormatInfo)
	{
		var tokens = [this.First, this.Second];
		
	    var evaluator = new DateEvaluator(dateFormatInfo);
		return evaluator.GetDate(tokens, date);
	}

	dp.TripletEntry = function(firstToken, secondToken, thirdToken)
	{
		Telerik.DateParsing.TripletEntry.base.constructor.call(this, "DATETRIPLET");
		
		this.First = firstToken;
		this.Second = secondToken;
		this.Third = thirdToken;
	}
	
	Extend(TripletEntry, DateEntry);
	
	TripletEntry.prototype.Evaluate = function(date, dateFormatInfo)
	{	
		var tokens = [this.First, this.Second, this.Third];
		
		var evaluator = new DateEvaluator(dateFormatInfo);
		return evaluator.GetDate(tokens, date);

	}

	dp.SingleEntry = function(token)
	{
		this.Token = token;
		Telerik.DateParsing.SingleEntry.base.constructor.call(this, token.Type);
	}
	
	Extend(SingleEntry, DateEntry);
	
	SingleEntry.prototype.Evaluate = function(date, dateFormatInfo)
	{
	    var evaluator = new DateEvaluator(dateFormatInfo);
		return evaluator.GetDateFromSingleEntry(this.Token, date);
	}
	
	dp.EmptyDateEntry = function(token)
	{
		this.Token = token;
		Telerik.DateParsing.EmptyDateEntry.base.constructor.call(this, "EMPTYDATE");
	}
	
	Extend(EmptyDateEntry, DateEntry);
	
	EmptyDateEntry.prototype.Evaluate = function(date, dateFormatInfo)
	{	
		return date;
	}
	
	dp.DateTimeEntry = function()
	{
		Telerik.DateParsing.DateTimeEntry.base.constructor.call(this, "DATETIME");
	}
	Extend(DateTimeEntry, DateEntry);
	
	DateTimeEntry.prototype.Evaluate = function(date, dateFormatInfo)
	{	
		var newDate = this.Date.Evaluate(date, dateFormatInfo);
		return this.Time.Evaluate(newDate, dateFormatInfo);
	}
	
	dp.TimeEntry = function(tokens)
	{
		Telerik.DateParsing.TimeEntry.base.constructor.call(this, "TIME");
		
		this.Tokens = tokens;
	}
	
	Extend(TimeEntry, DateEntry);
	
	TimeEntry.prototype.Evaluate = function(date, dateFormatInfo)
	{	
		var tokens = this.Tokens.slice(0, this.Tokens.length);
		
		var isPM = false;
		var isAMPMset = false;
		if (tokens[tokens.length - 1].Type == "AMPM")
		{
		    isAMPMset = true;
			isPM = tokens[tokens.length - 1].IsPM;
			tokens.pop();
		}
		
		if (tokens[tokens.length - 1].Value.length > 2)
		{
		    var militaryTimeNumber = tokens[tokens.length - 1].Value;
		    tokens[tokens.length - 1].Value = militaryTimeNumber.substring(0, militaryTimeNumber.length - 2);
		    tokens.push(NumberToken.Create(militaryTimeNumber.substring(militaryTimeNumber.length - 2, militaryTimeNumber.length), dateFormatInfo));
		}
		
		var result = DateEntry.CloneDate(date);
		result.setHours(0);
		result.setMinutes(0);
		result.setSeconds(0);
		result.setMilliseconds(0);
		
		var hours, minutes, seconds;
		
		
		
		if (tokens.length > 0)
		{
			hours = DateEvaluator.ParseDecimalInt(tokens[0].Value);
		}
		if (tokens.length > 1)
		{
			minutes = DateEvaluator.ParseDecimalInt(tokens[1].Value);
		}
		if (tokens.length > 2)
		{
			seconds = DateEvaluator.ParseDecimalInt(tokens[2].Value);
		}
		
		if (hours != null && hours < 24)
		{
			if (hours < 12 && isPM)
				hours += 12;
		    else if ((hours == 12) && !isPM && isAMPMset)
		        hours = 0;
				
			result.setHours(hours);
		}
		else
		{
			if (hours != null)
				throw new DateParseException();
		}
		if (minutes != null && minutes <= 60)
		{
			result.setMinutes(minutes);
		}
		else
		{
			if (minutes != null)
				throw new DateParseException();
		}
		if (seconds != null && seconds <=60)
		{
			result.setSeconds(seconds);
		}
		else
		{
			if (seconds != null)
				throw new DateParseException();
		}
		
		return result;
	}
	
	dp.DateParseException = function()
	{
		this.isDateParseException = true;
		this.message = "Invalid date!";
		
		//Safari hack. The browser does not hook the constructor properly.
		this.constructor = dp.DateParseException;
	};
};function RadDateInput (id, config, styles)
{    
	RadTextBox.Extend(this);
	
    this.CallBase("DisposeOldInstance", arguments);
    this.Constructor(id);
    this.Initialize(config, styles);
}

RadDateInput.prototype = 
{
	Constructor : function (id)
	{
		this.CallBase("Constructor", arguments); 
	},
	
    Initialize : function (config, styles)
	{
	    this.HoldsValidDateValue = true;
	    this.Step = 1;
	    this.hiddenFormat = "yyyy-MM-dd-HH-mm-ss";
		this.DateFormatInfo = new Telerik.DateParsing.DateTimeFormatInfo(config.DateTimeFormatInfo);   
		
		this.CallBase("Initialize", arguments);
		this.MaxDate = this.CloneDate(this.MaxDate);
		this.MinDate = this.CloneDate(this.MinDate);
	},
	
    AttachEventHandlers : function ()
	{
		this.CallBase("AttachEventHandlers", arguments);
		this.AttachToTextBoxEvent("keydown", "TextBoxKeyDownHandler");
		this.AttachToTextBoxEvent("keyup", "TextBoxKeyUpHandler");
	},
	
	TextBoxKeyUpHandler: function(e)
	{
		this.MoveUpDownInProgress = false;
	},
	
	TextBoxKeyDownHandler : function(e)
	{
		if (e.altKey || e.ctrlKey) return true;
		var isIE = /MSIE/.test(navigator.userAgent);
		var keyCode =  isIE ? e.keyCode : e.which;
		if (keyCode == 38)
		{   
			this.MoveUpDownInProgress = true;
			return this.Move(this.Step);           
		} 
		if (keyCode == 40)
		{   
			this.MoveUpDownInProgress = true;
			return this.Move(-this.Step);           
		} 
	},
	
	DelayValueChangedEvent: function()
	{
		var textBoxDelay = this.CallBase("DelayValueChangedEvent", arguments);
		return textBoxDelay || (this.MoveUpDownInProgress == true);
	},
	
	UpdateHiddenValueOnKeyPress: function()
	{
		//don't save the hidden -- we do that on blur only.
	},
	
	HandleWheel : function(isNegativeWheel)
	{
	    var step = (isNegativeWheel) ? -this.Step : this.Step;
	    return this.Move(step);
	},
	
    Move : function(step)
	{
	    var date = this.ParseDate(this.TextBoxElement.value);
	    
        if (!date)
	    {
	        return false;
	    }
    
	    var format = this.GetRaplacedFormat(date);
	    var part = this.GetCurrentDatePart(format);   
	    
        switch(part)
        {
            case "y":                
                date.setFullYear(date.getFullYear() + step);
              break;    
            case "M":
                date.setMonth(date.getMonth() + step);
              break;
            case "d":
                date.setDate(date.getDate() + step);
              break;
            case "h":
                date.setHours(date.getHours() + step);
              break;
            case "H":
                date.setHours(date.getHours() + step);
              break;
            case "m":
                date.setMinutes(date.getMinutes() + step);
              break;
            case "s":
                date.setSeconds(date.getSeconds() + step);
              break;   
            default:
              break;
        }	
        
        if ((this.GetMaxDate() < date) || (this.GetMinDate() > date))
        {
            return false;
        }
        this.SetValue(this.DateFormatInfo.FormatDate(date, this.DateFormat));
        
        var newFormat = this.GetRaplacedFormat(date);
        this.SetCaretPosition(newFormat.indexOf(part));
        return true;
	},
	
	GetRaplacedFormat : function(date)
	{     
	    var format = this.DateFormat;	 
	    
	    var dateParts = new Array(
	                                { "part": "y", "value": date.getYear() },
	                                { "part": "M", "value": date.getMonth() + 1 },
	                                { "part": "d", "value": date.getDate() },
	                                { "part": "h", "value": date.getHours() },
	                                { "part": "H", "value": date.getHours() },
	                                { "part": "m", "value": date.getMinutes() },
	                                { "part": "s", "value": date.getSeconds() }
	                               );
	                               
        var i;
        for (i = 0; i < dateParts.length; i++)	                               
        {
            var p = dateParts[i].part;
            var regexpReplace = new RegExp(p, "g");
	        var regexp1 = new RegExp(p);		
	        var regexp2 = new RegExp(p + p);
	        var newFormat = p + p;
    	    
            if (format.match(regexp1) && !format.match(regexp2) && dateParts[i].value.toString().length > 1)
	        {
	            format = format.replace(regexpReplace, newFormat);
	        }	
        }
	    
        if (format.match(/MMMM/))
	    {
	        var month = this.DateTimeFormatInfo.MonthNames[this.GetDate().getMonth()];
	        var i;
	        var newFormat = "";
	        for (i = 0; i < month.length; i++) newFormat += "M";
	        format = format.replace(/MMMM/, newFormat);
	    }	
        if (format.match(/dddd/))
	    {
	        var day = this.DateTimeFormatInfo.DayNames[this.GetDate().getDay()];
	        var i;
	        var newFormat = "";
	        for (i = 0; i < day.length; i++) newFormat += "d";
	        format = format.replace(/dddd/, newFormat);       
	    }	
	    
	    return format;
	},
	
	GetCurrentDatePart : function(format)
	{
	    var part = "";
	    var parts = "yhMdhHms";
	    
	    while (((parts.indexOf(part) == (-1))
                    || part == ""))
        {
	        this.CalculateSelection();	
            part = format.substring(this.SelectionStart, this.SelectionStart + 1);
            this.SelectText(this.SelectionStart - 1, this.SelectionEnd - 1);      
        }
        
        return part;
	},
	
	ValueChangedEventArgs : function(newValue, oldValue)
	{
		return { 
				"NewValue": newValue,
				"OldValue": oldValue,
				"NewDate": this.ParseDate(newValue), 
				"OldDate": this.ParseDate(oldValue)
			};
	},
	
    ParseDate : function (value, baseDate)
	{
	    try
		{
			var lexer = new Telerik.DateParsing.DateTimeLexer(this.DateFormatInfo);
			var tokens = lexer.GetTokens(value);
			var parser = new Telerik.DateParsing.DateTimeParser(this.DateTimeFormatInfo.TimeInputOnly);
			var entry = parser.Parse(tokens);
			
			baseDate = this.GetParsingBaseDate(baseDate);
				
			var date = entry.Evaluate(baseDate, this.DateFormatInfo);
			return date;
		}
		catch (parseError)
        {
			if (parseError.isDateParseException)
			{
				return null;
			}
			else
			{
				throw parseError;
			}
        }
	},
	
	GetParsingBaseDate: function(currentDate)
	{
		var result = currentDate;
		if (result == null)
			result = new Date();
			
		if (!this.DateInRange(result))
			result = this.GetMinDate();
			
		result.setHours(0, 0, 0, 0);
		return result;
	},
	
	GetFormattedValue: function(value, format)
	{
		if (value != "")
	    {
	        var date = this.ParseDate(value);
	        
	        date = (date > this.GetMaxDate()) ? this.GetMaxDate() : date;
	        date = (date < this.GetMinDate()) ? this.GetMinDate() : date;
	        value = this.DateFormatInfo.FormatDate(date, format);
	    }
	    return value;
	},

    GetMaxDate : function ()
    {
        return this.MaxDate;
    },

    GetMinDate : function ()
    {
        return this.MinDate;
    },
    
    SetDate : function (value)
    {
        this.SetValue(this.DateFormatInfo.FormatDate(value, this.DateFormat));
    },
    
    GetDate : function (value)
    {
        var date = this.CloneDate(this.HiddenElement.value);
        return date;
    },
    
    SetMaxDate : function(value)
	{
		return this.MaxDate;
	},
	
    SetMinDate : function(value)
	{
	    this.MinDate = value;
	},
	
    
    CloneDate : function (value)
    {
        if (!value)
		{
		    return null;
		}
		
        if (typeof(value) == "string")
        {
            value = value.split(/-/)
        }
        return new Date(
                        value[0], 
                        value[1] - 1, 
                        value[2], 
                        value[3], 
                        value[4], 
                        value[5],
                        0
                        );        
    },	
	
    // Overrdes
	SetHiddenValue : function(value)
	{
		var formattedValue = "";
		if (value != "")
	    {	
			var date = this.ParseDate(value);
        
			if (date == null)
			{
				var args = { Reason: RadInputErrorReason.ParseError, InputText: value };
				date = this.ResolveDateError(args, null)
			}
	        
	        if (date == null)
			{
				return false;
			}
			
	        if (!this.DateInRange(date))
	        {
				var args = { Reason: RadInputErrorReason.OutOfRange, InputText: value };
				date = this.ResolveDateError(args, date)
			}
	        
	        if (!this.DateInRange(date))
	        {
				return false;
	        }
	        
			formattedValue = this.DateFormatInfo.FormatDate(date, this.hiddenFormat);
	    }
	    
	    return this.CallBase("SetHiddenValue", [formattedValue]);
	},
	
	ResolveDateError: function(args, defaultDate)
	{
		var originalDate = this.GetDate();
		
		this.RaiseErrorEvent(args)
		
		var currentDate = this.GetDate();
		if (currentDate - originalDate != 0)
		{
			return currentDate;
		}
		else
		{
			return defaultDate;
		}
	},
	
	DateInRange: function(date)
	{
		return (this.CompareDates(date, this.GetMinDate()) >= 0) &&
				(this.CompareDates(date, this.GetMaxDate()) <= 0);
	},
	
	CompareDates: function(first, second)
	{
		return first - second;
	},

	GetDisplayValue : function()
	{
	    var date = this.CloneDate(this.HiddenElement.value);
		return this.DateFormatInfo.FormatDate(date, this.DisplayDateFormat);
	},

	GetEditValue : function()
	{
	    var date = this.CloneDate(this.HiddenElement.value);
		return this.DateFormatInfo.FormatDate(date, this.DateFormat);
	},
	
	UpdateHiddenValue : function ()
    {
		this.HoldsValidDateValue = (this.CallBase("UpdateHiddenValue", arguments) != false);
		return this.HoldsValidDateValue; 
    },

    UpdateDisplayValue : function ()
    {
		if (!this.HoldsValidDateValue)
		{
			this.HoldsValidDateValue = true;
		}
		else
		{
			this.CallBase("UpdateDisplayValue", arguments);
        }
    },
    
    UpdateCssClass: function()
    {
		if (!this.HoldsValidDateValue)
		{
			this.TextBoxElement.style.cssText = this.Styles["InvalidStyle"][0];
            this.TextBoxElement.className = this.Styles["InvalidStyle"][1];
		}
		else
		{
			this.CallBase("UpdateCssClass", arguments);
		}
    },
	
	GetValue : function ()
	{
		return this.GetEditValue();
	},
	
    IsNegative : function ()
	{
		return false;
	}
};;function RadDateInputMixins() 
{

}

RadDateInputMixins.Year = 
{
	PopulateDateInfo : function (dateInfo)
	{
		var value = this.GetValue().toString();
		if (value.length == 1) value = "0" + value;
		dateInfo[0] = "20" + value;
	},
	
	UpdateValue : function (dateObject)
	{
		this.value = dateObject.getFullYear().toString().substr(2);
	}
}; 

RadDateInputMixins.FullYear = 
{
	PopulateDateInfo : function (dateInfo)
	{
		dateInfo[0] = this.GetValue();
	},
	
	UpdateValue : function (dateObject)
	{
		this.value = dateObject.getFullYear().toString();
	}				
}; 

RadDateInputMixins.Month = 
{
	PopulateDateInfo : function (dateInfo)
	{
		dateInfo[1] = this.Options ? this.GetSelectedIndex() : this.GetValue() - 1;
	},
	
	
	UpdateAfterTrim : function (dateObject)
	{
		if (this.Options)
		{
			this.SetOption(dateObject.getMonth());
		}
		else
		{
			this.value = dateObject.getMonth() + 1;
		}
	},	
	
	UpdateValue : function (dateObject)
	{
		if (this.Options)
		{
			this.SetOption(dateObject.getMonth());
		}
		else
		{
			this.value = dateObject.getMonth() + 1;
		}
	},
	
	PostModifyDateOnChange : function (oldDate, newDate)
	{
		if (this.FlipDirection == 0)
		{
			return;
		}
		var offset = this.FlipDirection * 12;
		var value = this.Options ? this.GetSelectedIndex() : this.GetValue() - 1;
		newDate.setMonth(value + offset);		
	}		
}; 

RadDateInputMixins.Day = 
{
	PopulateDateInfo : function (dateInfo)
	{
		dateInfo[2] = this.GetValue();
	},

	UpdateAfterTrim : function (dateObject)
	{
		this.value = dateObject.getDate();
		this.upperLimit = this.controller.calendar.GetDaysInMonth(dateObject);
	},
	
	UpdateValue : function (dateObject)
	{
		
		this.value = dateObject.getDate();
		this.upperLimit = this.controller.calendar.GetDaysInMonth(dateObject);
	},
	
	PostModifyDateOnChange : function (oldDate, newDate)
	{
		if (this.FlipDirection == 0)
		{
			return;
		}		
		var offset = this.FlipDirection == 1 ? this.upperLimit : - this.upperLimit;
		
		newDate.setDate(this.value + offset);
	}
	
};
	
RadDateInputMixins.DayOfWeek = 
{
	PopulateDateInfo : function (dateInfo)
	{
	
	},
	
	UpdateValue : function (dateObject)
	{
		this.SetOption(dateObject.getDay());
	},
	
	PostModifyDateOnChange : function (oldDate, newDate)
	{
		var move = oldDate.getDay() - this.GetSelectedIndex() - (this.FlipDirection * 7);
		
		newDate.setDate(newDate.getDate() - move);
	}	
};	

RadDateInputMixins.Hour12 = 
{
	PopulateDateInfo : function (dateInfo)
	{
		
		dateInfo[6] = 11 - this.GetSelectedIndex();
	},
	
	UpdateValue : function (dateObject)
	{
		this.SetOption(11 - (dateObject.getHours() % 12));
	},
	
	PostModifyDateOnChange : function (oldDate, newDate)
	{
		var offset = this.FlipDirection * 12;
		
		newDate.setHours(newDate.getHours() - offset);
	}			
};	

RadDateInputMixins.Hour24 = 
{
	PopulateDateInfo : function (dateInfo)
	{
		dateInfo[3] = this.GetValue();
	},
	
	UpdateValue : function (dateObject)
	{
		this.value = dateObject.getHours();
	},
	
	PostModifyDateOnChange : function (oldDate, newDate)
	{
		var offset = this.FlipDirection * 24;
		newDate.setHours(newDate.getHours() + offset);
	}		
};	

RadDateInputMixins.AMPM = 
{
	PopulateDateInfo : function (dateInfo)
	{
		dateInfo[7] = this.GetSelectedIndex();
	},
	
	UpdateValue : function (dateObject)
	{
		this.SetOption(dateObject.getHours() >= 12 ? 1 : 0);
	}			
};	

RadDateInputMixins.Minute = 
{
	PopulateDateInfo : function (dateInfo)
	{
		dateInfo[4] = this.GetValue();
	},
	
	UpdateValue : function (dateObject)
	{
		this.value = dateObject.getMinutes();
	},
	
	PostModifyDateOnChange : function (oldDate, newDate)
	{
		var offset = this.FlipDirection * 60;
		
		newDate.setMinutes(newDate.getMinutes() + offset);
	}	
};		

RadDateInputMixins.Second = 
{
	PopulateDateInfo : function (dateInfo)
	{
		dateInfo[5] = this.GetValue();
	},
	
	UpdateValue : function (dateObject)
	{
		this.value = dateObject.getSeconds();
	},
	
	PostModifyDateOnChange : function (oldDate, newDate)
	{
		var offset = this.FlipDirection * 60;
		

		newDate.setSeconds(newDate.getSeconds() + offset);
	}	
	
};;