﻿var Spry;
if (!Spry) Spry = {};
if (!Spry.Widget) Spry.Widget = {};

Spry.Widget.BrowserSniff = function() {
	var b = navigator.appName.toString();
	var up = navigator.platform.toString();
	var ua = navigator.userAgent.toString();
	this.mozilla = this.ie = this.opera = r = false;
	var re_opera = /Opera.([0-9\.]*)/i;
	var re_msie = /MSIE.([0-9\.]*)/i;
	var re_gecko = /gecko/i;
	var re_safari = /safari\/([\d\.]*)/i;
	if (ua.match(re_opera)) {
		r = ua.match(re_opera);
		this.opera = true;
		this.version = parseFloat(r[1]);
	} else if (ua.match(re_msie)) {
		r = ua.match(re_msie);
		this.ie = true;
		this.version = parseFloat(r[1]);
	} else if (ua.match(re_safari)) {
		this.safari = true;
		this.version = 1.4;
	} else if (ua.match(re_gecko)) {
		var re_gecko_version = /rv:\s*([0-9\.]+)/i;
		r = ua.match(re_gecko_version);
		this.mozilla = true;
		this.version = parseFloat(r[1]);
	}
	this.windows = this.mac = this.linux = false;

	this.Platform = ua.match(/windows/i) ? "windows" :
					(ua.match(/linux/i) ? "linux" :
					(ua.match(/mac/i) ? "mac" :
					ua.match(/unix/i)? "unix" : "unknown"));
	this[this.Platform] = true;
	this.v = this.version;

	if (this.safari && this.mac && this.mozilla) {
		this.mozilla = false;
	}
};
Spry.is = new Spry.Widget.BrowserSniff();
Spry.Widget.ValidationTextField = function(element, type, options)
{
	type = Spry.Widget.Utils.firstValid(type, "none");
	if (typeof type != 'string') {
		return;
	}
	if (typeof Spry.Widget.ValidationTextField.ValidationDescriptors[type] == 'undefined') {
		return;
	}
	options = Spry.Widget.Utils.firstValid(options, {});
	this.type = type;
	if (!this.isBrowserSupported()) {
		options.useCharacterMasking = false;
	}
	this.init(element, options);
	var validateOn = ['submit'].concat(Spry.Widget.Utils.firstValid(this.options.validateOn, []));
	validateOn = validateOn.join(",");

	this.validateOn = 0;
	this.validateOn = this.validateOn | (validateOn.indexOf('submit') != -1 ? Spry.Widget.ValidationTextField.ONSUBMIT : 0);
	this.validateOn = this.validateOn | (validateOn.indexOf('blur') != -1 ? Spry.Widget.ValidationTextField.ONBLUR : 0);
	this.validateOn = this.validateOn | (validateOn.indexOf('change') != -1 ? Spry.Widget.ValidationTextField.ONCHANGE : 0);
	if (Spry.Widget.ValidationTextField.onloadDidFire)
		this.attachBehaviors();
	else
		Spry.Widget.ValidationTextField.loadQueue.push(this);
};
Spry.Widget.ValidationTextField.ONCHANGE = 1;
Spry.Widget.ValidationTextField.ONBLUR = 2;
Spry.Widget.ValidationTextField.ONSUBMIT = 4;
Spry.Widget.ValidationTextField.ERROR_REQUIRED = 1;
Spry.Widget.ValidationTextField.ERROR_FORMAT = 2;
Spry.Widget.ValidationTextField.ERROR_RANGE_MIN = 4;
Spry.Widget.ValidationTextField.ERROR_RANGE_MAX = 8;
Spry.Widget.ValidationTextField.ERROR_CHARS_MIN = 16;
Spry.Widget.ValidationTextField.ERROR_CHARS_MAX = 32;
Spry.Widget.ValidationTextField.ValidationDescriptors = {
	'none': {
	},
	'custom': {
	},
	'integer': {
		characterMasking: /[\-\+\d]/,
		regExpFilter: /^[\-\+]?\d*$/,
		validation: function(value, options) {
			if (value == '' || value == '-' || value == '+') {
				return false;
			}
			var regExp = /^[\-\+]?\d*$/;
			if (!regExp.test(value)) {
				return false;
			}
			options = options || {allowNegative:false};
			var ret = parseInt(value, 10);
			if (!isNaN(ret)) {
				var allowNegative = true;
				if (typeof options.allowNegative != 'undefined' && options.allowNegative == false) {
					allowNegative = false;
				}
				if (!allowNegative && value < 0) {
					ret = false;
				}
			} else {
				ret = false;
			}
			return ret;
		}
	},
	'real': {
		characterMasking: /[\d\.,\-\+e]/i,
		regExpFilter: /^[\-\+]?\d(?:|\.,\d{0,2})|(?:|e{0,1}[\-\+]?\d{0,})$/i,
		validation: function (value, options) {
			var regExp = /^[\+\-]?[0-9]+([\.,][0-9]+)?([eE]{0,1}[\-\+]?[0-9]+)?$/;
			if (!regExp.test(value)) {
				return false;
			}
			var ret = parseFloat(value);
			if (isNaN(ret)) {
				ret = false;
			}
			return ret;
		}
	},
	'currency': {
		formats: {
			'dot_comma': {
				characterMasking: /[\d\.\,\-\+\$]/,
				regExpFilter: /^[\-\+]?(?:[\d\.]*)+(|\,\d{0,2})$/,
				validation: function(value, options) {
					var ret = false;
					//2 or no digits after the comma
					if (/^(\-|\+)?\d{1,3}(?:\.\d{3})*(?:\,\d{2}|)$/.test(value) || /^(\-|\+)?\d+(?:\,\d{2}|)$/.test(value)) {
						value = value.toString().replace(/\./gi, '').replace(/\,/, '.');
						ret = parseFloat(value);
					}
					return ret;
				}
			},
			'comma_dot': {
				characterMasking: /[\d\.\,\-\+\$]/,
				regExpFilter: /^[\-\+]?(?:[\d\,]*)+(|\.\d{0,2})$/,
				validation: function(value, options) {
					var ret = false;
					
					if (/^(\-|\+)?\d{1,3}(?:\,\d{3})*(?:\.\d{2}|)$/.test(value) || /^(\-|\+)?\d+(?:\.\d{2}|)$/.test(value)) {
						value = value.toString().replace(/\,/gi, '');
						ret = parseFloat(value);
					}
					return ret;
				}
			}
		}
	},
	'email': {
		characterMasking: /[^\s]/,
		validation: function(value, options) {
			var rx = /^[\w\.-]+@[\w\.-]+\.\w+$/i;
			return rx.test(value);
		}
	},
	'date': {
		validation: function(value, options) {
			var formatRegExp = /^([mdy]+)[\.\-\/\\\s]+([mdy]+)[\.\-\/\\\s]+([mdy]+)$/i;
			var valueRegExp = this.dateValidationPattern;
			var formatGroups = options.format.match(formatRegExp);
			var valueGroups = value.match(valueRegExp);
			if (formatGroups !== null && valueGroups !== null) {
				var dayIndex = -1;
				var monthIndex = -1;
				var yearIndex = -1;
				for (var i=1; i<formatGroups.length; i++) {
					switch (formatGroups[i].toLowerCase()) {
						case "dd":
							dayIndex = i;
							break;
						case "mm":
							monthIndex = i;
							break;
						case "yy":
						case "yyyy":
							yearIndex = i;
							break;
					}
				}
				if (dayIndex != -1 && monthIndex != -1 && yearIndex != -1) {
					var maxDay = -1;
					var theDay = parseInt(valueGroups[dayIndex], 10);
					var theMonth = parseInt(valueGroups[monthIndex], 10);
					var theYear = parseInt(valueGroups[yearIndex], 10);
					if (theMonth < 1 || theMonth > 12) {
						return false;
					}
					switch (theMonth) {
						case 1:	// January
						case 3: // March
						case 5: // May
						case 7: // July
						case 8: // August
						case 10: // October
						case 12: // December
							maxDay = 31;
							break;
						case 4:	// April
						case 6: // Juna
						case 9: // September
						case 11: // November
							maxDay = 30;
							break;
						case 2: // February
							if ((parseInt(theYear/4, 10) * 4 == theYear) && (parseInt(theYear/100, 10) * 100 != theYear)) {
								maxDay = 29;
							} else {
								maxDay = 28;
							}
							break;
					}
					if (theDay < 1 || theDay > maxDay) {
						return false;
					}
					
					return (new Date(theYear, theMonth, theDay));
				}
			} else {
				return false;
			}
		}
	},
	'time': {
		validation: function(value, options) {
			//	HH:MM:SS T
			var formatRegExp = /([hmst]+)/gi;
			var valueRegExp = /(\d+|AM?|PM?)/gi;
			var formatGroups = options.format.match(formatRegExp);
			var valueGroups = value.match(valueRegExp);
			//mast match and have same length
			if (formatGroups !== null && valueGroups !== null) {
				if (formatGroups.length != valueGroups.length) {
					return false;
				}

				var hourIndex = -1;
				var minuteIndex = -1;
				var secondIndex = -1;
				//T is AM or PM
				var tIndex = -1;
				var theHour = 0, theMinute = 0, theSecond = 0, theT = 'AM';
				for (var i=0; i<formatGroups.length; i++) {
					switch (formatGroups[i].toLowerCase()) {
						case "hh":
							hourIndex = i;
							break;
						case "mm":
							minuteIndex = i;
							break;
						case "ss":
							secondIndex = i;
							break;
						case "t":
						case "tt":
							tIndex = i;
							break;
					}
				}
				if (hourIndex != -1) {
					var theHour = parseInt(valueGroups[hourIndex], 10);
					if (isNaN(theHour) || theHour > (formatGroups[hourIndex] == 'HH' ? 23 : 12 )) {
						return false;
					}
				}
				if (minuteIndex != -1) {
					var theMinute = parseInt(valueGroups[minuteIndex], 10);
					if (isNaN(theMinute) || theMinute > 59) {
						return false;
					}
				}
				if (secondIndex != -1) {
					var theSecond = parseInt(valueGroups[secondIndex], 10);
					if (isNaN(theSecond) || theSecond > 59) {
						return false;
					}
				}
				if (tIndex != -1) {
					var theT = valueGroups[tIndex].toUpperCase();
					if (
						formatGroups[tIndex].toUpperCase() == 'TT' && !/^a|pm$/i.test(theT) || 
						formatGroups[tIndex].toUpperCase() == 'T' && !/^a|p$/i.test(theT)
					) {
						return false;
					}
				}
				var date = new Date(2000, 0, 1, theHour + (theT.charAt(0) == 'P'?12:0), theMinute, theSecond);
				return date;
			} else {
				return false;
			}
		}
	},
	'credit_card': {
		characterMasking: /\d/,
		validation: function(value, options) {
			var regExp = null;
			options.format = options.format || 'ALL';
			switch (options.format.toUpperCase()) {
				case 'ALL': regExp = /^[3-6]{1}[0-9]{12,15}$/; break;
				case 'VISA': regExp = /^4[0-9]{12,15}$/; break;
				case 'MASTERCARD': regExp = /^5[1-5]{1}[0-9]{14}$/; break;
				case 'AMEX': regExp = /^3(4|7){1}[0-9]{13}$/; break;
				case 'DISCOVER': regExp = /^6011[0-9]{12}$/; break;
				case 'DINERSCLUB': regExp = /^3((0[0-5]{1}[0-9]{11})|(6[0-9]{12})|(8[0-9]{12}))$/; break;
			}
			if (!regExp.test(value)) {
				return false;
			}
			var digits = [];
			var j = 1, digit = '';
			for (var i = value.length - 1; i >= 0; i--) {
				if ((j%2) == 0) {
					digit = parseInt(value.charAt(i), 10) * 2;
					digits[digits.length] = digit.toString().charAt(0);
					if (digit.toString().length == 2) {
						digits[digits.length] = digit.toString().charAt(1);
					}
				} else {
					digit = value.charAt(i);
					digits[digits.length] = digit;
				}
				j++;
			}
			var sum = 0;
			for(i=0; i < digits.length; i++ ) {
				sum += parseInt(digits[i], 10);
			}
			if ((sum%10) == 0) {
				return true;
			}
			return false;
		}
	},
	'zip_code': {
		formats: {
			'zip_us9': {
				pattern:'00000-0000'
			},
			'zip_us5': {
				pattern:'00000'
			},
			'zip_uk': {
				characterMasking: /[\dA-Z\s]/,
				validation: function(value, options) {
					
					return /^[A-Z]{1,2}\d[\dA-Z]?\s?\d[A-Z]{2}$/.test(value);
				}
			},
			'zip_canada': {
				characterMasking: /[\dA-Z\s]/,
				pattern: 'A0A 0A0'
			},
			'zip_custom': {}
		}
	},
	'phone_number': {
		formats: {
			
			'phone_us': {
				pattern:'(000) 000-0000'
			},
			'phone_custom': {}
		}
	},
	'social_security_number': {
		pattern:'000-00-0000'
	},
	'ip': {
		characterMaskingFormats: {
			'ipv4': /[\d\.]/i,
			'ipv6_ipv4': /[\d\.\:A-F\/]/i,
			'ipv6': /[\d\.\:A-F\/]/i
		},
		validation: function (value, options) {
			return Spry.Widget.ValidationTextField.validateIP(value, options.format);
		}
	},

	'url': {
		characterMasking: /[^\s]/,
		validation: function(value, options) {
			
			var URI_spliter = /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
			var parts = value.match(URI_spliter);
			if (parts && parts[4]) {
				
				var host  = parts[4].split(".");
				var punyencoded = '';
				for (var i=0; i<host.length; i++) {
					punyencoded = Spry.Widget.Utils.punycode_encode(host[i], 64);
					if (!punyencoded) {
						return false;
					} else {
						if (punyencoded != (host[i] + "-")) {
							host[i] = 'xn--' + punyencoded;
						}
					}
				}
				host = host .join(".");
				
				value = value.replace(URI_spliter, "$1//" + host + "$5$6$8");
			}

			
			var regExp = /^(?:https?|ftp)\:\/\/(?:(?:[a-z0-9\-\._~\!\$\&\'\(\)\*\+\,\;\=:]|%[0-9a-f]{2,2})*\@)?(?:((?:(?:[a-z0-9][a-z0-9\-]*[a-z0-9]|[a-z0-9])\.)*(?:[a-z][a-z0-9\-]*[a-z0-9]|[a-z])|(?:\[[^\]]*\]))(?:\:[0-9]*)?)(?:\/(?:[a-z0-9\-\._~\!\$\&\'\(\)\*\+\,\;\=\:\@]|%[0-9a-f]{2,2})*)*(?:\?(?:[a-z0-9\-\._~\!\$\&\'\(\)\*\+\,\;\=\:\@\/\?]|%[0-9a-f]{2,2})*)?(?:\#(?:[a-z0-9\-\._~\!\$\&\'\(\)\*\+\,\;\=\:\@\/\?]|%[0-9a-f]{2,2})*)?$/i;

			var valid = value.match(regExp);
			if (valid) {
				//extract the  address from URL
				var address = valid[1];

				if (address) {
					if (address == '[]') {
						return false;
					}
					var first = address.charAt(0);
					var last = address.charAt(address.length - 1);
					if (first == '[' && last != ']' || first != '[' && last == ']') {
						return false;
					} else if (first == '[' && last == ']') {
						//IPv6 address or IPv4 enclosed in square brackets
						address = address.replace(/^\[|\]$/gi, '');
						return Spry.Widget.ValidationTextField.validateIP(address, 'ipv6_ipv4');
					} else {
						if (/[^0-9\.]/.test(address)) {
							return true;
						} else {
							//check if hostname is all digits and dots and then check for IPv4
							return Spry.Widget.ValidationTextField.validateIP(address, 'ipv4');
						}
					}
				} else {
					return true;
				}
			} else {
				return false;
			}
		}
	}
};
Spry.Widget.ValidationTextField.validateIP = function (value, format)
{
	var validIPv6Addresses = [
		//preferred
		/^(?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4}(?:\/\d{1,3})?$/i,
		//various compressed
		/^[a-f0-9]{0,4}::(?:\/\d{1,3})?$/i,
		/^:(?::[a-f0-9]{1,4}){1,6}(?:\/\d{1,3})?$/i,
		/^(?:[a-f0-9]{1,4}:){1,6}:(?:\/\d{1,3})?$/i,
		/^(?:[a-f0-9]{1,4}:)(?::[a-f0-9]{1,4}){1,6}(?:\/\d{1,3})?$/i,
		/^(?:[a-f0-9]{1,4}:){2}(?::[a-f0-9]{1,4}){1,5}(?:\/\d{1,3})?$/i,
		/^(?:[a-f0-9]{1,4}:){3}(?::[a-f0-9]{1,4}){1,4}(?:\/\d{1,3})?$/i,
		/^(?:[a-f0-9]{1,4}:){4}(?::[a-f0-9]{1,4}){1,3}(?:\/\d{1,3})?$/i,
		/^(?:[a-f0-9]{1,4}:){5}(?::[a-f0-9]{1,4}){1,2}(?:\/\d{1,3})?$/i,
		/^(?:[a-f0-9]{1,4}:){6}(?::[a-f0-9]{1,4})(?:\/\d{1,3})?$/i,
		//IPv6 mixes with IPv4
		/^(?:[a-f0-9]{1,4}:){6}(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i,
		/^:(?::[a-f0-9]{1,4}){0,4}:(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i,
		/^(?:[a-f0-9]{1,4}:){1,5}:(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i,
		/^(?:[a-f0-9]{1,4}:)(?::[a-f0-9]{1,4}){1,4}:(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i,
		/^(?:[a-f0-9]{1,4}:){2}(?::[a-f0-9]{1,4}){1,3}:(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i,	
		/^(?:[a-f0-9]{1,4}:){3}(?::[a-f0-9]{1,4}){1,2}:(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i,
		/^(?:[a-f0-9]{1,4}:){4}(?::[a-f0-9]{1,4}):(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,3})?$/i
	];
	var validIPv4Addresses = [
		//IPv4
		/^(\d{1,3}\.){3}\d{1,3}$/i
	];
	var validAddresses = [];
	if (format == 'ipv6' || format == 'ipv6_ipv4') {
		validAddresses = validAddresses.concat(validIPv6Addresses);
	}
	if (format == 'ipv4' || format == 'ipv6_ipv4') {
		validAddresses = validAddresses.concat(validIPv4Addresses);
	}
	var ret = false;
	for (var i=0; i<validAddresses.length; i++) {
		if (validAddresses[i].test(value)) {
			ret = true;
			break;
		}
	}
	if (ret && value.indexOf(".") != -1) {
		//if address contains IPv4 fragment, it must be valid; all 4 groups must be less than 256
		var ipv4 = value.match(/:?(?:\d{1,3}\.){3}\d{1,3}/i);
		if(!ipv4) {
			return false;
		}
		ipv4 = ipv4[0].replace(/^:/, '');
		var pieces = ipv4.split('.');
		if (pieces.length != 4) {
			return false;
		}
		var regExp = /^[\-\+]?\d*$/;
		for (var i=0; i< pieces.length; i++) {
			if (pieces[i] == '') {
				return false;
			}
			var piece = parseInt(pieces[i], 10);
			if (isNaN(piece) || piece > 255 || !regExp.test(pieces[i]) || pieces[i].length>3 || /^0{2,3}$/.test(pieces[i])) {
				return false;
			}
		}
	}
	if (ret && value.indexOf("/") != -1) {
		// if prefix-length is specified must be in [1-128]
		var prefLen = value.match(/\/\d{1,3}$/);
		if (!prefLen) return false;
		var prefLenVal = parseInt(prefLen[0].replace(/^\//,''), 10);
		if (isNaN(prefLenVal) || prefLenVal > 128 || prefLenVal < 1) {
			return false;
		}
	}
	return ret;
};
Spry.Widget.ValidationTextField.onloadDidFire = false;
Spry.Widget.ValidationTextField.loadQueue = [];
Spry.Widget.ValidationTextField.prototype.isBrowserSupported = function()
{
	return Spry.is.ie && Spry.is.v >= 5 && Spry.is.windows
		||
	Spry.is.mozilla && Spry.is.v >= 1.4
		||
	Spry.is.safari
		||
	Spry.is.opera && Spry.is.v >= 9;
};
Spry.Widget.ValidationTextField.prototype.init = function(element, options)
{
	this.element = this.getElement(element);
	this.errors = 0;
	this.flags = {locked: false};
	this.options = {};
	this.event_handlers = [];
	this.validClass = "textfieldValidState";
	this.focusClass = "textfieldFocusState";
	this.requiredClass = "textfieldRequiredState";
	this.invalidFormatClass = "textfieldInvalidFormatState";
	this.invalidRangeMinClass = "textfieldMinValueState";
	this.invalidRangeMaxClass = "textfieldMaxValueState";
	this.invalidCharsMinClass = "textfieldMinCharsState";
	this.invalidCharsMaxClass = "textfieldMaxCharsState";
	this.textfieldFlashTextClass = "textfieldFlashText";
	if (Spry.is.safari) {
		this.flags.lastKeyPressedTimeStamp = 0;
	}
	switch (this.type) {
		case 'phone_number':options.format = Spry.Widget.Utils.firstValid(options.format, 'phone_us');break;
		case 'currency':options.format = Spry.Widget.Utils.firstValid(options.format, 'comma_dot');break;
		case 'zip_code':options.format = Spry.Widget.Utils.firstValid(options.format, 'zip_us5');break;
		case 'date':
			options.format = Spry.Widget.Utils.firstValid(options.format, 'mm/dd/yy');
			break;
		case 'time':
			options.format = Spry.Widget.Utils.firstValid(options.format, 'HH:mm');
			options.pattern = options.format.replace(/[hms]/gi, "0").replace(/TT/gi, 'AM').replace(/T/gi, 'A');
			break;
		case 'ip':
			options.format = Spry.Widget.Utils.firstValid(options.format, 'ipv4');
			options.characterMasking = Spry.Widget.ValidationTextField.ValidationDescriptors[this.type].characterMaskingFormats[options.format]; 
			break;
	}
	var validationDescriptor = {};
	if (options.format && Spry.Widget.ValidationTextField.ValidationDescriptors[this.type].formats) {
		if (Spry.Widget.ValidationTextField.ValidationDescriptors[this.type].formats[options.format]) {
			Spry.Widget.Utils.setOptions(validationDescriptor, Spry.Widget.ValidationTextField.ValidationDescriptors[this.type].formats[options.format]);
		}
	} else {
		Spry.Widget.Utils.setOptions(validationDescriptor, Spry.Widget.ValidationTextField.ValidationDescriptors[this.type]);
	}
	options.useCharacterMasking = Spry.Widget.Utils.firstValid(options.useCharacterMasking, false);
	options.hint = Spry.Widget.Utils.firstValid(options.hint, '');
	options.isRequired = Spry.Widget.Utils.firstValid(options.isRequired, true);
	options.characterMasking = Spry.Widget.Utils.firstValid(options.characterMasking, validationDescriptor.characterMasking);
	options.regExpFilter = Spry.Widget.Utils.firstValid(options.regExpFilter, validationDescriptor.regExpFilter);
	options.pattern = Spry.Widget.Utils.firstValid(options.pattern, validationDescriptor.pattern);
	options.validation = Spry.Widget.Utils.firstValid(options.validation, validationDescriptor.validation);
	if (typeof options.validation == 'string') {
		options.validation = eval(options.validation);
	}
	options.minValue = Spry.Widget.Utils.firstValid(options.minValue, validationDescriptor.minValue);
	options.maxValue = Spry.Widget.Utils.firstValid(options.maxValue, validationDescriptor.maxValue);
	options.minChars = Spry.Widget.Utils.firstValid(options.minChars, validationDescriptor.minChars);
	options.maxChars = Spry.Widget.Utils.firstValid(options.maxChars, validationDescriptor.maxChars);
	Spry.Widget.Utils.setOptions(this, options);
	Spry.Widget.Utils.setOptions(this.options, options);
};
Spry.Widget.ValidationTextField.prototype.destroy = function() {
	for (var i=0; i<this.event_handlers.length; i++) {
		Spry.Widget.Utils.removeEventListener(this.event_handlers[i][0], this.event_handlers[i][1], this.event_handlers[i][2], false);
	}
	try { delete this.element; } catch(err) {}
	try { delete this.input; } catch(err) {}
	try { delete this.form; } catch(err) {}
	try { delete this.event_handlers; } catch(err) {}
	try { this.selection.destroy(); } catch(err) {}
	try { delete this.selection; } catch(err) {}
	var q = Spry.Widget.Form.onSubmitWidgetQueue;
	var qlen = q.length;
	for (var i = 0; i < qlen; i++) {
		if (q[i] == this) {
			q.splice(i, 1);
			break;
		}
	}
};
Spry.Widget.ValidationTextField.prototype.attachBehaviors = function()
{
	if (this.element) {
		if (this.element.nodeName == "INPUT") {
			this.input = this.element;
		} else {
			this.input = Spry.Widget.Utils.getFirstChildWithNodeNameAtAnyLevel(this.element, "INPUT");
		}
	}
	if (this.input) {
		if (this.maxChars) {
			this.input.removeAttribute("maxLength");
		}
		this.putHint();
		this.compilePattern();
		if (this.type == 'date') {
			this.compileDatePattern();
		}
		this.input.setAttribute("AutoComplete", "off");
		this.selection = new Spry.Widget.SelectionDescriptor(this.input);
		this.oldValue = this.input.value;
		var self = this;
		this.event_handlers = [];
		this.event_handlers.push([this.input, "keydown", function(e) { if (self.isDisabled()) return true; return self.onKeyDown(e || event); }]);
		this.event_handlers.push([this.input, "keypress", function(e) { if (self.isDisabled()) return true; return self.onKeyPress(e || event); }]);
		if (Spry.is.opera) {
			this.event_handlers.push([this.input, "keyup", function(e) { if (self.isDisabled()) return true; return self.onKeyUp(e || event); }]);
		}
		this.event_handlers.push([this.input, "focus", function(e) { if (self.isDisabled()) return true; return self.onFocus(e || event); }]);
		this.event_handlers.push([this.input, "blur", function(e) { if (self.isDisabled()) return true; return self.onBlur(e || event); }]);
		this.event_handlers.push([this.input, "mousedown", function(e) { if (self.isDisabled()) return true; return self.onMouseDown(e || event); }]);
		var changeEvent = 
			Spry.is.mozilla || Spry.is.opera || Spry.is.safari?"input":
			Spry.is.ie?"propertychange":
			"change";
		this.event_handlers.push([this.input, changeEvent, function(e) { if (self.isDisabled()) return true; return self.onChange(e || event); }]);
		if (Spry.is.mozilla || Spry.is.safari) {
			//oninput event on mozilla does not fire ondragdrop
			this.event_handlers.push([this.input, "dragdrop", function(e) { if (self.isDisabled()) return true; self.removeHint();return self.onChange(e || event); }]);
		} else if (Spry.is.ie){
			this.event_handlers.push([this.input, "drop", function(e) { if (self.isDisabled()) return true; return self.onDrop(e || event); }]);
		}
		for (var i=0; i<this.event_handlers.length; i++) {
			Spry.Widget.Utils.addEventListener(this.event_handlers[i][0], this.event_handlers[i][1], this.event_handlers[i][2], false);
		}
		this.form = Spry.Widget.Utils.getFirstParentWithNodeName(this.input, "FORM");
		if (this.form) {
			if (!this.form.attachedSubmitHandler && !this.form.onsubmit) {
				this.form.onsubmit = function(e) { e = e || event; return Spry.Widget.Form.onSubmit(e, e.srcElement || e.currentTarget) };
				this.form.attachedSubmitHandler = true;                 
			}
			if (!this.form.attachedResetHandler) {
				Spry.Widget.Utils.addEventListener(this.form, "reset", function(e) { e = e || event; return Spry.Widget.Form.onReset(e, e.srcElement || e.currentTarget) }, false);
				this.form.attachedResetHandler = true;                 
			}
			Spry.Widget.Form.onSubmitWidgetQueue.push(this);
		}
	}	
};
Spry.Widget.ValidationTextField.prototype.isDisabled = function() {
	return this.input && (this.input.disabled || this.input.readOnly) || !this.input;
};
Spry.Widget.ValidationTextField.prototype.getElement = function(ele)
{
	if (ele && typeof ele == "string")
		return document.getElementById(ele);
	return ele;
};
Spry.Widget.ValidationTextField.addLoadListener = function(handler)
{
	if (typeof window.addEventListener != 'undefined')
		window.addEventListener('load', handler, false);
	else if (typeof document.addEventListener != 'undefined')
		document.addEventListener('load', handler, false);
	else if (typeof window.attachEvent != 'undefined')
		window.attachEvent('onload', handler);
};
Spry.Widget.ValidationTextField.processLoadQueue = function(handler)
{
	Spry.Widget.ValidationTextField.onloadDidFire = true;
	var q = Spry.Widget.ValidationTextField.loadQueue;
	var qlen = q.length;
	for (var i = 0; i < qlen; i++)
		q[i].attachBehaviors();
};
Spry.Widget.ValidationTextField.addLoadListener(Spry.Widget.ValidationTextField.processLoadQueue);
Spry.Widget.ValidationTextField.addLoadListener(function(){
	Spry.Widget.Utils.addEventListener(window, "unload", Spry.Widget.Form.destroyAll, false);
});
Spry.Widget.ValidationTextField.prototype.setValue = function(newValue) {
	this.flags.locked = true;
	this.input.value = newValue;
	this.flags.locked = false;
	this.oldValue = newValue;
	if (!Spry.is.ie) {
		this.onChange();
	}
};
Spry.Widget.ValidationTextField.prototype.saveState = function()
{
	this.oldValue = this.input.value;
	this.selection.update();
};
Spry.Widget.ValidationTextField.prototype.revertState = function(revertValue)
{
	if (revertValue != this.input.value) {
		this.input.readOnly = true;
		this.input.value = revertValue;
		this.input.readOnly = false;
		if (Spry.is.safari && this.flags.active) {
			this.input.focus();
		}
	}
	this.selection.moveTo(this.selection.start, this.selection.end);

	this.redTextFlash();
};
Spry.Widget.ValidationTextField.prototype.removeHint = function()
{
	if (this.flags.hintOn) {
		this.input.value = "";
		this.flags.hintOn = false;
	}
};
Spry.Widget.ValidationTextField.prototype.putHint = function()
{
	if(this.hint && this.input && this.input.type == "text" && this.input.value == "") {
		this.flags.hintOn = true;
		this.input.value = this.hint;
	}
};
Spry.Widget.ValidationTextField.prototype.redTextFlash = function()
{
	var self = this;
	this.addClassName(this.element, this.textfieldFlashTextClass);
	setTimeout(function() {
		self.removeClassName(self.element, self.textfieldFlashTextClass)
	}, 100);
};
Spry.Widget.ValidationTextField.prototype.doValidations = function(testValue, revertValue)
{
	if (this.isDisabled()) return false;
	if (this.flags.locked) {
		return false;
	}
	if (testValue.length == 0 && !this.isRequired) {
		this.errors = 0;
		return false;
	}
	this.flags.locked = true;
	var mustRevert = false;
	var continueValidations = true;
	if (!this.options.isRequired && testValue.length == 0) {
		continueValidations = false;
	}
	var errors = 0;
	var fixedValue = testValue;
	if (this.useCharacterMasking && this.characterMasking) {
		for(var i=0; i<testValue.length; i++) {
			if (!this.characterMasking.test(testValue.charAt(i))) {
				errors = errors | Spry.Widget.ValidationTextField.ERROR_FORMAT;
				fixedValue = revertValue;
				mustRevert = true;
				break;
			}
		}
	}
	if (!mustRevert && this.useCharacterMasking && this.regExpFilter) {
		if (!this.regExpFilter.test(fixedValue)) {
			errors = errors | Spry.Widget.ValidationTextField.ERROR_FORMAT;
			mustRevert = true;
		}
	}
	if (!mustRevert && this.pattern) {
		var currentRegExp = this.patternToRegExp(testValue.length);
		if (!currentRegExp.test(testValue)) {
			errors = errors | Spry.Widget.ValidationTextField.ERROR_FORMAT;
			mustRevert = true;
		} else if (this.patternLength != testValue.length) {
			//testValue matches pattern so far, but it's not ok if it does not have the proper length
			errors = errors | Spry.Widget.ValidationTextField.ERROR_FORMAT;
		}
	}
	if (fixedValue == '') {
		errors = errors | Spry.Widget.ValidationTextField.ERROR_REQUIRED;
	}
	if (!mustRevert && this.pattern && this.useCharacterMasking) {
		var n = this.getAutoComplete(testValue.length);
		if (n) {
			fixedValue += n;
		}
	}
	if(!mustRevert && this.minChars !== null  && continueValidations) {
		if (testValue.length < this.minChars) {
			errors = errors | Spry.Widget.ValidationTextField.ERROR_CHARS_MIN;
			continueValidations = false;
		}
	}
	if(!mustRevert && this.maxChars !== null && continueValidations) {
		if (testValue.length > this.maxChars) {
			errors = errors | Spry.Widget.ValidationTextField.ERROR_CHARS_MAX;
			continueValidations = false;
		}
	}
	if (!mustRevert && this.validation && continueValidations) {
		var value = this.validation(fixedValue, this.options);
		if (false === value) {
			errors = errors | Spry.Widget.ValidationTextField.ERROR_FORMAT;
			continueValidations = false;
		} else {
			this.typedValue = value;
		}
	}
	if(!mustRevert && this.validation && this.minValue !== null && continueValidations) {
		var minValue = this.validation(this.minValue, this.options);
		if (minValue !== false) {
			if (this.typedValue < minValue) {
				errors = errors | Spry.Widget.ValidationTextField.ERROR_RANGE_MIN;
				continueValidations = false;
			}
		}
	}
	if(!mustRevert && this.validation && this.maxValue !== null && continueValidations) {
		var maxValue = this.validation(this.maxValue, this.options);
		if (maxValue !== false) {
			if( this.typedValue > maxValue) {
				errors = errors | Spry.Widget.ValidationTextField.ERROR_RANGE_MAX;
				continueValidations = false;
			}
		}
	}
	if (this.useCharacterMasking && mustRevert) {
		this.revertState(revertValue);
	}
	this.errors = errors;
	this.fixedValue = fixedValue;
	this.flags.locked = false;
	return mustRevert;
};
Spry.Widget.ValidationTextField.prototype.onChange = function(e)
{
	if (Spry.is.opera && this.flags.operaRevertOnKeyUp) {
		return true;
	}
	if (Spry.is.ie && e && e.propertyName != 'value') {
		return true;
	}
	if (this.flags.drop) {
		var self = this;
		setTimeout(function() {
			self.flags.drop = false;
			self.onChange(null);
		}, 0);
		return;
	}
	if (this.flags.hintOn) {
		return true;
	}
	if (this.keyCode == 8 || this.keyCode == 46 ) {
		var mustRevert = this.doValidations(this.input.value, this.input.value);
		this.oldValue = this.input.value;
		if ((mustRevert || this.errors) && this.validateOn & Spry.Widget.ValidationTextField.ONCHANGE) {
			var self = this;
			setTimeout(function() {self.validate();}, 0);
			return true;
		}
	}
	var mustRevert = this.doValidations(this.input.value, this.oldValue);
	if ((!mustRevert || this.errors) && this.validateOn & Spry.Widget.ValidationTextField.ONCHANGE) {
		var self = this;
		setTimeout(function() {self.validate();}, 0);
	}
	return true;
};
Spry.Widget.ValidationTextField.prototype.onKeyUp = function(e) {
	if (this.flags.operaRevertOnKeyUp) {
		this.setValue(this.oldValue);
		Spry.Widget.Utils.stopEvent(e);
		this.selection.moveTo(this.selection.start, this.selection.start);
		this.flags.operaRevertOnKeyUp = false;
		return false;
	}
	if (this.flags.operaPasteOperation) {
		window.clearInterval(this.flags.operaPasteOperation);
		this.flags.operaPasteOperation = null;
	}
};
Spry.Widget.ValidationTextField.prototype.operaPasteMonitor = function() {
	if (this.input.value != this.oldValue) {
		var mustRevert = this.doValidations(this.input.value, this.input.value);
		if (mustRevert) {
			this.setValue(this.oldValue);
			this.selection.moveTo(this.selection.start, this.selection.start);
		} else {
			this.onChange();
		}
	}
};
Spry.Widget.ValidationTextField.prototype.compileDatePattern = function () 
{
	var dateValidationPatternString = "";
	var groupPatterns = [];
	var fullGroupPatterns = [];
	var autocompleteCharacters = [];
	var formatRegExp = /^([mdy]+)([\.\-\/\\\s]+)([mdy]+)([\.\-\/\\\s]+)([mdy]+)$/i;
	var formatGroups = this.options.format.match(formatRegExp);
	if (formatGroups !== null) {
		for (var i=1; i<formatGroups.length; i++) {
			switch (formatGroups[i].toLowerCase()) {
				case "dd":
					groupPatterns[i-1] = "\\d{1,2}";
					fullGroupPatterns[i-1] = "\\d\\d";
					dateValidationPatternString += "(" + groupPatterns[i-1] + ")";
					autocompleteCharacters[i-1] = null;
					break;
				case "mm":
					groupPatterns[i-1] = "\\d{1,2}";
					fullGroupPatterns[i-1] = "\\d\\d";
					dateValidationPatternString += "(" + groupPatterns[i-1] + ")";
					autocompleteCharacters[i-1] = null;
					break;
				case "yy":
					groupPatterns[i-1] = "\\d{1,2}";
					fullGroupPatterns[i-1] = "\\d\\d";
					dateValidationPatternString += "(\\d\\d)";
					autocompleteCharacters[i-1] = null;
					break;
				case "yyyy":
					groupPatterns[i-1] = "\\d{1,4}";
					fullGroupPatterns[i-1] = "\\d\\d\\d\\d";
					dateValidationPatternString += "(\\d\\d\\d\\d)";
					autocompleteCharacters[i-1] = null;
					break;
				default:
					groupPatterns[i-1] = fullGroupPatterns[i-1] = Spry.Widget.ValidationTextField.regExpFromChars(formatGroups[i]);
					dateValidationPatternString += "["+ groupPatterns[i-1] + "]";
					autocompleteCharacters[i-1] = formatGroups[i];
			}
		}
	}
	this.dateValidationPattern = new RegExp("^" + dateValidationPatternString + "$" , "")
	this.dateAutocompleteCharacters = autocompleteCharacters;
	this.dateGroupPatterns = groupPatterns;
	this.dateFullGroupPatterns = fullGroupPatterns;
	this.lastDateGroup = formatGroups.length-2;
}
Spry.Widget.ValidationTextField.prototype.getRegExpForGroup = function (group) 
{
	var ret = '^';
	for (var j = 0; j <= group; j++) ret += this.dateGroupPatterns[j];
	ret += '$';
	return new RegExp(ret, "");	
}
Spry.Widget.ValidationTextField.prototype.getRegExpForFullGroup = function (group) 
{
	var ret = '^';
	for (var j = 0; j < group; j++) ret += this.dateGroupPatterns[j];
	ret += this.dateFullGroupPatterns[group];
	return new RegExp(ret, "");	
}
Spry.Widget.ValidationTextField.prototype.getDateGroup = function(value, pos) 
{
	if (pos == 0) return 0;
	var test_value = value.substring(0, pos);
	for (var i=0; i <= this.lastDateGroup; i++) 
		if (this.getRegExpForGroup(i).test(test_value)) return i;
	return -1;
};
Spry.Widget.ValidationTextField.prototype.isDateGroupFull = function(value, group) 
{
	return this.getRegExpForFullGroup(group).test(value);
}
Spry.Widget.ValidationTextField.prototype.isValueValid = function(value, pos, group) 
{
	var test_value = value.substring(0, pos);
	return this.getRegExpForGroup(group).test(test_value);
	}
Spry.Widget.ValidationTextField.prototype.isPositionAtEndOfGroup = function (value, pos, group)
{
	var test_value = value.substring(0, pos);
	return this.getRegExpForFullGroup(group).test(test_value);
}
Spry.Widget.ValidationTextField.prototype.nextDateDelimiterExists = function (value, pos, group)
{
	var autocomplete = this.dateAutocompleteCharacters[group+1];
	if (value.length < pos  + autocomplete.length) 
		return false;
	else 
	{
		var test_value = value.substring(pos, pos+autocomplete.length);
		if (test_value == autocomplete) 
			return true;
	}
	return false;
}
Spry.Widget.ValidationTextField.prototype.onKeyPress = function(e)
{
	if (this.flags.skp) {
		this.flags.skp = false;
		Spry.Widget.Utils.stopEvent(e);
		return false;
	}
	if (e.ctrlKey || e.metaKey || !this.useCharacterMasking) {
		return true;
	}
	if (Spry.is.opera && this.flags.operaRevertOnKeyUp) {
		Spry.Widget.Utils.stopEvent(e);
		return false;
	}
	if (this.keyCode == 8 || this.keyCode == 46) {
		var mr = this.doValidations(this.input.value, this.input.value);
		if (mr) {
			return true;
		}
	}
	var pressed = Spry.Widget.Utils.getCharacterFromEvent(e);
	if (pressed && this.characterMasking) {
		if (!this.characterMasking.test(pressed)) {
			Spry.Widget.Utils.stopEvent(e);
			this.redTextFlash();
			return false;
		}
	}
	if(pressed && this.pattern) {
		var currentPatternChar = this.patternCharacters[this.selection.start];
		if (/[ax]/i.test(currentPatternChar)) {
			if (currentPatternChar.toLowerCase() == currentPatternChar) {
				pressed = pressed.toLowerCase();
			} else {
				pressed = pressed.toUpperCase();
			}
		}
		var autocomplete = this.getAutoComplete(this.selection.start);
		if (this.selection.start == this.oldValue.length) {
			if (this.oldValue.length < this.patternLength) {
				if (autocomplete) {
					Spry.Widget.Utils.stopEvent(e);
					var futureValue = this.oldValue.substring(0, this.selection.start) + autocomplete + pressed;
					var mustRevert = this.doValidations(futureValue, this.oldValue);
					if (!mustRevert) {
						this.setValue(this.fixedValue);
						this.selection.moveTo(this.fixedValue.length, this.fixedValue.length);
					} else {
						this.setValue(this.oldValue.substring(0, this.selection.start) + autocomplete);
						this.selection.moveTo(this.selection.start + autocomplete.length, this.selection.start + autocomplete.length);
					}
					return false;
				}
			} else {
				Spry.Widget.Utils.stopEvent(e);
				this.setValue(this.input.value);
				return false;
			}
		} else if (autocomplete) {
			Spry.Widget.Utils.stopEvent(e);
			this.selection.moveTo(this.selection.start + autocomplete.length, this.selection.start + autocomplete.length);
			return false;
		}
		Spry.Widget.Utils.stopEvent(e);
		var futureValue = this.oldValue.substring(0, this.selection.start) + pressed + this.oldValue.substring(this.selection.start + 1);
		var mustRevert = this.doValidations(futureValue, this.oldValue);
		if (!mustRevert) {
			autocomplete = this.getAutoComplete(this.selection.start + 1);
			this.setValue(this.fixedValue);
			this.selection.moveTo(this.selection.start + 1 + autocomplete.length, this.selection.start + 1 + autocomplete.length);
		} else {
			this.selection.moveTo(this.selection.start, this.selection.start);
		}
		return false;
	}
	if (pressed && this.type == 'date' && this.useCharacterMasking) 
	{
		var group = this.getDateGroup(this.oldValue, this.selection.start);
		if (group != -1) {
			Spry.Widget.Utils.stopEvent(e);
			if ( (group % 2) !=0 ) 
				group ++;
			if (this.isDateGroupFull(this.oldValue, group)) 
			{
				if(this.isPositionAtEndOfGroup(this.oldValue, this.selection.start, group))
				{
					if(group == this.lastDateGroup) 
					{
						this.redTextFlash(); return false;
					}
					else 
					{
			var autocomplete = this.dateAutocompleteCharacters[group+1];
						
						if (this.nextDateDelimiterExists(this.oldValue, this.selection.start, group))
						{
							var autocomplete = this.dateAutocompleteCharacters[group+1];
							
							this.selection.moveTo(this.selection.start + autocomplete.length, this.selection.start + autocomplete.length);
							if (pressed == autocomplete) 
								return false;
							if (this.isDateGroupFull(this.oldValue, group+2)) 
								futureValue = this.oldValue.substring(0, this.selection.start) + pressed + this.oldValue.substring(this.selection.start + 1);
							else
								futureValue = this.oldValue.substring(0, this.selection.start) + pressed + this.oldValue.substring(this.selection.start);
								
							if (!this.isValueValid(futureValue, this.selection.start + 1, group +2 )) 
							{
								this.redTextFlash(); return false;						
							}
							else
							{
								this.setValue (futureValue);
								this.selection.moveTo(this.selection.start + 1, this.selection.start + 1);									
							}
							return false;					
						}
						else 
						{
							var autocomplete = this.dateAutocompleteCharacters[group+1];
							var insertedValue = autocomplete + pressed;
							futureValue = this.oldValue.substring(0, this.selection.start) + insertedValue + this.oldValue.substring(this.selection.start);
							if (!this.isValueValid(futureValue, this.selection.start + insertedValue.length, group +2 )) 
							{
								insertedValue = autocomplete;
								futureValue = this.oldValue.substring(0, this.selection.start) + insertedValue + this.oldValue.substring(this.selection.start);
								this.setValue (futureValue);
								this.selection.moveTo(this.selection.start + insertedValue.length, this.selection.start + insertedValue.length);									
								this.redTextFlash(); return false;
							}
							else 
							{
								this.setValue (futureValue);
								this.selection.moveTo(this.selection.start + insertedValue.length, this.selection.start + insertedValue.length);									
								return false;
							}
						}
						
					}
				}
				else
				{
					var movePosition = 1;
					futureValue = this.oldValue.substring(0, this.selection.start) + pressed + this.oldValue.substring(this.selection.start + 1);
					if (!this.isValueValid(futureValue, this.selection.start + 1, group)) 
					{
						this.redTextFlash(); return false;
					}
					else 
					{
						if(this.isPositionAtEndOfGroup(futureValue, this.selection.start+1, group)) 
						{
							if (group != this.lastDateGroup)
							{
								if (this.nextDateDelimiterExists(futureValue, this.selection.start + 1, group))
								{
									var autocomplete = this.dateAutocompleteCharacters[group+1];
									movePosition = 1 + autocomplete.length;
								}
								else
								{
							var autocomplete = this.dateAutocompleteCharacters[group+1];
									futureValue = this.oldValue.substring(0, this.selection.start) + pressed + autocomplete + this.oldValue.substring(this.selection.start + 1);
									movePosition = 1 + autocomplete.length;
								}
							}
						}
						this.setValue (futureValue);
						this.selection.moveTo(this.selection.start + movePosition, this.selection.start + movePosition);									
						return false;							
					}			
				}
			}
			else
			{
				futureValue = this.oldValue.substring(0, this.selection.start) + pressed + this.oldValue.substring(this.selection.start);
				var movePosition = 1;
				if (!this.isValueValid(futureValue, this.selection.start + 1, group) && !this.isValueValid(futureValue, this.selection.start + 1, group+1)) 
				{
					this.redTextFlash(); return false;
				}
				else 
				{
					var autocomplete = this.dateAutocompleteCharacters[group+1];
					if (pressed == autocomplete) 
					{
						if (this.nextDateDelimiterExists(this.oldValue, this.selection.start, group))
						{
							futureValue = this.oldValue;
							movePosition = 1;
						}
					}
					else
					{
						if(this.isPositionAtEndOfGroup(futureValue, this.selection.start+1, group)) 
						{
							if (group != this.lastDateGroup)
							{
								if (this.nextDateDelimiterExists(futureValue, this.selection.start + 1, group))
								{
									var autocomplete = this.dateAutocompleteCharacters[group+1];
									movePosition = 1 + autocomplete.length;
								}
								else
								{
									var autocomplete = this.dateAutocompleteCharacters[group+1];
									futureValue = this.oldValue.substring(0, this.selection.start) + pressed + autocomplete + this.oldValue.substring(this.selection.start + 1);
									movePosition = 1 + autocomplete.length;
								}
							}
						}
					}
					this.setValue (futureValue);
					this.selection.moveTo(this.selection.start + movePosition, this.selection.start + movePosition);									
					return false;						
				}	
			}
		}
		return false;
	}
	
};
Spry.Widget.ValidationTextField.prototype.onKeyDown = function(e)
{
	this.saveState();
	this.keyCode = e.keyCode;
	if (Spry.is.opera) {
		if (this.flags.operaPasteOperation) {
			window.clearInterval(this.flags.operaPasteOperation);
			this.flags.operaPasteOperation = null;
		}
		if (e.ctrlKey) {
			var pressed = Spry.Widget.Utils.getCharacterFromEvent(e);
			if (pressed && 'vx'.indexOf(pressed.toLowerCase()) != -1) {
				var self = this;
				this.flags.operaPasteOperation = window.setInterval(function() { self.operaPasteMonitor();}, 1);
				return true;
			}
		}
	}
	if (this.keyCode != 8 && this.keyCode != 46 && Spry.Widget.Utils.isSpecialKey(e)) {
		return true;
	}
	if (this.keyCode == 8 || this.keyCode == 46 ) {
		var mr = this.doValidations(this.input.value, this.input.value);
		if (mr) {
			return true;
		}
	}
	if (this.useCharacterMasking && this.pattern && this.keyCode == 46) {
		if (e.ctrlKey) {
			this.setValue(this.input.value.substring(0, this.selection.start));
		} else if (this.selection.end == this.input.value.length || this.selection.start == this.input.value.length-1){
			return true;
		} else {
			this.flags.operaRevertOnKeyUp = true;
		}
		if (Spry.is.mozilla && Spry.is.mac) {
			this.flags.skp = true;
		}
		Spry.Widget.Utils.stopEvent(e);
		return false;
	}
	if (this.useCharacterMasking && this.pattern && !e.ctrlKey && this.keyCode == 8) {
		if (this.selection.start == this.input.value.length) {
				var n = this.getAutoComplete(this.selection.start, -1);
			this.setValue(this.input.value.substring(0, this.input.value.length - (Spry.is.opera?0:1) - n.length));
			if (Spry.is.opera) {
				this.selection.start = this.selection.start - 1 - n.length;
				this.selection.end = this.selection.end - 1 - n.length;
			}
		} else if (this.selection.end == this.input.value.length){
			return true;
		} else {
			this.flags.operaRevertOnKeyUp = true;
		}
		if (Spry.is.mozilla && Spry.is.mac) {
			this.flags.skp = true;
		} 
		Spry.Widget.Utils.stopEvent(e);
		return false;
	}
	return true;
};
Spry.Widget.ValidationTextField.prototype.onMouseDown = function(e)
{
	if (this.flags.active) {
		this.saveState();
	}
};
Spry.Widget.ValidationTextField.prototype.onDrop = function(e)
{
	this.flags.drop = true;
	this.removeHint();
	this.saveState();
	this.flags.active = true;
	this.addClassName(this.element, this.focusClass);
};
Spry.Widget.ValidationTextField.prototype.onFocus = function(e)
{
	if (this.flags.drop) {
		return;
	}
	this.removeHint();

	if (this.pattern && this.useCharacterMasking) {
		var autocomplete = this.getAutoComplete(this.selection.start);
		this.setValue(this.input.value + autocomplete);
		this.selection.moveTo(this.input.value.length, this.input.value.length);
	}
	this.saveState();
	this.flags.active = true;
	this.addClassName(this.element, this.focusClass);
};
Spry.Widget.ValidationTextField.prototype.onBlur = function(e)
{
	this.flags.active = false;
	this.removeClassName(this.element, this.focusClass);
	var mustRevert = this.doValidations(this.input.value, this.input.value);
	if (this.validateOn & Spry.Widget.ValidationTextField.ONBLUR) {
		this.validate();
	}
	var self = this;
	setTimeout(function() {self.putHint();}, 10);
	return true;
};
Spry.Widget.ValidationTextField.prototype.compilePattern = function() {
	if (!this.pattern) {
		return;
	}
	var compiled = [];
	var regexps = [];
	var patternCharacters = [];
	var idx = 0;
	var c = '', p = '';
	for (var i=0; i<this.pattern.length; i++) {
		c = this.pattern.charAt(i);
		if (p == '\\') {
			if (/[0ABXY\?]/i.test(c)) {
				regexps[idx - 1] = c;
			} else {
				regexps[idx - 1] = Spry.Widget.ValidationTextField.regExpFromChars(c);
			}
			compiled[idx - 1] = c;
			patternCharacters[idx - 1] = null;
			p = '';
			continue;
		}
		regexps[idx] = Spry.Widget.ValidationTextField.regExpFromChars(c);
		if (/[0ABXY\?]/i.test(c)) {
			compiled[idx] = null;
			patternCharacters[idx] = c;
		} else if (c == '\\') {
			compiled[idx] = c;
			patternCharacters[idx] = '\\';
		} else {
			compiled[idx] = c;
			patternCharacters[idx] = null;
		}
		idx++;
		p = c;
	}
	this.autoCompleteCharacters = compiled;
	this.compiledPattern = regexps;
	this.patternCharacters = patternCharacters;
	this.patternLength = compiled.length;
};
Spry.Widget.ValidationTextField.prototype.getAutoComplete = function(from, direction) {
	if (direction == -1) {
		var n = '', m = '';
		while(from && (n = this.getAutoComplete(--from) )) {
			m = n;
		}
		return m;
	}
	var ret = '', c = '';
	for (var i=from; i<this.autoCompleteCharacters.length; i++) {
		c = this.autoCompleteCharacters[i];
		if (c) {
			ret += c;
		} else {
			break;
		}
	}
	return ret;
};
Spry.Widget.ValidationTextField.regExpFromChars = function (string) {
	var ret = '', character = '';
	for (var i = 0; i<string.length; i++) {
		character = string.charAt(i);
		switch (character) {
			case '0': ret += '\\d';break;
			case 'A': ret += '[A-Z]';break;
			case 'a': ret += '[a-z]';break;
			case 'B': case 'b': ret += '[a-zA-Z]';break;
			case 'x': ret += '[0-9a-z]';break;
			case 'X': ret += '[0-9A-Z]';break;
			case 'Y': case 'y': ret += '[0-9a-zA-Z]';break;
			case '?': ret += '.';break;
			case '1':case '2':case '3':case '4':case '5':case '6':case '7':case '8':case '9':
				ret += character;
				break;
			case 'c': case 'C': case 'e': case 'E': case 'f': case 'F':case 'r':case 'd': case 'D':case 'n':case 's':case 'S':case 'w':case 'W':case 't':case 'v':
				ret += character;
				break;
			default: ret += '\\' + character;
		}
	}
	return ret;
};
Spry.Widget.ValidationTextField.prototype.patternToRegExp = function(len) {
	var ret = '^';
	var end = Math.min(this.compiledPattern.length, len);
	for (var i=0; i < end; i++) {
		ret += this.compiledPattern[i];
	}
	ret += '$';
	ret = new RegExp(ret, "");
	return ret;
};
Spry.Widget.ValidationTextField.prototype.reset = function() {
	this.removeHint();
	this.oldValue = this.input.defaultValue;
	this.removeClassName(this.element, this.requiredClass);
	this.removeClassName(this.element, this.invalidFormatClass);
	this.removeClassName(this.element, this.invalidRangeMinClass);
	this.removeClassName(this.element, this.invalidRangeMaxClass);
	this.removeClassName(this.element, this.invalidCharsMinClass);
	this.removeClassName(this.element, this.invalidCharsMaxClass);
	this.removeClassName(this.element, this.validClass);
	var self = this;
	setTimeout(function() {self.putHint();}, 10);
};
Spry.Widget.ValidationTextField.prototype.validate = function() {
	this.removeClassName(this.element, this.requiredClass);
	this.removeClassName(this.element, this.invalidFormatClass);
	this.removeClassName(this.element, this.invalidRangeMinClass);
	this.removeClassName(this.element, this.invalidRangeMaxClass);
	this.removeClassName(this.element, this.invalidCharsMinClass);
	this.removeClassName(this.element, this.invalidCharsMaxClass);
	this.removeClassName(this.element, this.validClass);
	if (this.validateOn & Spry.Widget.ValidationTextField.ONSUBMIT) {
		this.removeHint();
		this.doValidations(this.input.value, this.input.value);
		if(!this.flags.active) {
			var self = this;
			setTimeout(function() {self.putHint();}, 10);
		}
	}
	if (this.isRequired && this.errors & Spry.Widget.ValidationTextField.ERROR_REQUIRED) {
		this.addClassName(this.element, this.requiredClass);
		return false;
	}
	if (this.errors & Spry.Widget.ValidationTextField.ERROR_FORMAT) {
		this.addClassName(this.element, this.invalidFormatClass);
		return false;
	}
	if (this.errors & Spry.Widget.ValidationTextField.ERROR_RANGE_MIN) {
		this.addClassName(this.element, this.invalidRangeMinClass);
		return false;
	}
	if (this.errors & Spry.Widget.ValidationTextField.ERROR_RANGE_MAX) {
		this.addClassName(this.element, this.invalidRangeMaxClass);
		return false;
	}
	if (this.errors & Spry.Widget.ValidationTextField.ERROR_CHARS_MIN) {
		this.addClassName(this.element, this.invalidCharsMinClass);
		return false;
	}
	if (this.errors & Spry.Widget.ValidationTextField.ERROR_CHARS_MAX) {
		this.addClassName(this.element, this.invalidCharsMaxClass);
		return false;
	}
	this.addClassName(this.element, this.validClass);
	return true;
}
Spry.Widget.ValidationTextField.prototype.addClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) != -1))
		return;
	ele.className += (ele.className ? " " : "") + className;
};
Spry.Widget.ValidationTextField.prototype.removeClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) == -1))
		return;
	ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};
Spry.Widget.SelectionDescriptor = function (element)
{
	this.element = element;
	this.update();
};
Spry.Widget.SelectionDescriptor.prototype.update = function()
{
	if (Spry.is.ie && Spry.is.windows) {
		if (this.element.nodeName == "TEXTAREA") {
		var range = this.element.ownerDocument.selection.createRange();
		if (range.parentElement() == this.element){
			var range_all = this.element.ownerDocument.body.createTextRange();
			range_all.moveToElementText(this.element);
			for (var sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start ++){
			 	range_all.moveStart('character', 1);
			}
			this.start = sel_start;
			range_all = this.element.ownerDocument.body.createTextRange();
			range_all.moveToElementText(this.element);
			for (var sel_end = 0; range_all.compareEndPoints('StartToEnd', range) < 0; sel_end++){
				range_all.moveStart('character', 1);
			}
			this.end = sel_end;
			this.length = this.end - this.start;
			this.text = range.text;
		 }
		} else if (this.element.nodeName == "INPUT"){
			this.range = this.element.ownerDocument.selection.createRange();
			this.length = this.range.text.length;
			var clone = this.range.duplicate();
			this.start = -clone.moveStart("character", -10000);
			clone = this.range.duplicate();
			clone.collapse(false);
			this.end = -clone.moveStart("character", -10000);
			this.text = this.range.text;
		}
	} else {
		var tmp = this.element;
		var selectionStart = 0;
		var selectionEnd = 0;
		try { selectionStart = tmp.selectionStart;} catch(err) {}
		try { selectionEnd = tmp.selectionEnd;} catch(err) {}
		if (Spry.is.safari) {
			if (selectionStart == 2147483647) {
				selectionStart = 0;
			}
			if (selectionEnd == 2147483647) {
				selectionEnd = 0;
			}
		}
		this.start = selectionStart;
		this.end = selectionEnd;
		this.length = selectionEnd - selectionStart;
		this.text = this.element.value.substring(selectionStart, selectionEnd);
	}
};
Spry.Widget.SelectionDescriptor.prototype.destroy = function() {
	try { delete this.range} catch(err) {}
	try { delete this.element} catch(err) {}
};
Spry.Widget.SelectionDescriptor.prototype.move = function(amount)
{
	if (Spry.is.ie && Spry.is.windows) {
		this.range.move("character", amount);
		this.range.select();
	} else {
		try { this.element.selectionStart++;}catch(err) {}
	}
	this.update();
};
Spry.Widget.SelectionDescriptor.prototype.moveTo = function(start, end)
{
	if (Spry.is.ie && Spry.is.windows) {
		if (this.element.nodeName == "TEXTAREA") {
			var ta_range = this.element.createTextRange();
			this.range = this.element.createTextRange();
			this.range.move("character", start);
			this.range.moveEnd("character", end - start);
			var c1 = this.range.compareEndPoints("StartToStart", ta_range);
			if (c1 < 0) {
				this.range.setEndPoint("StartToStart", ta_range);
			}
			var c2 = this.range.compareEndPoints("EndToEnd", ta_range);
			if (c2 > 0) {
				this.range.setEndPoint("EndToEnd", ta_range);
			}
		} else if (this.element.nodeName == "INPUT"){
			this.range = this.element.ownerDocument.selection.createRange();
			this.range.move("character", -10000);
			this.start = this.range.moveStart("character", start);
			this.end = this.start + this.range.moveEnd("character", end - start);
		}
		this.range.select();
	} else {
		this.start = start;
		try { this.element.selectionStart = start;} catch(err) {}
		this.end = end;
		try { this.element.selectionEnd = end;} catch(err) {}
	}
	this.ignore = true;
	this.update();
};
Spry.Widget.SelectionDescriptor.prototype.moveEnd = function(amount)
{
	if (Spry.is.ie && Spry.is.windows) {
		this.range.moveEnd("character", amount);
		this.range.select();
	} else {
		try { this.element.selectionEnd++;} catch(err) {}
	}
	this.update();
};
Spry.Widget.SelectionDescriptor.prototype.collapse = function(begin)
{
	if (Spry.is.ie && Spry.is.windows) {
		this.range = this.element.ownerDocument.selection.createRange();
		this.range.collapse(begin);
		this.range.select();
	} else {
		if (begin) {
			try { this.element.selectionEnd = this.element.selectionStart;} catch(err) {}
		} else {
			try { this.element.selectionStart = this.element.selectionEnd;} catch(err) {}
		}
	}

	this.update();
};
if (!Spry.Widget.Form) Spry.Widget.Form = {};
if (!Spry.Widget.Form.onSubmitWidgetQueue) Spry.Widget.Form.onSubmitWidgetQueue = [];
if (!Spry.Widget.Form.validate) {
	Spry.Widget.Form.validate = function(vform) {
		var isValid = true;
		var isElementValid = true;
		var q = Spry.Widget.Form.onSubmitWidgetQueue;
		var qlen = q.length;
		for (var i = 0; i < qlen; i++) {
			if (!q[i].isDisabled() && q[i].form == vform) {
				isElementValid = q[i].validate();
				isValid = isElementValid && isValid;
			}
		}
		return isValid;
	}
};
if (!Spry.Widget.Form.onSubmit) {
	Spry.Widget.Form.onSubmit = function(e, form)
	{
		if (Spry.Widget.Form.validate(form) == false) {
			return false;
		}
		return true;
	};
};
if (!Spry.Widget.Form.onReset) {
	Spry.Widget.Form.onReset = function(e, vform)
	{
		var q = Spry.Widget.Form.onSubmitWidgetQueue;
		var qlen = q.length;
		for (var i = 0; i < qlen; i++) {
			if (!q[i].isDisabled() && q[i].form == vform && typeof(q[i].reset) == 'function') {
				q[i].reset();
			}
		}
		return true;
	};
};
if (!Spry.Widget.Form.destroy) {
	Spry.Widget.Form.destroy = function(form)
	{
		var q = Spry.Widget.Form.onSubmitWidgetQueue;
		for (var i = 0; i < Spry.Widget.Form.onSubmitWidgetQueue.length; i++) {
			if (q[i].form == form && typeof(q[i].destroy) == 'function') {
				q[i].destroy();
				i--;
			}
		}
	}
};
if (!Spry.Widget.Form.destroyAll) {
	Spry.Widget.Form.destroyAll = function()
	{
		var q = Spry.Widget.Form.onSubmitWidgetQueue;
		for (var i = 0; i < Spry.Widget.Form.onSubmitWidgetQueue.length; i++) {
			if (typeof(q[i].destroy) == 'function') {
				q[i].destroy();
				i--;
			}
		}
	}
};
if (!Spry.Widget.Utils)	Spry.Widget.Utils = {};
Spry.Widget.Utils.punycode_constants = {
	base : 36, tmin : 1, tmax : 26, skew : 38, damp : 700,
  initial_bias : 72, initial_n : 0x80, delimiter : 0x2D,
  maxint : 2<<26-1
};
Spry.Widget.Utils.punycode_encode_digit = function (d) {
  return String.fromCharCode(d + 22 + 75 * (d < 26));
};
Spry.Widget.Utils.punycode_adapt = function (delta, numpoints, firsttime) {
	delta = firsttime ? delta / this.punycode_constants.damp : delta >> 1;
	delta += delta / numpoints;
	for (var k = 0; delta > ((this.punycode_constants.base - this.punycode_constants.tmin) * this.punycode_constants.tmax) / 2; k += this.punycode_constants.base) {
		delta /= this.punycode_constants.base - this.punycode_constants.tmin;
	}
	return k + (this.punycode_constants.base - this.punycode_constants.tmin + 1) * delta / (delta + this.punycode_constants.skew);
};
Spry.Widget.Utils.punycode_encode = function (input, max_out) {
	var inputc = input.split("");
	input = [];
	for(var i=0; i<inputc.length; i++) {
		input.push(inputc[i].charCodeAt(0));
	}
	var output = '';
  var h, b, j, m, q, k, t;
	var input_len = input.length;
  var n = this.punycode_constants.initial_n;
  var delta = 0;
  var bias = this.punycode_constants.initial_bias;
  var out = 0;
  for (j = 0; j < input_len; j++) {
		if (input[j] < 128) {
			if (max_out - out < 2) {
				return false;
			}
			output += String.fromCharCode(input[j]);
			out++;
		}
	}
	h = b = out;
	if (b > 0) {
		output += String.fromCharCode(this.punycode_constants.delimiter);
		out++;
	}
  while (h < input_len)	{
		for (m = this.punycode_constants.maxint, j = 0; j < input_len; j++) {
			if (input[j] >= n && input[j] < m) {
				m = input[j];
			}
		}
		if (m - n > (this.punycode_constants.maxint - delta) / (h + 1)) {
			return false;
		}
		
		delta += (m - n) * (h + 1);
		n = m;
		for (j = 0; j < input_len; j++) {
			if (input[j] < n ) {
				if (++delta == 0) {
					return false;
				}
			}
			if (input[j] == n) {
				for (q = delta, k = this.punycode_constants.base;; k += this.punycode_constants.base) {
					if (out >= max_out) {
						return false;
					}
					t = k <= bias ? this.punycode_constants.tmin : k >= bias + this.punycode_constants.tmax ? this.punycode_constants.tmax : k - bias;
					if (q < t) {
						break;
					}
					output += this.punycode_encode_digit(t + (q - t) % (this.punycode_constants.base - t));
					out++;
					q = (q - t) / (this.punycode_constants.base - t);
				}
				output += this.punycode_encode_digit(q);
				out++;
				bias = this.punycode_adapt(delta, h + 1, h == b);
				delta = 0;
				h++;
			}
		}
		delta++, n++;
	}
  return output;
};
Spry.Widget.Utils.setOptions = function(obj, optionsObj, ignoreUndefinedProps)
{
	if (!optionsObj)
		return;
	for (var optionName in optionsObj)
	{
		if (ignoreUndefinedProps && optionsObj[optionName] == undefined)
			continue;
		obj[optionName] = optionsObj[optionName];
	}
};
Spry.Widget.Utils.firstValid = function() {
	var ret = null;
	for(var i=0; i<Spry.Widget.Utils.firstValid.arguments.length; i++) {
		if (typeof(Spry.Widget.Utils.firstValid.arguments[i]) != 'undefined') {
			ret = Spry.Widget.Utils.firstValid.arguments[i];
			break;
		}
	}
	return ret;
};
Spry.Widget.Utils.specialCharacters = ",8,9,16,17,18,20,27,33,34,35,36,37,38,40,45,144,192,63232,";
Spry.Widget.Utils.specialSafariNavKeys = "63232,63233,63234,63235,63272,63273,63275,63276,63277,63289,";
Spry.Widget.Utils.specialNotSafariCharacters = "39,46,91,92,93,";
Spry.Widget.Utils.specialCharacters += Spry.Widget.Utils.specialSafariNavKeys;
if (!Spry.is.safari) {
	Spry.Widget.Utils.specialCharacters += Spry.Widget.Utils.specialNotSafariCharacters;
}
Spry.Widget.Utils.isSpecialKey = function (ev) {
	return Spry.Widget.Utils.specialCharacters.indexOf("," + ev.keyCode + ",") != -1;
};
Spry.Widget.Utils.getCharacterFromEvent = function(e){
	var keyDown = e.type == "keydown";
	var code = null;
	var character = null;
	if(Spry.is.mozilla && !keyDown){
		if(e.charCode){
			character = String.fromCharCode(e.charCode);
		} else {
			code = e.keyCode;
		}
	} else {
		code = e.keyCode || e.which;
		if (code != 13) {
			character = String.fromCharCode(code);
		}
	}
	if (Spry.is.safari) {
		if (keyDown) {
			code = e.keyCode || e.which;
			character = String.fromCharCode(code);
		} else {
			code = e.keyCode || e.which;
			if (Spry.Widget.Utils.specialCharacters.indexOf("," + code + ",") != -1) {
				character = null;
			} else {
				character = String.fromCharCode(code);
			}
		}
	}
	if(Spry.is.opera) {
		if (Spry.Widget.Utils.specialCharacters.indexOf("," + code + ",") != -1) {
			character = null;
		} else {
			character = String.fromCharCode(code);
		}
	}
	return character;
};
Spry.Widget.Utils.getFirstChildWithNodeNameAtAnyLevel = function(node, nodeName)
{
	var elements  = node.getElementsByTagName(nodeName);
	if (elements) {
		return elements[0];
	}
	return null;
};
Spry.Widget.Utils.getFirstParentWithNodeName = function(node, nodeName)
{
	while (node.parentNode
			&& node.parentNode.nodeName.toLowerCase() != nodeName.toLowerCase()
			&& node.parentNode.nodeName != 'BODY') {
		node = node.parentNode;
	}
	if (node.parentNode && node.parentNode.nodeName.toLowerCase() == nodeName.toLowerCase()) {
		return node.parentNode;
	} else {
		return null;
	}
};
Spry.Widget.Utils.destroyWidgets = function (container)
{
	if (typeof container == 'string') {
		container = document.getElementById(container);
	}
	var q = Spry.Widget.Form.onSubmitWidgetQueue;
	for (var i = 0; i < Spry.Widget.Form.onSubmitWidgetQueue.length; i++) {
		if (typeof(q[i].destroy) == 'function' && Spry.Widget.Utils.contains(container, q[i].element)) {
			q[i].destroy();
			i--;
		}
	}
};
Spry.Widget.Utils.contains = function (who, what)
{
	if (typeof who.contains == 'object') {
		return what && who && (who == what || who.contains(what));
	} else {
		var el = what;
		while(el) {
			if (el == who) {
				return true;
			}
			el = el.parentNode;
		}
		return false;
	}
};
Spry.Widget.Utils.addEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.addEventListener)
			element.addEventListener(eventType, handler, capture);
		else if (element.attachEvent)
			element.attachEvent("on" + eventType, handler, capture);
	}
	catch (e) {}
};
Spry.Widget.Utils.removeEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.removeEventListener)
			element.removeEventListener(eventType, handler, capture);
		else if (element.detachEvent)
			element.detachEvent("on" + eventType, handler, capture);
	}
	catch (e) {}
};
Spry.Widget.Utils.stopEvent = function(ev)
{
	try
	{
		this.stopPropagation(ev);
		this.preventDefault(ev);
	}
	catch (e) {}
};
Spry.Widget.Utils.stopPropagation = function(ev)
{
	if (ev.stopPropagation)
	{
		ev.stopPropagation();
	}
	else
	{
		ev.cancelBubble = true;
	}
};
Spry.Widget.Utils.preventDefault = function(ev)
{
	if (ev.preventDefault)
	{
		ev.preventDefault();
	}
	else
	{
		ev.returnValue = false;
	}
};
var Spry;
if (!Spry) Spry = {};
if (!Spry.Widget) Spry.Widget = {};

Spry.Widget.ValidationSelect = function(element, opts)
{
	this.init(element);
	Spry.Widget.Utils.setOptions(this, opts);
	var validateOn = ['submit'].concat(this.validateOn || []);
	validateOn = validateOn.join(",");
	this.validateOn = 0 | (validateOn.indexOf('submit') != -1 ? Spry.Widget.ValidationSelect.ONSUBMIT : 0);
	this.validateOn = this.validateOn | (validateOn.indexOf('blur') != -1 ? Spry.Widget.ValidationSelect.ONBLUR : 0);
	this.validateOn = this.validateOn | (validateOn.indexOf('change') != -1 ? Spry.Widget.ValidationSelect.ONCHANGE : 0);
	if (Spry.Widget.ValidationSelect.onloadDidFire)
		this.attachBehaviors();
	else 
		Spry.Widget.ValidationSelect.loadQueue.push(this);
};
Spry.Widget.ValidationSelect.ONCHANGE = 1;
Spry.Widget.ValidationSelect.ONBLUR = 2;
Spry.Widget.ValidationSelect.ONSUBMIT = 4;
Spry.Widget.ValidationSelect.prototype.init = function(element)
{
	this.element = this.getElement(element);
	this.selectElement = null;
	this.form = null;
	this.event_handlers = [];
	this.requiredClass = "selectRequiredState";
	this.invalidClass = "selectInvalidState";
	this.focusClass = "selectFocusState";
	this.validClass = "selectValidState";
	this.emptyValue = "";
	this.invalidValue = null;
	this.isRequired = true;
	this.validateOn = ["submit"];  
	this.validatedByOnChangeEvent = false;
};
Spry.Widget.ValidationSelect.prototype.destroy = function() {
	for (var i=0; i<this.event_handlers.length; i++) {
		Spry.Widget.Utils.removeEventListener(this.event_handlers[i][0], this.event_handlers[i][1], this.event_handlers[i][2], false);
	}
	try { delete this.element; } catch(err) {}
	try { delete this.selectElement; } catch(err) {}
	try { delete this.form; } catch(err) {}
	try { delete this.event_handlers; } catch(err) {}
	var q = Spry.Widget.Form.onSubmitWidgetQueue;
	var qlen = q.length;
	for (var i = 0; i < qlen; i++) {
		if (q[i] == this) {
			q.splice(i, 1);
			break;
		}
	}
};
Spry.Widget.ValidationSelect.onloadDidFire = false;
Spry.Widget.ValidationSelect.loadQueue = [];
Spry.Widget.ValidationSelect.prototype.getElement = function(ele)
{
	if (ele && typeof ele == "string")
		return document.getElementById(ele);
	return ele;
};
Spry.Widget.ValidationSelect.processLoadQueue = function(handler)
{
	Spry.Widget.ValidationSelect.onloadDidFire = true;
	var q = Spry.Widget.ValidationSelect.loadQueue;
	var qlen = q.length;
	for (var i = 0; i < qlen; i++)
		q[i].attachBehaviors();
};
Spry.Widget.ValidationSelect.addLoadListener = function(handler)
{
	if (typeof window.addEventListener != 'undefined')
		window.addEventListener('load', handler, false);
	else if (typeof document.addEventListener != 'undefined')
		document.addEventListener('load', handler, false);
	else if (typeof window.attachEvent != 'undefined')
		window.attachEvent('onload', handler);
};
Spry.Widget.ValidationSelect.addLoadListener(Spry.Widget.ValidationSelect.processLoadQueue);
Spry.Widget.ValidationSelect.addLoadListener(function(){
	Spry.Widget.Utils.addEventListener(window, "unload", Spry.Widget.Form.destroyAll, false);
});
Spry.Widget.ValidationSelect.prototype.attachBehaviors = function()
{
	if (this.element.nodeName == "SELECT") {
		this.selectElement = this.element;
	} else {
		this.selectElement = Spry.Widget.Utils.getFirstChildWithNodeNameAtAnyLevel(this.element, "SELECT");
	}
	if (this.selectElement) {
		var self = this;
		this.event_handlers = [];
		var focusEventName = "focus";
		if (navigator.userAgent.toLowerCase().indexOf("msie 7.") != -1) {
			focusEventName = "beforeactivate";
		}
		this.event_handlers.push([this.selectElement, focusEventName, function(e) { if (self.isDisabled()) return true; return self.onFocus(e); }]);
		this.event_handlers.push([this.selectElement, "blur", function(e) { if (self.isDisabled()) return true; return self.onBlur(e); }]);
		if (this.validateOn & Spry.Widget.ValidationSelect.ONCHANGE) {
			this.event_handlers.push([this.selectElement, "change", function(e) { if (self.isDisabled()) return true; return self.onChange(e); }]);
			this.event_handlers.push([this.selectElement, "keypress", function(e) { if (self.isDisabled()) return true; return self.onChange(e); }]);
		}
		for (var i=0; i<this.event_handlers.length; i++) {
			Spry.Widget.Utils.addEventListener(this.event_handlers[i][0], this.event_handlers[i][1], this.event_handlers[i][2], false);
		}
		this.form = Spry.Widget.Utils.getFirstParentWithNodeName(this.selectElement, "FORM");
		if (this.form) {
			if (!this.form.attachedSubmitHandler && !this.form.onsubmit) {
				this.form.onsubmit = function(e) { e = e || event; return Spry.Widget.Form.onSubmit(e, e.srcElement || e.currentTarget) };
				this.form.attachedSubmitHandler = true;                 
			}
			if (!this.form.attachedResetHandler) {
				Spry.Widget.Utils.addEventListener(this.form, "reset", function(e) { e = e || event; return Spry.Widget.Form.onReset(e, e.srcElement || e.currentTarget) }, false);
				this.form.attachedResetHandler = true;                 
			}
			Spry.Widget.Form.onSubmitWidgetQueue.push(this);
		}
	}
};
Spry.Widget.ValidationSelect.prototype.addClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) != -1))
		return;
	ele.className += (ele.className ? " " : "") + className;
};
Spry.Widget.ValidationSelect.prototype.removeClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) == -1))
		return;
	ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};
Spry.Widget.ValidationSelect.prototype.onFocus = function(e)
{
	this.hasFocus = true;
	this.validatedByOnChangeEvent = false;
	this.addClassName(this.element, this.focusClass);
};
Spry.Widget.ValidationSelect.prototype.onBlur = function(e)
{
	this.hasFocus = false;
	var doValidation = false;
	if (this.validateOn & Spry.Widget.ValidationSelect.ONBLUR)
		doValidation = true;
	if (doValidation && !this.validatedByOnChangeEvent)
		this.validate();
	this.removeClassName(this.element, this.focusClass);
};
Spry.Widget.ValidationSelect.prototype.onChange = function(e)
{
	this.hasFocus = false;
	this.validate();
	this.validatedByOnChangeEvent = true;
};
Spry.Widget.ValidationSelect.prototype.reset = function() {
	this.removeClassName(this.element, this.requiredClass);
	this.removeClassName(this.element, this.invalidClass);
	this.removeClassName(this.element, this.validClass);
};
Spry.Widget.ValidationSelect.prototype.validate = function() {
	this.removeClassName(this.element, this.requiredClass);
	this.removeClassName(this.element, this.invalidClass);
	this.removeClassName(this.element, this.validClass);
	if (this.isRequired) {
		if (this.selectElement.options.length == 0 || this.selectElement.selectedIndex == -1) {
			this.addClassName(this.element, this.requiredClass);
			return false;
		}
		if (this.selectElement.options[this.selectElement.selectedIndex].getAttribute("value") == null) {
			this.addClassName(this.element, this.requiredClass);
			return false;
		}
		if (this.selectElement.options[this.selectElement.selectedIndex].value == this.emptyValue) {
			this.addClassName(this.element, this.requiredClass);
			return false;
		}
		if (this.selectElement.options[this.selectElement.selectedIndex].disabled) {
			this.addClassName(this.element, this.requiredClass);
			return false;
		}
	}
	if (this.invalidValue) {
		if (this.selectElement.options.length > 0 && 
			this.selectElement.selectedIndex != -1 &&
			this.selectElement.options[this.selectElement.selectedIndex].value == this.invalidValue) {
			this.addClassName(this.element, this.invalidClass);
			return false;
		}
	}
	this.addClassName(this.element, this.validClass);
	return true;
}
Spry.Widget.ValidationSelect.prototype.isDisabled = function() {
	return this.selectElement.disabled;	
}
if (!Spry.Widget.Form) Spry.Widget.Form = {};
if (!Spry.Widget.Form.onSubmitWidgetQueue) Spry.Widget.Form.onSubmitWidgetQueue = [];
if (!Spry.Widget.Form.validate) {
	Spry.Widget.Form.validate = function(vform) {
		var isValid = true;
		var isElementValid = true;
		var q = Spry.Widget.Form.onSubmitWidgetQueue;
		var qlen = q.length;
		for (var i = 0; i < qlen; i++) {
			if (!q[i].isDisabled() && q[i].form == vform) {
				isElementValid = q[i].validate();
				isValid = isElementValid && isValid;
			}
		}
		return isValid;
	}
};
if (!Spry.Widget.Form.onSubmit) {
	Spry.Widget.Form.onSubmit = function(e, form)
	{
		if (Spry.Widget.Form.validate(form) == false) {
			return false;
		}
		return true;
	};
};
if (!Spry.Widget.Form.onReset) {
	Spry.Widget.Form.onReset = function(e, vform)
	{
		var q = Spry.Widget.Form.onSubmitWidgetQueue;
		var qlen = q.length;
		for (var i = 0; i < qlen; i++) {
			if (!q[i].isDisabled() && q[i].form == vform && typeof(q[i].reset) == 'function') {
				q[i].reset();
			}
		}
		return true;
	};
};
if (!Spry.Widget.Form.destroy) {
	Spry.Widget.Form.destroy = function(form)
	{
		var q = Spry.Widget.Form.onSubmitWidgetQueue;
		for (var i = 0; i < Spry.Widget.Form.onSubmitWidgetQueue.length; i++) {
			if (q[i].form == form && typeof(q[i].destroy) == 'function') {
				q[i].destroy();
				i--;
			}
		}
	}
};
if (!Spry.Widget.Form.destroyAll) {
	Spry.Widget.Form.destroyAll = function()
	{
		var q = Spry.Widget.Form.onSubmitWidgetQueue;
		for (var i = 0; i < Spry.Widget.Form.onSubmitWidgetQueue.length; i++) {
			if (typeof(q[i].destroy) == 'function') {
				q[i].destroy();
				i--;
			}
		}
	}
};
if (!Spry.Widget.Utils)	Spry.Widget.Utils = {};
Spry.Widget.Utils.setOptions = function(obj, optionsObj, ignoreUndefinedProps)
{
	if (!optionsObj)
		return;
	for (var optionName in optionsObj)
	{
		if (ignoreUndefinedProps && optionsObj[optionName] == undefined)
			continue;
		obj[optionName] = optionsObj[optionName];
	}
};
Spry.Widget.Utils.getFirstChildWithNodeNameAtAnyLevel = function(node, nodeName)
{
	var elements  = node.getElementsByTagName(nodeName);
	if (elements) {
		return elements[0];
	}
	return null;
};
Spry.Widget.Utils.getFirstParentWithNodeName = function(node, nodeName)
{
	while (node.parentNode
			&& node.parentNode.nodeName.toLowerCase() != nodeName.toLowerCase()
			&& node.parentNode.nodeName != 'BODY') {
		node = node.parentNode;
	}

	if (node.parentNode && node.parentNode.nodeName.toLowerCase() == nodeName.toLowerCase()) {
		return node.parentNode;
	} else {
		return null;
	}
};
Spry.Widget.Utils.destroyWidgets = function (container)
{
	if (typeof container == 'string') {
		container = document.getElementById(container);
	}

	var q = Spry.Widget.Form.onSubmitWidgetQueue;
	for (var i = 0; i < Spry.Widget.Form.onSubmitWidgetQueue.length; i++) {
		if (typeof(q[i].destroy) == 'function' && Spry.Widget.Utils.contains(container, q[i].element)) {
			q[i].destroy();
			i--;
		}
	}
};
Spry.Widget.Utils.contains = function (who, what)
{
	if (typeof who.contains == 'object') {
		return what && who && (who == what || who.contains(what));
	} else {
		var el = what;
		while(el) {
			if (el == who) {
				return true;
			}
			el = el.parentNode;
		}
		return false;
	}
};
Spry.Widget.Utils.addEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.addEventListener)
			element.addEventListener(eventType, handler, capture);
		else if (element.attachEvent)
			element.attachEvent("on" + eventType, handler, capture);
	}
	catch (e) {}
};
Spry.Widget.Utils.removeEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.removeEventListener)
			element.removeEventListener(eventType, handler, capture);
		else if (element.detachEvent)
			element.detachEvent("on" + eventType, handler, capture);
	}
	catch (e) {}
};
var Spry;
if (!Spry) Spry = {};
if (!Spry.Widget) Spry.Widget = {};
Spry.Widget.ValidationCheckbox = function(element, opts)
{
	this.init(element);
	Spry.Widget.Utils.setOptions(this, opts);
	var validateOn = ['submit'].concat(this.validateOn || []);
	validateOn = validateOn.join(",");
	this.validateOn = 0 | (validateOn.indexOf('submit') != -1 ? Spry.Widget.ValidationCheckbox.ONSUBMIT : 0);
	this.validateOn = this.validateOn | (validateOn.indexOf('blur') != -1 ? Spry.Widget.ValidationCheckbox.ONBLUR : 0);
	this.validateOn = this.validateOn | (validateOn.indexOf('change') != -1 ? Spry.Widget.ValidationCheckbox.ONCHANGE : 0);
	if (!isNaN(this.minSelections)) {
		this.minSelections = (this.minSelections > 0)? parseInt(this.minSelections, 10): null;
	}
	if (!isNaN(this.maxSelections)) {
		this.maxSelections = (this.maxSelections > 0)? parseInt(this.maxSelections, 10): null;
	}
	if (Spry.Widget.ValidationCheckbox.onloadDidFire)
		this.attachBehaviors();
	else 
		Spry.Widget.ValidationCheckbox.loadQueue.push(this);
};
Spry.Widget.ValidationCheckbox.ONCHANGE = 1;
Spry.Widget.ValidationCheckbox.ONBLUR = 2;
Spry.Widget.ValidationCheckbox.ONSUBMIT = 4;
Spry.Widget.ValidationCheckbox.prototype.init = function(element)
{
	this.element = this.getElement(element);
	this.checkboxElements = null;
	this.form = null;
	this.event_handlers = [];
	this.hasFocus = false;
	this.requiredClass = "checkboxRequiredState";
	this.minSelectionsClass = "checkboxMinSelectionsState";
	this.maxSelectionsClass = "checkboxMaxSelectionsState";
	this.focusClass = "checkboxFocusState";
	this.validClass = "checkboxValidState";
	this.isRequired = true;
	this.minSelections = null;
	this.maxSelections = null;
	this.validateOn = ["submit"];  
};
Spry.Widget.ValidationCheckbox.prototype.destroy = function() {
	for (var i=0; i<this.event_handlers.length; i++) {
		Spry.Widget.Utils.removeEventListener(this.event_handlers[i][0], this.event_handlers[i][1], this.event_handlers[i][2], false);
	}
	try { delete this.element; } catch(err) {}
	for(var i=0; i<this.checkboxElements.length; i++) {
		try { delete this.checkboxElements[i];} catch(err) {}
	}
	try { delete this.checkboxElements; } catch(err) {}
	try { delete this.form; } catch(err) {}
	try { delete this.event_handlers; } catch(err) {}
	var q = Spry.Widget.Form.onSubmitWidgetQueue;
	var qlen = q.length;
	for (var i = 0; i < qlen; i++) {
		if (q[i] == this) {
			q.splice(i, 1);
			break;
		}
	}
};
Spry.Widget.ValidationCheckbox.onloadDidFire = false;
Spry.Widget.ValidationCheckbox.loadQueue = [];
Spry.Widget.ValidationCheckbox.prototype.getElement = function(ele)
{
	if (ele && typeof ele == "string")
		return document.getElementById(ele);
	return ele;
};
Spry.Widget.ValidationCheckbox.processLoadQueue = function(handler)
{
	Spry.Widget.ValidationCheckbox.onloadDidFire = true;
	var q = Spry.Widget.ValidationCheckbox.loadQueue;
	var qlen = q.length;
	for (var i = 0; i < qlen; i++)
		q[i].attachBehaviors();
};
Spry.Widget.ValidationCheckbox.addLoadListener = function(handler)
{
	if (typeof window.addEventListener != 'undefined')
		window.addEventListener('load', handler, false);
	else if (typeof document.addEventListener != 'undefined')
		document.addEventListener('load', handler, false);
	else if (typeof window.attachEvent != 'undefined')
		window.attachEvent('onload', handler);
};
Spry.Widget.ValidationCheckbox.addLoadListener(Spry.Widget.ValidationCheckbox.processLoadQueue);
Spry.Widget.ValidationCheckbox.addLoadListener(function(){
Spry.Widget.Utils.addEventListener(window, "unload", Spry.Widget.Form.destroyAll, false);
});
Spry.Widget.ValidationCheckbox.prototype.attachBehaviors = function()
{
	if (this.element.nodeName == "INPUT") {
		this.checkboxElements = [this.element];
	} else {
		this.checkboxElements = this.getCheckboxes();
	}
	if (this.checkboxElements) {
		var self = this;
		this.event_handlers = [];
		var qlen = this.checkboxElements.length;
		for (var i = 0; i < qlen; i++) {
			this.event_handlers.push([this.checkboxElements[i], "focus", function(e) { return self.onFocus(e); }]);
			this.event_handlers.push([this.checkboxElements[i], "blur", function(e) { return self.onBlur(e); }]);
			if (this.validateOn & Spry.Widget.ValidationCheckbox.ONCHANGE) {
				this.event_handlers.push([this.checkboxElements[i], "click", function(e) { return self.onClick(e); }]);
			}
		}
		for (var i=0; i<this.event_handlers.length; i++) {
			Spry.Widget.Utils.addEventListener(this.event_handlers[i][0], this.event_handlers[i][1], this.event_handlers[i][2], false);
		}
		this.form = Spry.Widget.Utils.getFirstParentWithNodeName(this.element, "FORM");
		if (this.form) {
			if (!this.form.attachedSubmitHandler && !this.form.onsubmit) {
				this.form.onsubmit = function(e) { e = e || event; return Spry.Widget.Form.onSubmit(e, e.srcElement || e.currentTarget) };
				this.form.attachedSubmitHandler = true;                 
			}
			if (!this.form.attachedResetHandler) {
				Spry.Widget.Utils.addEventListener(this.form, "reset", function(e) { e = e || event; return Spry.Widget.Form.onReset(e, e.srcElement || e.currentTarget) }, false);
				this.form.attachedResetHandler = true;                 
			}
			Spry.Widget.Form.onSubmitWidgetQueue.push(this);
		}
	}
	
};
Spry.Widget.ValidationCheckbox.prototype.getCheckboxes = function() {
	var arrCheckboxes;
	var elements  = this.element.getElementsByTagName("INPUT");
	if (elements.length) {
		arrCheckboxes = [];
		var qlen = elements.length;
		for (var i = 0; i < qlen; i++) {
			if (elements[i].type == "checkbox") {
				arrCheckboxes.push(elements[i]);
			}
		}
		return arrCheckboxes;
	}
	return null;
}
Spry.Widget.ValidationCheckbox.prototype.addClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) != -1))
		return;
	ele.className += (ele.className ? " " : "") + className;
};
Spry.Widget.ValidationCheckbox.prototype.removeClassName = function(ele, className)
{
	if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) == -1))
		return;
	ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};
Spry.Widget.ValidationCheckbox.prototype.onFocus = function(e)
{
	var eventCheckbox = (e.srcElement != null) ? e.srcElement : e.target;
 	if (eventCheckbox.disabled) return;
 	
	this.hasFocus = true;
	this.addClassName(this.element, this.focusClass);
};
Spry.Widget.ValidationCheckbox.prototype.onBlur = function(e)
{
	var eventCheckbox = (e.srcElement != null) ? e.srcElement : e.target;
	if (eventCheckbox.disabled) return;
	
	this.hasFocus = false;
	var doValidation = false;
	if (this.validateOn & Spry.Widget.ValidationCheckbox.ONBLUR)
		doValidation = true;
	if (doValidation)
		this.validate();
	this.removeClassName(this.element, this.focusClass);
	
};
Spry.Widget.ValidationCheckbox.prototype.onClick = function(e) {
	var eventCheckbox = (e.srcElement != null) ? e.srcElement : e.target;
	if (eventCheckbox.disabled) return;
	
	this.validate();
};
Spry.Widget.ValidationCheckbox.prototype.reset = function() {
	this.removeClassName(this.element, this.validClass);
	this.removeClassName(this.element, this.requiredClass);
	this.removeClassName(this.element, this.minSelectionsClass);
	this.removeClassName(this.element, this.maxSelectionsClass);
};
Spry.Widget.ValidationCheckbox.prototype.validate = function() {
	this.removeClassName(this.element, this.validClass);
	this.removeClassName(this.element, this.requiredClass);
	this.removeClassName(this.element, this.minSelectionsClass);
	this.removeClassName(this.element, this.maxSelectionsClass);
	var nochecked = 0;
	if (this.checkboxElements) {
		var qlen = this.checkboxElements.length;
		for (var i = 0; i < qlen; i++) {
			if (!this.checkboxElements[i].disabled && this.checkboxElements[i].checked) {
				nochecked++;
			}
		}
	}
	if (this.isRequired) {
		if (nochecked == 0) {
			this.addClassName(this.element, this.requiredClass);
			return false;
		}
	}
	if (this.minSelections) {
		if (this.minSelections > nochecked) {
			this.addClassName(this.element, this.minSelectionsClass);
			return false;
		}
	}
	if (this.maxSelections) {
		if (this.maxSelections < nochecked) {
			this.addClassName(this.element, this.maxSelectionsClass);
			return false;
		}
	}
	this.addClassName(this.element, this.validClass);
	return true;
}
Spry.Widget.ValidationCheckbox.prototype.isDisabled = function() {
	var ret = true;
	if (this.checkboxElements) {
		var qlen = this.checkboxElements.length;
		for (var i = 0; i < qlen; i++) {
			if (!this.checkboxElements[i].disabled) {
				ret = false;
				break;
			}
		}
	}
	return ret;
}
if (!Spry.Widget.Form) Spry.Widget.Form = {};
if (!Spry.Widget.Form.onSubmitWidgetQueue) Spry.Widget.Form.onSubmitWidgetQueue = [];
if (!Spry.Widget.Form.validate) {
	Spry.Widget.Form.validate = function(vform) {
		var isValid = true;
		var isElementValid = true;
		var q = Spry.Widget.Form.onSubmitWidgetQueue;
		var qlen = q.length;
		for (var i = 0; i < qlen; i++) {
			if (!q[i].isDisabled() && q[i].form == vform) {
				isElementValid = q[i].validate();
				isValid = isElementValid && isValid;
			}
		}
		return isValid;
	}
};
if (!Spry.Widget.Form.onSubmit) {
	Spry.Widget.Form.onSubmit = function(e, form)
	{
		if (Spry.Widget.Form.validate(form) == false) {
			return false;
		}
		return true;
	};
};
if (!Spry.Widget.Form.onReset) {
	Spry.Widget.Form.onReset = function(e, vform)
	{
		var q = Spry.Widget.Form.onSubmitWidgetQueue;
		var qlen = q.length;
		for (var i = 0; i < qlen; i++) {
			if (!q[i].isDisabled() && q[i].form == vform && typeof(q[i].reset) == 'function') {
				q[i].reset();
			}
		}
		return true;
	};
};
if (!Spry.Widget.Form.destroy) {
	Spry.Widget.Form.destroy = function(form)
	{
		var q = Spry.Widget.Form.onSubmitWidgetQueue;
		for (var i = 0; i < Spry.Widget.Form.onSubmitWidgetQueue.length; i++) {
			if (q[i].form == form && typeof(q[i].destroy) == 'function') {
				q[i].destroy();
				i--;
			}
		}
	}
};
if (!Spry.Widget.Form.destroyAll) {
	Spry.Widget.Form.destroyAll = function()
	{
		var q = Spry.Widget.Form.onSubmitWidgetQueue;
		for (var i = 0; i < Spry.Widget.Form.onSubmitWidgetQueue.length; i++) {
			if (typeof(q[i].destroy) == 'function') {
				q[i].destroy();
				i--;
			}
		}
	}
};
if (!Spry.Widget.Utils)	Spry.Widget.Utils = {};
Spry.Widget.Utils.setOptions = function(obj, optionsObj, ignoreUndefinedProps)
{
	if (!optionsObj)
		return;
	for (var optionName in optionsObj)
	{
		if (ignoreUndefinedProps && optionsObj[optionName] == undefined)
			continue;
		obj[optionName] = optionsObj[optionName];
	}
};
Spry.Widget.Utils.getFirstParentWithNodeName = function(node, nodeName)
{
	while (node.parentNode
			&& node.parentNode.nodeName.toLowerCase() != nodeName.toLowerCase()
			&& node.parentNode.nodeName != 'BODY') {
		node = node.parentNode;
	}
	if (node.parentNode && node.parentNode.nodeName.toLowerCase() == nodeName.toLowerCase()) {
		return node.parentNode;
	} else {
		return null;
	}
};
Spry.Widget.Utils.destroyWidgets = function (container)
{
	if (typeof container == 'string') {
		container = document.getElementById(container);
	}
	var q = Spry.Widget.Form.onSubmitWidgetQueue;
	for (var i = 0; i < Spry.Widget.Form.onSubmitWidgetQueue.length; i++) {
		if (typeof(q[i].destroy) == 'function' && Spry.Widget.Utils.contains(container, q[i].element)) {
			q[i].destroy();
			i--;
		}
	}
};
Spry.Widget.Utils.contains = function (who, what)
{
	if (typeof who.contains == 'object') {
		return what && who && (who == what || who.contains(what));
	} else {
		var el = what;
		while(el) {
			if (el == who) {
				return true;
			}
			el = el.parentNode;
		}
		return false;
	}
};
Spry.Widget.Utils.addEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.addEventListener)
			element.addEventListener(eventType, handler, capture);
		else if (element.attachEvent)
			element.attachEvent("on" + eventType, handler, capture);
	}
	catch (e) {}
};
Spry.Widget.Utils.removeEventListener = function(element, eventType, handler, capture)
{
	try
	{
		if (element.removeEventListener)
			element.removeEventListener(eventType, handler, capture);
		else if (element.detachEvent)
			element.detachEvent("on" + eventType, handler, capture);
	}
	catch (e) {}
};
var MooTools={version:'1.11'};function $defined(obj){return(obj!=undefined);};function $type(obj){if(!$defined(obj))return false;if(obj.htmlElement)return'element';var type=typeof obj;if(type=='object'&&obj.nodeName){switch(obj.nodeType){case 1:return'element';case 3:return(/\S/).test(obj.nodeValue)?'textnode':'whitespace';}}
if(type=='object'||type=='function'){switch(obj.constructor){case Array:return'array';case RegExp:return'regexp';case Class:return'class';}
if(typeof obj.length=='number'){if(obj.item)return'collection';if(obj.callee)return'arguments';}}
return type;};function $merge(){var mix={};for(var i=0;i<arguments.length;i++){for(var property in arguments[i]){var ap=arguments[i][property];var mp=mix[property];if(mp&&$type(ap)=='object'&&$type(mp)=='object')mix[property]=$merge(mp,ap);else mix[property]=ap;}}
return mix;};var $extend=function(){var args=arguments;if(!args[1])args=[this,args[0]];for(var property in args[1])args[0][property]=args[1][property];return args[0];};var $native=function(){for(var i=0,l=arguments.length;i<l;i++){arguments[i].extend=function(props){for(var prop in props){if(!this.prototype[prop])this.prototype[prop]=props[prop];if(!this[prop])this[prop]=$native.generic(prop);}};}};$native.generic=function(prop){return function(bind){return this.prototype[prop].apply(bind,Array.prototype.slice.call(arguments,1));};};$native(Function,Array,String,Number);function $chk(obj){return!!(obj||obj===0);};function $pick(obj,picked){return $defined(obj)?obj:picked;};function $random(min,max){return Math.floor(Math.random()*(max-min+1)+min);};function $time(){return new Date().getTime();};function $clear(timer){clearTimeout(timer);clearInterval(timer);return null;};var Abstract=function(obj){obj=obj||{};obj.extend=$extend;return obj;};var Window=new Abstract(window);var Document=new Abstract(document);document.head=document.getElementsByTagName('head')[0];window.xpath=!!(document.evaluate);if(window.ActiveXObject)window.ie=window[window.XMLHttpRequest?'ie7':'ie6']=true;else if(document.childNodes&&!document.all&&!navigator.taintEnabled)window.webkit=window[window.xpath?'webkit420':'webkit419']=true;else if(document.getBoxObjectFor!=null)window.gecko=true;window.khtml=window.webkit;Object.extend=$extend;if(typeof HTMLElement=='undefined'){var HTMLElement=function(){};if(window.webkit)document.createElement("iframe");HTMLElement.prototype=(window.webkit)?window["[[DOMElement.prototype]]"]:{};}
HTMLElement.prototype.htmlElement=function(){};if(window.ie6)try{document.execCommand("BackgroundImageCache",false,true);}catch(e){};var Class=function(properties){var klass=function(){return(arguments[0]!==null&&this.initialize&&$type(this.initialize)=='function')?this.initialize.apply(this,arguments):this;};$extend(klass,this);klass.prototype=properties;klass.constructor=Class;return klass;};Class.empty=function(){};Class.prototype={extend:function(properties){var proto=new this(null);for(var property in properties){var pp=proto[property];proto[property]=Class.Merge(pp,properties[property]);}
return new Class(proto);},implement:function(){for(var i=0,l=arguments.length;i<l;i++)$extend(this.prototype,arguments[i]);}};Class.Merge=function(previous,current){if(previous&&previous!=current){var type=$type(current);if(type!=$type(previous))return current;switch(type){case'function':var merged=function(){this.parent=arguments.callee.parent;return current.apply(this,arguments);};merged.parent=previous;return merged;case'object':return $merge(previous,current);}}
return current;};var Chain=new Class({chain:function(fn){this.chains=this.chains||[];this.chains.push(fn);return this;},callChain:function(){if(this.chains&&this.chains.length)this.chains.shift().delay(10,this);},clearChain:function(){this.chains=[];}});var Events=new Class({addEvent:function(type,fn){if(fn!=Class.empty){this.$events=this.$events||{};this.$events[type]=this.$events[type]||[];this.$events[type].include(fn);}
return this;},fireEvent:function(type,args,delay){if(this.$events&&this.$events[type]){this.$events[type].each(function(fn){fn.create({'bind':this,'delay':delay,'arguments':args})();},this);}
return this;},removeEvent:function(type,fn){if(this.$events&&this.$events[type])this.$events[type].remove(fn);return this;}});var Options=new Class({setOptions:function(){this.options=$merge.apply(null,[this.options].extend(arguments));if(this.addEvent){for(var option in this.options){if($type(this.options[option]=='function')&&(/^on[A-Z]/).test(option))this.addEvent(option,this.options[option]);}}
return this;}});Array.extend({forEach:function(fn,bind){for(var i=0,j=this.length;i<j;i++)fn.call(bind,this[i],i,this);},filter:function(fn,bind){var results=[];for(var i=0,j=this.length;i<j;i++){if(fn.call(bind,this[i],i,this))results.push(this[i]);}
return results;},map:function(fn,bind){var results=[];for(var i=0,j=this.length;i<j;i++)results[i]=fn.call(bind,this[i],i,this);return results;},every:function(fn,bind){for(var i=0,j=this.length;i<j;i++){if(!fn.call(bind,this[i],i,this))return false;}
return true;},some:function(fn,bind){for(var i=0,j=this.length;i<j;i++){if(fn.call(bind,this[i],i,this))return true;}
return false;},indexOf:function(item,from){var len=this.length;for(var i=(from<0)?Math.max(0,len+from):from||0;i<len;i++){if(this[i]===item)return i;}
return-1;},copy:function(start,length){start=start||0;if(start<0)start=this.length+start;length=length||(this.length-start);var newArray=[];for(var i=0;i<length;i++)newArray[i]=this[start++];return newArray;},remove:function(item){var i=0;var len=this.length;while(i<len){if(this[i]===item){this.splice(i,1);len--;}else{i++;}}
return this;},contains:function(item,from){return this.indexOf(item,from)!=-1;},associate:function(keys){var obj={},length=Math.min(this.length,keys.length);for(var i=0;i<length;i++)obj[keys[i]]=this[i];return obj;},extend:function(array){for(var i=0,j=array.length;i<j;i++)this.push(array[i]);return this;},merge:function(array){for(var i=0,l=array.length;i<l;i++)this.include(array[i]);return this;},include:function(item){if(!this.contains(item))this.push(item);return this;},getRandom:function(){return this[$random(0,this.length-1)]||null;},getLast:function(){return this[this.length-1]||null;}});Array.prototype.each=Array.prototype.forEach;Array.each=Array.forEach;function $A(array){return Array.copy(array);};function $each(iterable,fn,bind){if(iterable&&typeof iterable.length=='number'&&$type(iterable)!='object'){Array.forEach(iterable,fn,bind);}else{for(var name in iterable)fn.call(bind||iterable,iterable[name],name);}};Array.prototype.test=Array.prototype.contains;String.extend({test:function(regex,params){return(($type(regex)=='string')?new RegExp(regex,params):regex).test(this);},toInt:function(){return parseInt(this,10);},toFloat:function(){return parseFloat(this);},camelCase:function(){return this.replace(/-\D/g,function(match){return match.charAt(1).toUpperCase();});},hyphenate:function(){return this.replace(/\w[A-Z]/g,function(match){return(match.charAt(0)+'-'+match.charAt(1).toLowerCase());});},capitalize:function(){return this.replace(/\b[a-z]/g,function(match){return match.toUpperCase();});},trim:function(){return this.replace(/^\s+|\s+$/g,'');},clean:function(){return this.replace(/\s{2,}/g,' ').trim();},rgbToHex:function(array){var rgb=this.match(/\d{1,3}/g);return(rgb)?rgb.rgbToHex(array):false;},hexToRgb:function(array){var hex=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);return(hex)?hex.slice(1).hexToRgb(array):false;},contains:function(string,s){return(s)?(s+this+s).indexOf(s+string+s)>-1:this.indexOf(string)>-1;},escapeRegExp:function(){return this.replace(/([.*+?^${}()|[\]\/\\])/g,'\\$1');}});Array.extend({rgbToHex:function(array){if(this.length<3)return false;if(this.length==4&&this[3]==0&&!array)return'transparent';var hex=[];for(var i=0;i<3;i++){var bit=(this[i]-0).toString(16);hex.push((bit.length==1)?'0'+bit:bit);}
return array?hex:'#'+hex.join('');},hexToRgb:function(array){if(this.length!=3)return false;var rgb=[];for(var i=0;i<3;i++){rgb.push(parseInt((this[i].length==1)?this[i]+this[i]:this[i],16));}
return array?rgb:'rgb('+rgb.join(',')+')';}});Function.extend({create:function(options){var fn=this;options=$merge({'bind':fn,'event':false,'arguments':null,'delay':false,'periodical':false,'attempt':false},options);if($chk(options.arguments)&&$type(options.arguments)!='array')options.arguments=[options.arguments];return function(event){var args;if(options.event){event=event||window.event;args=[(options.event===true)?event:new options.event(event)];if(options.arguments)args.extend(options.arguments);}
else args=options.arguments||arguments;var returns=function(){return fn.apply($pick(options.bind,fn),args);};if(options.delay)return setTimeout(returns,options.delay);if(options.periodical)return setInterval(returns,options.periodical);if(options.attempt)try{return returns();}catch(err){return false;};return returns();};},pass:function(args,bind){return this.create({'arguments':args,'bind':bind});},attempt:function(args,bind){return this.create({'arguments':args,'bind':bind,'attempt':true})();},bind:function(bind,args){return this.create({'bind':bind,'arguments':args});},bindAsEventListener:function(bind,args){return this.create({'bind':bind,'event':true,'arguments':args});},delay:function(delay,bind,args){return this.create({'delay':delay,'bind':bind,'arguments':args})();},periodical:function(interval,bind,args){return this.create({'periodical':interval,'bind':bind,'arguments':args})();}});Number.extend({toInt:function(){return parseInt(this);},toFloat:function(){return parseFloat(this);},limit:function(min,max){return Math.min(max,Math.max(min,this));},round:function(precision){precision=Math.pow(10,precision||0);return Math.round(this*precision)/precision;},times:function(fn){for(var i=0;i<this;i++)fn(i);}});var Element=new Class({initialize:function(el,props){if($type(el)=='string'){if(window.ie&&props&&(props.name||props.type)){var name=(props.name)?' name="'+props.name+'"':'';var type=(props.type)?' type="'+props.type+'"':'';delete props.name;delete props.type;el='<'+el+name+type+'>';}
el=document.createElement(el);}
el=$(el);return(!props||!el)?el:el.set(props);}});var Elements=new Class({initialize:function(elements){return(elements)?$extend(elements,this):this;}});Elements.extend=function(props){for(var prop in props){this.prototype[prop]=props[prop];this[prop]=$native.generic(prop);}};function $(el){if(!el)return null;if(el.htmlElement)return Garbage.collect(el);if([window,document].contains(el))return el;var type=$type(el);if(type=='string'){el=document.getElementById(el);type=(el)?'element':false;}
if(type!='element')return null;if(el.htmlElement)return Garbage.collect(el);if(['object','embed'].contains(el.tagName.toLowerCase()))return el;$extend(el,Element.prototype);el.htmlElement=function(){};return Garbage.collect(el);};document.getElementsBySelector=document.getElementsByTagName;function $$(){var elements=[];for(var i=0,j=arguments.length;i<j;i++){var selector=arguments[i];switch($type(selector)){case'element':elements.push(selector);case'boolean':break;case false:break;case'string':selector=document.getElementsBySelector(selector,true);default:elements.extend(selector);}}
return $$.unique(elements);};$$.unique=function(array){var elements=[];for(var i=0,l=array.length;i<l;i++){if(array[i].$included)continue;var element=$(array[i]);if(element&&!element.$included){element.$included=true;elements.push(element);}}
for(var n=0,d=elements.length;n<d;n++)elements[n].$included=null;return new Elements(elements);};Elements.Multi=function(property){return function(){var args=arguments;var items=[];var elements=true;for(var i=0,j=this.length,returns;i<j;i++){returns=this[i][property].apply(this[i],args);if($type(returns)!='element')elements=false;items.push(returns);};return(elements)?$$.unique(items):items;};};Element.extend=function(properties){for(var property in properties){HTMLElement.prototype[property]=properties[property];Element.prototype[property]=properties[property];Element[property]=$native.generic(property);var elementsProperty=(Array.prototype[property])?property+'Elements':property;Elements.prototype[elementsProperty]=Elements.Multi(property);}};Element.extend({set:function(props){for(var prop in props){var val=props[prop];switch(prop){case'styles':this.setStyles(val);break;case'events':if(this.addEvents)this.addEvents(val);break;case'properties':this.setProperties(val);break;default:this.setProperty(prop,val);}}
return this;},inject:function(el,where){el=$(el);switch(where){case'before':el.parentNode.insertBefore(this,el);break;case'after':var next=el.getNext();if(!next)el.parentNode.appendChild(this);else el.parentNode.insertBefore(this,next);break;case'top':var first=el.firstChild;if(first){el.insertBefore(this,first);break;}
default:el.appendChild(this);}
return this;},injectBefore:function(el){return this.inject(el,'before');},injectAfter:function(el){return this.inject(el,'after');},injectInside:function(el){return this.inject(el,'bottom');},injectTop:function(el){return this.inject(el,'top');},adopt:function(){var elements=[];$each(arguments,function(argument){elements=elements.concat(argument);});$$(elements).inject(this);return this;},remove:function(){return this.parentNode.removeChild(this);},clone:function(contents){var el=$(this.cloneNode(contents!==false));if(!el.$events)return el;el.$events={};for(var type in this.$events)el.$events[type]={'keys':$A(this.$events[type].keys),'values':$A(this.$events[type].values)};return el.removeEvents();},replaceWith:function(el){el=$(el);this.parentNode.replaceChild(el,this);return el;},appendText:function(text){this.appendChild(document.createTextNode(text));return this;},hasClass:function(className){return this.className.contains(className,' ');},addClass:function(className){if(!this.hasClass(className))this.className=(this.className+' '+className).clean();return this;},removeClass:function(className){this.className=this.className.replace(new RegExp('(^|\\s)'+className+'(?:\\s|$)'),'$1').clean();return this;},toggleClass:function(className){return this.hasClass(className)?this.removeClass(className):this.addClass(className);},setStyle:function(property,value){switch(property){case'opacity':return this.setOpacity(parseFloat(value));case'float':property=(window.ie)?'styleFloat':'cssFloat';}
property=property.camelCase();switch($type(value)){case'number':if(!['zIndex','zoom'].contains(property))value+='px';break;case'array':value='rgb('+value.join(',')+')';}
this.style[property]=value;return this;},setStyles:function(source){switch($type(source)){case'object':Element.setMany(this,'setStyle',source);break;case'string':this.style.cssText=source;}
return this;},setOpacity:function(opacity){if(opacity==0){if(this.style.visibility!="hidden")this.style.visibility="hidden";}else{if(this.style.visibility!="visible")this.style.visibility="visible";}
if(!this.currentStyle||!this.currentStyle.hasLayout)this.style.zoom=1;if(window.ie)this.style.filter=(opacity==1)?'':"alpha(opacity="+opacity*100+")";this.style.opacity=this.$tmp.opacity=opacity;return this;},getStyle:function(property){property=property.camelCase();var result=this.style[property];if(!$chk(result)){if(property=='opacity')return this.$tmp.opacity;result=[];for(var style in Element.Styles){if(property==style){Element.Styles[style].each(function(s){var style=this.getStyle(s);result.push(parseInt(style)?style:'0px');},this);if(property=='border'){var every=result.every(function(bit){return(bit==result[0]);});return(every)?result[0]:false;}
return result.join(' ');}}
if(property.contains('border')){if(Element.Styles.border.contains(property)){return['Width','Style','Color'].map(function(p){return this.getStyle(property+p);},this).join(' ');}else if(Element.borderShort.contains(property)){return['Top','Right','Bottom','Left'].map(function(p){return this.getStyle('border'+p+property.replace('border',''));},this).join(' ');}}
if(document.defaultView)result=document.defaultView.getComputedStyle(this,null).getPropertyValue(property.hyphenate());else if(this.currentStyle)result=this.currentStyle[property];}
if(window.ie)result=Element.fixStyle(property,result,this);if(result&&property.test(/color/i)&&result.contains('rgb')){return result.split('rgb').splice(1,4).map(function(color){return color.rgbToHex();}).join(' ');}
return result;},getStyles:function(){return Element.getMany(this,'getStyle',arguments);},walk:function(brother,start){brother+='Sibling';var el=(start)?this[start]:this[brother];while(el&&$type(el)!='element')el=el[brother];return $(el);},getPrevious:function(){return this.walk('previous');},getNext:function(){return this.walk('next');},getFirst:function(){return this.walk('next','firstChild');},getLast:function(){return this.walk('previous','lastChild');},getParent:function(){return $(this.parentNode);},getChildren:function(){return $$(this.childNodes);},hasChild:function(el){return!!$A(this.getElementsByTagName('*')).contains(el);},getProperty:function(property){var index=Element.Properties[property];if(index)return this[index];var flag=Element.PropertiesIFlag[property]||0;if(!window.ie||flag)return this.getAttribute(property,flag);var node=this.attributes[property];return(node)?node.nodeValue:null;},removeProperty:function(property){var index=Element.Properties[property];if(index)this[index]='';else this.removeAttribute(property);return this;},getProperties:function(){return Element.getMany(this,'getProperty',arguments);},setProperty:function(property,value){var index=Element.Properties[property];if(index)this[index]=value;else this.setAttribute(property,value);return this;},setProperties:function(source){return Element.setMany(this,'setProperty',source);},setHTML:function(){this.innerHTML=$A(arguments).join('');return this;},setText:function(text){var tag=this.getTag();if(['style','script'].contains(tag)){if(window.ie){if(tag=='style')this.styleSheet.cssText=text;else if(tag=='script')this.setProperty('text',text);return this;}else{this.removeChild(this.firstChild);return this.appendText(text);}}
this[$defined(this.innerText)?'innerText':'textContent']=text;return this;},getText:function(){var tag=this.getTag();if(['style','script'].contains(tag)){if(window.ie){if(tag=='style')return this.styleSheet.cssText;else if(tag=='script')return this.getProperty('text');}else{return this.innerHTML;}}
return($pick(this.innerText,this.textContent));},getTag:function(){return this.tagName.toLowerCase();},empty:function(){Garbage.trash(this.getElementsByTagName('*'));return this.setHTML('');}});Element.fixStyle=function(property,result,element){if($chk(parseInt(result)))return result;if(['height','width'].contains(property)){var values=(property=='width')?['left','right']:['top','bottom'];var size=0;values.each(function(value){size+=element.getStyle('border-'+value+'-width').toInt()+element.getStyle('padding-'+value).toInt();});return element['offset'+property.capitalize()]-size+'px';}else if(property.test(/border(.+)Width|margin|padding/)){return'0px';}
return result;};Element.Styles={'border':[],'padding':[],'margin':[]};['Top','Right','Bottom','Left'].each(function(direction){for(var style in Element.Styles)Element.Styles[style].push(style+direction);});Element.borderShort=['borderWidth','borderStyle','borderColor'];Element.getMany=function(el,method,keys){var result={};$each(keys,function(key){result[key]=el[method](key);});return result;};Element.setMany=function(el,method,pairs){for(var key in pairs)el[method](key,pairs[key]);return el;};Element.Properties=new Abstract({'class':'className','for':'htmlFor','colspan':'colSpan','rowspan':'rowSpan','accesskey':'accessKey','tabindex':'tabIndex','maxlength':'maxLength','readonly':'readOnly','frameborder':'frameBorder','value':'value','disabled':'disabled','checked':'checked','multiple':'multiple','selected':'selected'});Element.PropertiesIFlag={'href':2,'src':2};Element.Methods={Listeners:{addListener:function(type,fn){if(this.addEventListener)this.addEventListener(type,fn,false);else this.attachEvent('on'+type,fn);return this;},removeListener:function(type,fn){if(this.removeEventListener)this.removeEventListener(type,fn,false);else this.detachEvent('on'+type,fn);return this;}}};window.extend(Element.Methods.Listeners);document.extend(Element.Methods.Listeners);Element.extend(Element.Methods.Listeners);var Garbage={elements:[],collect:function(el){if(!el.$tmp){Garbage.elements.push(el);el.$tmp={'opacity':1};}
return el;},trash:function(elements){for(var i=0,j=elements.length,el;i<j;i++){if(!(el=elements[i])||!el.$tmp)continue;if(el.$events)el.fireEvent('trash').removeEvents();for(var p in el.$tmp)el.$tmp[p]=null;for(var d in Element.prototype)el[d]=null;Garbage.elements[Garbage.elements.indexOf(el)]=null;el.htmlElement=el.$tmp=el=null;}
Garbage.elements.remove(null);},empty:function(){Garbage.collect(window);Garbage.collect(document);Garbage.trash(Garbage.elements);}};window.addListener('beforeunload',function(){window.addListener('unload',Garbage.empty);if(window.ie)window.addListener('unload',CollectGarbage);});var Event=new Class({initialize:function(event){if(event&&event.$extended)return event;this.$extended=true;event=event||window.event;this.event=event;this.type=event.type;this.target=event.target||event.srcElement;if(this.target.nodeType==3)this.target=this.target.parentNode;this.shift=event.shiftKey;this.control=event.ctrlKey;this.alt=event.altKey;this.meta=event.metaKey;if(['DOMMouseScroll','mousewheel'].contains(this.type)){this.wheel=(event.wheelDelta)?event.wheelDelta/120:-(event.detail||0)/3;}else if(this.type.contains('key')){this.code=event.which||event.keyCode;for(var name in Event.keys){if(Event.keys[name]==this.code){this.key=name;break;}}
if(this.type=='keydown'){var fKey=this.code-111;if(fKey>0&&fKey<13)this.key='f'+fKey;}
this.key=this.key||String.fromCharCode(this.code).toLowerCase();}else if(this.type.test(/(click|mouse|menu)/)){this.page={'x':event.pageX||event.clientX+document.documentElement.scrollLeft,'y':event.pageY||event.clientY+document.documentElement.scrollTop};this.client={'x':event.pageX?event.pageX-window.pageXOffset:event.clientX,'y':event.pageY?event.pageY-window.pageYOffset:event.clientY};this.rightClick=(event.which==3)||(event.button==2);switch(this.type){case'mouseover':this.relatedTarget=event.relatedTarget||event.fromElement;break;case'mouseout':this.relatedTarget=event.relatedTarget||event.toElement;}
this.fixRelatedTarget();}
return this;},stop:function(){return this.stopPropagation().preventDefault();},stopPropagation:function(){if(this.event.stopPropagation)this.event.stopPropagation();else this.event.cancelBubble=true;return this;},preventDefault:function(){if(this.event.preventDefault)this.event.preventDefault();else this.event.returnValue=false;return this;}});Event.fix={relatedTarget:function(){if(this.relatedTarget&&this.relatedTarget.nodeType==3)this.relatedTarget=this.relatedTarget.parentNode;},relatedTargetGecko:function(){try{Event.fix.relatedTarget.call(this);}catch(e){this.relatedTarget=this.target;}}};Event.prototype.fixRelatedTarget=(window.gecko)?Event.fix.relatedTargetGecko:Event.fix.relatedTarget;Event.keys=new Abstract({'enter':13,'up':38,'down':40,'left':37,'right':39,'esc':27,'space':32,'backspace':8,'tab':9,'delete':46});Element.Methods.Events={addEvent:function(type,fn){this.$events=this.$events||{};this.$events[type]=this.$events[type]||{'keys':[],'values':[]};if(this.$events[type].keys.contains(fn))return this;this.$events[type].keys.push(fn);var realType=type;var custom=Element.Events[type];if(custom){if(custom.add)custom.add.call(this,fn);if(custom.map)fn=custom.map;if(custom.type)realType=custom.type;}
if(!this.addEventListener)fn=fn.create({'bind':this,'event':true});this.$events[type].values.push(fn);return(Element.NativeEvents.contains(realType))?this.addListener(realType,fn):this;},removeEvent:function(type,fn){if(!this.$events||!this.$events[type])return this;var pos=this.$events[type].keys.indexOf(fn);if(pos==-1)return this;var key=this.$events[type].keys.splice(pos,1)[0];var value=this.$events[type].values.splice(pos,1)[0];var custom=Element.Events[type];if(custom){if(custom.remove)custom.remove.call(this,fn);if(custom.type)type=custom.type;}
return(Element.NativeEvents.contains(type))?this.removeListener(type,value):this;},addEvents:function(source){return Element.setMany(this,'addEvent',source);},removeEvents:function(type){if(!this.$events)return this;if(!type){for(var evType in this.$events)this.removeEvents(evType);this.$events=null;}else if(this.$events[type]){this.$events[type].keys.each(function(fn){this.removeEvent(type,fn);},this);this.$events[type]=null;}
return this;},fireEvent:function(type,args,delay){if(this.$events&&this.$events[type]){this.$events[type].keys.each(function(fn){fn.create({'bind':this,'delay':delay,'arguments':args})();},this);}
return this;},cloneEvents:function(from,type){if(!from.$events)return this;if(!type){for(var evType in from.$events)this.cloneEvents(from,evType);}else if(from.$events[type]){from.$events[type].keys.each(function(fn){this.addEvent(type,fn);},this);}
return this;}};window.extend(Element.Methods.Events);document.extend(Element.Methods.Events);Element.extend(Element.Methods.Events);Element.Events=new Abstract({'mouseenter':{type:'mouseover',map:function(event){event=new Event(event);if(event.relatedTarget!=this&&!this.hasChild(event.relatedTarget))this.fireEvent('mouseenter',event);}},'mouseleave':{type:'mouseout',map:function(event){event=new Event(event);if(event.relatedTarget!=this&&!this.hasChild(event.relatedTarget))this.fireEvent('mouseleave',event);}},'mousewheel':{type:(window.gecko)?'DOMMouseScroll':'mousewheel'}});Element.NativeEvents=['click','dblclick','mouseup','mousedown','mousewheel','DOMMouseScroll','mouseover','mouseout','mousemove','keydown','keypress','keyup','load','unload','beforeunload','resize','move','focus','blur','change','submit','reset','select','error','abort','contextmenu','scroll'];Function.extend({bindWithEvent:function(bind,args){return this.create({'bind':bind,'arguments':args,'event':Event});}});Elements.extend({filterByTag:function(tag){return new Elements(this.filter(function(el){return(Element.getTag(el)==tag);}));},filterByClass:function(className,nocash){var elements=this.filter(function(el){return(el.className&&el.className.contains(className,' '));});return(nocash)?elements:new Elements(elements);},filterById:function(id,nocash){var elements=this.filter(function(el){return(el.id==id);});return(nocash)?elements:new Elements(elements);},filterByAttribute:function(name,operator,value,nocash){var elements=this.filter(function(el){var current=Element.getProperty(el,name);if(!current)return false;if(!operator)return true;switch(operator){case'=':return(current==value);case'*=':return(current.contains(value));case'^=':return(current.substr(0,value.length)==value);case'$=':return(current.substr(current.length-value.length)==value);case'!=':return(current!=value);case'~=':return current.contains(value,' ');}
return false;});return(nocash)?elements:new Elements(elements);}});function $E(selector,filter){return($(filter)||document).getElement(selector);};function $ES(selector,filter){return($(filter)||document).getElementsBySelector(selector);};$$.shared={'regexp':/^(\w*|\*)(?:#([\w-]+)|\.([\w-]+))?(?:\[(\w+)(?:([!*^$]?=)["']?([^"'\]]*)["']?)?])?$/,'xpath':{getParam:function(items,context,param,i){var temp=[context.namespaceURI?'xhtml:':'',param[1]];if(param[2])temp.push('[@id="',param[2],'"]');if(param[3])temp.push('[contains(concat(" ", @class, " "), " ',param[3],' ")]');if(param[4]){if(param[5]&&param[6]){switch(param[5]){case'*=':temp.push('[contains(@',param[4],', "',param[6],'")]');break;case'^=':temp.push('[starts-with(@',param[4],', "',param[6],'")]');break;case'$=':temp.push('[substring(@',param[4],', string-length(@',param[4],') - ',param[6].length,' + 1) = "',param[6],'"]');break;case'=':temp.push('[@',param[4],'="',param[6],'"]');break;case'!=':temp.push('[@',param[4],'!="',param[6],'"]');}}else{temp.push('[@',param[4],']');}}
items.push(temp.join(''));return items;},getItems:function(items,context,nocash){var elements=[];var xpath=document.evaluate('.//'+items.join('//'),context,$$.shared.resolver,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for(var i=0,j=xpath.snapshotLength;i<j;i++)elements.push(xpath.snapshotItem(i));return(nocash)?elements:new Elements(elements.map($));}},'normal':{getParam:function(items,context,param,i){if(i==0){if(param[2]){var el=context.getElementById(param[2]);if(!el||((param[1]!='*')&&(Element.getTag(el)!=param[1])))return false;items=[el];}else{items=$A(context.getElementsByTagName(param[1]));}}else{items=$$.shared.getElementsByTagName(items,param[1]);if(param[2])items=Elements.filterById(items,param[2],true);}
if(param[3])items=Elements.filterByClass(items,param[3],true);if(param[4])items=Elements.filterByAttribute(items,param[4],param[5],param[6],true);return items;},getItems:function(items,context,nocash){return(nocash)?items:$$.unique(items);}},resolver:function(prefix){return(prefix=='xhtml')?'http://www.w3.org/1999/xhtml':false;},getElementsByTagName:function(context,tagName){var found=[];for(var i=0,j=context.length;i<j;i++)found.extend(context[i].getElementsByTagName(tagName));return found;}};$$.shared.method=(window.xpath)?'xpath':'normal';Element.Methods.Dom={getElements:function(selector,nocash){var items=[];selector=selector.trim().split(' ');for(var i=0,j=selector.length;i<j;i++){var sel=selector[i];var param=sel.match($$.shared.regexp);if(!param)break;param[1]=param[1]||'*';var temp=$$.shared[$$.shared.method].getParam(items,this,param,i);if(!temp)break;items=temp;}
return $$.shared[$$.shared.method].getItems(items,this,nocash);},getElement:function(selector){return $(this.getElements(selector,true)[0]||false);},getElementsBySelector:function(selector,nocash){var elements=[];selector=selector.split(',');for(var i=0,j=selector.length;i<j;i++)elements=elements.concat(this.getElements(selector[i],true));return(nocash)?elements:$$.unique(elements);}};Element.extend({getElementById:function(id){var el=document.getElementById(id);if(!el)return false;for(var parent=el.parentNode;parent!=this;parent=parent.parentNode){if(!parent)return false;}
return el;},getElementsByClassName:function(className){return this.getElements('.'+className);}});document.extend(Element.Methods.Dom);Element.extend(Element.Methods.Dom);Element.extend({getValue:function(){switch(this.getTag()){case'select':var values=[];$each(this.options,function(option){if(option.selected)values.push($pick(option.value,option.text));});return(this.multiple)?values:values[0];case'input':if(!(this.checked&&['checkbox','radio'].contains(this.type))&&!['hidden','text','password'].contains(this.type))break;case'textarea':return this.value;}
return false;},getFormElements:function(){return $$(this.getElementsByTagName('input'),this.getElementsByTagName('select'),this.getElementsByTagName('textarea'));},toQueryString:function(){var queryString=[];this.getFormElements().each(function(el){var name=el.name;var value=el.getValue();if(value===false||!name||el.disabled)return;var qs=function(val){queryString.push(name+'='+encodeURIComponent(val));};if($type(value)=='array')value.each(qs);else qs(value);});return queryString.join('&');}});Element.extend({scrollTo:function(x,y){this.scrollLeft=x;this.scrollTop=y;},getSize:function(){return{'scroll':{'x':this.scrollLeft,'y':this.scrollTop},'size':{'x':this.offsetWidth,'y':this.offsetHeight},'scrollSize':{'x':this.scrollWidth,'y':this.scrollHeight}};},getPosition:function(overflown){overflown=overflown||[];var el=this,left=0,top=0;do{left+=el.offsetLeft||0;top+=el.offsetTop||0;el=el.offsetParent;}while(el);overflown.each(function(element){left-=element.scrollLeft||0;top-=element.scrollTop||0;});return{'x':left,'y':top};},getTop:function(overflown){return this.getPosition(overflown).y;},getLeft:function(overflown){return this.getPosition(overflown).x;},getCoordinates:function(overflown){var position=this.getPosition(overflown);var obj={'width':this.offsetWidth,'height':this.offsetHeight,'left':position.x,'top':position.y};obj.right=obj.left+obj.width;obj.bottom=obj.top+obj.height;return obj;}});Element.Events.domready={add:function(fn){if(window.loaded){fn.call(this);return;}
var domReady=function(){if(window.loaded)return;window.loaded=true;window.timer=$clear(window.timer);this.fireEvent('domready');}.bind(this);if(document.readyState&&window.webkit){window.timer=function(){if(['loaded','complete'].contains(document.readyState))domReady();}.periodical(50);}else if(document.readyState&&window.ie){if(!$('ie_ready')){var src=(window.location.protocol=='https:')?'://0':'javascript:void(0)';document.write('<script id="ie_ready" defer src="'+src+'"><\/script>');$('ie_ready').onreadystatechange=function(){if(this.readyState=='complete')domReady();};}}else{window.addListener("load",domReady);document.addListener("DOMContentLoaded",domReady);}}};window.onDomReady=function(fn){return this.addEvent('domready',fn);};window.extend({getWidth:function(){if(this.webkit419)return this.innerWidth;if(this.opera)return document.body.clientWidth;return document.documentElement.clientWidth;},getHeight:function(){if(this.webkit419)return this.innerHeight;if(this.opera)return document.body.clientHeight;return document.documentElement.clientHeight;},getScrollWidth:function(){if(this.ie)return Math.max(document.documentElement.offsetWidth,document.documentElement.scrollWidth);if(this.webkit)return document.body.scrollWidth;return document.documentElement.scrollWidth;},getScrollHeight:function(){if(this.ie)return Math.max(document.documentElement.offsetHeight,document.documentElement.scrollHeight);if(this.webkit)return document.body.scrollHeight;return document.documentElement.scrollHeight;},getScrollLeft:function(){return this.pageXOffset||document.documentElement.scrollLeft;},getScrollTop:function(){return this.pageYOffset||document.documentElement.scrollTop;},getSize:function(){return{'size':{'x':this.getWidth(),'y':this.getHeight()},'scrollSize':{'x':this.getScrollWidth(),'y':this.getScrollHeight()},'scroll':{'x':this.getScrollLeft(),'y':this.getScrollTop()}};},getPosition:function(){return{'x':0,'y':0};}});var Fx={};Fx.Base=new Class({options:{onStart:Class.empty,onComplete:Class.empty,onCancel:Class.empty,transition:function(p){return-(Math.cos(Math.PI*p)-1)/2;},duration:500,unit:'px',wait:true,fps:50},initialize:function(options){this.element=this.element||null;this.setOptions(options);if(this.options.initialize)this.options.initialize.call(this);},step:function(){var time=$time();if(time<this.time+this.options.duration){this.delta=this.options.transition((time-this.time)/this.options.duration);this.setNow();this.increase();}else{this.stop(true);this.set(this.to);this.fireEvent('onComplete',this.element,10);this.callChain();}},set:function(to){this.now=to;this.increase();return this;},setNow:function(){this.now=this.compute(this.from,this.to);},compute:function(from,to){return(to-from)*this.delta+from;},start:function(from,to){if(!this.options.wait)this.stop();else if(this.timer)return this;this.from=from;this.to=to;this.change=this.to-this.from;this.time=$time();this.timer=this.step.periodical(Math.round(1000/this.options.fps),this);this.fireEvent('onStart',this.element);return this;},stop:function(end){if(!this.timer)return this;this.timer=$clear(this.timer);if(!end)this.fireEvent('onCancel',this.element);return this;},custom:function(from,to){return this.start(from,to);},clearTimer:function(end){return this.stop(end);}});Fx.Base.implement(new Chain,new Events,new Options);Fx.CSS={select:function(property,to){if(property.test(/color/i))return this.Color;var type=$type(to);if((type=='array')||(type=='string'&&to.contains(' ')))return this.Multi;return this.Single;},parse:function(el,property,fromTo){if(!fromTo.push)fromTo=[fromTo];var from=fromTo[0],to=fromTo[1];if(!$chk(to)){to=from;from=el.getStyle(property);}
var css=this.select(property,to);return{'from':css.parse(from),'to':css.parse(to),'css':css};}};Fx.CSS.Single={parse:function(value){return parseFloat(value);},getNow:function(from,to,fx){return fx.compute(from,to);},getValue:function(value,unit,property){if(unit=='px'&&property!='opacity')value=Math.round(value);return value+unit;}};Fx.CSS.Multi={parse:function(value){return value.push?value:value.split(' ').map(function(v){return parseFloat(v);});},getNow:function(from,to,fx){var now=[];for(var i=0;i<from.length;i++)now[i]=fx.compute(from[i],to[i]);return now;},getValue:function(value,unit,property){if(unit=='px'&&property!='opacity')value=value.map(Math.round);return value.join(unit+' ')+unit;}};Fx.CSS.Color={parse:function(value){return value.push?value:value.hexToRgb(true);},getNow:function(from,to,fx){var now=[];for(var i=0;i<from.length;i++)now[i]=Math.round(fx.compute(from[i],to[i]));return now;},getValue:function(value){return'rgb('+value.join(',')+')';}};Fx.Style=Fx.Base.extend({initialize:function(el,property,options){this.element=$(el);this.property=property;this.parent(options);},hide:function(){return this.set(0);},setNow:function(){this.now=this.css.getNow(this.from,this.to,this);},set:function(to){this.css=Fx.CSS.select(this.property,to);return this.parent(this.css.parse(to));},start:function(from,to){if(this.timer&&this.options.wait)return this;var parsed=Fx.CSS.parse(this.element,this.property,[from,to]);this.css=parsed.css;return this.parent(parsed.from,parsed.to);},increase:function(){this.element.setStyle(this.property,this.css.getValue(this.now,this.options.unit,this.property));}});Element.extend({effect:function(property,options){return new Fx.Style(this,property,options);}});var Drag={};Drag.Base=new Class({options:{handle:false,unit:'px',onStart:Class.empty,onBeforeStart:Class.empty,onComplete:Class.empty,onSnap:Class.empty,onDrag:Class.empty,limit:false,modifiers:{x:'left',y:'top'},grid:false,snap:6},initialize:function(el,options){this.setOptions(options);this.element=$(el);this.handle=$(this.options.handle)||this.element;this.mouse={'now':{},'pos':{}};this.value={'start':{},'now':{}};this.bound={'start':this.start.bindWithEvent(this),'check':this.check.bindWithEvent(this),'drag':this.drag.bindWithEvent(this),'stop':this.stop.bind(this)};this.attach();if(this.options.initialize)this.options.initialize.call(this);},attach:function(){this.handle.addEvent('mousedown',this.bound.start);return this;},detach:function(){this.handle.removeEvent('mousedown',this.bound.start);return this;},start:function(event){this.fireEvent('onBeforeStart',this.element);this.mouse.start=event.page;var limit=this.options.limit;this.limit={'x':[],'y':[]};for(var z in this.options.modifiers){if(!this.options.modifiers[z])continue;this.value.now[z]=this.element.getStyle(this.options.modifiers[z]).toInt();this.mouse.pos[z]=event.page[z]-this.value.now[z];if(limit&&limit[z]){for(var i=0;i<2;i++){if($chk(limit[z][i]))this.limit[z][i]=($type(limit[z][i])=='function')?limit[z][i]():limit[z][i];}}}
if($type(this.options.grid)=='number')this.options.grid={'x':this.options.grid,'y':this.options.grid};document.addListener('mousemove',this.bound.check);document.addListener('mouseup',this.bound.stop);this.fireEvent('onStart',this.element);event.stop();},check:function(event){var distance=Math.round(Math.sqrt(Math.pow(event.page.x-this.mouse.start.x,2)+Math.pow(event.page.y-this.mouse.start.y,2)));if(distance>this.options.snap){document.removeListener('mousemove',this.bound.check);document.addListener('mousemove',this.bound.drag);this.drag(event);this.fireEvent('onSnap',this.element);}
event.stop();},drag:function(event){this.out=false;this.mouse.now=event.page;for(var z in this.options.modifiers){if(!this.options.modifiers[z])continue;this.value.now[z]=this.mouse.now[z]-this.mouse.pos[z];if(this.limit[z]){if($chk(this.limit[z][1])&&(this.value.now[z]>this.limit[z][1])){this.value.now[z]=this.limit[z][1];this.out=true;}else if($chk(this.limit[z][0])&&(this.value.now[z]<this.limit[z][0])){this.value.now[z]=this.limit[z][0];this.out=true;}}
if(this.options.grid[z])this.value.now[z]-=(this.value.now[z]%this.options.grid[z]);this.element.setStyle(this.options.modifiers[z],this.value.now[z]+this.options.unit);}
this.fireEvent('onDrag',this.element);event.stop();},stop:function(){document.removeListener('mousemove',this.bound.check);document.removeListener('mousemove',this.bound.drag);document.removeListener('mouseup',this.bound.stop);this.fireEvent('onComplete',this.element);}});Drag.Base.implement(new Events,new Options);Element.extend({makeResizable:function(options){return new Drag.Base(this,$merge({modifiers:{x:'width',y:'height'}},options));}});Drag.Move=Drag.Base.extend({options:{droppables:[],container:false,overflown:[]},initialize:function(el,options){this.setOptions(options);this.element=$(el);this.droppables=$$(this.options.droppables);this.container=$(this.options.container);this.position={'element':this.element.getStyle('position'),'container':false};if(this.container)this.position.container=this.container.getStyle('position');if(!['relative','absolute','fixed'].contains(this.position.element))this.position.element='absolute';var top=this.element.getStyle('top').toInt();var left=this.element.getStyle('left').toInt();if(this.position.element=='absolute'&&!['relative','absolute','fixed'].contains(this.position.container)){top=$chk(top)?top:this.element.getTop(this.options.overflown);left=$chk(left)?left:this.element.getLeft(this.options.overflown);}else{top=$chk(top)?top:0;left=$chk(left)?left:0;}
this.element.setStyles({'top':top,'left':left,'position':this.position.element});this.parent(this.element);},start:function(event){this.overed=null;if(this.container){var cont=this.container.getCoordinates();var el=this.element.getCoordinates();if(this.position.element=='absolute'&&!['relative','absolute','fixed'].contains(this.position.container)){this.options.limit={'x':[cont.left,cont.right-el.width],'y':[cont.top,cont.bottom-el.height]};}else{this.options.limit={'y':[0,cont.height-el.height],'x':[0,cont.width-el.width]};}}
this.parent(event);},drag:function(event){this.parent(event);var overed=this.out?false:this.droppables.filter(this.checkAgainst,this).getLast();if(this.overed!=overed){if(this.overed)this.overed.fireEvent('leave',[this.element,this]);this.overed=overed?overed.fireEvent('over',[this.element,this]):null;}
return this;},checkAgainst:function(el){el=el.getCoordinates(this.options.overflown);var now=this.mouse.now;return(now.x>el.left&&now.x<el.right&&now.y<el.bottom&&now.y>el.top);},stop:function(){if(this.overed&&!this.out)this.overed.fireEvent('drop',[this.element,this]);else this.element.fireEvent('emptydrop',this);this.parent();return this;}});Element.extend({makeDraggable:function(options){return new Drag.Move(this,options);}});
function WebForm_PostBackOptions(eventTarget, eventArgument, validation, validationGroup, actionUrl, trackFocus, clientSubmit) {
    this.eventTarget = eventTarget;
    this.eventArgument = eventArgument;
    this.validation = validation;
    this.validationGroup = validationGroup;
    this.actionUrl = actionUrl;
    this.trackFocus = trackFocus;
    this.clientSubmit = clientSubmit;
}
function WebForm_DoPostBackWithOptions(options) {
    var validationResult = true;
    if (options.validation) {
        if (typeof(Page_ClientValidate) == 'function') {
            validationResult = Page_ClientValidate(options.validationGroup);
        }
    }
    if (validationResult) {
        if ((typeof(options.actionUrl) != "undefined") && (options.actionUrl != null) && (options.actionUrl.length > 0)) {
            theForm.action = options.actionUrl;
        }
        if (options.trackFocus) {
            var lastFocus = theForm.elements["__LASTFOCUS"];
            if ((typeof(lastFocus) != "undefined") && (lastFocus != null)) {
                if (typeof(document.activeElement) == "undefined") {
                    lastFocus.value = options.eventTarget;
                }
                else {
                    var active = document.activeElement;
                    if ((typeof(active) != "undefined") && (active != null)) {
                        if ((typeof(active.id) != "undefined") && (active.id != null) && (active.id.length > 0)) {
                            lastFocus.value = active.id;
                        }
                        else if (typeof(active.name) != "undefined") {
                            lastFocus.value = active.name;
                        }
                    }
                }
            }
        }
    }
    if (options.clientSubmit) {
        __doPostBack(options.eventTarget, options.eventArgument);
    }
}
var __pendingCallbacks = new Array();
var __synchronousCallBackIndex = -1;
function WebForm_DoCallback(eventTarget, eventArgument, eventCallback, context, errorCallback, useAsync) {
    var postData = __theFormPostData +
                "__CALLBACKID=" + WebForm_EncodeCallback(eventTarget) +
                "&__CALLBACKPARAM=" + WebForm_EncodeCallback(eventArgument);
    if (theForm["__EVENTVALIDATION"]) {
        postData += "&__EVENTVALIDATION=" + WebForm_EncodeCallback(theForm["__EVENTVALIDATION"].value);
    }
    var xmlRequest,e;
    try {
        xmlRequest = new XMLHttpRequest();
    }
    catch(e) {
        try {
            xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e) {
        }
    }
    var setRequestHeaderMethodExists = true;
    try {
        setRequestHeaderMethodExists = (xmlRequest && xmlRequest.setRequestHeader);
    }
    catch(e) {}
    var callback = new Object();
    callback.eventCallback = eventCallback;
    callback.context = context;
    callback.errorCallback = errorCallback;
    callback.async = useAsync;
    var callbackIndex = WebForm_FillFirstAvailableSlot(__pendingCallbacks, callback);
    if (!useAsync) {
        if (__synchronousCallBackIndex != -1) {
            __pendingCallbacks[__synchronousCallBackIndex] = null;
        }
        __synchronousCallBackIndex = callbackIndex;
    }
    if (setRequestHeaderMethodExists) {
        xmlRequest.onreadystatechange = WebForm_CallbackComplete;
        callback.xmlRequest = xmlRequest;
        xmlRequest.open("POST", theForm.action, true);
        xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        xmlRequest.send(postData);
        return;
    }
    callback.xmlRequest = new Object();
    var callbackFrameID = "__CALLBACKFRAME" + callbackIndex;
    var xmlRequestFrame = document.frames[callbackFrameID];
    if (!xmlRequestFrame) {
        xmlRequestFrame = document.createElement("IFRAME");
        xmlRequestFrame.width = "1";
        xmlRequestFrame.height = "1";
        xmlRequestFrame.frameBorder = "0";
        xmlRequestFrame.id = callbackFrameID;
        xmlRequestFrame.name = callbackFrameID;
        xmlRequestFrame.style.position = "absolute";
        xmlRequestFrame.style.top = "-100px"
        xmlRequestFrame.style.left = "-100px";
        try {
            if (callBackFrameUrl) {
                xmlRequestFrame.src = callBackFrameUrl;
            }
        }
        catch(e) {}
        document.body.appendChild(xmlRequestFrame);
    }
    var interval = window.wxXInterval(function() {
        xmlRequestFrame = document.frames[callbackFrameID];
        if (xmlRequestFrame && xmlRequestFrame.document) {
            window.clearInterval(interval);
            xmlRequestFrame.document.write("");
            xmlRequestFrame.document.close();
            xmlRequestFrame.document.write('<html><body><form method="post"><input type="hidden" name="__CALLBACKLOADSCRIPT" value="t"></form></body></html>');
            xmlRequestFrame.document.close();
            xmlRequestFrame.document.forms[0].action = theForm.action;
            var count = __theFormPostCollection.length;
            var element;
            for (var i = 0; i < count; i++) {
                element = __theFormPostCollection[i];
                if (element) {
                    var fieldElement = xmlRequestFrame.document.createElement("INPUT");
                    fieldElement.type = "hidden";
                    fieldElement.name = element.name;
                    fieldElement.value = element.value;
                    xmlRequestFrame.document.forms[0].appendChild(fieldElement);
                }
            }
            var callbackIdFieldElement = xmlRequestFrame.document.createElement("INPUT");
            callbackIdFieldElement.type = "hidden";
            callbackIdFieldElement.name = "__CALLBACKID";
            callbackIdFieldElement.value = eventTarget;
            xmlRequestFrame.document.forms[0].appendChild(callbackIdFieldElement);
            var callbackParamFieldElement = xmlRequestFrame.document.createElement("INPUT");
            callbackParamFieldElement.type = "hidden";
            callbackParamFieldElement.name = "__CALLBACKPARAM";
            callbackParamFieldElement.value = eventArgument;
            xmlRequestFrame.document.forms[0].appendChild(callbackParamFieldElement);
            if (theForm["__EVENTVALIDATION"]) {
                var callbackValidationFieldElement = xmlRequestFrame.document.createElement("INPUT");
                callbackValidationFieldElement.type = "hidden";
                callbackValidationFieldElement.name = "__EVENTVALIDATION";
                callbackValidationFieldElement.value = theForm["__EVENTVALIDATION"].value;
                xmlRequestFrame.document.forms[0].appendChild(callbackValidationFieldElement);
            }
            var callbackIndexFieldElement = xmlRequestFrame.document.createElement("INPUT");
            callbackIndexFieldElement.type = "hidden";
            callbackIndexFieldElement.name = "__CALLBACKINDEX";
            callbackIndexFieldElement.value = callbackIndex;
            xmlRequestFrame.document.forms[0].appendChild(callbackIndexFieldElement);
            wxXys(xmlRequestFrame.document.forms[0])  ;
        }
    }, 10);
}
function WebForm_CallbackComplete() {
    for (i = 0; i < __pendingCallbacks.length; i++) {
        callbackObject = __pendingCallbacks[i];
        if (callbackObject && callbackObject.xmlRequest && (callbackObject.xmlRequest.readyState == 4)) {
            WebForm_ExecuteCallback(callbackObject);
            if (!__pendingCallbacks[i].async) {
                __synchronousCallBackIndex = -1;
            }
            __pendingCallbacks[i] = null;
            var callbackFrameID = "__CALLBACKFRAME" + i;
            var xmlRequestFrame = document.getElementById(callbackFrameID);
            if (xmlRequestFrame) {
                xmlRequestFrame.parentNode.removeChild(xmlRequestFrame);
            }
        }
    }
}
function WebForm_ExecuteCallback(callbackObject) {
    var response = callbackObject.xmlRequest.responseText;
    if (response.charAt(0) == "s") {
        if ((typeof(callbackObject.eventCallback) != "undefined") && (callbackObject.eventCallback != null)) {
            callbackObject.eventCallback(response.substring(1), callbackObject.context);
        }
    }
    else if (response.charAt(0) == "e") {
        if ((typeof(callbackObject.errorCallback) != "undefined") && (callbackObject.errorCallback != null)) {
            callbackObject.errorCallback(response.substring(1), callbackObject.context);
        }
    }
    else {
        var separatorIndex = response.indexOf("|");
        if (separatorIndex != -1) {
            var validationFieldLength = parseInt(response.substring(0, separatorIndex));
            if (!isNaN(validationFieldLength)) {
                var validationField = response.substring(separatorIndex + 1, separatorIndex + validationFieldLength + 1);
                if (validationField != "") {
                    var validationFieldElement = theForm["__EVENTVALIDATION"];
                    if (!validationFieldElement) {
                        validationFieldElement = document.createElement("INPUT");
                        validationFieldElement.type = "hidden";
                        validationFieldElement.name = "__EVENTVALIDATION";
                        theForm.appendChild(validationFieldElement);
                    }
                    validationFieldElement.value = validationField;
                }
                if ((typeof(callbackObject.eventCallback) != "undefined") && (callbackObject.eventCallback != null)) {
                    callbackObject.eventCallback(response.substring(separatorIndex + validationFieldLength + 1), callbackObject.context);
                }
            }
        }
    }
}
function WebForm_FillFirstAvailableSlot(array, element) {
    var i;
    for (i = 0; i < array.length; i++) {
        if (!array[i]) break;
    }
    array[i] = element;
    return i;
}
var __nonMSDOMBrowser = (window.navigator.appName.toLowerCase().indexOf('explorer') == -1);
var __theFormPostData = "";
var __theFormPostCollection = new Array();
function WebForm_InitCallback() {
    var count = theForm.elements.length;
    var element;
    for (var i = 0; i < count; i++) {
        element = theForm.elements[i];
        var tagName = element.tagName.toLowerCase();
        if (tagName == "input") {
            var type = element.type;
            if ((type == "text" || type == "hidden" || type == "password" ||
                ((type == "checkbox" || type == "radio") && element.checked)) &&
                (element.id != "__EVENTVALIDATION")) {
                WebForm_InitCallbackAddField(element.name, element.value);
            }
        }
        else if (tagName == "select") {
            var selectCount = element.options.length;
            for (var j = 0; j < selectCount; j++) {
                var selectChild = element.options[j];
                if (selectChild.selected == true) {
                    WebForm_InitCallbackAddField(element.name, element.value);
                }
            }
        }
        else if (tagName == "textarea") {
            WebForm_InitCallbackAddField(element.name, element.value);
        }
    }
}
function WebForm_InitCallbackAddField(name, value) {
    var nameValue = new Object();
    nameValue.name = name;
    nameValue.value = value;
    __theFormPostCollection[__theFormPostCollection.length] = nameValue;
    __theFormPostData += name + "=" + WebForm_EncodeCallback(value) + "&";
}
function WebForm_EncodeCallback(parameter) {
    if (encodeURIComponent) {
        return encodeURIComponent(parameter);
    }
    else {
        return escape(parameter);
    }
}
var __disabledControlArray = new Array();
function WebForm_ReEnableControls() {
    if (typeof(__enabledControlArray) == 'undefined') {
        return false;
    }
    var disabledIndex = 0;
    for (var i = 0; i < __enabledControlArray.length; i++) {
        var c;
        if (__nonMSDOMBrowser) {
            c = document.getElementById(__enabledControlArray[i]);
        }
        else {
            c = document.all[__enabledControlArray[i]];
        }
        if ((typeof(c) != "undefined") && (c != null) && (c.disabled == true)) {
            c.disabled = false;
            __disabledControlArray[disabledIndex++] = c;
        }
    }
    wxXTimeout("WebForm_ReDisableControls()", 0);
    return true;
}
function WebForm_ReDisableControls() {
    for (var i = 0; i < __disabledControlArray.length; i++) {
        __disabledControlArray[i].disabled = true;
    }
}
function WebForm_FireDefaultButton(event, target) {
        if (event.keyCode == 13 && !(event.srcElement && (event.srcElement.tagName.toLowerCase() == "textarea"))) {
        var defaultButton;
        if (__nonMSDOMBrowser) {
            defaultButton = document.getElementById(target);
        }
        else {
            defaultButton = document.all[target];
        }
        if (defaultButton && typeof(defaultButton.click) != "undefined") {
            defaultButton.click();
            event.cancelBubble = true;
            if (event.stopPropagation) event.stopPropagation();
            return false;
        }
    }
    return true;
}
function WebForm_GetScrollX() {
    if (__nonMSDOMBrowser) {
        return window.pageXOffset;
    }
    else {
        if (document.documentElement && document.documentElement.scrollLeft) {
            return document.documentElement.scrollLeft;
        }
        else if (document.body) {
            return document.body.scrollLeft;
        }
    }
    return 0;
}
function WebForm_GetScrollY() {
    if (__nonMSDOMBrowser) {
        return window.pageYOffset;
    }
    else {
        if (document.documentElement && document.documentElement.scrollTop) {
            return document.documentElement.scrollTop;
        }
        else if (document.body) {
            return document.body.scrollTop;
        }
    }
    return 0;
}
function WebForm_SaveScrollPositionSubmit() {
    if (__nonMSDOMBrowser) {
        theForm.elements['__SCROLLPOSITIONY'].value = window.pageYOffset;
        theForm.elements['__SCROLLPOSITIONX'].value = window.pageXOffset;
    }
    else {
        theForm.__SCROLLPOSITIONX.value = WebForm_GetScrollX();
        theForm.__SCROLLPOSITIONY.value = WebForm_GetScrollY();
    }
    if ((typeof(this.oldSubmit) != "undefined") && (this.oldSubmit != null)) {
        return this.oldSubmit();
    }
    return true;
}
function WebForm_SaveScrollPositionOnSubmit() {
    theForm.__SCROLLPOSITIONX.value = WebForm_GetScrollX();
    theForm.__SCROLLPOSITIONY.value = WebForm_GetScrollY();
    if ((typeof(this.oldOnSubmit) != "undefined") && (this.oldOnSubmit != null)) {
        return this.oldOnSubmit();
    }
    return true;
}
function WebForm_RestoreScrollPosition() {
    if (__nonMSDOMBrowser) {
        window.scrollTo(theForm.elements['__SCROLLPOSITIONX'].value, theForm.elements['__SCROLLPOSITIONY'].value);
    }
    else {
        window.scrollTo(theForm.__SCROLLPOSITIONX.value, theForm.__SCROLLPOSITIONY.value);
    }
    if ((typeof(theForm.oldOnLoad) != "undefined") && (theForm.oldOnLoad != null)) {
        return theForm.oldOnLoad();
    }
    return true;
}
function WebForm_TextBoxKeyHandler(event) {
    if (event.keyCode == 13) {
        var target;
        if (__nonMSDOMBrowser) {
            target = event.target;
        }
        else {
            target = event.srcElement;
        }
        if ((typeof(target) != "undefined") && (target != null)) {
            if (typeof(target.onchange) != "undefined") {
                target.onchange();
                event.cancelBubble = true;
                if (event.stopPropagation) event.stopPropagation();
                return false;
            }
        }
    }
    return true;
}
function WebForm_AppendToClassName(element, className) {
    var current = element.className;
    if (current) {
        if (current.charAt(current.length - 1) != ' ') {

            current += ' ';
        }
        current += className;
    }
    else {
        current = className;
    }
    element.className = current;
}
function WebForm_RemoveClassName(element, className) {
    var current = element.className;
    if (current) {
        if (current.substring(current.length - className.length - 1, current.length) == ' ' + className) {
            element.className = current.substring(0, current.length - className.length - 1);
            return;
        }
        if (current == className) {
            element.className = "";
            return;
        }
        var index = current.indexOf(' ' + className + ' ');
        if (index != -1) {
            element.className = current.substring(0, index) + current.substring(index + className.length + 2, current.length);
            return;
        }
        if (current.substring(0, className.length) == className + ' ') {
            element.className = current.substring(className.length + 1, current.length);
        }
    }
}
function WebForm_GetElementById(elementId) {
    if (document.getElementById) {
        return document.getElementById(elementId);
    }
    else if (document.all) {
        return document.all[elementId];
    }
    else return null;
}
function WebForm_GetElementByTagName(element, tagName) {
    var elements = WebForm_GetElementsByTagName(element, tagName);
    if (elements && elements.length > 0) {
        return elements[0];
    }
    else return null;
}
function WebForm_GetElementsByTagName(element, tagName) {
    if (element && tagName) {
        if (element.getElementsByTagName) {
            return element.getElementsByTagName(tagName);
        }
        if (element.all && element.all.tags) {
            return element.all.tags(tagName);
        }
    }
    return null;
}
function WebForm_GetElementDir(element) {
    if (element) {
        if (element.dir) {
            return element.dir;
        }
        return WebForm_GetElementDir(element.parentNode);
    }
    return "ltr";
}
function WebForm_GetElementPosition(element) {
    var result = new Object();
    result.x = 0;
    result.y = 0;
    result.width = 0;
    result.height = 0;
    if (element.offsetParent) {
        result.x = element.offsetLeft;
        result.y = element.offsetTop;
        var parent = element.offsetParent;
        while (parent) {
            result.x += parent.offsetLeft;
            result.y += parent.offsetTop;
            var parentTagName = parent.tagName.toLowerCase();
            if (parentTagName != "table" &&
                parentTagName != "body" && 
                parentTagName != "html" && 
                parentTagName != "div" && 
                parent.clientTop && 
                parent.clientLeft) {
                result.x += parent.clientLeft;
                result.y += parent.clientTop;
            }
            parent = parent.offsetParent;
        }
    }
    else if (element.left && element.top) {
        result.x = element.left;
        result.y = element.top;
    }
    else {
        if (element.x) {
            result.x = element.x;
        }
        if (element.y) {
            result.y = element.y;
        }
    }
    if (element.offsetWidth && element.offsetHeight) {
        result.width = element.offsetWidth;
        result.height = element.offsetHeight;
    }
    else if (element.style && element.style.pixelWidth && element.style.pixelHeight) {
        result.width = element.style.pixelWidth;
        result.height = element.style.pixelHeight;
    }
    return result;
}
function WebForm_GetParentByTagName(element, tagName) {
    var parent = element.parentNode;
    var upperTagName = tagName.toUpperCase();
    while (parent && (parent.tagName.toUpperCase() != upperTagName)) {
        parent = parent.parentNode ? parent.parentNode : parent.parentElement;
    }
    return parent;
}
function WebForm_SetElementHeight(element, height) {
    if (element && element.style) {
        element.style.height = height + "px";
    }
}
function WebForm_SetElementWidth(element, width) {
    if (element && element.style) {
        element.style.width = width + "px";
    }
}
function WebForm_SetElementX(element, x) {
    if (element && element.style) {
        element.style.left = x + "px";
    }
}
function WebForm_SetElementY(element, y) {
    if (element && element.style) {
        element.style.top = y + "px";
    }
}
   if(typeof(igedit_all)!="object")
	var igedit_all=new Object();
function igedit_getById(id,elem)
{
	var o,e=elem,i1=-2;
	if(e!=null)
	{
		while(true)
		{
			if(e==null)return null;
			try{if(e.getAttribute!=null)id=e.getAttribute("editID");}catch(ex){}
			if(!ig_csom.isEmpty(id))break;
			if(++i1>4)return null;
			e=e.parentNode;
		}
		var ids=id.split(",");
		if(ig_csom.isEmpty(ids))return null;
		id=ids[0];
		i1=(ids.length>1)?parseInt(ids[1]):-1;
	}
	if((e=igedit_all)!=null)if((o=e[id])==null)for(var i in e)if((o=e[i])!=null)
		if(o.ID==id||o.ID_==id||o.uniqueId==id)break;else o=null;
	if(o!=null&&i1>-2)o.elemID=i1;
	return o;
}
function igedit_init(id,t,prop0,prop1,cb)
{
	var o=igedit_all[id],elem=document.getElementById("igtxt"+id);
	if(o&&o.msV)
	{
		var i=-1,b=o.buttons;
		if(b)while(++i<b.length)if(b[i])b[i].elem=null;
		o.Element=o.elem=o.elemViewState=o.elemValue=o.tr=o.Event=o.webGrid=null;
		ig_dispose(o);
	}
	if(!elem||!prop0)return;
	prop0=prop0.split(",");
	if(t>=4)o=igedit_number(elem,id,prop0,prop1);
	else if(t==2)o=igedit_date(elem,id,prop0,prop1);
	else if(t==1)o=igedit_mask(elem,id,prop0,prop1);
	else o=new igedit_new(elem,id,prop0);
	igedit_all[id]=o;
	o.fix=1;
	if(cb)ig_csom.getCBManager().addPanel(o,id,id,o.Element,(cb=='1')?null:cb);
	o.setValue(prop1[0]);
	o.fcs=o._np=0;
	o._dtt();
	if((o._flag&2)!=0)wxXf(o)  ;
	o.fireEvent(10);
}
function igedit_number(elem,id,prop0,prop1)
{
	var i=1,me=new igedit_new(elem,id,prop0);
	var j=-1,v=me.valI(prop1,i++);
	var n=v.length;if(n<1)v=".";if(n<2){n=2;v+=v;}
	me.dec_vld=v.substring(n>>=1);
	me.decimalSeparator=v.substring(0,n);
	me.groupSeparator=me.valI(prop1,i++);
	v=me.valI(prop1,i++);
	if(v.length<1)v="-";
	me.minus=v;
	me.symbol=me.valI(prop1,i++);
	me.nullText=me.valI(prop1,i++);
	me.positivePattern=me.valI(prop1,i++);
	me.negativePattern=me.valI(prop1,i++);
	me.mode=me.valI(prop1,i++);
	me.decimals=me.valI(prop1,i++);
	me.minDecimals=me.valI(prop1,i++);
	v=me.valI(prop1,i++);
	if(v==1)me.min=me.valI(prop1,i++);
	v=me.valI(prop1,i++);
	if(v==1)me.max=me.valI(prop1,i++);
	me.clr1=me.valI(prop1,i++);
	me.clr0=me.valI(prop1,i++);
	me.groups=new Array();
	while(++j<6){if((v=me.valI(prop1,i++))>0)me.groups[j]=v;else break;}
	me.getMaxValue=function(){return this.max;}
	me.setMaxValue=function(v){this.max=this.toNum(v,false);}
	me.getMinValue=function(){return this.min;}
	me.setMinValue=function(v){this.min=this.toNum(v,false);}
	me.toNum=function(t,limit,fire)
	{
		var c,num=null,i=-1,div=1,dec=-1,iLen=0;
		if(t==="")t=null;
		if(t==null||t.length==null)num=t;
		else
		{
			var neg=false,dot=this.decimalSeparator.charCodeAt(0);
			if(t)
			{
				c=this.symbol;
				if(c.length>0)if((iLen=t.indexOf(c))>=0)t=t.substring(0,iLen)+t.substring(iLen+c.length);
				if(t.toUpperCase==null)t=t.toString();
				iLen=t.length;
			}
			while(++i<iLen)
			{
				if(this.isMinus(c=this.jpn(t.charCodeAt(i)))){if(neg)break;neg=true;}
				if(c==dot||c==12290){if(dec>=0)break;dec=0;}
				if(c<48||c>57)continue;
				if(num==null)num=0;
				if(dec<0)num=num*10+c-48;
				else{dec=dec*10+c-48;div*=10;}
			}
			if(num!=null){if(dec>0)num+=dec/div;if(neg)num=-num;}
		}
		i=limit?this.limits(num):num;
		if(fire!=true)return i;
		c="";
		if(i!=num||(i==null&&iLen>0))
		{
			fire=new Object();fire.value=i;fire.text=t;
			fire.type=(num==null)?((iLen==0)?2:0):1;
			c=String.fromCharCode(30);
			c+=t+c+fire.type;
			if(this.fireEvent(13,null,fire))c="";
			i=fire.value;
		}
		this.value=i;
		this.elemViewState.value=this.toTxt(i,true,null,"-",".")+c;
		this.valid(this.toTxt(i,true,null,"-",this.dec_vld));
		return i;
	}
	me.enter0=function(){return this.toTxt(null,true,this.elem.value,"-",".");}
	me.focusTxt=function(foc,e)
	{
		if(e!=null&&!foc)this.value=this.toNum(this.elem.value,true,true);
		return this.toTxt(this.value,foc);
	}
	me.toTxt=function(v,foc,t,m,dec)
	{
		if(t==null)
		{
			if(v==null)return foc?"":this.nullText;
			var neg=(v<0);
			if(neg)v=-v;
			try{t=v.toFixed(this.decimals);}catch(ex){t=""+v;}
			return this.toTxt(neg,foc,t.toUpperCase(),(m==null)?this.minus:m,(dec==null)?this.decimalSeparator:dec);
		}
		var c,i=-1,iL=t.length;
		if(v==null)
		{
			if(iL==0)return foc?t:this.nullText;
			if(v=this.isMinus(t.charCodeAt(0)))t=t.substring(1);
		}
		var iE=t.indexOf("E");
		if(iE<0)iE=0;
		else
		{
			iL=parseInt(t.substring(iE+1));
			t=t.substring(0,iE);
			iE=iL;
		}
		iL=t.length;
		while(++i<iL)
		{
			c=t.charCodeAt(i);
			if(c<48||c>57){t=t.substring(0,i)+t.substring(i+1);iL--;break;}
		}
		
		while(i<iL){if(t.charCodeAt(iL-1)!=48)break;t=t.substring(0,--iL);}
		if(iE!=0)
		{
			while(iE-->0)if(i++>=iL)t+="0";
			if(++iE<0){if(i==0)t="0"+t;while(++iE<0)t="0"+t;t="0"+t;i=1;}
		}
		iL=i;
		var iDec=0;
		if(this.decimals>0&&iL<t.length)
		{
			iDec=t.length-iL;
			t=t.substring(0,iL)+dec+t.substring(iL);
			iL+=dec.length+this.decimals;
		}
		if(iL<t.length)t=t.substring(0,iL);
		if((iL=this.minDecimals)!=0){if(iDec==0)t+=dec;while(iL-->iDec)t+="0";}
		if(foc)return v?(m+t):t;
		var g0=(this.groups.length>0)?this.groups[0]:0;
		var ig=0,g=g0;
		while(g>0&&--i>0)if(--g==0)
		{
			t=t.substring(0,i)+this.groupSeparator+t.substring(i);
			g=this.groups[++ig];
			if(g==null||g<1)g=g0;
			else g0=g;
		}
		var txt=v?this.negativePattern:this.positivePattern;
		txt=txt.replace("$",me.symbol);
		return txt.replace("n",t);
	}
	me.setText=function(v){this.sTxt=1;this.setValue(v);this.sTxt=0;}
	me.isMinus=function(k){return k==this.minus.charCodeAt(0)||k == 45||k==40||k==12540;}
	me.doKey=function(k,c,t,i,sel0,sel1,bad)
	{
		if(bad)
		{
			if(!(k<9||this.isMinus(k)||(k>=48&&k<=57)||k==this.decimalSeparator.charCodeAt(0)))
				ig_cancelEvent(e);
			return;
		}
		if(sel0!=sel1){t=t.substring(0,sel0)+t.substring(sel1);sel1=sel0;i=t.length;}
		
		else if(k==7){if(sel1++>=i||i==0)return;}
		else if(k==8){if(sel0--<1)return;}
		if(k<9||this.maxLength==0||this.maxLength>i)
		{
			var dot=k==this.decimalSeparator.charCodeAt(0);
			var ok=(k>47&&k<58)||(sel0==0&&this.isMinus(k))||(dot&&this.decimals>0);
			if(i>0&&sel0==0)if(this.isMinus(t.charCodeAt(0)))ok=false;
			if(k>8&&!ok)return;
			if(dot)if((dot=t.indexOf(this.decimalSeparator))>=0)
			{
				if(dot==sel0||dot==sel0-1)return;
				i--;
				if(dot<sel0)sel0=--sel1;
				t=t.substring(0,dot)+t.substring(dot+1);
			}
			if(k>8&&sel1>=i)t+=c;
			else t=t.substring(0,sel0)+c+t.substring(sel1);
		}
		else k=0;
		this.elem.value=t;
		this.select((k>10)?sel1+1:sel0);
	}
	me.limits=function(v,r)
	{
		if(v==null&&!this.nullable)v=0;
		if(v!=null)
		{
			var n=this.min,x=this.max;
			if(n!=null&&v<=n)return r?x:n;
			if(x!=null&&v>=x)return r?n:x;
		}
		return v;
	}
	me.getNumber=function(){return this.instant(true,true,true);}
	me.setNumber=function(v){this.setValue(v);}
	me.instant=function(num,limit,v)
	{
		v=(this.fcs==2||v)?this.toNum(this.elem.value,limit==true):this.value;
		if(this._vld==1)this.msV(this.toTxt(v,true,null,"-",this.dec_vld));
		return (num||this.mode>0)?v:this.toTxt(v,true);
	}
	me.getValue=function(num){this._ok();this._vld=1;return this.instant(num,true,true);}
	me.setValue=function(v)
	{
		this.text=this.toTxt(this.value=this.toNum(v,true,true),this.fcs==2);
		this.repaint();
		this.select(1000);
		if(this.fix==1)this.old=this.instant(true);
	}
	me.spin=function(v)
	{
		var val=this.toNum(this.elem.value);
		if(val==null)val=0;
		this.fix=0;this.setValue(val+v);this.fix=1;
	}
	me.getRenderedValue=function(v){return this.toTxt(this.toNum(v),false);}
	return me;
}
function igedit_date(elem,id,prop0,prop1)
{
	var me=igedit_mask(elem,id,prop0,prop1);
	me.mask1=me.dMask(me.valI(prop1,3),true);
	me.nullText=me.valI(prop1,4);
	me.century=prop1[5];
	me.yearFix=prop1[6];
	me.str=me.valI(prop1,7).split(",");
	me.getMaxValue=function(){return this.max;}
	me.setMaxValue=function(v){if(v!=null&&v.getTime==null)v=this.toDate(v.toString(),true);this.max=v;}
	me.getMinValue=function(){return this.min;}
	me.setMinValue=function(v){if(v!=null&&v.getTime==null)v=this.toDate(v.toString(),true);this.min=v;}
	me.getAMPM=function(am){var v=this.valI(this.str,am?0:1);return (v.length>0)?v:(am?"AM":"PM");}
	me.setAMPM=function(v,am){return this.str[am?0:1]=v;}
	me.getMonthNameAt=function(i){return this.valI(this.str,2+i%12);}
	me.setMonthNameAt=function(v,i){return this.str[2+i%12]=v;}
	me.getDowNameAt=function(i){return this.valI(this.str,14+i%7);}
	me.setDowNameAt=function(v,i){return this.str[14+i%7]=v;}
	me.setNow=function(){this.setValue(new Date());}
	me.date=new Date();
	me.isNull=false;
	me.d_s=10;
	me.setText=function(v){this.sTxt=1;this.setValue(v,true);this.sTxt=0;}
	me.fieldValue=function(field,d,e,c)
	{
		var v,i=(field&1)*2;
		if(field<4){v=d.getFullYear()+this.yearFix;if(field==3)i=4;else{v%=100;i=(field==2)?2:0;}}
		else if(field<8){this.d_s=2;v=d.getMonth()+1;if(field>5){field=this.getMonthNameAt(v-1);if(field.length>0)return field;}}
		else if(field<10)v=d.getDate();
		else if(field<16)
		{
			v=d.getHours();
			if(field>13)
			{
				v=this.getAMPM(v<12);
				if((field-=13)==(i=v.length))return v;
				if(i<field)v+=" ";
				return v.substring(0,field);
			}
			if(field<12){v%=12;if(v==0)v=12;}
		}
		else if(field<18)v=d.getMinutes();
		else if(field<20)v=d.getSeconds();
		else if(field<22)return this.getDowNameAt(d.getDay());
		else
		{
			v=d.getMilliseconds();
			var j=i=field-21;
			while(j-->3)v*=10;
			while(j++<2)v=Math.floor(v/10);
		}
		v=""+v;
		if(field<20)
		{
			field=v.length;
			if(e){if(i==0)i=2;else e=false;}
			if(i>0){if(i<field)v=v.substring(0,i);else while(field++<i)v=(e?c:"0")+v;}
		}
		return v;
	}
	me.limits=function(d,r)
	{
		if(d==null)return d;
		var v=d.getTime(),n=this.min,x=this.max;
		if(n!=null)n=n.getTime();if(x!=null)x=x.getTime();
		if(n!=null&&(v<n||(r&&v==n))){d.setTime(r?x:n);return d;}
		if(x!=null&&(v>x||(r&&v==x))){d.setTime(r?n:x);return d;}
		return null;
	}
	me.toDate=function(t,foc,limit,fire)
	{
		var fields=(foc&&fire)?this.fields0(t):this.fields1(t,foc);
		
		var v,i0,n=0,i=-1,j=-1,iLen=fields.length,c,y=-1,mo=-1,day=-1,h=-2,m=-2,s=-2,ms=-2,pm=-1;
		var any=false,arg=new Object();
		while(++i<iLen)
		{
			j++;v=fields[i];i0=foc?this.field0IDs[i]:this.field1IDs[i];
			if(i0<4){if(v>100&&v>this.yearFix)v-=this.yearFix;if((arg.year=y=v)<0)n|=8;else{n++;c=this.century;if(v<100){if(i0<3&&c<0)c=29;if(c>=0)y+=(v>c)?1900:2000;}}}
			else if(i0<8){arg.month=mo=v;if(v<1||v>12)n|=8;else n++;}
			else if(i0<10){arg.day=day=v;if(v<1||v>31)n|=8;else n++;}
			else if(i0<14)
			{
				if(v==24)v=0;
				if(i0>11)pm=-4;else{if(v==12)v=0;if(v>12)n|=8;}
				arg.hours=h=v;if(v>23||v<0)n|=8;
			}
			else if(i0<16){j--;if(v>0)pm++;continue;}
			else if(i0<18){arg.minutes=m=v;if(v>59||v<0)n|=8;}
			else if(i0<20){arg.seconds=s=v;if(v>59||v<0)n|=8;}
			else if(i0<22){j--;continue;}
			else{while(i0++<24)v*=10;while(i0-->25)v=Math.floor(v/10);arg.milliseconds=ms=v;if(v>999||v<0)n|=8;}
			if(v>=0)any=true;
			if(j<this.minF&&n>7)n|=32;
		}
		if(pm==0&&h>=0&&h<12)arg.hours=(h+=12);
		var inv=fire?(":"+y+","+mo+","+day+","+h+","+m+","+s+","+ms+","):"";
		var d=null;
		if((n&3)==3){d=new Date(y,mo-1,day);if(y<100)d.setFullYear(y);}
		else if(n<30)
		{
			d=new Date();if(this.date)d.setTime(this.date.getTime());
			if(day>0)d.setDate(day);if(y>=0)d.setFullYear(y);if(mo>0)d.setMonth(mo-1);
		}
		n&=15;
		if(day>0&&d!=null)if(day!=d.getDate())n|=8;
		day=this.good;
		if(fire&&d==null&&!this.nullable)
		{
			d=day;
			if(d==null||d.getTime==null){d=new Date();n|=8;}else n|=32;
		}
		if(d!=null)
		{
			if(h>-2)d.setHours((h<0)?0:h);if(m>-2)d.setMinutes((m<0)?0:m);
			if(s>-2)d.setSeconds((s<0)?0:s);if(ms>-2)d.setMilliseconds((ms<0)?0:ms);
			if(limit){if((d=this.limits(i=d))!=null)n=16;else d=i;}
		}
		if(fire)
		{
			if(any&&d==null&&t.length>0&&day!=null&&day.getTime!=null){d=day;n=32;}
			arg.date=d;
			if(n<8||(n==8&&!any&&this.nullable))inv="";
			else
			{
				inv+=(arg.type=(n<16)?2:((n==16)?1:0));
				if(this.fireEvent(13,null,arg))inv="";
				d=arg.date;
			}
			this.updatePost(d,inv);
			if(day!=false)this.good=d;
		}
		return d;
	}
	me.updatePost=function(d,inv)
	{
		if(d!=null)inv=""+d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+"-"+d.getHours()+"-"+d.getMinutes()+"-"+d.getSeconds()+"-"+d.getMilliseconds()+inv;
		this.elemViewState.value=inv;
		this.valid((d==null)?"":this.toTxt(d,true,""));
	}
	me.enter0=function()
	{
		var d=this.toDate(this.elem.value,true);
		return (d==null)?"":this.toTxt(d,true,"");
	}
	me.toTxt=function(d,foc,prompt,txt)
	{
		var t="",mask=foc?this.mask:this.mask1;
		if(d==null)return foc?this.getTxt(5,prompt,txt?(this.txt=mask):mask):this.nullText;
		var ids=foc?this.field0IDs:this.field1IDs;
		var c,k,i=-1,f0=0;
		this.d_s=6;
		while(++i<mask.length)
		{
			c=mask.charAt(i);
			if((k=mask.charCodeAt(i))<21)
			{
				t+=this.fieldValue(ids[f0++],d,foc,c);
				if(foc)while(i+1<mask.length)if(mask.charCodeAt(i+1)==k)i++;else break;
			}
			else t+=c;
		}
		if(!foc)return t;
		if(txt)this.txt=t;
		return this.getTxt(5,prompt,t);
	}
	me.focusTxt=function(foc,e,t)
	{
		var d=null,prompt="";
		if(t==null)
		{
			prompt=this.promptChar;
			
			if(e==null&&foc)return this.getTxt(5,prompt);
			if(e!=null&&!foc)
			{
				
				d=this.toDate(this.elem.value,e==="",true,true);
				if(!(this.isNull=(d==null)))this.date=d;
			}
			else if(!this.isNull)d=this.date;
		}
		else d=this.toDate(t,foc,true);
		return this.toTxt(d,foc,prompt,e!=null);
	}
	me.fields1=function(t,foc)
	{
		var ids=foc?this.field0IDs:this.field1IDs;
		var iLen=ids.length;
		var j,i=-1,v=-1,field=0,fields=new Array(iLen);
		while(++i<iLen)fields[i]=-1;
		if(t==null)return fields;
		t=t.toUpperCase();
		i=-1;
		while(++i<t.length&&field<iLen)
		{
			var k=this.jpn(t.charCodeAt(i))-48,j=ids[field];
			if(j==20||j==21)j=ids[++field];
			if(j==14||j==15)
			{
				if(k>=0&&k<=9){v=-1;field++;i--;continue;}
				if(this.getAMPM(false).charAt(0).toUpperCase()==t.charAt(i))
				{fields[field++]=1;v=-1;}
			}
			else
			{
				if(k>=0&&k<=9){if(v<0)v=k;else v=v*10+k;}
				else
				{
					if(v>=0){fields[field++]=v;v=-1;}
					else if(j==6||j==7)while(v-->-3)
					{
						for(k=0;k<12;k++)
						{
							var m=this.getMonthNameAt(k).toUpperCase();
							if((j=m.length)<1)continue;
							if(v==-3){if(j<4)continue;m=m.substring(0,3);}
							if((j=t.indexOf(m)-1)>-2)if(j<0||t.charAt(j).toLowerCase()==t.charAt(j))break;
						}
						if(k<12){fields[field++]=k+1;break;}
					}
				}
			}
		}
		if(field<iLen)fields[field]=v;
		return fields;
	}
	me.fields0=function(t)
	{
		var fields=new Array();
		if(t==null)t="";
		var x,k,i=-1,v=-1,field=-1,n=22;
		while(++i<this.mask.length)
		{
			if((x=this.mask.charCodeAt(i))>21&&n>21)continue;
			if(x>21){if(field>=0)fields[field]=v;}
			else
			{
				if(n>21){v=-1;field++;}
				if(i>=t.length)continue;
				if(x>18)
				{
					k=this.jpn(t.charCodeAt(i))-48;
					if(k>=0&&k<=9){if(v<0)v=k;else v=v*10+k;}
				}
				else if(n!=x)if(this.getAMPM(false).charAt(0).toUpperCase()==t.charAt(i).toUpperCase())
					v=1;
			}
			n=x;
		}
		fields[field]=v;
		return fields;
	}
	me.curField=function(s,mask)
	{
		var x,n=22,field=this.n0=this.n1=-1;
		for(var i=0;i<mask.length;i++)
		{
			if(((x=mask.charCodeAt(i))>21)==(n>21))continue;
			if(x>21){if(i>=s)break;}
			else{this.n0=i;field++;}
			n=x;
		}
		if(this.n0>=0)this.n1=i;
		if((field=this.field0IDs[field])==null)return -1;
		if(field<8)return (field<4)?0:1;
		if(field<20)return Math.floor((field-4)/2);
		return (field>21)?8:-1;
	}
	me.key=function(k,c,t,i,s,mask)
	{
		var n=0,v=-1,field=this.curField(s,mask);
		if(s>=this.n1)if(t.charCodeAt(--s)>21)return this.key(k,c,t,i,s+2,mask);
		if(field<0)return -1;
		if(field==5)
		{
			if(s<=this.n0)
			{
				v=this.getAMPM(false);
				if(v.charAt(0).toUpperCase()!=c.toUpperCase())v=this.getAMPM(true);
				if(this.n1==this.n0+1)v=v.charAt(0);
				else if((i=v.length)<2)v+=" ";else if(i>2)v=v.substring(0,2);
				this.txt=t.substring(0,this.n0)+v+t.substring(this.n1);
			}
			return this.n1;
		}
		if(k<48||k>57)
		{
			if(s==0||(k!=47&&k!=58&&(k<44||k>57)))return -1;
			if(mask.charCodeAt(s-1)>=21||this.n1==i)return s;
			while(s<i)
			{
				if(mask.charCodeAt(s++)>=21)break;
				t=t.substring(0,s-1)+mask.charAt(s-1)+t.substring(s);
			}
			this.txt=t;
			return s;
		}
		k-=48;
		if(this.n0==s)
		{
			v=t.charCodeAt(s+1)-48;
			
			switch(field)
			{
				case 4:k--;v-=2;
				case 3:case 1:if(k>1)n=1;else if(k==1&&v>2)n=2;break;
				case 2:if(k>3)n=1;else if(k==3&&v>1)n=2;break;
				case 6:case 7:if(k>6)n=1;else if(k==6&&v>0)n=2;break;
				default:break;
			}
		}
		if(this.n0+1==s)
		{
			v=t.charCodeAt(s-1)-48;
			switch(field)
			{
				case 4:v--;k-=2;
				case 3:case 1:if(v>1||(v==1&&k>2))n=3;break;
				case 2:if(v>3||(v==3&&k>1))n=3;break;
				case 6:case 7:if(v>6||(v==6&&k>0))n=3;break;
				default:break;
			}
		}
		if(n==1){t=t.substring(0,s)+mask.charAt(s)+t.substring(s+1);s++;}
		if(n==2)t=t.substring(0,s+1)+mask.charAt(s+1)+t.substring(s+2);
		if(n==3)
		{
			while(++s<i)if(mask.charCodeAt(s)<21)break;
			if(s>=i)return -1;
			return this.key(k+48,c,t,i,s,mask);
		}
		this.txt=t.substring(0,s)+c+t.substring(s+1);
		return ++s;
	}
	me.spin=function(v)
	{
		var x,i=this.spinF,d=new Date();
		d.setTime(this.date.getTime());
		if(i<0||i>8)
		{
			if(this.fcs==2)
			{
				this.getSelectedText();
				i=this.curField(this.sel0,this.mask);
				if((d=this.toDate(this.elem.value,true,true,true))==null)d=new Date();
				this.spinF=i;
			}
			else this.spinF=i=this.d_s;
		}
		
		if(i==5)v=(v>0)?12:-12;
		x=this.spinOnlyOneField;
		switch(i)
		{
			case 0:d.setFullYear(v+=d.getFullYear());if(x&&v!=d.getFullYear())i=-1;break;
			case 1:d.setMonth(v+=d.getMonth());if(x&&v!=d.getMonth())i=-1;break;
			case 2:d.setDate(v+=d.getDate());if(x&&v!=d.getDate())i=-1;break;
			case 3:case 4:case 5:i=d.getDate();d.setHours(v+=d.getHours());if(x&&i!=d.getDate())i=-1;break;
			case 6:d.setMinutes(v+=d.getMinutes());if(x&&v!=d.getMinutes())i=-1;break;
			case 7:d.setSeconds(v+=d.getSeconds());if(x&&v!=d.getSeconds())i=-1;break;
			case 8:for(i=this.n1-this.n0;i++<3;)v*=10;
				d.setMilliseconds(v+=d.getMilliseconds());if(x&&v!=d.getMilliseconds())i=-1;break;
		}
		if(i<0)return;
		if((v=this.limits(d))!=null)d=v;
		this.text=this.toTxt(d,this.fcs==2,this.promptChar,true);
		this.date=d;this.isNull=false;
		this.updatePost(d,"");
		this.repaint();this.select(this.sel0);
	}
	me.getDate=function(){return this.instant(true);}
	me.setDate=function(v){this.setValue(v);}
	me.getValueByMode=function(vt,limit)
	{
		this._ok();
		var d=(this.fcs<2)?(this.isNull?null:this.date):this.toDate(this.elem.value,true,limit);
		if(this._vld==1)this.msV(d?this.toTxt(d,true,""):"");
		if(vt==0)return d;
		return this.toTxt(d,vt==1,this.emptyChar);
	}
	me.instant=function(date,limit){return this.getValueByMode(date?0:this.mode,limit==true);}
	me.date_7=function(v)
	{
		if(v.length<10)return null;
		var y,o=v.split("-");
		if(o.length<7)return null;
		v=new Date(y=this.intI(o,0),this.intI(o,1),this.intI(o,2),this.intI(o,3),this.intI(o,4),this.intI(o,5),this.intI(o,6));
		if(y<100)v.setFullYear(y);
		return v;
	}
	me.getValue=function(date){this._ok();this._vld=1;return this.instant(date,true);}
	me.setValue=function(v,o)
	{
		if(v!=null&&v.getTime==null)
		{
			if(this.fcs<0)
			{
				if(v.length<8)v="";
				o=v.split(",");
				if(o.length>2)this.max=this.date_7(o[2]);
				if(o.length>1)this.min=this.date_7(o[1]);
				v=this.date_7(o[0]);
			}
			else v=this.toDate(v.toString(),this.mode<2&&o!=true);
		}
		o=v;
		if((v=this.limits(v))==null)v=o;
		this.txt=this.mask;
		if(this.isNull=(v==null))v=new Date();
		else this.toTxt(v,true,"",true);
		this.date=v;
		if(this.good!=false)this.good=v;
		this.text=this.focusTxt(this.fcs>1);
		this.updatePost(this.isNull?null:v,"");
		this.repaint();
		if(this.fix==1)this.old=this.instant(true);
	}
	me.getRenderedValue=function(v)
	{
		if(v!=null&&v.getTime==null)v=this.toDate(v.toString(),false);
		return this.toTxt(v,false,"");
	}
	return me;
}
function igedit_mask(elem,id,prop0,prop1)
{
	var me=new igedit_new(elem,id,prop0);
	prop1[0]=ig_csom.replace(prop1[0],'~^+=','\03');
	var prop=me.valI(prop1,2);
	me.promptChar=prop.charAt(0);
	me.padChar=prop.charAt(1);
	me.emptyChar=prop.charAt(2);
	me.mode=parseInt(prop.charAt(3));
	me.minF=parseInt(prop.charAt(4));
	me.good=prop.length>5;
	me.flag=function(c,u)
	{
		switch(c)
		{
			case '>':return -1;case '<':return -2;
			case '&':c=1;break;case 'C':c=2;break;
			case 'A':c=7;break;case 'a':c=8;break;
			case 'L':c=13;break;case '?':c=14;break;
			case '#':case '0':return 19;
			case '9':return 20;
			default:return 0;
		}
		return c+u*2;
	}
	me.filter=function(flag,s,i,sf)
	{
		if(i>=s.length)return sf;
		var c=s.charCodeAt(i),f=Math.floor((flag-1)/6);
		s=s.charAt(i);
		if(c<21)return sf;
		if(f==1||f==3)if(c>100)if((c=this.jpn(c))<100)s=String.fromCharCode(c);
		switch(f)
		{
			case 0:break;
			case 1:if(c>47&&c<58)return s;
			case 2:if(c>255||s.toUpperCase()!=s.toLowerCase())break;return sf;
			case 3:return (c>47&&c<58)?s:sf;
		}
		if((flag=Math.floor((flag-1)/2)%3)==0)return s;
		return (flag==2)?s.toLowerCase():s.toUpperCase();
	}
	me.getTxt=function(vt,prompt,t)
	{
		var flag,mask=this.mask,o="",non=(t!=null);
		if(!non)t=(this.bad!=0&&this.fcs>1)?this.elem.value:this.txt;
		if(non||this.fcs<0)non=this.minF==0;
		if(t==null||mask==null)return o;
		for(var i=0;i<mask.length;i++)if((flag=mask.charCodeAt(i))<21)
		{
			if(i<t.length&&t.charCodeAt(i)>=21){o+=t.charAt(i);non=false;}
			else if(vt%3==2||(vt%3==1&&(flag&1)==1))o+=prompt;
		}
		else if(vt>=3)o+=mask.charAt(i);
		return non?"":o;
	}
	me.setTxt=function(v,vt,render)
	{
		var c,flag,j=0,i=-1,mask=this.mask,t=this.mask;
		if(v!=null)while(++i<mask.length)
		{
			if(vt==1000+j)vt=this.mode;
			if(j>=v.length)break;
			if((flag=mask.charCodeAt(i))<21)
			{
				if((c=this.filter(mask.charCodeAt(i),v,j))!=null)t=t.substring(0,i)+c+t.substring(i+1);
				j++;
			}
			else if(vt>=3)j++;
		}
		if(render)return t;
		this.txt=t;
		this.text=this.focusTxt(this.fcs>1," ");
		this.repaint();
	}
	me.getInputMask=function(){return this.m0;}
	me.setInputMask=function(mask)
	{
		if(mask==null)mask="";
		this.m0=mask;
		var x,c,i,i0=0,u=0,n="",t="",t0=this.getTxt(0);
		for(i=0;i<mask.length;i++)
		{
			if((x=this.flag(c=mask.charAt(i),u))!=0)
			{
				if(x<0){u=(u==-x)?0:-x;continue;}
				n+=(c=String.fromCharCode(x));
				c=this.filter(x,t0,i0++,c);
			}
			else if(c=="\\"&&i+1<mask.length&&this.flag(mask.charAt(i+1),0)!=0)
				n+=(c=mask.charAt(++i));
			else n+=c;
			t+=c;
		}
		this.txt=t;this.mask=n;
	}
	me.dMask=function(v,d)
	{
		if(this.field0IDs==null)this.field0IDs=new Array();
		if(this.field1IDs==null)this.field1IDs=new Array();
		if(v==null)v="";
		var x,i,i0=0,flag=-1,t="";
		for(i=0;i<v.length;i++)
		{
			x=v.charCodeAt(i);
			if(x<48||x>57)
			{
				if(d==true&&(flag=v.charAt(i))=="\\"&&i+1<v.length)
				{
					if((x=v.charAt(++i))=="\\")continue;
					if(x=="0"||x=="9")t+=flag;
					t+=x;
				}
				else t+=v.charAt(i);
				continue;
			}
			flag=(x-48)*10+v.charCodeAt(++i)-48;
			if(d==true){this.field1IDs[i0++]=flag;t+="\01";continue;}
			this.field0IDs[i0++]=flag;
			if(flag==14)t+="L";else if(flag==15)t+="LL";
			else if(flag==22)t+="#";
			else{t+="##";if(flag==3)t+="##";while(flag-->23)t+="#";}
		}
		return t;
	}
	prop=me.valI(prop1,1);
	if(prop1.length>3)prop=me.dMask(prop);
	me.setInputMask(prop);
	me.focusTxt=function(foc,e)
	{
		var t=null;
		if(e!=null&&!foc)
		{
			e=e!=="";
			if(e&&this.bad!=0)this.txt=this.setTxt(this.elem.value,5,true);
			t=this.txt;
			var inv=t.length;
			if(!e&&this.hadFocus)
			{
				var iL=inv-this.elem.value.length,s0=this.sel0,s1=this.sel1;
				if(iL>0&&s1-s0==iL)
					this.txt=t=t.substring(0,s0)+this.mask.substring(s0,s1)+t.substring(s1);
			}
			while(inv-->0)
			{
				var c=t.charCodeAt(inv);
				if(c<21&&(c&1)==1)break;
			}
			if(!e&&inv>=0)if(this.fireEvent(13))inv=-1;
			this.elemViewState.value=(t=this.txt)+((inv<0)?"":String.fromCharCode(30));
			this.valid(this.getTxt(this.mode,""));
		}
		return this.getTxt(foc?5:4,foc?this.promptChar:this.padChar,t);
	}
	me.enter0=function(){return this.getTxt(this.mode,"");}
	me.setText=function(v,s){this.sTxt=1;this.setTxt(v,(s==null)?5:(1000+s));this.sTxt=0;if(this.fix==1)this.old=this.instant(true);}
	me.key=function(k,c,t,i,s,mask){return -2;}
	me.doKey=function(k,c,t,i,sel0,sel1,bad)
	{
		if(i<1||k<7||(k>8&&k<32))k=0;
		if(bad)
		{
			if(k==0||(this.getAMPM!=null&&!(this.mask.indexOf(c)>0||this.getAMPM(false).indexOf(c)>=0||this.getAMPM(true).indexOf(c)>=0||(k>=48&&k<=57))))
				ig_cancelEvent(e);
			return;
		}
		if(k==0)return;
		t=this.txt;
		var mask=this.mask;
		if(sel0!=sel1){while(--sel1>=sel0)t=t.substring(0,sel1)+mask.charAt(sel1)+t.substring(sel1+1);sel1++;}
		else if(k==7)
		{
			while(sel1<i&&mask.charCodeAt(sel1)>=21)sel1++;
			if(sel1>=i)return;
			t=t.substring(0,sel1)+mask.charAt(sel1)+t.substring(sel1+1);
			sel1++;
		}
		else if(k==8)
		{
			while(sel1>0&&mask.charCodeAt(sel1-1)>=21)sel1--;
			if(sel1--<1)return;
			t=t.substring(0,sel1)+mask.charAt(sel1)+t.substring(sel1+1);
		}
		if(k>8&&sel1<i)
		{
			if(sel1>=i)return;
			if((sel0=this.key(k,c,t,i,sel1,mask))>=0){t=this.txt;sel1=sel0;}
			else{if(sel0==-1)return;while(mask.charCodeAt(sel1)>=21)if(++sel1>=i)return;}
			if(sel0>=0){t=this.txt;sel1=sel0;}
			else
			{
				if((c=this.filter(mask.charCodeAt(sel1),c,0))==null)return;
				t=t.substring(0,sel1)+c+t.substring(sel1+1);
				sel1++;
			}
		}
		this.txt=t;
		this.elem.value=this.focusTxt(true);
		this.select(sel1);
	}
	me.getValueByMode=function(vt){return this.getTxt(vt,this.emptyChar);}
	me.instant=function(){return this.getValueByMode(this.mode);}
	me.getValue=function(){this._ok();this.msV(this.getTxt(this.mode,""));return this.instant();}
	me.setValue=function(v){this.setTxt(v,(this.fcs<0)?2:this.mode);if(this.fix==1)this.old=this.instant(true);}
	me.getRenderedValue=function(v)
	{
		v=(v==null)?"":v.toString();
		return this.getTxt(4,this.padChar,(this.mode==5)?v:this.setTxt(v,this.mode,true));
	}
	return me;
}
function igedit_new(elem,id,prop0)
{
	this.fcs=-1;
	this.valI=function(o,i){o=(o==null||o.length<=i)?null:o[i];return (o==null)?"":o;}
	this.intI=function(o,i){return ig_csom.isEmpty(o=this.valI(o,i))?-1:parseInt(o);}
	this._lsnr=function(e,n){if(e&&!e._old)ig_csom.addEventListener(e,n,igedit_event);}
	this.initButElem=function(e,c,o)
	{
		if(e==null)return;
		var i=-1,n=e.nodeName=="IMG";
		if(n||e.nodeName=="TD")if(c==null)
		{
			if(o&&n)o.imgE=e;
			this._lsnr(e,"mousedown");this._lsnr(e,"mouseup");this._lsnr(e,"mousemove");this._lsnr(e,"mouseout");
			e._old=true;
			e.unselectable="on";
		}
		else if(!ig_csom.isEmpty(e.bgColor)){e.bgColor=c;e.style.color=c;}
		if(!n)if((n=e.childNodes)!=null)while(++i<n.length)this.initButElem(n[i],c,o);
	}
	this.focusTxt=function(foc,e)
	{
		if(e!=null&&!foc)this.valid(this.elemViewState.value=this.elem.value);
		return this.elem.value;
	}
	this.elemID=-10;
	this.bad=0;
	this.Element=elem;
	elem.Object=this;
	this.eventID=function(s)
	{
		switch(s.toLowerCase())
		{
			case "keydown":return 0;
			case "keypress":return 1;
			case "keyup":return 2;
			case "mousedown":return 3;
			case "mouseup":return 4;
			case "mousemove":return 5;
			case "mouseover":return 6;
			case "mouseout":return 7;
			case "focus":return 8;
			case "blur":return 9;
			case "initialize":return 10;
			case "valuechange":return 11;
			case "textchanged":return 12;
			case "invalidvalue":return 13;
			case "custombutton":return 14;
			case "spin": return 15;
		}
		return -1;
	}
	this.events=new Array(16);
	this.evtH=function(n,fRef,add,o,s)
	{
		if(n<0||n>15)return;
		var e=this.events[n];
		if(e==null){if(add)e=this.events[n]=new Array();else return;}
		for(n=0;n<e.length;n++)if(e[n]!=null&&e[n].fRef==fRef)
		{if(!add){delete e[n];e[n]=null;}return;}
		if(add)for(n=0;n<=e.length;n++)if(e[n]==null)
		{e[n]={fRef:fRef,o:o,s:s};break;}
	}
	this.removeEventListener=function(name,fref){this.evtH(this.eventID(name),fref,false);}
	this.addEventListener=function(name,fref,o){this.evtH(this.eventID(name),fref,true,o);}
	this.getRenderedValue=function(v){return (v==null)?"":v.toString();}
	var n,o,ii,j,i=0,e=document.getElementById(id+"_p");
	if(e==null)e=new Object();
	e.value=String.fromCharCode(30);
	this.elemViewState=e;
	if((e=document.getElementById(id))==null)if((e=document.getElementById(id.substring(1)))==null)e=new Object();
	this.elemValue=e;
	this.uniqueId=prop0[i++];
	e=prop0[i++];
	if(e.length>2)
	{
		e=e.split(" ");
		for(j=0;j<e.length-1;j+=2)
		{
			o=this.intI(e,j);
			n=ig_csom.replace(this.valI(e,j+1),'&quot;','\"');
			n=ig_csom.replace(ig_csom.replace(n,'&coma;',','),'&nbsp;',' ');
			if(o==99)this._dt=n;else if(o==98)this._null=n;
			else if(ig_csom.isName(n))try{this.evtH(o,eval(n),true);}catch(o){}
			else this.evtH(o,n,true,null,true);
		}
	}
	this.nullable=!ig_csom.isEmpty(prop0[i++]);
	this.postValue=!ig_csom.isEmpty(prop0[i++]);
	this.postButton=!ig_csom.isEmpty(prop0[i++]);
	this.postEnter=!ig_csom.isEmpty(prop0[i++]);
	this.maxLength=this.intI(prop0,i++);
	this.spinDelta=ig_csom.isEmpty(o=this.valI(prop0,i++))?1:parseFloat(o);
	this.spinOnArrows=!ig_csom.isEmpty(prop0[i++]);
	this.spinOnlyOneField=!ig_csom.isEmpty(prop0[i++]);
	this.hideEnter=!ig_csom.isEmpty(prop0[i++]);
	this.selectionOnFocus=this.intI(prop0,i++)-1;
	this._flag=this.intI(prop0,i++);
	this.roll=!ig_csom.isEmpty(prop0[i++]);
	this.css=this.intI(prop0,i++);
	this.repaint=function(){if(this.elem.value==this.text)return;this.elem.value=this.text;}
	if((e=document.getElementById(id+"_t"))==null)e=elem;
	this.elem=e;
	if(!igedit_all._end){igedit_all._end=true;this._lsnr(window,"unload");this._lsnr(e.form,"submit");}
	o=e.parentNode;ii=o.childNodes;n=ii.length-1;
	while(n-->0)if(ii[n]==e)break;
	n=(n<0)?null:ii[n+1];
	o.removeChild(e);
	this._lsnr(e,"keydown");this._lsnr(e,"keypress");this._lsnr(e,"keyup");
	this._lsnr(e,"focus");this._lsnr(e,"blur");
	this._lsnr(e,"mousedown");this._lsnr(e,"mouseup");
	this._lsnr(e,"mousemove");this._lsnr(e,"mouseover");this._lsnr(e,"mouseout");
	e._old=true;
	if(n)o.insertBefore(e,n);else o.appendChild(e);
	this.ID=id;
	if(id.indexOf("x_")==0)this.ID_=id.substring(1);
	e.setAttribute("editID",id);
	this.k0=this.sel0=this._wh=0;
	this.getEnabled=function(){return !this.elem.disabled;}
	this.setEnabled=function(v)
	{
		if(this.elem.disabled==!v)return;this.elem.disabled=!v;
		for(var i=0;i<3;i++)this.butState(i,v?0:3);
	}
	if(this.css>=0)
	{
		this.butP=-1;this.butL=1;
		this.buttons=new Array(3);
		for(j=0;j<3;j++)
		{
			if((e=document.getElementById(id+"_b"+j))==null)i+=4;
			else
			{
				o={elem:e,img:new Array(4)};
				this.initButElem(e,null,o);
				e.setAttribute("editID",id+","+j);
				for(ii=0;ii<4;ii++)o.img[ii]=this.valI(prop0,i++);
				o.state=this.getEnabled()?0:3;this.buttons[j]=o;
			}
		}
		ii=1;
		if((o=this.intI(prop0,i++))<0)ii=8;
		else{while(o++<3)ii/=2;while(o-->4)ii*=2;}
		this.spinSpeedUp=ii;
		this.spinOnReadOnly=!ig_csom.isEmpty(prop0[i++]);
		this.spinDelay=this.intI(prop0,i++);
		this.spinFocus=!ig_csom.isEmpty(prop0[i++]);
		this.ccss=new Array(4);
		for(ii=0;ii<4;ii++){o=this.valI(prop0,i++);if(ii>0)o=this.ccss[0]+((o.length>0)?(" "+o):"");this.ccss[ii]=o;}
		this._wh=this.intI(prop0,i++);
	}
	this.getVisible=function(){return this.Element.style.display!="none";}
	this.setVisible=function(v,x,y,w,h)
	{
		var d,h0=h,e0=this.Element,e1=this.elem,hd=this.hd;
		if(!v&&this.fcs>0)wxb(e1)  ;
		var s0=e0.style,s1=e1.style,td=e1.parentNode;
		s0.display=v?"":"none";
		s0.visibility=v?"visible":"hidden";
		if(!v)return;
		if(hd==null)
		{
			hd=e0.offsetHeight;d=e1.offsetHeight;
			if(hd==null||hd<5||d==null||d<5)hd=0;
			else if((hd-=d)<0)hd=0;
			if(hd>5)hd-=2;else if(hd>3)hd--;
			this.hd=hd;
			this._bw=(s1==s0)?0:(e0.offsetWidth-td.offsetWidth+1);
			if(this._bw<0)this._bw=0;
		}
		if(x!=null){s0.position="absolute";s0.left=x+"px";s0.top=y+"px";}
		if(w!=null){s0.width=w+"px";s1.width=(w-this._bw)+"px";}
		if(h!=null)
		{
			s0.height=h+"px";
			s1.height=(h-=hd)+"px";
			if(this.buttons!=null)
			{
				td.style.height="";
				d=this.buttons[0];x=this.buttons[1];y=this.buttons[2];
				if(d&&(d=d.elem)!=null)d.style.height=h+"px";
				if(x&&(x=x.elem)!=null)
				{
					try{h-=parseInt(e0.cellSpacing);}catch(ex){}
					y=y.elem;
					x.style.height=(d=Math.floor(h/2))+"px";
					y.style.height=d+"px";
					if(e0.offsetHeight>h0)
					{
						x.style.height=(d=Math.floor(--h/2))+"px";
						y.style.height=d+"px";
						if(td.offsetHeight>h+1)td.style.height=h+"px";
						if(e1.offsetHeight>h+1)s1.height=h+"px";
					}
				}
			}
		}
		if(v)wxXf(this)  ;
	}
	this.getReadOnly=function(){return this.elem.readOnly;}
	this.setReadOnly=function(v){this.elem.readOnly=v;}
	this.getText=function(){var v=this.elem.value;this.msV(v);return v;}
	this.setText=function(v){this.elemValue.value=this.elemViewState.value=this.text=v;this.repaint();if(this.fix==1)this.old=this.instant(true);}
	this.instant=function(){return this.getText();}
	this.getValue=function(){this._ok();return this.instant();}
	this.setValue=function(v){this.setText(""+((v==null)?"":v));}
	this.spinF=-1;
	this.spin_=function(v)
	{
		if(this.fireEvent(15,null,v))return;
		var t=this.elem.value;
		this.spin(v);
		if(this.elem.value==t&&this.roll&&this.min!=null&&this.max!=null)
		{
			v=this.sel0;
			this.setValue(this.limits(this.getValue(true),true));
			this.select(v);
		}
		if(this.elem.value!=t)this.fireEvent(12,null);
	}
	this.spin=function(v){}
	this.doKey=function(k,c,t,i,sel0,sel1)
	{
		if(sel0!=sel1){t=t.substring(0,sel0)+t.substring(sel1);sel1=sel0;i=t.length;}
		else if(k==7){if(sel1++>=i||i==0)return;}
		else if(k==8){if(sel0--<1)return;}
		if(k<9||this.maxLength==0||this.maxLength>i)
		{
			if(k>8&&sel1>=i)t+=c;
			else t=t.substring(0,sel0)+c+t.substring(sel1);
		}
		else k=0;
		this.elem.value=t;
		this.select((k>10)?sel1+1:sel0);
	}
	this.doKey0=function(e,a)
	{
		var t0=this.text,t1=this.elem.value,k=e.keyCode;
		if(a!=1)this._np=2-a;else if(this._np!=2)this._np=1;
		if(this.fcs!=2||(k==114&&a!=1)||k==9)return;
		if(k==0||k==null)if((k=e.which)==null)return;
		if(this.bad>2){if(a==0)this.bad=2;if(a==2)this.bad-=3;}
		if(a==0&&k==229)if(t0!=t1)this.bad=2;else this.bad+=3;
		if(this.bad==2)return;
		if(e.ctrlKey||e.altKey||k==17)
		{
			if(e.altKey)this.k0=-1;
			else if(t0!=t1)this.paste(t1);
			else if(k==17)this.getSelectedText();
			if(a==0&&(k==38||k==40))this.doBut(e,a,0);
			return;
		}
		if(a==0)this.k0=k;
		if(a==2){if(this.k0>0)this.k0=0;this.spinF=-1;}
		var i=t1.length,bad=this.bad!=0;
		if(k<=46)
		{
			switch(k)
			{
				case 8:case 46:
					if(this.k0==k&&a==1)a=2;
					if(a==0){a=1;if(k==46)k=7;}
					break;
				case 27:ig_cancelEvent(e);return;
				case 13:
					if(this.hideEnter)ig_cancelEvent(e);
					else if(a==0){this.valid(this.enter0());this.update();}
					if(this.postEnter&&a==0){ig_cancelEvent(e);try{window.wxXTimeout("try{igedit_all['"+this.ID+"'].doPost(2);}catch(e){}",0);}catch(ex){}}
					return;
				case 38:case 40:
					if(a==0&&this.spinOnArrows&&!e.shiftKey)this.spin_((k==38)?this.spinDelta:-this.spinDelta);
					if(this.k0==k)a=2;
					break;
			}
		}
		if(a==1&&k==this.k0&&((k<48&&k>9&&k!=32)||k>90))return;
		if(!bad)
		{
			if(a!=0&&k!=9)ig_cancelEvent(e);
			if(a==1&&this.k0==-1){this.k0=0;if((this._flag&1)!=0)this.getSelectedText();else return;}
			if(a==0||k<9)this.getSelectedText();
		}
		if(a==1&&k>6)
		{
			if(k>31)
			{
				if(this.fireEvent(1,e,k)){if(bad)ig_cancelEvent(e);return;}
				if((a=this.Event)!=null)if((a=a.keyCode)!=null)k=a;
			}
			this.doKey(k,(k<10)?"":String.fromCharCode(k),t1,i,this.sel0,this.sel1,bad);
		}
	}
	this.paste=function(v)
	{
		var m=this.maxLength;if(this._np==1)return;
		if(m>0&&m<v.length)v=v.substring(0,m);
		this.text="";this.fix=0;
		this.setText(v,this.sel0);
		this.fix=1;this.fireEvent(12,null);
	}
	this.spin0=function(b,o)
	{
		var z=0;
		if(o!=null){o.delay=o.spinDelay;ig_csom.edit_o=o;z++;o.spinF=-1;if(o.fcs<1&&o.spinFocus){o._fcs=1;wxXf(o)  ;}}
		else
		{
			if((o=ig_csom.edit_o)==null)return;
			b=o.buttons!=null&&o.buttons[1].state==2;
			if(o.spinSpeedUp>1){if(o.delay>o.spinDelay/o.spinSpeedUp)z=o.delay=Math.ceil(o.delay*6/7);}
			if(o.spinSpeedUp<1){if(o.delay<o.spinDelay/o.spinSpeedUp)z=o.delay=Math.ceil(o.delay*7/6);}
		}
		o.spin_(b?o.spinDelta:-o.spinDelta);
		if(z==0)return;
		if(ig_csom.edit_f!=null)window.clearInterval(ig_csom.edit_f);
		ig_csom.edit_f=window.wxXInterval(o.spin0,o.delay);
	}
	this.butState=function(b,s)
	{
		var e,i=-1,bb=this.buttons;
		if(bb!=null)bb=bb[b];
		if(bb==null||bb.state==s)return;
		while(i++<3)if(i!=b&&(e=this.buttons[i])!=null)if(e.state==1||e.state==2)
			this.butState(i,0);
		if(b>0&&(s==2||bb.state==2))
		{
			if(ig_csom.edit_f!=null){window.clearInterval(ig_csom.edit_f);ig_csom.edit_f=null;}
			if(s==2)this.spin0(b==1,this);
		}
		bb.state=s;
		if(this.css>=0)
		{
			if((i=s)>0)i=((this.css&(1<<(s-1)))==0)?0:s;
			if(bb.elem.className!=(e=this.ccss[s]))bb.elem.className=e;
		}
		if(ig_csom.isEmpty(i=bb.img[s]))if(ig_csom.isEmpty(i=bb.img[0]))return;
		e=bb.imgE;
		if(e&&e.src!=i)e.src=i;
		bb=bb.elem.childNodes;
		for(s=0;s<bb.length;s++)
			if((e=bb[s])!=null)if(e.nodeName=="TABLE")if(e.ig_clr!=i)this.initButElem(e,e.ig_clr=i);
	}
	this.doBut=function(e,a,but)
	{
		ig_cancelEvent(e);
		if(!this.getEnabled()||but>2)return;
		if(but==0)
		{
			if(a<=3)
			{
				if(this.fireEvent(14,e))return;
				if(this.Event.needPostBack||(this.postButton&&!this.Event.cancelPostBack)){this.doPost(1);return;}
				if(a<3)return;
			}
		}
		else if(this.getReadOnly()&&!this.spinOnReadOnly)return;
		if(a==4)this.butP=-1;
		else if(a!=3&&e.button!=0&&this.butP<0)return;
		var b=this.buttons[but].elem;
		if(a==7)
		{
			var z,x=0,y=0,w=b.offsetWidth,h=b.offsetHeight;
			if(w!=null)
			{
				while(b!=null){x+=b.offsetLeft;y+=b.offsetTop;b=b.offsetParent;}
				z=1;
				if(e.clientX>x+z&&e.clientY>y+z&&e.clientX+z<x+w&&e.clientY+z<y+h)return;
			}
			if(this.butP==0)this.butP=-1;
		}
		b=this.butP;
		if(a==3)
		{
			if(b>=0)this.butState(b,0);
			this.butP=-2;
			if(e.button<2){this.butP=but;this.butL=e.button;this.butState(but,2);}
			return;
		}
		if(e.button==0&&b<-1)b=this.butP=-1;
		if(b>=0&&a==5)if(e.button!=this.butL){b=this.butP=-1;this.butState(but,1);return;}
		if(b<-1||(b>=0&&b!=but))return;
		this.butState(but,(a==7)?0:((b>=0)?2:1));
	}
	this.enter0=function(){return this.elem.value;}
	this.update=function(post)
	{
		this.text=this.focusTxt(false,(this.fcs==2||this.hadFocus)?"":null);
		var v=this.instant(true);
		if(v!=null&&this.old!=null)if(v.getTime!=null&&v.getTime()==this.old.getTime())
			v=this.old;
		if(v!=this.old||this.bad==2)
		{
			if(this.fireEvent(11,null,this.old))
			{
				this.fix=0;this.setValue(this.old);this.fix=1;
				this.text=this.focusTxt(false,null);
			}
			else
			{
				if(ig_csom.notEmpty(this.clr1))this.elem.style.color=(v!=null&&v<0)?this.clr1:this.clr0;
				if(post&&(this.Event.id!=11||!this.Event.cancelPostBack))this.doPost(3);
				else if(this.k0!=13||this.postEnter||!this.postValue)this.old=v;
				this._dtt(true);
			}
		}
	}
	this._ok=function(){if(this._fcs==null&&this.elem.value!=this.text)this.setText(this.elem.value);}
	this.doEvt=function(e)
	{
		var v=this.elemID,type=this.eventID(e.type);
		if(this._fcs==null)
		{
			this._ok();
			try{if(this.elem.selectionStart!=null)this.tr=1;}catch(ex){}
			if(this.tr!=1)this.tr=(this.elem.createTextRange!=null)?this.elem.createTextRange():null;
			this.bad=(this.tr==null)?1:0;
		}
		this._fcs=0;
		if(type==5&&this.fcs==2&&e.button==1)this.getSelectedText();
		if(type!=1)if(this.fireEvent(type,e))if(type<8){ig_cancelEvent(e);return;}
		if(v>=0){this.doBut(e,type,v);return;}
		var val=this.elem.value;
		if(type<3)this.doKey0(e,type);
		if(type>=8)
		{
			if(this.bad>2)this.bad=2;
			this.spinF=-1;
			var foc=(type==8);
			if(foc==(this.fcs>0))return;
			v=(!this.getReadOnly()&& this.getEnabled())?2:1;
			this.fcs=foc?v:0;
			if(v==1)return;
			this.hadFocus=!foc;
			if(foc)
			{
				if(val!=this.text){this.getSelectedText();this.paste(val);}
				this.text=this.focusTxt(foc,e);
			}
			else{if(this.bad!=0)this.setText(val);this.update(this.postValue);}
			this.repaint();
			this.select(this.selectionOnFocus*10000);
			this.hadFocus=false;
			return;
		}
		if(val!=this.text&&!(this.webGrid&&type==5&&this.fcs==0))
		{
			if(type>3&&this.k0==0){this.paste(val);return;}
			this.text=val;this.fireEvent(12,e);
		}
	}
	this.fireEvent=function(id,evnt,arg)
	{
		if(id==12)
		{
			if(this.lastText==(arg=this.elem.value))return false;
			this.lastText=this.text=arg;
			if(this.fcs<2&&this._fcs!=1)this.update();
		}
		var evt=this.Event;
		if(evt==null)evt=this.Event=new ig_EventObject();
		evt.id=id;
		var i=evt.srcType=this.elemID;
		evt.srcElement=(i<0)?this.elem:this.buttons[i].elem;
		var evts=this.events[id];
		i=(evts==null)?0:evts.length;
		if(i==0)return false;
		var o,cancel=false,once=true;
		evt.keyCode=null;
		if(arg==null)
		{
			if(id<3){arg=evnt.keyCode;if(arg==0||arg==null)arg=evnt.which;}
			else arg=this.elem.value;
		}
		while(i-->0)
		{
			if((o=evts[i])==null)continue;
			if(once){evt.reset();evt.event=evnt;once=false;}
			if(o.s)ig_fireEvent(this,o.fRef);
			else o.fRef(this,arg,evt,o.o);
			if(evt.cancel)cancel=true;
		}
		if(evt.needPostBack&&id!=14)this.doPost(0);
		return cancel;
	}
	
	this.msV=function(v){this._vld=0;if(this.elemValue.value==v)return false;this.elemValue.value=v;return true;}
	this.valid=function(v)
	{
		if(this.msV(v))if(this.fcs>=0&&window.event)
			try{if(window.event.srcElement==this.elem){this.elem.Validators=this.elemValue.Validators;this.elemValue.onchange();}}catch(e){}
	}
	this.select=function(sel0,sel1)
	{
		if(this.fcs!=2||!this.getVisible())return;
		var e=this.elem;
		var i=e.value.length;
		if(sel1==null){sel1=sel0;if(sel0==null||sel0<0){sel0=0;sel1=i;}}
		if(sel1>=i)sel1=i;
		else if(sel1<sel0)sel1=sel0;
		if(sel0>sel1)sel0=sel1;
		this.sel0=sel0;this.sel1=sel1;
		if(this.tr==1){e.readOnly=true;e.selectionStart=sel0;e.selectionEnd=sel1;e.readOnly=false;return;}
		if(this.tr==null){if(sel0!=sel1)try{e.select();}catch(ex){}return;}
		sel1-=sel0;
		this.tr.move("textedit",-1);
		this.tr.move("character",sel0);
		if(sel1>0)this.tr.moveEnd("character",sel1);
		this.tr.select();
	}
	this.getSelectedText=function()
	{
		var r="";
		this.sel0=this.sel1=0;
		if(this.tr==null)return r;
		if(this.tr==1)
		{
			if((this.sel0=this.elem.selectionStart)<(this.sel1=this.elem.selectionEnd))
				r=this.elem.value.substring(this.sel0,this.sel1);
			return r;
		}
		var sel=document.selection.createRange();
		r=sel.duplicate();
		r.move("textedit",-1);
		try{while(r.compareEndPoints("StartToStart",sel)<0)
		{
			if(this.sel0++>1000)break;
			r.moveStart("character",1);
		}}catch(ex){}
		r=sel.text;
		this.sel1=this.sel0+r.length;
		return r;
	}
	this.getSelection=function(start){this.getSelectedText();return start?this.sel0:this.sel1;}
	this.doPost=function(type)
	{
		if(type!=0&&this.Event!=null&&this.Event.cancelPostBack)return;
		if(this.fcs==2)this.update();
		else if(this.fcs==0)try{if(document.activeElement!=null)document.activeElement.fireEvent("onblur");else wxb(window)  ;}catch(ex){}
		try{__doPostBack(this.uniqueId,type);}catch(ex){}
	}
	this.focus=function(){try{wxXf(this.elem)  ;}catch(e){}}
	this.hasFocus=function(){return this.fcs>0;}
	this.jpn=function(k){return(this.sTxt==1&&k>65295&&k<65306)?(k-65248):k;}
	this._dtt=function(foc)
	{
		var o=this.old,e=this.elem,t=this._dt;
		if(t)e.title=e.alt=t.replace('[value]',(!o||o=='')?this._null:(foc?this.focusTxt():this.elem.value));
	}
	this._onTimer=function()
	{
		var v=0,i=-1,w=-1,e=this.elem,bb=this.buttons;
		var p=e.parentNode;
		if(!p||!bb)return false;
		while(++i<3)
		{
			var im=null,b=bb[i];
			if(b)im=b.imgE;
			if(!im||b.ok)continue;
			if(im.complete||im.readyState=='complete'){im.onreadystatechange=im.onload=null;b.ok=true;continue;}
			im.onreadystatechange=igedit_event;
			im.onload=igedit_event;
			v++;
		}
		if(v>0)return false;
		if((v=p.offsetHeight)<3)
		{
			if(!this._timer&&typeof ig_handleTimer=='function'){this._timer=true;ig_handleTimer(this);}
			return false;
		}
		if((this._wh&4)!=0)if(v>e.offsetHeight){e.style.height=v+"px";w=-2;}
		if((this._wh&2)!=(v=0))while(v++<6&&e.offsetWidth-p.offsetWidth>w)p.style.paddingRight=v+"px";
		delete this._onTimer;
		if((this._wh&1)==0||(e=this.buttons[1])==null)return true;
		e=e.elem;
		while((e=e.parentNode)!=null)if(e.tagName=="TABLE"){if((v=e.parentNode.offsetHeight)>4)e.style.height=v+"px";break;}
		return true;
	}
	if(this._wh>0)this._onTimer();
	this.doResponse=function(vals,man)
	{
		var e,ei,div=document.createElement('DIV');
		div.style.display='none';
		man.setHtml(vals[1],div);
		var ch=div.childNodes;
		for(var i=0;i<ch.length;i++)
		{
			ei=ch[i];
			e=this.elemViewState;
			if(ei.id==e.id)e.value=ei.value;
			e=this.elemValue;
			if(ei.id==e.id)e.value=ei.value;
			e=this.Element;
			if(ei.id==e.id)
			{
				var pe=e.parentNode;
				pe.replaceChild(ei,e);
			}
		}
	}
}
function igedit_event(e)
{
	if(e==null)if((e=window.event)==null)return;
	var i,o=e.target,u=e.type=='unload',l=e.type=='readystatechange'||e.type=='load';
	if(e.type=='submit'||u||l)
	{
		for(i in igedit_all)if((o=igedit_all[i])!=null)
		{
			if(l){if(o._onTimer)o._onTimer();}
			else if(o.fcs==2)o.update();
			if(u)igedit_init(i,-1);
		}
		return;
	}
	if(!o)if((o=e.srcElement)==null)o=this;
	if((o=igedit_getById(null,o))!=null)if(o.doEvt!=null)o.doEvt(e);
}
    function ig_WebControl(id)
{
	if(arguments.length > 0){
		this.init(id);
	}
}
ig_WebControl.prototype.init=function(id)
{
	this._id=id;
	var o=ig_all[id];
	if(o && o._deleteMe)
		o._deleteMe();
	ig_all[id]=this;
	this._posted=this._postRequest=0;
	ig_shared._isPosted=false;
	this.postField = ig_csom.getElementById(this.getClientID() + "_Data");	
	this.clientState = ig_ClientState.createRootNode();	
	this.rootNode = ig_ClientState.addNode(this.clientState, "XMLRootNode");
}
ig_WebControl.prototype.constructor=ig_WebControl;
ig_WebControl.prototype.getElement=function(){return this._element;}
ig_WebControl.prototype.getID=function(){return this._id;}
ig_WebControl.prototype.getUniqueID=function(){return this._uniqueID;}
ig_WebControl.prototype.getClientID=function(){return this._clientID;}
ig_WebControl.prototype.updateControlState = function(propName, propValue) {
	if(this.controlState == null)
		this.controlState = ig_ClientState.addNode(this.rootNode, "ControlState");
	ig_ClientState.setPropertyValue(this.controlState, propName, propValue);
	if(this.postField != null)
		this.postField.value = ig_ClientState.getText(this.clientState);	
}
ig_WebControl.prototype.addStateItem  = function(name, value) {
	if(this.stateItems == null)
		this.stateItems = ig_ClientState.addNode(this.rootNode, "StateItems");
	var stateItem = ig_ClientState.addNode(this.stateItems, "StateItem");
	this.updateStateItem(stateItem, name, value);
	return stateItem;
}
ig_WebControl.prototype.updateStateItem = function(stateItem, propName, propValue) {
	ig_ClientState.setPropertyValue(stateItem, propName, propValue);
	if(this.postField != null)
		this.postField.value = ig_ClientState.getText(this.clientState);	
}
ig_WebControl.prototype.fireServerEvent = function(eventName, data)
{
	if(ig_shared._isPosted)
		return;
	if(this._postRequest == -1)
	{
		this._postRequest = 0;
		return;
	}
	this._postRequest = 0;
	try
	{
		ig_shared._isPosted = true;
		__doPostBack(this._uniqueID, eventName + ":" + data);
	}
	catch(e){}
}
ig_WebControl.prototype.removeEventListener = function(name, handler)
{
	var i, evts = this._clientEvents ? this._clientEvents[name] : null;
	if(evts != null) for(i = 0; i < evts.length; i++)
		if(evts[i] != null && evts[i]._handler == handler)
	{
		delete evts[i];
		evts[i] = null;
		return;
	}
}
ig_WebControl.prototype.addEventListener = function(name, handler, obj, post)
{
	if(typeof handler != "function")
		return;
	if(!this._clientEvents) this._clientEvents = new Object();
	var i, evts = this._clientEvents[name];
	if(evts == null)
		evts = this._clientEvents[name] = new Array();
	var i0 = evts.length;
	for(i = 0; i < evts.length; i++)
	{
		if(evts[i] == null)
			i0 = i;
		else if(evts[i]._handler == handler)
			return;
	}
	var evt = new ig_EventObject();
	evt._object = obj;
	evts[i0] = {_webcontrol:this, _eventName:name, _handler:handler, _autoPostBack:(post==true), _event:evt};
}
ig_WebControl.prototype.fireEvent = function(name, evnt)
{
	if(!name || this._isInitializing || !this._clientEvents)
		return false;
	this._postRequest = 0;
	var evt, evts = this._clientEvents[name];
	var cancel = false, post = 0, i = (evts == null) ? 0 : evts.length;
	if(i == 0)
		return false;
	if(evnt == "check")
		return true;
	var args = this.fireEvent.arguments;
	while(i-- > 0)
	{
		if(evts[i] == null)
			continue;
		evt = evts[i]._event;
		evt.reset();
		evt.event=evnt;
		evt.needPostBack=evts[i]._autoPostBack;
		try
		{
			evts[i]._handler(this, evt, args[2], args[3], args[4], args[5], args[6], args[7]);
		}catch(ex){continue;}
		if(evt.cancelPostBack)
			post = -1;
		else if(post == 0 && evt.needPostBack)
			post = 1;
		if(evt.cancel)
			cancel = true;
		evt.event = null;
	}
	if(!cancel || post < 0)
		this._postRequest = post;
	return cancel;
}
ig_WebControl.prototype._decodeProps	= function(props)
{
	for(var i = 0; i < props.length; i++)
	{
		if(props[i] != null)
		{
			if(props[i].push != null)
				this._decodeProps(props[i]);
			if(typeof props[i]=="string")
			{
					props[i] = decodeURI(props[i]);
					props[i] = unescape(props[i]).replace(/\+/g," ");
					props[i] = unescape(props[i]);
			} 
		}
	}
}
ig_WebControl.prototype._initControlProps	= function(props)
{	
	this._decodeProps(props);
	this._props = props[0];
	this._uniqueID	= this._props[0];
	this._clientID = this._props[1];
	var i = props[1] ? props[1].length : 0;
	while(i-- > 0) try
	{
		this.addEventListener(props[1][i][0], eval(props[1][i][1]), null, props[1][i][2]);
	}catch(e)
	{AdMchaaaaaaaaa= "Can't find " + props[1][i][1];}
	this._objects = props[2];
	this._collections = props[3];
}	
function ig_initShared()
{
	this.ScriptVersion="5.3.20053.14";
	try{this.AgentName=navigator.userAgent.toLowerCase();}catch(e){this.AgentName="";}
	this.MajorVersionNumber =parseInt(navigator.appVersion);
	this.IsDom=document.getElementById?true:false;
	this.IsNetscape62=this.AgentName.indexOf("netscape6")>=0;
	var i=this.AgentName.indexOf("netscape/7.");
	this.Netscape7=(i>0)?this.AgentName.charCodeAt(i+11)-48:-1;
	this.IsNetscape=document.layers!=null;
	this.IsNetscape6=(this.IsDom&&navigator.appName=="Netscape");
	this.IsSafari=this.AgentName.indexOf("safari")>=0;
	this.IsFireFox=this.AgentName.indexOf("firefox")>=0;
	this.IsFireFox10=this.AgentName.indexOf("firefox/1.0")>=0;
	this.IsFireFox20=this.AgentName.indexOf("firefox/2.0")>=0;
	this.IsFireFox15=this.IsFireFox20||this.AgentName.indexOf("firefox/1.5")>=0;
	this.IsOpera=this.AgentName.indexOf("opera")>=0;
	this.IsMac=this.AgentName.indexOf("mac")>=0;
	this.IsIE=document.all!=null&&!this.IsOpera&&!this.IsSafari;
	this.IsIE4=this.IsIE&&!this.IsDom;
	this.IsIE4Plus=this.IsIE&&this.MajorVersionNumber>=4;
	this.IsIE5=this.IsIE&&this.IsDom;
	this.IsIE50=this.IsIE5&&this.AgentName.indexOf("msie 5.0")>0;
	this.IsWin=this.AgentName.indexOf("win")>=0;
	this.IsIEWin=this.IsIE&&this.IsWin;
	this.IsIE55=this.IsIEWin&&this.AgentName.indexOf("msie 5.5")>0;
	this.IsIE6=this.IsIEWin&&this.AgentName.indexOf("msie 6.0")>0;
	this.IsIE7=this.IsIEWin&&this.AgentName.indexOf("msie 7.0")>0;
	this.IsIE55Plus = this.IsIE55 || this.IsIE6 || this.IsIE7;
	this.IsStandardsMode=(document.compatMode=="CSS1Compat");
	this.attrID = "ig_mark";
	this._isPosted = false;
	this.isFormPosted = function(){return this._isPosted;}
	this.getElementById = function (tagName)
	{
		if(this.IsIE)
			return document.all[tagName];
		else
			return document.getElementById(tagName);
	}
	this.isArray = function(a) {
		return a!=null && a.length!=null;
	}
	this.isEmpty = function(o) {
		return !(this.isArray(o) && o.length>0);
	}
	this.notEmpty = function(o) {
		return (this.isArray(o) && o.length>0);
	}
	this.addEventListener=function(elem,evtName,fn,flag)
	{ 
		try{if(elem.addEventListener){elem.addEventListener(evtName,fn,flag==true); return;}}catch(ex){}
		try{if(elem.attachEvent){elem.attachEvent("on"+evtName,fn); return;}}catch(ex){}
		eval("var old=elem.on"+evtName);
		var sF=fn.toString();
		var i=sF.indexOf("(")+1;
		try
		{
		if((typeof old =="function") && i>10)
		{
			old=old.toString();
			var args=old.substring(old.indexOf("(")+1,old.indexOf(")"));
			args=ig_shared.replace(args," ","");
			if(args.length>0) args=args.split(",");
			old=old.substring(old.indexOf("{")+1,old.lastIndexOf("}"));
			sF=sF.substring(9,i);
			if(old.indexOf(sF)>=0)return;
			var s="fn=new Function(";
			for(i=0;i<args.length;i++)
			{
				if(i>0)sF+=",";
				s+="\""+args[i]+"\",";
				sF+=args[i];
			}
			sF+=");"+old;
			eval(s+"sF)");
		}
		eval("elem.on"+evtName+"=fn");
		}catch(ex){}
	}
	this.removeEventListener = function(elem, evt, fn)
	{ 
		try
		{
			if(elem && elem.removeEventListener)
			{
				elem.removeEventListener(evt, fn);
				return;
			}
		}catch(ex){}
		try
		{
			if(elem && elem.detachEvent)
				elem.detachEvent('on' + evt, fn);
		}catch(ex){}
	}
	this.getSourceElement = function (evnt, o)
	{
		if(evnt.target) 
			return evnt.target;
		else 
		if(evnt.srcElement)
			return evnt.srcElement;
		else
			return o;
	}
	this.getText = function (e){
		if(e==null)return "";
		var i,v=null,ii=(e.childNodes==null)?0:e.childNodes.length;
		for(i=-1;i<ii;i++)
		{
			var ei=(i<0)?e:e.childNodes[i];
			if(ei.nodeName=="#text")v=(v==null)?ei.nodeValue:v+" "+ei.nodeValue;
		}
		if(v!=null)return v;
		if((v=e.text)!=null)return v;
		try{return e.innerText;}catch(ex){}
		try{return e.innerHTML;}catch(ex){}
		return "";
	}
	this.setText = function (e, text)
	{
		if(e==null)return false;
		if(text==null)text="";
		var i,ii=(e.childNodes==null)?0:e.childNodes.length;
		for(i=-1;i<ii;i++)
		{
			var ei=(i<0)?e:e.childNodes[i];
			if(ei.nodeName=="#text")
			{
				if(text!=null){ei.nodeValue=text; text=null;}
				else ei.nodeValue="";
			}
		}
		if(text!=null)try
		{
			if(e.text!=null)e.text=text;
			else if(e.innerText!=null)e.innerText=text;
			else e.innerHTML=text;
			text=null;
		}catch(ex){}
		return text==null;
	}
	this.setEnabled = function (e, bEnabled)
	{
		if(this.IsIE)
			e.disabled = !bEnabled;
	}
	this.getEnabled = function (e){
		if(this.IsIE)
			return !e.disabled;
	}
	this.navigateUrl =	function (targetUrl, targetFrame)
	{
		if(targetUrl == null || targetUrl.length == 0)
			return;
		var newUrl=targetUrl.toLowerCase();
		if(newUrl.indexOf("javascript:") == 0)
			eval(targetUrl);
		else 
		if(targetFrame != null && targetFrame!="")	{
			if(ig_shared.getElementById(targetFrame) != null) 
				ig_shared.getElementById(targetFrame).src = targetUrl;
			else {
				var oFrame = ig_searchFrames(top, targetFrame);
				if(oFrame != null)
					oFrame.location=targetUrl;
				else 
				if(targetFrame == "_self" 
					|| targetFrame == "_parent"
					|| targetFrame == "_media"
					|| targetFrame == "_top"
					|| targetFrame == "_blank"
					|| targetFrame == "_search")
					window.wxXy(targetUrl, targetFrame);
				else
					window.wxXy(targetUrl);
			}
		}
		else {
			try {
				location.href = targetUrl;
			}
			catch (x) {
			}
		}
	}
	function ig_searchFrames(frame, targetFrame) {
		if(frame.frames[targetFrame] != null)
			return frame.frames[targetFrame];
		var i;
		for(i=0; i<frame.frames.length; i++) {
			var subFrame = ig_searchFrames(frame.frames[i], targetFrame);
			if(subFrame != null)
				return subFrame; 
		}
		return null;
	}
	this.findControl=function(startElement,idList,closestMatch){
		var item;
		var searchString="";
		var i=0;
		var partialId=idList.split(":");
		while(partialId[i+1]!=null&&partialId[i+1].length>0){
			searchString+=partialId[i]+".*";
			i++;
		}
		searchString+=partialId[i]+"$";
		var searchExp=new RegExp(searchString);
		var curElement;
		if(startElement != null)
			curElement=startElement.firstChild;
		else
			curElement = window.document.firstChild;
		while(curElement!=null){
			if(curElement.id!=null&&(curElement.id.search(searchExp))!=-1){
				ig_dispose(searchExp);
				return curElement;
			}
			item=this.findControl(curElement,idList);
			if(item!=null){
				ig_dispose(searchExp);
				return item;
			}
			curElement=curElement.nextSibling;		
		}
		ig_dispose(searchExp);
		if(closestMatch)
			return findClosestMatch(startElement,partialId);
		else return null;
	}
	this.createTransparentPanel=function (){
		if(!this.IsIE)return null;
		var transLayer=document.createElement("IFRAME");
		transLayer.style.zIndex=1000;
		transLayer.frameBorder="no";
		transLayer.scrolling="no";
		transLayer.style.filter="progid:DXImageTransform.Microsoft.Alpha(Opacity=0);";
		transLayer.style.visibility='hidden';
		transLayer.style.display='none';
		transLayer.style.position="absolute";
		transLayer.src='javascript:new String("<html></html>")';
		var e = document.body.firstChild;
		document.body.insertBefore(transLayer, e);
		return new ig_TransparentPanel(transLayer);
	}
	this.isInside=function(evt,container,elem,shift)
	{
		var to=evt.toElement;
		if(to==null)to=evt.relatedTarget;
		if(to!=null && shift!=-1)
		{
			while(to!=null)
			{
				if(to==container)return true;
				to=to.parentNode;
			}
			return false;
		}
		if(elem==null)elem=container; if(shift==null)shift=0;
		var z,x=-evt.clientX,y=-evt.clientY;
		var w=elem.offsetWidth,h=elem.offsetHeight;
		while(elem!=null)
		{
			if((z=elem.offsetLeft)!=null){x+=z; y+=elem.offsetTop;}
			elem=elem.offsetParent;
		}
		return x<-1 && y<-1 && 1<x+w && 2+shift<y+h;
	}
	this.createHoverBehavior= function(objectToCallBackWith,element,mouseOverHandler,mouseOutHandler){
		element.__callBackObject=objectToCallBackWith;
		element.__isEventReady=true;
		objectToCallBackWith.__onFilteredMouseOver=mouseOverHandler;
		objectToCallBackWith.__onFilteredMouseOut=mouseOutHandler;
		this.addEventListener(element,"mouseover",ig_filterMouseOverEvents,false);
		this.addEventListener(element,"mouseout",ig_filterMouseOutEvents,false);
	}
	this.getCBManager = function(form)
	{
		if(!ig_all._ig_cbManager)
			ig_all._ig_cbManager = new ig_callBackManager(form);
		return ig_all._ig_cbManager;
	}
    this.addCBEventListener = function(evalCtl, elemID)
	{
		if(!this._cbListeners)
			this._cbListeners = new Array();
		var i = -1;
		while(++i < this._cbListeners.length)
			if(this._cbListeners[i].evalCtl == evalCtl)
				return;
		this._cbListeners[i] = {evalCtl:evalCtl, elemID:elemID};
	}
	this.addCBSubmitListener = function(fn)
	{
		this.addCBEventListener(fn);
	}
    this.getForm = function()
	{
		var form = document.forms[0];
		if(!form && (form = document.form1) == null)
		{
			var i = -1, eds = document.getElementsByTagName('INPUT');
			while(!form && ++i < eds.length)
				form = eds[i].form;
		}
		return form;
	}
	this.getElement = function(id, form)
	{
		var e = document.getElementById(id);
		if(e)
			return e;
		if(!form)
			form = this.getForm();
		return form ? form[id] : null;
	}
    this.absPosition = function(elem, pan, pos, ie, ed)
	{
		var z, htm = null, e = elem, body = document.body;
		var i = 1, ok = 0, y = 0, x = 0, pe = e;
		var elemH = e ? e.offsetHeight : -1, elemW = e ? e.offsetWidth : 0;
		while(e != null)
		{
			if(ok < 1 || e == body)
			{
				if((z = e.offsetLeft) != null)
					x += z;
				if((z = e.offsetTop) != null)
					y += z;
			}
			if(e.nodeName == "HTML")
				htm = body = e;
			if(e == body)
				break;
			z = e.scrollLeft;
			if(z == null || z == 0)
				z = pe.scrollLeft;
			if(z != null && z > 0)
				x -= z;
			z = e.scrollTop;
			if(z == null || z == 0)
				z = pe.scrollTop;
			if(z != null && z > 0)
				y -= z;
			pe = e.parentNode;
			e = e.offsetParent;
			if(pe.tagName == "TR")
				pe = e;
			if(e == body && pe.tagName == "DIV")
			{
				e = pe;
				ok++;
			}
		}
		if(elem && document.elementFromPoint)
		{
			var xOld = x, yOld = y;
			ok = true;
			var x0 = body.scrollLeft, y0 = body.scrollTop;
			while(++i < 16)
			{
				z = (i > 2) ? ((i & 2) - 1) * (i & 14) / 2 * 5 : 2;
				e = document.elementFromPoint(x + z - x0, y + z - y0);
				if(!e || e == ed || e == elem)
					break;
			}
			if(i > 15 || !e)
				ok = false;
			x += z;
			y += z;
			i = z = 0;
			while(ok && ++i < 22)
			{
				if(z == 0) x--;
				else y--;
				e = document.elementFromPoint(x - x0, y - y0);
				if(!e || i > 20)
					ok = false;
				if(e != ed && e != elem)
					if(z > 0)
						break;
					else
					{
						i = z = 1;
						x++;
					}
			}
			if(ok)
			{
				x--;
				y--;
			}
			else
			{
				x = xOld;
				y = yOld;
			}
		}
		if(!pan)
			return {x:x, y:y};
		ok = pan.style;
		ok.position = 'absolute';
		ok.visibility = 'visible';
		ok.display = '';
		ok.zIndex = 11000;
		ed = ed ? 0 : 20;
		var panH = pan.offsetHeight, panW = pan.offsetWidth;
		var iH = body.clientHeight, iW = body.clientWidth, iL = body.scrollLeft, iT = body.scrollTop;
		if(!iH || iH < 50)
		{
			iH = body.offsetHeight - ed;
			iW = body.offsetWidth - ed;
		}
		z = body;
		while(!htm && (z = z.parentNode) != null)
			if(z.nodeName == 'HTML')
				htm = z;
		if(htm)
		{
			z = htm.clientHeight;
			i = htm.offsetHeight;
			if(z && z > 20 && !ig_shared.IsOpera)
			{
				iH = z;
				iW = htm.clientWidth;
				iL = htm.scrollLeft;
				iT = htm.scrollTop;
			}
		}
		if(elemH < 0)
		{
			x = ++iL;
			y = ++iT;
			elemH = --iH;
			elemW = --iW;
		}
		if(iH < 20)
			iH = 20;
		if(iW < 90)
			iW = 90;
		if(!pos)
			pos = 0;
		if(typeof pos == 'object')
		{
			if((z = pos.x) != null)
				x += z;
			if((z = pos.y) != null)
				y += z;
			pos = 0;
		}
		if((pos & 4) != 0)
			x += elemW;
		else if((pos & 3) == 3)
			x -= panW;
		else if((pos & 1) != 0)
			x += (elemW >> 1) - (panW >> 1);
		else if((pos & 2) != 0)
			x += elemW - panW;
		if((pos & 8) != 0)
			y += (elemH >> 1) - (panH >> 1);
		else if((pos & 16) != 0)
			y += elemH - panH;
		else if((pos & 32) != 0)
			y -= panH;
		else if((pos & 64) != 0)
			y += elemH;
		if(y + panH > iH + iT)
		{
			if((pos & 64) != 0 && y - iT - 3 > panH + elemH)
				y -= panH + elemH;
			else
				y = iH + iT - panH;
		}
		if(y < iT)
			y = iT;
		if(x + panW > iW + iL)
		{
			if((pos & 4) != 0 && x - iL - 3 > panW + elemW)
				x -= panW + elemW;
			else
				x = iW + iL - panW;
		}
		if(x < iL)
			x = iL;
		if(ig_csom.IsMac && (ig_csom.IsIE || ig_csom.IsSafari))
		{
			x += ig_csom.IsIE ? 5 : -5;
			y += ig_csom.IsIE ? 11 : -7;
		}
		ok.left = x + 'px';
		ok.top = y + 'px';
		if(ie && (z = ie.Element) != null)
			ie = z;
		if(!ie || (z = ie.style) == null)
			return;
		z.position = 'absolute';
		z.left = --x + 'px';
		z.top = --y + 'px';
		z.width = (panW + 2) + 'px';
		z.height = (panH + 2) + 'px';
		z.visibility = 'visible';
		z.display = '';
		z.zIndex = 10999;
	}
	this.isName = function(n)
	{
		return n && n.indexOf('=') < 0 && n.indexOf(':') < 0 && n.indexOf('(') < 0 && n.indexOf(';') < 0 && n.indexOf(',') < 0 && n.indexOf('[') < 0 && n.indexOf('{') < 0 && n.indexOf('\"') < 0 && n.indexOf("'") < 0;
	}
	this.replace = function(txt, s0, s1)
	{
		while(txt.indexOf(s0) >= 0)
			txt = txt.replace(s0, s1);
		return txt;
	}
}
function ig_delete(o){ig_dispose(o);}
function ig_filterMouseOverEvents(evt){
	var element=ig_shared.getSourceElement(evt);
	if(!element.__isEventReady){
		while(element!=null && !element.__isEventReady && element.tagName!="BODY")element=element.parentNode;
	}
	if(element.__isEventReady && (element._hasMouse||!ig_isMouseOverSourceAChild(evt,element))) 
	{
		element._hasMouse=true;
		element.__callBackObject.__onFilteredMouseOver(evt);
	}	
}
function ig_filterMouseOutEvents(evt){
	var element=ig_shared.getSourceElement(evt);
	if(!element.__isEventReady){
		while(element!=null && !element.__isEventReady && element.tagName!="BODY")element=element.parentNode;
	}
	if(element&&element.__isEventReady&&!ig_isMouseOutSourceAChild(evt,element)) 
	{
		element._hasMouse=false;
		element.__callBackObject.__onFilteredMouseOut(evt);
	}	
}
function ig_isMouseOverSourceAChild(evt,element){
	var evnt=evt?evt:window.event;
	if(evnt==null)return false;
	var from=evnt.fromElement&&typeof evnt.fromElement!="undefined"?evnt.fromElement:evnt.relatedTarget;
	if(from==element)return true;
	if(from==null)return false;
	return ig_isAChildOfB(from,element);
}
function ig_isMouseOutSourceAChild(evt,element){
	var evnt=window.event?window.event:evt;
	if(!evnt)return false;
	var to=evnt.toElement&&typeof evnt.toElement!="undefined"?evnt.toElement:evnt.relatedTarget;
	if(to==element)return true;
	if(to==null)return false;
	return ig_isAChildOfB(to,element);	
}
function ig_isAChildOfB(a,b){
	if(a==null||b==null)return false;
	while(a!=null){
		a=a.parentNode;
		if(a==b)return true;
	}
	return false;
}
function ig_getWebControlById(id)
{
	var i,o=null;
	if(!ig_shared.isEmpty(id))if((o=ig_all[id])==null)for(i in ig_all)
	{
		if((o=ig_all[i])!=null)if(o._id==id || o._clientID==id || o._uniqueID==id)
			return o;
		o=null;
	}
	return o;
}
if(typeof ig_all !="object")
	var ig_all=new Object();
function ig_cancelEvent(e, type)
{
	if(e == null) if((e = window.event) == null) return;
	if(type && e.type != type) return;
	if(e.stopPropagation != null) e.stopPropagation();
	if(e.preventDefault != null) e.preventDefault();
	e.cancelBubble = true;
	e.returnValue = false;
}
function ig_TransparentPanel(transLayer){
	this.Element=transLayer;
	this.show=function(){
		this.Element.style.visibility="visible";
		this.Element.style.display="";
	}
	this.hide=function(){
		this.Element.style.visibility="hidden";
		this.Element.style.display="none";
	}
	this.setPosition=function(top,left,width,height){
		this.Element.style.top=top;
		this.Element.style.left=left;
		this.Element.style.width=width;
		this.Element.style.height=height;
	}
}
if(typeof ig_shared !="object")
	var ig_shared=new ig_initShared();
var ig_csom=ig_shared,ig=ig_shared;
if ((typeof Function != 'undefined')&&
    (typeof Function.prototype != 'undefined')&&
    (typeof Function.apply != 'function')) {
    Function.prototype.apply = function(obj, args){
        var result, fn = 'ig_apply'
        while(typeof obj[fn] != 'undefined') fn += fn;
        obj[fn] = this;
        var length=(((ig_shared.isArray(args))&&(typeof args == 'object'))?args.length:0);
		switch(length){
		case 0:
			result = obj[fn]();
			break;
		default:
			for(var item=0, params=''; item<args.length;item++){
			if(item!=0) params += ',';
			params += 'args[' + item +']';
			}
			result = eval('obj.'+fn+'('+params+');');
			break;
		}
        ig_dispose(obj[fn]);
        return result;
    };
}
function findClosestMatch(startElement,partialId){
	var item;
	var searchString="";
	var i=0;
	while(partialId[i+1]!=null&&partialId[i+1].length>0){
		searchString+="("+partialId[i]+")?";
		i++;
	}
	searchString+=partialId[i]+"$";
	var searchExp=new RegExp(searchString);
	var curElement=startElement.firstChild;
	while(curElement!=null){
		if(curElement.id!=null&&(curElement.id.search(searchExp))!=-1){
			return curElement;
		}
		item=findClosestMatch(curElement,partialId);
		if(item!=null)return item;
		curElement=curElement.nextSibling;		
	}
	return null;
}
function ig_EventObject(){
	this.event=null;
	this.cancel=false;
	this.cancelPostBack=false;
	this.needPostBack=false;
	this.reset=function()
	{
		this.event=null;
		this.needPostBack=false;
		this.cancel=false;
		this.cancelPostBack=false;
	}
}
function ig_fireEvent(oControl,eventName)
{
	var i, fn = eventName;
	if(!fn || !oControl) return false;
	if(ig_shared.isName(fn))
	{
		fn += "(oControl";
		for(i = 2; i < ig_fireEvent.arguments.length; i++)
			fn += ", ig_fireEvent.arguments[" + i + "]";
		fn += ");";
	}
	try{eval(fn);}
	catch(i){AdMchaaaaaaaaa= "Can't eval " + fn; return false;}
	return true;
}
function ig_dispose(obj)
{
	if(ig_shared.IsIE&&ig_shared.IsWin)	
		for(var item in obj)
		{
			var t = typeof obj[item];
			if(obj[item] && t != 'undefined' && !obj[item].tagName && !obj[item].disposing && t != 'boolean' && t != 'number' && t != 'string' && t != 'function')
			{
				try {
					obj[item].disposing=true;
					ig_dispose(obj[item]);
				} catch(e1) {;}
			}
			try{delete obj[item];}catch(e2){;}
		}
}
function ig_initClientState(){
	this.XmlDoc=document;
	this.createRootNode=function(){
		if(!ig_shared.IsIE){
			var str ='<?xml version="1.0"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><ClientState id="vs"></ClientState></html>';
			var p = new DOMParser();
			var doc = p.parseFromString(str,"text/xml");
			this.XmlDoc=doc;
			return doc.getElementById("vs");
		}
		if(ig_shared.IsIE50)this.XmlDoc=ig_createActiveXFromProgIDs(["MSXML2.DOMDocument","Microsoft.XMLDOM"]);
		return this.createNode("ClientState");
	}
	this.setPropertyValue=function(element,name,value){
		if(element!=null)element.setAttribute(name,escape(value));
	}
	this.getPropertyValue=function(element,name){
		if(element==null)return "";
		return unescape(element.getAttribute(name));
	}
	this.addNode=function(element,nodeName){
		var newNode=this.createNode(nodeName);
		if(element!=null)element.appendChild(newNode);
		return newNode;
	}
	this.removeNode=function(element,nodeName){
		var nodeToRemove=this.findNode(element,nodeName);
		if(element!=null)
			return element.removeChild(nodeToRemove);
		return null;
	}
	this.createNode=function(nodeName){
		return this.XmlDoc.createElement(nodeName);
	}
	this.findNode=function(element,node){
		if(element==null)return null;
		var curElement=element.firstChild;
		while(curElement!=null){
			if(curElement.nodeName==node || curElement==node){
				return curElement;
			}
			var item=this.findNode(curElement,node);
			if(item!=null)return item;
			curElement=curElement.nextSibling;		
		}
		return null;
	}
	this.getText=function(element){
		if(element==null)return "";
		if(ig_shared.IsIE55Plus)return escape(element.innerHTML);
		return escape(this.XmlToString(element));
	}
	this.XmlToString=function(startElem){
		var str="";
		if(!startElem)return "";
		var curElement=startElem.firstChild;
		while(curElement!=null){
			str+="<"+curElement.tagName+" ";
			for(var i=0; i<curElement.attributes.length;i++)
			{
				var attrib=curElement.attributes[i];
				str+=attrib.nodeName+"=\""+attrib.nodeValue+"\" ";
			}
			str+=">";
			str+=this.XmlToString(curElement);
			str+="</"+curElement.tagName+">";
			curElement=curElement.nextSibling;		
		}
		return str;
	}
}
function ig_xmlNode(name)
{
	this.lastChild = null;
	this.name = name;	
	this.getText = function(){return escape(this.toString());}
	this.childNodes = new Array();
	this.toString = function()
	{
		var i, s = (this.name == null) ? "" : "<" + this.name;
		if(this.props != null) for(i = 0; i < this.props.length; i++)
			s += " " + this.props[i].name + "=\"" + this.props[i].value + "\"";
		if(this.name != null) s += ">";
		for(i = 0; i < this.childNodes.length; i++)
			s += this.childNodes[i].toString();
		if(this.name != null) s += "</" + this.name + ">";
		return s;
	}
	this.addNode = function(node, unique)
	{
		if(node == null) return null;
		if(unique == true) if((unique = this.findNode(node)) != null) return unique;		
		if(node.name == null) node = new ig_xmlNode(node);
		node.parentNode = this;
		this.lastChild = node;
		return this.childNodes[this.childNodes.length] = node;
	}
	this.appendChild = this.addNode;
	this.setAttribute = function(name, value)
	{
		if(name == null) return;
		if(this.props == null) this.props = new Array();
		var prop, i = this.props.length;
		value = (value == null) ? "" : value;
		while(i-- > 0)
		{
			prop = this.props[i];
			if(prop.name == name){prop.value = value; return;}
		}
		prop = new Object();
		prop.name = name;
		prop.value = value;
		this.props[this.props.length] = prop;
	}
	this.setPropertyValue = function(name, value){this.setAttribute(name, (value == null) ? value : escape(value));}
	this.findNode = function(node, descendants)
	{
		if(node != null) for(var i = 0; i < this.childNodes.length; i++)
		{
			var n = this.childNodes[i];
			if(n != null)
			{
				if(n.name == node || n == node)
				{
					n.index = i;
					return n;
				}
				if(descendants == true && (n = n.findNode(node)) != null) return n;
			}
		}
		return null;
	}
	this.removeNode=function(n)
	{
		if((n=this.findNode(n))==null)return n;
		var i=-1,j=0,a=new Array(),a0=n.parentNode.childNodes;
		while(++i<a0.length)if(i!=n.index)a[j++]=a0[i];
		n.parentNode.childNodes=a;
		this.lastChild = a.length <= 0 ? null : a[a.length-1] ;
		return n;
	}
	this.getPropertyValue = function(name)
	{
		var i = (this.props == null) ? 0 : this.props.length;
		while(i-- > 0)
			if(this.props[i].name == name)
				return unescape(this.props[i].value);
		return null;
	}
}
function ig_xmlNodeStatic()
{
	this.createRootNode = function(){return new ig_xmlNode("Temp");}
	this.addNode = function(e, n){return (e == null) ? (new ig_xmlNode(n)) : e.addNode(n);}
	this.removeNode = function(e, n){return (e == null) ? e : e.removeNode(n);}
	this.findNode = function(e, n){return (e == null) ? e : e.findNode(n);}
	this.setPropertyValue = function(e, n, v){if(e != null)e.setPropertyValue(n, v);}
	this.getPropertyValue = function(e, n){return (e == null) ? "" : e.getPropertyValue(n);}
	this.getText = function(e)
	{
		var s = "", i = (e == null) ? 0 : e.childNodes.length;
		for(var j = 0; j < i; j++) s += e.childNodes[j].getText();
		return s;
	}
}
try{ig_shared.addEventListener(window, "load", ig_handleEvent);}catch(ex){}
try{ig_shared.addEventListener(window, "unload", ig_handleEvent);}catch(ex){}
try{ig_shared.addEventListener(window, "resize", ig_handleEvent);}catch(ex){}
function ig_findElemWithAttr(elem, attr)
{
	while(elem != null)
	{
		try
		{
			if(elem.getAttribute != null && !ig_shared.isEmpty(elem.getAttribute(attr)))
				return elem;
		}catch(ex){}
		elem = elem.parentNode;
	}
	return null;
}
function ig_handleEvent(evt)
{
	if(evt == null) if((evt = window.event) == null) return;
	var obj, attr = ig_shared.attrID, src = evt.target, type = evt.type;
	if(ig_shared.isEmpty(type)) return;
	var fn = "obj._on" + type.substring(0, 1).toUpperCase() + type.substring(1);
	if(!src)
		src = evt.srcElement;
	if(type == "load" || type == "unload" || type == "resize" || !src)
	{
		for(obj in ig_all)
		{
			if((obj = ig_all[obj]) == null)
				continue;
			eval("if(" + fn + "!=null){" + fn + "(src,evt); obj=null;}");
			if(obj && obj._onHandleEvent)
				obj._onHandleEvent(src, evt);
		}
		if(type == "unload")
		{
			ig_dispose(ig_all);
			for(var id in ig_all) if(ig_all[id])
				ig_all[id].base = null;
		}
		return;
	}
	var elem = ig_findElemWithAttr(src, attr);
	if(elem == null)
		elem = ig_findElemWithAttr(this, attr);
	if(elem != null && (obj = ig_getWebControlById(elem.getAttribute(attr))) != null)
	{
		eval("if(" + fn + "!=null){" + fn + "(src,evt); obj=null;}");
		if(obj != null && obj._onHandleEvent != null)
			obj._onHandleEvent(src, evt);
	}
}
function ig_handleTimer(obj)
{
	var i, all = ig_shared._timers, fn = ig_shared._timerFn;
	if(obj)
	{
		if(!obj._onTimer) return;
		if(!all) ig_shared._timers = all = new Array();
		i = all.length;
		while(i-- > 0) if(all[i] == obj) break;
		if(i < 0) all[all.length] = obj;
		if(!fn) ig_shared._timerFn = fn = window.wxXInterval(ig_handleTimer, 200);
		return;
	}
	if(!fn) return;
	for(i = 0; i < all.length; i++) if(all[i] && all[i]._onTimer) if(!all[i]._onTimer())
		obj = true;
	if(obj) return;
	window.clearInterval(fn);
	delete ig_shared._timerFn;
}
var ig_ClientState=null;
if(!ig_shared.IsIE55Plus||!ig_shared.IsWin) ig_ClientState = new ig_xmlNodeStatic();
else ig_ClientState=new ig_initClientState();
var _asyncSmartCallbacks = new Array();
var _inCallback = false;
function ig_SmartCallback(clientContext, serverContext, callbackFunction, uniqueId, control, waitResponse)
{
    var _callbackFunction;
    var _url = null;
    var _postdata = "";
    var _async = true;
    this._registeredControls = new Array();
    this._control = control;
    this._waitResponse=(waitResponse===true);
    this._progressIndicator = null;
    this._registeredControls[0] = {clientContext:clientContext, serverContext:serverContext, callbackFunction:callbackFunction, uniqueId:uniqueId, control:control};
	if(typeof XMLHttpRequest != "undefined") {
	   __xmlHttpRequest = new XMLHttpRequest();
	}
	else if(typeof ActiveXObject != "undefined")
	{
	   try{
		    __xmlHttpRequest = ig_createActiveXFromProgIDs(["MSXML2.XMLHTTP","Microsoft.XMLHTTP"]);
	   }
	   catch(e)
	   {
	   }
	}
	this.registerControl = function(clientContext, serverContext, callbackFunction, uniqueId, control)
	{
		this._registeredControls.push({clientContext:clientContext, serverContext:serverContext, callbackFunction:callbackFunction, uniqueId:uniqueId, control:control});
	}
	this._xmlHttpRequest = __xmlHttpRequest;
    this.execute = function () 
    {
		var exec = true;
		if(this.beforeCallback != null)
				exec = this.beforeCallback();
		if(exec)
		{
			if(this._progressIndicator != null)
				this._progressIndicator.display();
			this.formatCallbackArguments();
		    this.registerSmartCallback();
		    this._xmlHttpRequest.open("POST", this.getUrl(), !this._waitResponse);
		    this._xmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		    this._xmlHttpRequest.onreadystatechange = this._responseComplete;
		    this._xmlHttpRequest.send(this.getCallbackArguments());
		 }
    }
    this.getCallbackArguments = function () {
        return this._callbackArguments;
    }
    this.setCallbackArguments = function (callbackArguments) {
        this._callbackArguments = callbackArguments;
    }
    this.getUrl = function () {
        if(this._url == null) {
            return this.getForm().action;
        }
        return this._url;
    }
    this.setUrl = function (url) {
        this._url = url;
    }
    this.getForm = function () 
    {
        var form;
        if(document.forms.length > 1)
        {
			for(var i = 0; i < document.forms.length; i++)
			{
				if(document.forms[i].method == "post" && document.forms[i].action != "")
				{
					form = document.forms[i];
					break;
				}
			}   
			if(form == null)
				 form = document.forms[0]; 
        }
		else
			form = document.forms[0];
        if (!form) 
            form = document.form1;
        return form;
    }
    this.setProgressIndicator = function(value)
    {
		this._progressIndicator = value; 
    }
    this._responseComplete = function () 
    {
		var proccessComplete = null;
        for (var i = 0; i < _asyncSmartCallbacks.length; i++) {
            smartCallback = _asyncSmartCallbacks[i];
            if (smartCallback && smartCallback._xmlHttpRequest && (smartCallback._xmlHttpRequest.readyState == 4)) 
            {
				_asyncSmartCallbacks[i] = null;
                smartCallback.processSmartCallback();
                proccessComplete = smartCallback;
            }
        }
        if(proccessComplete != null)
        {
            if(proccessComplete.callbackFinished != null)
				proccessComplete.callbackFinished();
			proccessComplete._control = null;
			proccessComplete._registeredControls = null;
			proccessComplete._progressIndicator = null; 
			ig_dispose(proccessComplete);
			proccessComplete = null;
        }
    }
    this.processSmartCallback = function () {
       var responseString = this._xmlHttpRequest.responseText;
       var startIndex = responseString.indexOf("_ig_start");
       var endIndex = responseString.indexOf("_ig_end");
       var length = endIndex;
       if(startIndex > -1 && endIndex > -1) {
            responseString = responseString.substring(startIndex + 9, length); 
            var response = eval(responseString);
            var index;
            for(index = 0; index < response.length; index++) 
            {
                controlResponse = response[index];
                var header = controlResponse[0];
                var payload = controlResponse[1].replace(/\ig_NL/g, "\n");
			
                for(var i = 0; i < this._registeredControls.length; i++)
                {
					if(this._registeredControls[i] != null && header == this._registeredControls[i].uniqueId)
					{
						if(payload.length > 0)
						{
							if(this._registeredControls[i].clientContext.requestType != null && this._registeredControls[i].clientContext.requestType == "styles")
								this._resolveStyles(payload);
							else if(this._registeredControls[i].callbackFunction != null)
								this._registeredControls[i].callbackFunction(payload, this._registeredControls[i].clientContext);
							else if(this._registeredControls[i].control.callbackRender != null)
								this._registeredControls[i].control.callbackRender(payload, this._registeredControls[i].clientContext);
						}
						this._registeredControls[i] = null;
						break;
					}
                }
            }
       }
       if(this._progressIndicator != null)
		this._progressIndicator.hide();
    }
    this._resolveStyles = function(response)
    {
		var json = eval(response.replace(/\^/g, "\""));
		var key = json[0];
		var styleBlock = eval(json[1]);
		if(styleBlock != null && styleBlock.length > 0)
		{
			var styles = document.getElementsByTagName("style");	
			for(var i = 0; i < styles.length; i++)
			{
				var rules;
				
				if(ig_shared.IsIE)
					rules = styles[i].styleSheet.rules
				else
					rules = styles[i].sheet.cssRules
					
				for(var j  = 0; j < rules.length; j++)
				{
					if(rules[j].selectorText.indexOf(key) > -1)
					{
						if(ig_shared.IsIE)
							styles[i].styleSheet.removeRule(j);
						else
							styles[i].sheet.deleteRule(j);
					}	
				}
				for(var j = 0; j < styleBlock.length; j++)
				{
					if(styleBlock[j] != null)
					{
						if(ig_shared.IsIE)
							styles[i].styleSheet.addRule(styleBlock[j][0], styleBlock[j][1], 0);
						else
							styles[i].sheet.insertRule(styleBlock[j][0] + "{" +  styleBlock[j][1] + "}", 0);
					}
				}
			}
		}
		return;	
    }
    this.registerSmartCallback = function () {
        var index;
        for(index = 0; index < _asyncSmartCallbacks.length; index++)
            if(!_asyncSmartCallbacks[index])
                break;
        _asyncSmartCallbacks[index] = this;
        return index;
    }
    this.formatCallbackArguments = function () {
        var form = this.getForm();
        if(!form) return;
        var count = form.elements.length;
        var element;
        for (var i = 0; i < count; i++) {
            element = form.elements[i];
            if (element.tagName.toLowerCase() == "input" && (element.type == "hidden" || element.type == 'password' || element.type == 'text' || ((element.type == "checkbox"|| element.type =='radio')&& element.checked))) 
               this.addCallbackField(element.name, element.value);
            else if(element.tagName.toLowerCase() == "textarea")
				this.addCallbackField(element.name, element.value);
			else if(element.tagName.toLowerCase() == "select")
			{
				var o = element.options.length;
				while(o-- > 0)
				{
					if(element.options[o].selected)
						this.addCallbackField(element.name, element.options[o].value);
				}
			}
        }   
        var args =  _postdata + "__EVENTTARGET=&__EVENTARGUMENT=&" + 
                            "__CALLBACKID=" + 
                           this._registeredControls[0].uniqueId +
                            //this.getServerId() +
                            "&__CALLBACKPARAM=";
        var xml = '&lt;SmartCallback&gt;';
        if(this._registeredControls!= null) {
			for(var i = 0; i < this._registeredControls.length; i++)
			{
				xml += "&lt;Control";
				var control = this._registeredControls[i];
				xml += " id='" + control.uniqueId + "'";
				for(property in control.serverContext)
				{
					if(control.serverContext[property] != null) {
						var value = control.serverContext[property].toString();
						while(value.indexOf("'") != -1) {
							value = value.replace("'", "^^");
						}
						xml += " " + property + "='" + escape(value) + "'";
					}
				}
				xml += "/&gt;"
			}
        }
        xml += "&lt;/SmartCallback&gt;";
        xml = escape(xml); 
        args += xml; 
        this.setCallbackArguments(args);
    }
    this.addCallbackField = function(name, value) {
        _postdata += name + "=" + this.encodeValue(value) + "&";
    }
    this.isAsynchronous = function () {
            return _async;
    }
    this.setAsynchronous = function (async) {
        _async = async;
    }
    this.encodeValue = function(uri) {
        if(encodeURIComponent != null) 
            return encodeURIComponent(uri);
        else
            return escape(parameter);
    }
}
ig_createCallback = function(method, context ) {
	return function() {
		method.apply(context, [null]);
	}
}
var ViewportOrientationEnum = new function() {
   this.Horizontal = 0;
   this.Vertical  = 1;
} 
var AnimationDirectionEnum = new function() {
   this.Up  = 1;
   this.Down  = 2; 
   this.Left = 3;
   this.Right = 4;
} 
var AnimationRateEnum = new function() {
   this.Static = 0;
   this.Accelerate  = 1;
   this.Decelerate  = 2; 
   this.AccelDecel = 3;
   this.Linear = 4;
}  
ig_viewport = function() {
	this.createViewport  = function(elem, orientation) {
		if(this.elem) 
			return;
		this.elem = elem;
		this.orientation = orientation;
		this.div = document.createElement("div");
		this.div.style.position = "relative";
		this.table = document.createElement("table");
		var tr = document.createElement("tr");
		var tbody = document.createElement("tbody");
		this.td1 = document.createElement("td");
		this.td2 = document.createElement("td");
		this.div.style.overflow = "hidden";
		this.div.style.width = elem.offsetWidth + "px"; 
		this.div.style.height = elem.offsetHeight + "px"; 
		this.table.cellSpacing = "0px"; 
		this.table.cellPadding = "0px";
		this.div.appendChild(this.table);								
		this.table.appendChild(tbody);
		tbody.appendChild(tr);
		tr.appendChild(this.td1);
		this.td1.style.verticalAlign = "top";
		this.td2.style.verticalAlign = "top";
		if(this.orientation == ViewportOrientationEnum.Horizontal) {
			tr.appendChild(this.td2);
		}
		else {
			tr = document.createElement("tr");
			tbody.appendChild(tr);
			tr.appendChild(this.td2);
		}
		elem.parentNode.insertBefore(this.div, elem);
		this.td1.appendChild(elem);
		this.animate = new ig_SlideAnimation();
	}
	this.transferPositionToDiv = function(elem, oldElem)
	{
		if(elem.style.position != "" && elem.style.position != "static")
		{
			this.div.style.position = elem.style.position;
			elem.style.position = "static";
			if(oldElem)
			    oldElem.style.position = "static";
		}
		this.div.style.top = elem.style.top;
		this.div.style.left = elem.style.left;
		elem.style.top = "";
		elem.style.left = "";
		if(oldElem) {
		    oldElem.style.top = "";
		    oldElem.style.left = "";
		}
	}
	this.scroll = function(eCurrent, eNew, direction, rate) {
		this.direction = direction;
		this.animate.setElement(this.table);
		this.animate.setContainer(this.div);
		this.animate.setDirection(direction);
		this.animate.setRate(rate);
		switch (this.direction) {
			case AnimationDirectionEnum.Down :
			case AnimationDirectionEnum.Right :
				if(this.td1.firstChild != null)
					this.td1.removeChild(this.td1.firstChild);
				this.td1.appendChild(eCurrent);
				if(this.td2.firstChild != null)
					this.td2.removeChild(this.td2.firstChild);
				this.td2.appendChild(eNew);
				this.animate.startPos = 0;
				this.animate.finishPos = this.td1.offsetWidth;
				break;
			case AnimationDirectionEnum.Up :
			case AnimationDirectionEnum.Left :
				if(this.td1.firstChild != null)
					this.td1.removeChild(this.td1.firstChild);
				this.td1.appendChild(eNew);
				if(this.td2.firstChild != null)
					this.td2.removeChild(this.td2.firstChild);
				this.td2.appendChild(eCurrent);
				this.div.scrollLeft = this.td1.offsetWidth;
				this.animate.startPos = this.div.scrollLeft;
				this.animate.finishPos = 0;
				break;
		}
		this.animate.play();		
	}
}
ig_WebAnimation = function() {
    this.timerInterval = 30;
    this.startPos = 0;
	var _inProgress;
	this.eContainer = null;
	this.duration = null; 
	this.cancel = false;
}   
ig_WebAnimation.prototype.getElement = function() {
        return this.element;
}
ig_WebAnimation.prototype.setElement = function(value) {
	this.element = value;
}
 ig_WebAnimation.prototype.getTimerInterval = function() {
	return timerInterval;
}
ig_WebAnimation.prototype.setTimerInterval = function(value) {
	timerInterval = value;
}
ig_WebAnimation.prototype.isInProgress = function() {
	return _inProgress;
}
ig_WebAnimation.prototype.cancelAnimation = function() {
    clearTimeout(this.timerId);
	this.cancel = true;
}
ig_WebAnimation.prototype.setContainer = function(container) {
	this.eContainer = container;
}
ig_WebAnimation.prototype.getContainer = function() {
	return this.eContainer;
}
ig_WebAnimation.prototype.onBegin = function() {
}
ig_WebAnimation.prototype.onNext = function() {
}
ig_WebAnimation.prototype.onEnd = function() {
}
ig_WebAnimation.prototype.play = function() {
	this.currentPos = this.startPos;
	this.cancel = false;
	this.begin();
	if(!this.cancel)
		this.timerId = wxXInterval(ig_createCallback(this.tickHandler, this, null), this.timerInterval);
}
ig_WebAnimation.prototype.tickHandler = function() {
   if(this.cancel || !this.next())
   {
      clearTimeout(this.timerId);
	  this.end();
   }
}
ig_WebAnimation.prototype.getDuration = function() {
	return this.duration; 
}
ig_WebAnimation.prototype.setDuration = function(value) {
	this.duration = value; 
}
ig_WebAnimation.prototype.calcDurationIncrement = function()
{
	return this.distance /(this.duration / this.timerInterval);
}
ig_WebAnimation.prototype.ensureContainer = function(e) {
	var parent = e.parentNode;
	if(parent.getAttribute("container") == '1')
		return;
	if(e.getAttribute("container") == '1')
		return;
	var eDiv = window.document.createElement("DIV");
	eDiv.setAttribute("container", '1');
	eDiv.cssText = 'overflow:hidden; position:absolute;z-index:12000;';
	parent.insertBefore(eDiv, e);
	parent.removeChild(e);
	eDiv.appendChild(e);
}
ig_WebAnimation.prototype.removeContainer = function() {
	var container = this._element;
	var child = container.firstChild;
	if(container.getAttribute("container") != '1'){
		container = container.parentNode;
		if(container.getAttribute("container") != '1')
			return;
	}
	var parent = container.parentNode;
	container.removeChild(child);
	parent.removeChild(container);
	delete container;
	parent.appendChild(child);
}
ig_SlideAnimation.prototype = new ig_WebAnimation();
function ig_SlideAnimation(direction, rate)
{
	this.init(direction, rate);
	return this;
}
ig_SlideAnimation.prototype.init = function(direction, rate) {
	if(direction)
		this.direction = direction;
	else
		this.direction = AnimationDirectionEnum.Right;
	if(rate)
		this.rate = rate;
	else	
		this.rate = AnimationRateEnum.Linear;
}
ig_SlideAnimation.prototype.getDirection = function() {
	return this.direction;
}
ig_SlideAnimation.prototype.setDirection = function(value) {
	this.direction = value;
}
ig_SlideAnimation.prototype.getRate = function() {
	return this.rate;
}
ig_SlideAnimation.prototype.setRate = function(value) {
	this.rate = value;
}
ig_SlideAnimation.prototype.begin = function() {
	switch (this.direction) {
		case AnimationDirectionEnum.Up :
		case AnimationDirectionEnum.Down :
			this.distance = Math.abs(this.finishPos - this.startPos);
			break;
		case AnimationDirectionEnum.Right :
		case AnimationDirectionEnum.Left :
			this.distance = Math.abs(this.finishPos - this.startPos);
			break;
	}
	switch(this.rate) {
		case AnimationRateEnum.Accelerate :
			this.increment = 1;
			break;
		case AnimationRateEnum.Decelerate :
			this.increment = .5 * Math.abs(this.distance);;
			break;
		case AnimationRateEnum.AccelDecel :
			this.midPoint = this.distance / 2;
			this.accel = true;
			this.increment = 1;
			break;
		case AnimationRateEnum.Linear :
			if(this.duration != null)
				this.increment = this.calcDurationIncrement();
			else
			{
				if(this.increment == null)
					this.increment = 30; 
				this._originalIncrement = this.increment; 
				this.increment = 1; 
				var totalCount = 0; 
				var temp = 1; 
				var distance = this.distance; 
				while(temp * 2 < this._originalIncrement)
				{
					temp *=2; 
					distance -= temp*2; 
					totalCount++;
				}
				this._acelCount = totalCount; 
				temp = this._originalIncrement; 
				totalCount *= 2; 
				totalCount += parseInt(distance / this._originalIncrement); 
				this._decelCount = totalCount - this._acelCount; 
				this._currentCount = 1; 
			}
			break;
	}
	this.onBegin();
}
ig_SlideAnimation.prototype.next = function() {
	switch (this.direction) {
		case AnimationDirectionEnum.Down :
		case AnimationDirectionEnum.Right :
			this.currentPos += this.increment;
			if(this.currentPos > this.finishPos)
				return false;
			if(this.direction == AnimationDirectionEnum.Right)
				this.getContainer().scrollLeft = this.currentPos;
			else
				this.getContainer().scrollTop = this.currentPos;
			break;
		case AnimationDirectionEnum.Up :
		case AnimationDirectionEnum.Left :
			this.currentPos -= this.increment;
			if(this.currentPos < this.finishPos)
				return false;
			if(this.direction == AnimationDirectionEnum.Left)
				this.getContainer().scrollLeft = this.currentPos;
			else
				this.getContainer().scrollTop = this.currentPos;
			break;
	}
	switch(this.rate) {
		case AnimationRateEnum.Accelerate :
			this.increment *= 2;
			break;
		case AnimationRateEnum.Decelerate :
			this.increment = Math.max(2, this.increment / 2);
			break;
		case AnimationRateEnum.AccelDecel :
			if(this.accel) {
				if(this.direction == AnimationDirectionEnum.Right || this.direction == AnimationDirectionEnum.Down) {
					if(this.currentPos + this.increment >= this.midPoint) {
						this.accel = false;
						this.increment = this.midPoint / 2;
					}
					else
						this.increment *= 2;
				}
				else {
					if(this.currentPos - this.increment <= this.midPoint) {
						this.accel = false;
						this.increment = this.midPoint / 2;
					}
					else
						this.increment *= 2;
				}
			}
			else {
				this.increment = Math.max(2, this.increment / 2);
			}
			break;			
		case AnimationRateEnum.Linear :
			if(this.duration == null)
			{
				if(this._currentCount <= this._acelCount)
					this.increment *=2; 
				else if(this._currentCount > this._decelCount)
				{
					this.increment = Math.pow(2,this._acelCount);
					if(this._acelCount > 3)
						this._acelCount--; 
				}
				else
					this.increment = this._originalIncrement; 
				this._currentCount++; 
			}
		break;
	}
	this.onNext();
	return true;
}
ig_SlideAnimation.prototype.end = function() {
	this.getContainer().scrollLeft = this.finishPos;
	if(this.rate == AnimationRateEnum.Linear && this.duration == null)
	{
		this._currentCount = 0; 
		this.increment = this._originalIncrement; 
	}
	this.onEnd();
}
ig_SlideRevealAnimation.prototype = new ig_SlideAnimation();
function ig_SlideRevealAnimation(direction, rate)
{
	this.init(direction, rate);
	return this;
}
ig_SlideRevealAnimation.prototype.begin = function() {
	this.eContainer.style.overflow = "hidden";
	this.element.style.position = "relative";
	this.distance = Math.abs(this.finishPos - this.startPos);
	this.currentPos = this.startPos; 
	switch (this.direction) {
		case AnimationDirectionEnum.Up :
			this.element.style.top  = this.currentPos.toString();
			break;
		case AnimationDirectionEnum.Down :
			this.element.style.display = "";
			this.element.style.top  = this.currentPos.toString();
			break;
		case AnimationDirectionEnum.Right :
			this.element.style.display = "";
			this.element.style.left = this.currentPos.toString();
			break;
		case AnimationDirectionEnum.Left :
			this.element.style.left = this.currentPos.toString();
			break;
	}
	switch(this.rate) {
		case AnimationRateEnum.Accelerate :
			this.increment = 1;
			break;
		case AnimationRateEnum.Decelerate :
			this.increment = .5 * Math.abs(this.distance);;
			break;
		case AnimationRateEnum.AccelDecel :
			this.midPoint = this.distance / 2;
			this.accel = true;
			this.increment = 1;
			break;
		case AnimationRateEnum.Linear :
			if(!this.increment)
				this.increment = 20;
			break;
	}
	this.onBegin();
}
ig_SlideRevealAnimation.prototype.next = function() {
	switch (this.direction) {
		case AnimationDirectionEnum.Down :
		case AnimationDirectionEnum.Right :
			this.currentPos += this.increment;
			if(this.currentPos > this.finishPos)
				return false;
			if(this.direction == AnimationDirectionEnum.Right)
				this.element.style.left = this.currentPos.toString();
			else
				this.element.style.top = this.currentPos.toString();
			break;
		case AnimationDirectionEnum.Up :
		case AnimationDirectionEnum.Left :
			this.currentPos -= this.increment;
			if(this.currentPos < this.finishPos)
				return false;
			if(this.direction == AnimationDirectionEnum.Left)
				this.element.style.left = this.currentPos.toString();
			else
				this.element.style.top = this.currentPos.toString();
			break;
	}
	switch(this.rate) {
		case AnimationRateEnum.Accelerate :
			this.increment *= 2;
			break;
		case AnimationRateEnum.Decelerate :
			this.increment = Math.max(2, this.increment / 2);
			break;
		case AnimationRateEnum.AccelDecel :
			if(this.accel) {
				if(this.direction == AnimationDirectionEnum.Right || this.direction == AnimationDirectionEnum.Down) {
					if(this.currentPos + this.increment >= this.midPoint) {
						this.accel = false;
						this.increment = this.midPoint / 2;
					}
					else
						this.increment *= 2;
				}
				else {
					if(this.currentPos - this.increment <= this.midPoint) {
						this.accel = false;
						this.increment = this.midPoint / 2;
					}
					else
						this.increment *= 2;
				}
			}
			else {
				this.increment = Math.max(2, this.increment / 2);
			}
			break;		
	}
	this.onNext();
	return true;
}
ig_SlideRevealAnimation.prototype.end = function() {
	if(this.cancel)
		return;
	if(this.direction == AnimationDirectionEnum.Left ||this.direction == AnimationDirectionEnum.Right)
		this.element.style.left = this.finishPos;
	else
		this.element.style.top = this.finishPos;
	this.onEnd();
}
ig_RevealAnimation.prototype = new ig_WebAnimation();
function ig_RevealAnimation(direction, rate)
{
	this.init(direction, rate);
	return this;
}
ig_RevealAnimation.prototype.init = function(direction, rate) {
	if(direction)
		this.direction = direction;
	else
		this.direction = AnimationDirectionEnum.Right;
	if(rate)
		this.rate = rate;
	else	
		this.rate = AnimationRateEnum.Linear;
}
ig_RevealAnimation.prototype.getDirection = function() {
	return this.direction;
}
ig_RevealAnimation.prototype.setDirection = function(value) {
	this.direction = value;
}
ig_RevealAnimation.prototype.getRate = function() {
	return this.rate;
}
ig_RevealAnimation.prototype.setRate = function(value) {
	this.rate = value;
}
ig_RevealAnimation.prototype.begin = function() {
    this.element.style.overflow = "hidden";
	this.distance = Math.abs(this.finishPos - this.startPos);
	switch (this.direction) {
		case AnimationDirectionEnum.Up :
			if(!this.startPos)
				this.startPos = this.element.scrollHeight;
			break;
		case AnimationDirectionEnum.Down :
			if(!this.startPos)
				this.startPos = 1;
			break;
	}
	switch(this.rate) {
		case AnimationRateEnum.Accelerate :
			this.increment = 1;
			break;
		case AnimationRateEnum.Decelerate :
			this.increment = .5 * Math.abs(this.distance);;
			break;
		case AnimationRateEnum.AccelDecel :
			this.midPoint = this.distance / 2;
			this.accel = true;
			this.increment = 1;
			break;
		case AnimationRateEnum.Linear :
			if(!this.increment)
				this.increment = 20;
			break;
	}
	this.onBegin();
	this.currentPos = this.startPos;
}
ig_RevealAnimation.prototype.next = function() {
	switch (this.direction) {
		case AnimationDirectionEnum.Down :
			this.currentPos += this.increment;
			if(this.currentPos > this.finishPos)
				return false;
			break;
		case AnimationDirectionEnum.Up :
			this.currentPos -= this.increment;
			if(this.currentPos < this.finishPos)
				return false;
			break;
	}
	this.element.style.height = this.currentPos;
	switch(this.rate) {
		case AnimationRateEnum.Accelerate :
			this.increment *= 2;
			break;
		case AnimationRateEnum.Decelerate :
			this.increment = Math.max(2, this.increment / 2);
			break;
		case AnimationRateEnum.AccelDecel :
			if(this.accel) {
				if(this.direction == AnimationDirectionEnum.Right || this.direction == AnimationDirectionEnum.Down) {
					if(this.currentPos + this.increment >= this.midPoint) {
						this.accel = false;
						this.increment = this.midPoint / 2;
					}
					else
						this.increment *= 2;
				}
				else {
					if(this.currentPos - this.increment <= this.midPoint) {
						this.accel = false;
						this.increment = this.midPoint / 2;
					}
					else
						this.increment *= 2;
				}
			}
			else {
				this.increment = Math.max(2, this.increment / 2);
			}
			break;		
	}
	this.onNext();
	return true;
}
ig_RevealAnimation.prototype.end = function() {
	switch (this.direction) {
		case AnimationDirectionEnum.Down :
			this.element.style.height = "";
			break;
		case AnimationDirectionEnum.Up :
			this.element.style.display = "none";
			break;
	}
    this.element.style.overflow = "";
	this.element.style.width = "";
	this.onEnd();
}
var ig_Location = {TopLeft:0, TopCenter:1, TopRight:2, TopInfront:3, TopBehind:4,
	MiddleLeft:8, MiddleCenter:9, MiddleRight:10, MiddleInfront:11, MiddleBehind:12,
	BottomLeft:16, BottomCenter:17, BottomRight:18, BottomInfront:19, BottomBehind:20,
	AboveLeft:32, AboveCenter:33, AboveRight:34, AboveInfront:35, AboveBehind:36,
	BelowLeft:64, BelowCenter:65, BelowRight:66, BelowInfront:67, BelowBehind:68};
function ig_progressIndicator(imageUrl, relativeContainer)
{
	this._img = imageUrl;
	this._rc = relativeContainer;
	this.setImageUrl = function(url)
	{
		if(this._elem)
			this._elem.parentNode.removeChild(this._elem);
		this._elem = null;
		this._img = url;
	}
	this.getImageUrl = function()
	{
		return this._img; 
	}

	this.setTemplate = function(html)
	{
		var elem = this._elem;
		if(elem)
		{
			if(elem.tagName == 'DIV' && html)
			{
				elem.innerHTML = html;
				return;
			}
			elem.parentNode.removeChild(elem);
			this._elem = null;
		}
		this._html = html;
	}
	this.getTemplate = function()
	{
		return this._html; 
	}
	this.setLocation = function(location)
	{
		this._location = location;
	}
	this.setCssStyle = function(css)
	{
		this._css = css;
	}
	this.setRelativeContainer = function(elem)
	{
		this._rc = elem;
	}
	this.display = function(rc, loc)
	{
		this.visible = true;
		var elem = this._elem;
		if(!rc)
			rc = this._rc;
		if(!elem)
		{
			var body = document.body, append = !ig_shared.IsIE || document.readyState == 'complete';
			if(this._html)
			{
				elem = document.createElement('DIV');
				if(append)
					body.appendChild(elem);
				else
				
					body.insertBefore(elem,body.firstChild);
				elem.innerHTML = this._html;
			}
			else
			{
				elem = document.createElement('IMG');
				if(append)
					body.appendChild(elem);
				else
				
					body.insertBefore(elem,body.firstChild);
				var img = this._img;
				if(!img)
					img = (typeof ig_pi_imageUrl == 'string') ? ig_pi_imageUrl : '/ig_common/images/ig_progressIndicator.gif';
				elem.src = img;
			}
			elem.unselectable = 'on';
			this._elem = elem;
		}
		if(this._css)
			elem.className = this._css;
		if(loc == null)
			if((loc = this._location) == null)
				loc = ig_Location.BottomRight;
		ig_shared.absPosition(rc, elem, loc);
	}
	this.hide = function()
	{
		this.visible = false;
		if(this._elem)
			this._elem.style.display = 'none';
	}
}
function ig_callBackManager(form)
{
	if(!form)
		if((form = ig_shared.getForm()) == null)
	{
		return;
	}
	this._onUnload = function()
	{
		var f = this._form;
		if(!f)
			return;
		this._form = this._submit = this._style = null;
		ig_shared.removeEventListener(f, 'submit', this._onFormSubmit);
		ig_shared.removeEventListener(f, 'click', this._onFormEvt);
		ig_shared.removeEventListener(f, 'mousedown', this._onFormEvt);
		ig_shared.removeEventListener(f, 'mouseup', this._onFormEvt);
		if(f._ig_cb_submit)
		{
			f.submit = f._ig_cb_submit;
			f._ig_cb_submit = null;
		}
		if(this._onsubmit)
			f.onsubmit = this._onsubmit;
	}
  this.addPanel = function(control, id, elemID, rc, link, ids, post, noResp)
	{
		if(!this._form || !control)
			return;
		var i = -1;
		while(++i < this._panels.length)
			if(this._panels[i].elemID == elemID)
				break;
		this._panels[i] = {control:control, id:id, elemID:elemID, rc:rc, link:link, ids:ids, post:post, noResp:noResp};
	}
	this.addCallBack = function(control, id, rc, flag)
	{
		var e, ee, j, form = this._form;
		if(!control || !form)
			return;
		if(!this._ok)
		{
			wxXys(form)  ;
			return;
		}
		if(!id)
		{
			id = control.id;
			rc = control.rc;
			control = control.control;
		}
		var i = null, args = this._submitElem;
		if(args)
		{
			args += '&';
			this._submitElem = null;
		}
		else args = '';
		if(this._wait || this._jsSrcs.length > 0)
			return;
		var id1 = this._elemID, id2 = this._evtElem;
		if(id2)
			id2 = id2.id;
		var triggers = [id2,this._subID,id1];
		if(!id1)
			id1 = id2;
		if(control.beforeCBSubmit)
			i = control.beforeCBSubmit(id1);
		var lsnrs = ig_shared._cbListeners;
		var elem, count = lsnrs ? lsnrs.length : 0;
		while(count-- > 0)
		{
			var fn = lsnrs[count];
			if(fn) if((fn = fn.evalCtl) != null)try
			{
				if(typeof fn == 'function')
					fn = fn(id1);
				else if(fn)
					fn = eval(fn).onCBSubmit(id1);
				if(!i)
					i = fn;
			}catch(e){}
		}
		if(i == 'fullPostBack')
		{
			wxXys(form)  ;
			return;
		}
		if(i == 'cancelSubmit' || i === true)
			return;
		var resp = (i != 'cancelResponse'), request = null;
		try
		{
			if(this._ie)
				request = ig_createActiveXFromProgIDs(["MSXML2.XMLHTTP","Microsoft.XMLHTTP"]);
			else
				request = new XMLHttpRequest();
		}catch(e){}
		if(!request)
			return;
		if(resp)
		{
			id1 = this.__id(id1);
			id2 = this.__id(id2);
			ee = this._panels;
			i = ee.length;
			while(i-- > 0 && resp)
			{
				e = ee[i].noResp;
				j = e ? e.length : e;
				while(j-- > 0) if(e[j] == id1 || e[j] == id2)
					resp = false;
			}
		}
		this._wait = true;
		var tags = ['INPUT', 'TEXTAREA', 'SELECT'], evs = ['__EVENTTARGET', '__EVENTARGUMENT'];
	   var vs = control.getCBSubmitElems ? control.getCBSubmitElems(flag) : null;
		var elems = vs ? vs : form.elements;
		var count = j = elems.length;
		if(vs)
		{
			elems = new Array();
			count = 0;
			while(j-- > 0)
			{
				e = vs[j];
				for(var t = 0; t < 3; t++) try
				{
					if(e.tagName == tags[0])
					{
						elems[count++] = e;
						break;
					}
					ee = e.getElementsByTagName(tags[t]);
					for(i = 0; i < ee.length; i++)
						elems[count++] = ee[i];
				}catch(ex){}
			}
			vs = this._vs;
			for(i = 0; i < vs.length; i += 2)
				elems[count++] = form[vs[i]];
		}
		while(count-- > 0)
		{
			if((elem = elems[count]) == null)
				continue;
			var val = null, name = elem.name;
			var tag = ig_csom.isEmpty(name) ? null : elem.tagName;
			i = 2;
			if(tag == tags[0])
			{
				var type = elem.type;
				if(type == 'text' || type == 'password' || type == 'hidden' || ((type == 'checkbox' || type == 'radio') && elem.checked))
					val = elem.value;
			}
			else if(tag == tags[1])
				val = elem.value;
			else if(tag == tags[2])
			{
				var o = elem.options;
				i = o ? o.length : 0;
				while(i-- > 0) if(o[i].selected)
					args += name + '=' + this._encode(o[i].value) + '&';
			}
			if(val != null)
			{
				args += name + '=' + this._encode(val) + '&';
				while(i-- > 0) if(name == evs[i])
				{
					elem.value = '';
					evs[i] = null;
				}
			}
		}
		i = 2;
		while(i-- > 0) if(evs[i])
			args += evs[i] + '=&';
		var postKey = '_' + Math.random(), cb = -1;
		while(++cb < this._callBacks.length)
			if(!this._callBacks[cb])
				break;
		args += '__IG_CALLBACK=' + this._encode(id + '#' + postKey);
		try
		{
			request.open('POST', form.action, true);
			try
			{
				if(this._ie || request.setRequestHeader)
					request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			}catch(e){}
			if(resp)
			{
				if(!(i = this._ie)) try
				{
					i = !request.addEventListener;
				}
				catch(e)
				{
					i = true;
				}
				if(i)
					request.onreadystatechange = this._responseEvt;
				else
					request.addEventListener('load', this._responseEvt, false);
			}
			request.send(args);
			ig_shared._isPosted = false;
			if(resp)
			{
				window.wxXTimeout("try{ig_all._ig_cbManager._timeOut('" + postKey + "');}catch(i){}", this._timeLimit + 1000);
				cb = this._callBacks[cb] = {request:request, id:id, postKey:postKey, control:control, timer:control._timer, time:(new Date()).getTime(), triggers:triggers};
				if(rc !== false)
				{
					cb.pis = new Array();
					if(!rc || rc.nodeName)
						cb.pis[0] = this._showPI(rc, control);
					else for(i = 0; i < rc.length; i++)
						cb.pis[i] = this._showPI(rc[i], control);
				}
			}
		}
		catch(e)
		{
		}
		this._wait = false;
	}
	this._timeOut = function(key)
	{
		var cb, i = this._callBacks.length;
		while(i-- > 0) if((cb = this._callBacks[i]) != null)
			if(cb.postKey == key)
				break;
		if(i < 0)
			return;
		var j = cb.control;
		if(j && j.onError)
			j.onError(6);
		j = cb.pis ? cb.pis.length : 0;
		while(j-- > 0)
			cb.pis[j].hide();
		delete this._callBacks[i];
	}
	
	this._showPI = function(rc, ctl)
	{
		var pis = this._indicators;
		if(!pis)
			pis = this._indicators = new Array();
		var pi = null, j = pis.length, i = -1;
		while(++i < j)
		{
			pi = pis[i];
			if(!pi.visible)
				break;
		}
		if(i == j)
		{
			pi = pis[j] = new ig_progressIndicator();
			if(ctl.fixPI)
				ctl.fixPI(pi);
		}
		if(pi._rc)
			rc = null;
		pi.display(rc);
		return pi;
	}
  this.setHtml = function(txt, elem)
	{
		if(!txt || !elem)
			return null;
		var i = 0, css = '';
		while(ig_shared.IsOpera)
		{
			var i0 = txt.indexOf('<style ', i), i1 = txt.indexOf('<style>', i), i2 = txt.indexOf('<STYLE ', i), i3 = txt.indexOf('<STYLE>', i);
			if(i > i0 || (i1 >= i && i0 > i1))
				i0 = i1;
			if(i > i0 || (i2 >= i && i0 > i2))
				i0 = i2;
			if(i > i0 || (i3 >= i && i0 > i3))
				i0 = i3;
			i1 = txt.indexOf('>', i0);
			if(i > i0 || i0 > i1)
				break;
			i2 = txt.indexOf('</style>', i0);
			i3 = txt.indexOf('</STYLE>', i0);
			if(i1 > i2 || (i3 > i1 && i2 > i3))
				i2 = i3;
			if(i1 > i2)
				break;
			css += txt.substring(i1 + 1, i2);
			txt = txt.substring(0, i0) + txt.substring(i2 + 8);
			i = i0;
		}
		if(css.length > 5)
			this._setCss(null, css, elem.id + '_ig_css');
		i = -3;
		while((i = txt.indexOf('<&>3', i += 3)) >= 0)
			txt = txt.replace('<&>3', '<&>');
		i = 0;
		while(true)
		{
			var iLen = txt.length;
			var i1 = txt.indexOf('<script', i), i2 = txt.indexOf('<SCRIPT', i);
			if(i1 > i2 && i2 >= i)
				i1 = i2;
			if(i1 < i)
				break;
			var t = this._fixScript(txt, i1);
			if(t == null)
				i = i1 + 7;
			else
				txt = t;
		}
		this._fireBeforeResponse(elem);
		elem.innerHTML = txt;
		return txt;
	}
	this._fixScript = function(txt, i)
	{
		var i2 = txt.indexOf('>', i);
		if(i2 < i)
			return null;
		var i3 = txt.indexOf('</script>', i2), i4 = txt.indexOf('</SCRIPT>', i2);
		if(i3 > i4 && i4 > i)
			i3 = i4;
		var js = txt.substring(i, i2);
		if(js.toLowerCase().indexOf('javascript') < 0)
			return null;
		var first = js.indexOf('IG_FIRST') > 0;
		js = txt.substring(i2 + 1, i3);
		txt = txt.substring(0, i) + txt.substring(i3 + 9);
		if(js.length < 2)
			return txt;
		if(!this._scripts)
			this._scripts = new Array();
		i = this._scripts.length;
		this._scripts[i] = js;
		if(first)
		{
			while(i-- > 0)
				this._scripts[i + 1] = this._scripts[i];
			this._scripts[0] = js;
		}
		return txt;
	}
	this._fireBeforeResponse = function(elem)
	{
		var el, ec, control, i = -1, lsnrs = ig_shared._cbListeners;
		if(lsnrs) while(++i < lsnrs.length)
		{
			if((el = lsnrs[i].elemID) == null)
				continue;
			if((el = ig_shared.getElement(el, this._form)) == null)
				continue;
			try
			{
				control = eval(ec = lsnrs[i].evalCtl);
			}
			catch(ex)
			{
				continue;
			}
			while((el = el.parentNode) != null)
				if(el == elem)
			{
				if(control.onCBBeforeResponse)
					control.onCBBeforeResponse();
				var cb = this._cb;
				if(!cb || !control.onCBAfterResponse)
					continue;
				if(!cb.lsnrs)
					cb.lsnrs = new Array();
				cb.lsnrs[cb.lsnrs.length] = ec;
			}
		}
	}
	this._form = form;
	this._timeLimit = 20000;
	this._vs = ['__VIEWSTATE', null, '__EVENTVALIDATION', null];
	this._sep = '<&>0';
	this._sepLen = this._sep.length;
	this._doPostBack = function(target, arg)
	{
		var me = ig_all._ig_cbManager, evt = window.event;
		if(!me || me._wait)
			return ig_cancelEvent(evt, 'submit');
		var pan = me._findPanel(target), form = me._form;
		if(!pan)
		{
			me._evtElem = null;
			me._oldPostBack(target, arg);
			return;
		}
		me._panelToSubmit = pan;
		var e = form ? form.__EVENTTARGET : null;
		if(e)
			e.value = target;
		e = form ? form.__EVENTARGUMENT : null;
		if(e)
			e.value = arg;
		me._elemID = target;
		me._onFormSubmit();
		me._elemID = null;
		ig_cancelEvent(evt, 'submit');
	}
	this._isMatch = function(x, v)
	{
		if(x == v)
			return true;
		if(x && x.charCodeAt(0) != 42)
			return false;
		var i = v.lastIndexOf(x = x.substring(1));
		return i >= 0 && i + x.length == v.length;
	}
	this.__id = function(id){return id ? id.replace(/\:/g, '_').replace(/\$/g, '_') : id;}
	this._findPanel = function(id, e)
	{
		var j, i, pans = this._panels.length, form = this._form;
		if(this._wait || pans < 1)
			return null;
		if(e)
			id = e.id;
		else if(!id)
			return null;
		var id0 = id;
		id = this.__id(id);
		if(!e && id)
			if((e = ig_shared.getElement(id, form)) == null)
				if((e = ig_shared.getElement(id + "_Data", form)) == null)
					if((e = ig_shared.getElement(id + "_hidden", form)) == null)
						if((e = ig_shared.getElement(id.replace(/\_/g, 'x'), form)) != null)
							if(id0 != id) if((e = ig_shared.getElement(id0, form)) == null)
								e = ig_shared.getElement(id0 + "_Data", form);
		id0 = id;
		while(e || id)
		{
			if(id || (e && e.id)) for(i = 0; i < pans; i++)
			{
				var p = this._panels[i];
				if(e && p.elemID == e.id)
				{
					if(p.post) for(j = 0; j < p.post.length; j++)
						if(this._isMatch(p.post[j], id0))
							return null;
					return p;
				}
				if(p.ids && id) for(j = 0; j < p.ids.length; j++)
					if(this._isMatch(p.ids[j], id0))
						return p;
				if(p.noResp && id) for(j = 0; j < p.noResp.length; j++)
					if(this._isMatch(p.noResp[j], id0))
						return p;
			}
			id = null;
			if(e)
				e = e.parentNode;
		}
		return null;
	}
	this._onFormEvt = function(evt)
	{
		if(!evt)
			if((evt = window.event) == null)
				return;
		var elem = evt.target;
		if(!elem)
			if((elem = evt.srcElement) == null)
				elem = this;
		var me = ig_all._ig_cbManager, type = elem.type, tag = elem.tagName, name = elem.name;
		if(!me)
			return;
		me._evtElem = elem;
		me._evtTime = (new Date()).getTime();
		if(evt.type != 'click' || elem.disabled)
			return;
		me._subID = me._submitElem = null;
		var pan = me._findPanel(null, elem);
		if(!pan)
			return;
		var val = null, x = evt.offsetX;
		if(type == 'image' && tag == 'INPUT')
			val = name + '.x=' + (x ? x : 1) + '&' + name + '.y=' + (x ? evt.offsetY : 1);
		else if(type == 'submit' && (tag == 'BUTTON' || tag == 'INPUT'))
			val = name + '=' + me._encode(elem.value);
		else
			return;
		if(ig_csom.notEmpty(me._subID = name))
			me._submitElem = val;
		me._panelToSubmit = pan;
	}
	this._encode = function(val)
	{
		return (typeof encodeURIComponent == 'function') ? encodeURIComponent(val) : escape(val);
	}
	this._restore = function()
	{
		for(var i = 0; i < 3; i += 2)
		{
			var val = this._vs[i + 1], e = ig_shared.getElement(this._vs[i], this._form);
			if(e && val)
				e.value = val;
		}
	}
	this._onFormSubmit = function(evt, me)
	{
		var my = me && me._vs;
		if(!my)
		{
			me = ig_all._ig_cbManager;
			if(!evt)
				evt = window.event;
		}
		if(me && me._wait)
			me = null;
		if(me && me._onsubmit && !my)
		{
			try
			{
				if(me._onsubmit() === false)
					me = null;
			}catch(ex)
			{
				me = null;
			}
			if(evt && evt.returnValue == false)
				me = null;
		}
		if(!me)
			return ig_cancelEvent(evt, 'submit');
		var form = me._form, pan = me._panelToSubmit, pp = me._panels;
		if(!pan || !form || form.action != form._ig_cb_act)
			return true;
		ig_cancelEvent(evt, 'submit');
		
		var p, rc = pan.rc, i = pp.length, id = pan.link;
		if(id) while(i-- > 0)
			if((p = pp[i]) != null)
				if(p.elemID == id || p.id == id)
					pan = p;
		if(pan)
			me.addCallBack(pan.control, pan.id, rc ? rc : pan.rc);
		me._panelToSubmit = null;
		me._evtElem = null;
		return false;
	}
	this._responseEvt = function()
	{
		var me = ig_all._ig_cbManager;
		if(!me || me._wait)
			return;
		for(var i = 0; i < me._callBacks.length; i++)
		{
			var j = -1, cb = me._callBacks[i];
			if(cb && me._doResponse(cb))
			{
				if(cb.pis)
					j = cb.pis.length;
				while(j-- > 0)
					cb.pis[j].hide();
				me._cb = me._scripts = null;
				delete me._callBacks[i];
				if(!me._jsWait && cb.timer)
					me._timer(cb.id, true);
			}
		}
	}
	this._doCss = function(e, v)
	{
		e.cssText = v;
		var e1, ss = document.styleSheets;
		var i = ss.length;
		while(i-- > 0)
		{
			e1 = ss[i];
			if(e1 == e)
				return;
			if(!e1.readOnly && !e1.disabled && e1.type == 'text/css')
				break;
		}
		if(i < 0)
			return;
	}
	this._doResponse = function(cb)
	{
		var request = cb.request;
		if(!request || request.readyState != 4)
			return false;
		var txt = request.responseText, sep = this._sep, sepLen = this._sepLen;
		if(!txt)
			return (new Date()).getTime() - cb.time > this._timeLimit;
		this.serverError = null;
		var e, i, i0 = txt.indexOf(sep);
		var iID = txt.indexOf(sep, i0 + sepLen);
		var iKey = txt.indexOf(sep, iID + sepLen);
		if(i0 < 0 || iID < 0 || iKey < 0)
		{
	  return false;
		}
		this.triggers = cb.triggers;
		this._jsWait = false;
		var id = txt.substring(i0 + sepLen, iID), postKey = txt.substring(iID + sepLen, iKey);
		this._error = 0;
		if(postKey.indexOf('<error>') == 0)
		{
			i = this._panels.length;
			this.serverError = txt.split(this._sep)[3];
			while(i-- > 0)
			{
				e = this._panels[i].control;
				if(e && e.onError)
					e.onError(1);
			}
			var lsnrs = ig_shared._cbError;
			i = lsnrs ? lsnrs.length : 0;
			
			while(i-- > 0)try
			{
				lsnrs[i](cb.control,cb.triggers,this.serverError);
			}catch(e){}
			this._restore();
			try
			{
				this._submit(9);
			}catch(e){}
			return true;
		}
		if(id == cb.id && postKey == cb.postKey)
		{
			if(this._cb)
			{
				window.wxXTimeout("try{ig_all._ig_cbManager._responseEvt();}catch(i){}", 1);
				return this._killCB++ > 20;
			}
			this._cb = cb;

			this._killCB = 0;
			txt = txt.substring(iKey + sepLen);
			var vals = txt.split(sep), old = this._vs;
			for(i = 2; i < vals.length - 1; i += 2)
			{
				var index = -1, v0 = vals[i], v1 = vals[i + 1];
				if(v0 == old[2])
					index = 2;
				else if(v0 == old[0])
					index = 0;
				else if(v0 && v0.indexOf('<') != 0)
					continue;
				vals[i] = vals[i + 1] = null;
				if(index > -1)
				{
					e = ig_shared.getElement(v0, this._form);
					if(e)
					{
						old[index + 1] = e.value;
						e.value = v1;
					}
				}
				else if(v0 == '<script>')
					this._scripts = new Array(v1);
				else if(v0 == '<jssrc>')
				{
					e = document.scripts;
					if(!e || e.length < 2)
						e = document.getElementsByTagName('SCRIPT');
					if(!e)
						continue;
					var s, x = -1, src = '';
					while(++x < e.length) if(e[x]) if((s = e[x].src) != null)
						src += s;
					v1 = v1.split('|');
					this._scriptCount = 0; x = -1;
					while(++x < v1.length)
					{
						s = v1[x].replace('&amp;','&');
						if(src.indexOf((s.charCodeAt(0) < 47) ? s.substring(1) : s) < 0)
							this._addJS(this._runScript(s, true), s, cb);
					}
				}
				else if(v0 == '<style>')
					this._setCss(this._style, v1);
			}
			var ctl = cb.control;
			
			if(vals[0] == '<error>')
			{
				this.serverError = vals[1];
				this._error = 2;
			}
			else if(ctl && ctl.doResponse) try
			{
				ctl.doResponse(vals, this);
			}catch(e){this._error |= 4;}
			cb._js = this._scripts;
			if(this._jsWait)
				window.wxXTimeout("try{ig_all._ig_cbManager._killJsSrc('" + id + "');}catch(i){}", 3000);
			else
				this._jsDelay(cb);
			if(this._error > 0 && ctl.onError)
				ctl.onError(this._error);
			return true;
		}

		return false;
	}
	this._setCss = function(e, v, id)
	{
		try
		{
			if(!id && document.createStyleSheet)
			{
				var e0 = e ? e.owningElement : null;
				e = e0 ? e0.parentElement : null;
				if(e && e.parentNode)
					e.removeChild(e0);
				this._doCss(this._style = document.createStyleSheet(), v);
				return;
			}
			if(id)
				e = document.getElementById(id);
			if(!e)
			{
				e = document.createElement('STYLE');
				e.type = 'text/css';
				var h = document.getElementsByTagName('HEAD');
				h = (h && h.length > 0) ? h[0] : document.body;
				h.appendChild(e);
				if(id)
					e.id = id;
				else
					this._style = e;
			}
			e.innerHTML = v;
		}catch(e)
		{
			this._error |= 32;
		}
	}
	this._jsDelay = function(cb)
	{
		if(!cb)
			return;
		var i, ctl = cb.control, js = cb._js;
		cb.control = cb._js = null;
		if(js) for(i = 0; i < js.length; i++)
			this._runScript(js[i]);
		if(cb.lsnrs) for(i = 0; i < cb.lsnrs.length; i++) try
		{
			eval(cb.lsnrs[i]).onCBAfterResponse();
		}catch(ex){}
		cb.lsnrs = null;
		
		if(ctl && ctl.afterCBResponse)
			ctl.afterCBResponse();
	}
  this._addJS = function(se, src, cb)
	{
		if(!se)
			return;
		this._jsWait = true;
		var js = this._jsSrcs;
		var j = -1, jL = js.length;
		while(++j < jL) if(js[j].src == src)
		{
			js[j].cb[js[j].cb.length] = cb;
			return;
		}
		js[jL] = {se:se,src:src,cb:[cb]};
		ig_shared.addEventListener(se, 'readystatechange', this._removeJS);
	}
	this._removeJS = function(se)
	{
		var me = ig_all._ig_cbManager;
		if(!me || !se)
			return;
		var e = se.srcElement;
		if(e)
		{
			if(e.readyState != 'loaded')
				return;
			se = e;
		}
		ig_shared.removeEventListener(se, 'readystatechange', me._removeJS);
		var js = me._jsSrcs;
		var x, i, cbx, cb = null, j = -1, jL = js ? js.length : 0;
		while(++j < jL) if(js[j].se == se)
		{
			cb = js[j].cb;
			js[j].se = null;
		}
		i = cb ? cb.length : 0;
		while(i-- > 0)
		{
			var cbi = cb[i];
			j = jL;
			while(j-- > 0 && cbi) if(js[j].se)
			{
				cbx = js[j].cb;
				x = cbx.length;
				while(x-- > 0) if(cbx[x] == cbi)
				{
					cbi = null;
					break;
				}
			}
			if(!cbi)
				continue;
			j = jL;
			while(j-- > 0)
			{
				if(js[j].se)
					se = null;
				cbx = js[j].cb;
				x = cbx.length;
				while(x-- > 0) if(cbx[x] == cbi)
					delete cbx[x];
			}
			if(se)
			{
				while(++j < jL)
					delete js[j];
				me._jsSrcs = new Array();
			}
			me._jsDelay(cbi);
			if(cbi.timer)
				me._timer(cbi.id, true);
		}
	}
	this._killJsSrc = function(id)
	{
		var me = ig_all._ig_cbManager;
		var js = me ? me._jsSrcs : null;
		var j = js ? js.length : 0;
		while(j-- > 0)
		{
			var x = -1, cbx = js[j].cb;
			while(++x < cbx.length)
				if(cbx[x] && cbx[x].id == id)
					me._removeJS(js[j].se);
		}
	}
	this._timer = function(id, wait)
	{
		var me = ig_all._ig_cbManager;
		var pan, cb = me ? me._callBacks : null;
		var i = cb ? cb.length : 0;
		while(i-- > 0) if(cb[i] && cb[i].id == id)
			return;
		i = me._panels.length;
		while(i-- > 0)
		{
			pan = me._panels[i];
			if(pan.id == id)
				break;
		}
		if(i >= 0)
			i = pan.control._timer;
		if(!i || i < 1)
			return;
		if(!wait)
		{
			pan.wait = false;
			me.addCallBack(pan);
			return;
		}
		if(!pan.wait)
			window.wxXTimeout("try{ig_all._ig_cbManager._timer('" + id + "');}catch(i){}", i);
		pan.wait = true;
	}
	this._runScript = function(js, src)
	{
		var e = document.getElementsByTagName('HEAD');
		e = (e && e.length > 0) ? e[0] : document.body;
		if(js && js.length > 1) try
		{
			var se = document.createElement('SCRIPT');
			se.type = 'text/javascript';
			if(src)
				se.src = js;
			else
				se.text = js;
			e.appendChild(se);
			if(src && document.all)
				return se;
		}
		catch(ex)
		{
			this._error |= 16;
		}
	}
	this.newPanel = function(id, uid, ids, prop, post, noResp)
	{
		var elem = document.getElementById(id);
		if(!elem)
			return;
		var o = ig_all[id];
		if(o)
			ig_dispose(o);
		var pi = {loc:ig_Location.MiddleCenter};
		pi.setImageUrl = function(v){this.url = v;}
		pi.getImageUrl = function(){return this.url;}
		pi.setTemplate = function(v){this.html = v;}
		pi.getTemplate = function(){return this.html;}
		pi.setLocation = function(v){this.loc = v;}
		pi.getLocation = function(){return this.loc;}
		o = ig_all[id] = {_id:id, _uniqueID:uid, _element:elem, _pi:pi, _evts:prop};
		var t = o._timer = prop[5] ? prop[5] : 0;
		o.getTimer = function(){return this._timer;}
		o.setTimer = function(v){this._timer = v;}
		o.getID = function(){return this._id;}
		o.getUniqueID = function(){return this._uniqueID;}
		o.getElement = function(){return this._element;}
		o.getProgressIndicator = function(){return this._pi;}
		o.findControl = function(id){return ig_shared.findControl(this._element, id);}
		o._fire = function(evt, p3)
		{
			evt = this._evts ? this._evts[evt] : null;
			if(!evt)
				return false;
			var evtO = new ig_EventObject();
			ig_fireEvent(this, ig_shared.replace(evt, "&quot;", "'"), evtO, p3);
			if(evtO.cancelResponse)
				return 'cancelResponse';
			if(evtO.fullPostBack)
				return 'fullPostBack';
			return evtO.cancel;
		}
		o.beforeCBSubmit = function(src){return this._fire(1, src);}
		o.afterCBResponse = function(){this._fire(3);}
		AdMchaaaaa= function(flags){this._fire(4, flags);}
		o.doResponse = function(vals, man)
		{
			if(!this._fire(2)) for(var i = 0; i + 1 < vals.length; i += 2)
			{
				var e, v, v0 = vals[i], v1 = vals[i + 1];
				if(!v0)
					continue;
				if(v0.indexOf('-') == 0)
				{
					e = ig_shared.getElement(v = v0.substring(2), man._form);
					if(!e)
						e = ig_shared.getElement(man.__id(v), man._form);
					if(e)
						v0 = v0.charCodeAt(1);
					if(v0 == 51)
						e.innerHTML = v1;
					else if(v1 == '&nbsp;')
						v1 = '';
					if(v0 == 48)
						e.value = v1;
					if(v0 == 49)
						e.checked = v1.toLowerCase() == 'true';
					if(v0 == 50)
						e.selectedIndex = parseInt(v1);
					if(v0 == 52)
						e.src = v1;
					continue;
				}
				e = ig_getWebControlById(v0);
				if(e)
				{
					man.setHtml(v1, e._element);
					continue;
				}
				try
				{
					var multi = v0.indexOf('+') == 0;
					e = eval(multi ? v0.substring(1) : v0);
					if(e && e.doResponse)
					{
						if(multi)
						{
							v1 = parseInt(v1);
							v0 = new Array();
							while(v1-- > 0)
							{
								v0[v0.length] = vals[i += 2];
								v0[v0.length] = vals[i + 1];
							}
						}
						else
							v0 = [v0,v1];
						e.doResponse(v0, man);
					}
				}catch(e){man._error |= 8;}
			}
		}
		o.fixPI = function(pi)
		{
			var p = this._pi;
			pi.setLocation(p.loc);
			if(p.url)
				pi.setImageUrl(p.url);
			else if(p.html)
				pi.setTemplate(p.html);
		}
		o.refresh = function()
		{
			try
			{
				ig_all._ig_cbManager.addCallBack(this, this._uniqueID, this._element);
			}catch(e){}
		}
		this.addPanel(o, uid, id, elem, null, ids, post, noResp);
		o._fire(0);
		if(t > 0)
			window.wxXTimeout("try{ig_all._ig_cbManager._timer('" + id + "');}catch(i){}", t);
	}
	this._submit = function(flag)
	{
		var me = ig_all._ig_cbManager;
		if(!me)
			return;
		var pan = me._panelToSubmit, elem = me._evtElem, f = me._form;
		if(!pan && elem && flag != 9)
		{
			if((new Date()).getTime() < me._evtTime + ((elem.nodeName == 'A') ? 200 : 30))
				pan = me._panelToSubmit = me._findPanel(null, elem);
			if(pan)
				if(!me._onFormSubmit(null, me))
					return;
			me._evtElem = me._panelToSubmit = null;
		}
		if(f && f._ig_cb_submit)try
		{
			f._ig_cb_submit();
		}catch(me){}
	}
	this._callBacks = new Array();
	this._panels = new Array();
	this._jsSrcs = new Array();
	this._ie = typeof ActiveXObject != 'undefined';
	this._ok = this._ie || typeof XMLHttpRequest != 'undefined';
	if(!this._ok)
		return;
	form._ig_cb_act = form.action;
	this._onsubmit = form.onsubmit;
	form.onsubmit = null;
	form._ig_cb_submit = form.submit;
	form.submit = this._submit;
	ig_shared.addEventListener(form, 'submit', this._onFormSubmit, true);
	ig_shared.addEventListener(form, 'click', this._onFormEvt, true);
	ig_shared.addEventListener(form, 'mousedown', this._onFormEvt, true);
	ig_shared.addEventListener(form, 'mouseup', this._onFormEvt, true);
	this._oldPostBack = window.__doPostBack;
	if(this._oldPostBack)
		window.__doPostBack = this._doPostBack;
}
function ig_createActiveXFromProgIDs(progIDs)
{
	var e;
	for(var i=0;i<progIDs.length;i++)
	{
		try
		{
			var activeX=new ActiveXObject(progIDs[i]);
			return activeX;
		}
		catch (e){;}
	}
	return null;
}
function ig$(id)
{
	var o = null;
	if(typeof ig_getWebControlById == "function")
		o = ig_getWebControlById(id);
	if(o)
		return o;
	if(typeof igedit_getById == "function")
		o = igedit_getById(id);
	if(o)
		return o;
	if(typeof igtab_getTabById == "function")
		o = igtab_getTabById(id);
	if(o)
		return o;
	if(typeof igcal_getCalendarById == "function")
		o = igcal_getCalendarById(id);
	if(o)
		return o;
	if(typeof iged_getById == "function")
		o = iged_getById(id);
	if(o)
		return o;
	if(typeof iglbar_getListbarById == "function")
		o = iglbar_getListbarById(id);
	if(o)
		return o;
	if(typeof igcmbo_getComboById == "function")
		o = igcmbo_getComboById(id);
	if(o)
		return o;
	if(typeof igtbl_getGridById == "function")
		o = igtbl_getGridById(id);
	if(o)
		return o;
	if(typeof igtbar_getToolbarById == "function")
		o = igtbar_getToolbarById(id);
	if(o)
		return o;
	if(typeof igmenu_getMenuById == "function")
		o = igmenu_getMenuById(id);
	if(o)
		return o;
	if(typeof igtree_getTreeById == "function")
		o = igtree_getTreeById(id);
	return o;
}
 var Calendar = new Class({	
	options: {
		blocked: [],
		classes: [],
		days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
		direction: 0, 
		draggable: true,
		months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
		navigation: 1,
		offset: 0,
		onHideStart: Class.empty,
		onHideComplete: Class.empty,
		onShowStart: Class.empty,
		onShowComplete: Class.empty,
		pad: 1, 
		tweak: {x: 0, y: 0}
	},
	initialize: function(obj, options) {
		if (!obj) { return false; }
		this.setOptions(options);
		var keys = ['calendar', 'prev', 'next', 'month', 'year', 'today', 'invalid', 'valid', 'inactive', 'active', 'hover', 'hilite'];
		var values = keys.map(function(key, i) {
			if (this.options.classes[i]) {
				if (this.options.classes[i].length) { key = this.options.classes[i]; }
			}
			return key;
		}, this);
		this.classes = values.associate(keys);
		this.calendar = new Element('div', { 
			'styles': { left: '-1000px', opacity: 0, position: 'absolute', top: '-1000px', zIndex: 1000 }
		}).addClass(this.classes.calendar).injectInside(document.body);
		if (window.ie6) {
			this.iframe = new Element('iframe', { 
				'styles': { left: '-1000px', position: 'absolute', top: '-1000px', zIndex: 999 }
			}).injectInside(document.body);
			this.iframe.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
		}
		this.fx = this.calendar.effect('opacity', { 
			onStart: function() { 
				if (this.calendar.getStyle('opacity') == 0) { // show
					if (window.ie6) { this.iframe.setStyle('display', 'block'); }
					this.calendar.setStyle('display', 'block');
					this.fireEvent('onShowStart', this.element);
				}
				else { 
					this.fireEvent('onHideStart', this.element);
				}
			}.bind(this),
			onComplete: function() { 
				if (this.calendar.getStyle('opacity') == 0) {
					this.calendar.setStyle('display', 'none');
					if (window.ie6) { this.iframe.setStyle('display', 'none'); }
					this.fireEvent('onHideComplete', this.element);
				}
				else {
					this.fireEvent('onShowComplete', this.element);
				}
			}.bind(this)
		});
		if (window.Drag && this.options.draggable) {
			this.drag = new Drag.Move(this.calendar, { 
				onDrag: function() {
					if (window.ie6) { this.iframe.setStyles({ left: this.calendar.style.left, top: this.calendar.style.top }); } 
				}.bind(this) 
			}); 
		}
		this.calendars = [];
		var id = 0;
		var d = new Date();
		d.setDate(d.getDate() + this.options.direction.toInt()); 
		for (var i in obj) {
			var cal = { 
				button: new Element('button', { 'type': 'button' }),
				el: $(i),
				els: [],
				id: id++,
				month: d.getMonth(),
				visible: false,
				year: d.getFullYear()
			};
			if (!this.element(i, obj[i], cal)) { continue; }
			cal.el.addClass(this.classes.calendar);
			cal.button.addClass(this.classes.calendar).addEvent('click', function(cal) { this.toggle(cal); }.pass(cal, this)).injectAfter(cal.el);
			cal.val = this.read(cal);
			$extend(cal, this.bounds(cal));
			$extend(cal, this.values(cal)); 
			this.rebuild(cal);
			this.calendars.push(cal); 
		}	
	},
	blocked: function(cal) {
		var blocked = [];
		var offset = new Date(cal.year, cal.month, 1).getDay(); 
		var last = new Date(cal.year, cal.month + 1, 0).getDate();
		this.options.blocked.each(function(date){
			var values = date.split(' ');
			for (var i = 0; i <= 3; i++){ 
				if (!values[i]){ values[i] = (i == 3) ? '' : '*'; } 
				values[i] = values[i].contains(',') ? values[i].split(',') : new Array(values[i]); 
				var count = values[i].length - 1;
				for (var j = count; j >= 0; j--){
					if (values[i][j].contains('-')){ 
						var val = values[i][j].split('-');
						for (var k = val[0]; k <= val[1]; k++){
							if (!values[i].contains(k)){ values[i].push(k + ''); }
						}
						values[i].splice(j, 1);
					}
				}
			}
			if (values[2].contains(cal.year + '') || values[2].contains('*')){
				if (values[1].contains(cal.month + 1 + '') || values[1].contains('*')){
					values[0].each(function(val){ 
						if (val > 0){ blocked.push(val.toInt()); }
					});

					if (values[3]){ 
						for (var i = 0; i < last; i++){
								var day = (i + offset) % 7;
	
								if (values[3].contains(day + '')){ 
									blocked.push(i + 1);
								}
						}
					}
				}
			}
		}, this);
		return blocked;
	},
	bounds: function(cal) {
		var start = new Date(1000, 0, 1); // jan 1, 1000
		var end = new Date(2999, 11, 31); // dec 31, 2999
		var date = new Date().getDate() + this.options.direction.toInt();
		if (this.options.direction > 0) {
			start = new Date();
			start.setDate(date + this.options.pad * cal.id);
		}
		if (this.options.direction < 0) {
			end = new Date();
			end.setDate(date - this.options.pad * (this.calendars.length - cal.id - 1));
		}
		cal.els.each(function(el) {	
			if (el.getTag() == 'select') {		
				if (el.format.test('(y|Y)')) {
					var years = [];
					el.getChildren().each(function(option) { 
						var values = this.unformat(option.value, el.format);
						if (!years.contains(values[0])) { years.push(values[0]); } 
					}, this);
					years.sort(this.sort);
					if (years[0] > start.getFullYear()) { 
						d = new Date(years[0], start.getMonth() + 1, 0); 
						if (start.getDate() > d.getDate()) { start.setDate(d.getDate()); }
						start.setYear(years[0]); 
					}
					if (years.getLast() < end.getFullYear()) { 
						d = new Date(years.getLast(), end.getMonth() + 1, 0); 
						if (end.getDate() > d.getDate()) { end.setDate(d.getDate()); }
						end.setYear(years.getLast());
					}		
				}
				if (el.format.test('(F|m|M|n)')) { 
					var months_start = [];
					var months_end = [];
					el.getChildren().each(function(option) { 
						var values = this.unformat(option.value, el.format);
						if ($type(values[0]) != 'number' || values[0] == years[0]) { 
							if (!months_start.contains(values[1])) { months_start.push(values[1]); }
						}
						if ($type(values[0]) != 'number' || values[0] == years.getLast()) { 
							if (!months_end.contains(values[1])) { months_end.push(values[1]); } 
						}
					}, this);
					months_start.sort(this.sort);
					months_end.sort(this.sort);
					if (months_start[0] > start.getMonth()) { 
						d = new Date(start.getFullYear(), months_start[0] + 1, 0);
						if (start.getDate() > d.getDate()) { start.setDate(d.getDate()); }
						start.setMonth(months_start[0]); 
					}
					if (months_end.getLast() < end.getMonth()) { 
						d = new Date(start.getFullYear(), months_end.getLast() + 1, 0); 
						if (end.getDate() > d.getDate()) { end.setDate(d.getDate()); }
						end.setMonth(months_end.getLast());
					}		
				}
			}
		}, this);
		return { 'start': start, 'end': end };
	},
	caption: function(cal) {
		var navigation = {
			prev: { 'month': true, 'year': true },
			next: { 'month': true, 'year': true }
		};
		if (cal.year == cal.start.getFullYear()) { 
			navigation.prev.year = false; 
			if (cal.month == cal.start.getMonth() && this.options.navigation == 1) { 
				navigation.prev.month = false;
			}		
		}		
		if (cal.year == cal.end.getFullYear()) { 
			navigation.next.year = false; 
			if (cal.month == cal.end.getMonth() && this.options.navigation == 1) { 
				navigation.next.month = false;
			}
		}
		if ($type(cal.months) == 'array') {
			if (cal.months.length == 1 && this.options.navigation == 2) {
				navigation.prev.month = navigation.next.month = false;
			}
		}
		var caption = new Element('caption');
		var prev = new Element('a').addClass(this.classes.prev).appendText('\x3c'); // <		
		var next = new Element('a').addClass(this.classes.next).appendText('\x3e'); // >
		if (this.options.navigation == 2) {
			var month = new Element('span').addClass(this.classes.month).injectInside(caption);
			if (navigation.prev.month) { prev.clone().addEvent('click', function(cal) { this.navigate(cal, 'm', -1); }.pass(cal, this)).injectInside(month); }
			month.adopt(new Element('span').appendText(this.options.months[cal.month]));
			if (navigation.next.month) { next.clone().addEvent('click', function(cal) { this.navigate(cal, 'm', 1); }.pass(cal, this)).injectInside(month); }
			var year = new Element('span').addClass(this.classes.year).injectInside(caption);
			if (navigation.prev.year) { prev.clone().addEvent('click', function(cal) { this.navigate(cal, 'y', -1); }.pass(cal, this)).injectInside(year); }
			year.adopt(new Element('span').appendText(cal.year));
			if (navigation.next.year) { next.clone().addEvent('click', function(cal) { this.navigate(cal, 'y', 1); }.pass(cal, this)).injectInside(year); }
		}
		else { // 1 or 0
			if (navigation.prev.month && this.options.navigation) { prev.clone().addEvent('click', function(cal) { this.navigate(cal, 'm', -1); }.pass(cal, this)).injectInside(caption); }
			caption.adopt(new Element('span').addClass(this.classes.month).appendText(this.options.months[cal.month]));
			caption.adopt(new Element('span').addClass(this.classes.year).appendText(cal.year));
			if (navigation.next.month && this.options.navigation) { next.clone().addEvent('click', function(cal) { this.navigate(cal, 'm', 1); }.pass(cal, this)).injectInside(caption); }
		}
		return caption;
	},
	changed: function(cal) {
		cal.val = this.read(cal); 
		$extend(cal, this.values(cal)); 
		this.rebuild(cal); 
		if (!cal.val) { return; } 
		if (cal.val.getDate() < cal.days[0]) { cal.val.setDate(cal.days[0]); }
		if (cal.val.getDate() > cal.days.getLast()) { cal.val.setDate(cal.days.getLast()); }
		cal.els.each(function(el) {	
			el.value = this.format(cal.val, el.format); 		
		}, this);
		this.check(cal); 
		this.calendars.each(function(kal) { 
			if (kal.visible) { this.display(kal); }
		}, this);
	},
	check: function(cal) {
		this.calendars.each(function(kal, i) {
			if (kal.val) { 
				var change = false;
				if (i < cal.id) { 
					var bound = new Date(Date.parse(cal.val));
					bound.setDate(bound.getDate() - (this.options.pad * (cal.id - i)));
					if (bound < kal.val) { change = true; }
				}
				if (i > cal.id) { 
					var bound = new Date(Date.parse(cal.val));
					bound.setDate(bound.getDate() + (this.options.pad * (i - cal.id)));
					if (bound > kal.val) { change = true; }
				}
				if (change) {
					if (kal.start > bound) { bound = kal.start; }
					if (kal.end < bound) { bound = kal.end; }
					kal.month = bound.getMonth();
					kal.year = bound.getFullYear();		
					$extend(kal, this.values(kal));			
					kal.val = kal.days.contains(bound.getDate()) ? bound : null;
					this.write(kal);
					if (kal.visible) { this.display(kal); } 
				}
			}
			else {
				kal.month = cal.month;
				kal.year = cal.year;
			}
		}, this);
	},
	clicked: function(td, day, cal) {
		cal.val = (this.value(cal) == day) ? null : new Date(cal.year, cal.month, day); 
		this.write(cal); 
		if (!cal.val) { cal.val = this.read(cal); }
		if (cal.val) {
			this.check(cal);				
			this.toggle(cal); 
		} 
		else { 
			td.addClass(this.classes.valid);
			td.removeClass(this.classes.active);
		}
	},
	display: function(cal) {
		this.calendar.empty(); // init div
		this.calendar.className = this.classes.calendar + ' ' + this.options.months[cal.month].toLowerCase();
		var div = new Element('div').injectInside(this.calendar); 
		var table = new Element('table').injectInside(div).adopt(this.caption(cal));
		var thead = new Element('thead').injectInside(table);
		var tr = new Element('tr').injectInside(thead);
		for (var i = 0; i <= 6; i++) {
			var th = this.options.days[(i + this.options.offset) % 7];
			tr.adopt(new Element('th', { 'title': th }).appendText(th.substr(0, 1)));
		}
		var tbody = new Element('tbody').injectInside(table);
		var tr = new Element('tr').injectInside(tbody);
		var d = new Date(cal.year, cal.month, 1);
		var offset = ((d.getDay() - this.options.offset) + 7) % 7; 
		var last = new Date(cal.year, cal.month + 1, 0).getDate(); 
		var prev = new Date(cal.year, cal.month, 0).getDate();
		var active = this.value(cal); 
		var valid = cal.days; 
		var inactive = []; 
		var hilited = [];
		this.calendars.each(function(kal, i) {
			if (kal != cal && kal.val) {
				if (cal.year == kal.val.getFullYear() && cal.month == kal.val.getMonth()) { inactive.push(kal.val.getDate()); }
				if (cal.val) {
					for (var day = 1; day <= last; day++) {
						d.setDate(day);
						if ((i < cal.id && d > kal.val && d < cal.val) || (i > cal.id && d > cal.val && d < kal.val)) { 
							if (!hilited.contains(day)) { hilited.push(day); }
						}
					}
				}
			}
		}, this);
		var d = new Date();
		var today = new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime(); 
		for (var i = 1; i < 43; i++) {
			if ((i - 1) % 7 == 0) { tr = new Element('tr').injectInside(tbody); } 
			var td = new Element('td').injectInside(tr);
			var day = i - offset;
			var date = new Date(cal.year, cal.month, day);
			var cls = '';
			if (day === active) { cls = this.classes.active; }
			else if (inactive.contains(day)) { cls = this.classes.inactive; }
			else if (valid.contains(day)) { cls = this.classes.valid; } 
			else if (day >= 1 && day <= last) { cls = this.classes.invalid; } 
			if (date.getTime() == today) { cls = cls + ' ' + this.classes.today; } 
			if (hilited.contains(day)) { cls = cls + ' ' + this.classes.hilite; } 
			td.addClass(cls);
			if (valid.contains(day)) { 
				td.setProperty('title', this.format(date, 'D M jS Y'));
				td.addEvents({
					'click': function(td, day, cal) { 
						this.clicked(td, day, cal); 
					}.pass([td, day, cal], this),
					'mouseover': function(td, cls) { 
						td.addClass(cls); 
					}.pass([td, this.classes.hover]),
					'mouseout': function(td, cls) { 
						td.removeClass(cls); 
					}.pass([td, this.classes.hover])
				});
			}
			if (day < 1) { day = prev + day; }
			else if (day > last) { day = day - last; }
			td.appendText(day);
		}
	},
	element: function(el, f, cal) {
		if ($type(f) == 'object') {
			for (var i in f) { 
				if (!this.element(i, f[i], cal)) { return false; }		
			}
			return true;
		}
		el = $(el);
		if (!el) { return false; }
		el.format = f;
		if (el.getTag() == 'select') { 
			el.addEvent('change', function(cal) { this.changed(cal); }.pass(cal, this));
		}
		else { 
			el.readOnly = true;
			el.addEvent('focus', function(cal) { this.toggle(cal); }.pass(cal, this));
		}
		cal.els.push(el);
		return true;
	},
	format: function(date, format) {
		var str = '';
		if (date) {
			var j = date.getDate(); 
      var w = date.getDay();
			var l = this.options.days[w];
			var n = date.getMonth() + 1; 
			var f = this.options.months[n - 1];
			var y = date.getFullYear() + '';
			for (var i = 0, len = format.length; i < len; i++) {
				var cha = format.charAt(i); 
				switch(cha) {
					case 'y': 
						y = y.substr(2);
					case 'Y': 
						str += y;
						break;
					case 'm': // 01 - 12
						if (n < 10) { n = '0' + n; }
					case 'n': // 1 - 12
						str += n;
						break;
					case 'M': 
						f = f.substr(0, 3);
					case 'F': 
						str += f;
						break;
					case 'd': // 01 - 31
						if (j < 10) { j = '0' + j; }
					case 'j': // 1 - 31
						str += j;
						break;
					case 'D': 
						l = l.substr(0, 3);
					case 'l': 
						str += l;
						break;
					case 'N': 
						w += 1;
					case 'w': 
						str += w;
						break;
					case 'S': 
						if (j % 10 == 1 && j != '11') { str += 'st'; }
						else if (j % 10 == 2 && j != '12') { str += 'nd'; }
						else if (j % 10 == 3 && j != '13') { str += 'rd'; }
						else { str += 'th'; }
						break;
					default:
						str += cha;
				}
			}
		}
	  return str;
	},
	navigate: function(cal, type, n) {
		switch (type) {
			case 'm': 
					if ($type(cal.months) == 'array') {
						var i = cal.months.indexOf(cal.month) + n; 
						if (i < 0 || i == cal.months.length) { 
							if (this.options.navigation == 1) { 
								this.navigate(cal, 'y', n);		
							}
							i = (i < 0) ? cal.months.length - 1 : 0;
						}
						cal.month = cal.months[i];
					}
					else { 
						var i = cal.month + n;
						if (i < 0 || i == 12) {
							if (this.options.navigation == 1) {
								this.navigate(cal, 'y', n);	
							}
							i = (i < 0) ? 11 : 0;
						}
						cal.month = i;
					}		
					break;
				case 'y': 
					if ($type(cal.years) == 'array') {
						var i = cal.years.indexOf(cal.year) + n;
						cal.year = cal.years[i]; 
					}
					else { 
						cal.year += n;
					}						
					break;		
		}
		$extend(cal, this.values(cal));
		if ($type(cal.months) == 'array') { 
			var i = cal.months.indexOf(cal.month); 
			if (i < 0) { cal.month = cal.months[0]; } 
		}
		this.display(cal);
	},
	read: function(cal) {
		var arr = [null, null, null];
		cal.els.each(function(el) {
			var values = this.unformat(el.value, el.format);
			values.each(function(val, i) { 
				if ($type(val) == 'number') { arr[i] = val; }
			}); 
		}, this);
		if ($type(arr[0]) == 'number') { cal.year = arr[0]; }
		if ($type(arr[1]) == 'number') { cal.month = arr[1]; }
		var val = null;
		if (arr.every(function(i) { return $type(i) == 'number'; })) {
			var last = new Date(arr[0], arr[1] + 1, 0).getDate(); 

			if (arr[2] > last) { arr[2] = last; }
			
			val = new Date(arr[0], arr[1], arr[2]);
		}
		return (cal.val == val) ? null : val; 
	},
	rebuild: function(cal) {
		cal.els.each(function(el) {			
			if (el.getTag() == 'select' && el.format.test('^(d|j)$')) { 
				var d = this.value(cal);
				if (!d) { d = el.value.toInt(); } 
				el.empty();
				cal.days.each(function(day) {
					var option = new Element('option', {
						'selected': (d == day),
						'value': ((el.format == 'd' && day < 10) ? '0' + day : day)
					}).appendText(day).injectInside(el);
				}, this);
			}
		}, this); 
	},
	sort: function(a, b) {
		return a - b;
	},
	toggle: function(cal) {
		document.removeEvent('mousedown', this.fn);
		if (cal.visible) { 					
			cal.visible = false;
			cal.button.removeClass(this.classes.active);
			this.fx.start(1, 0);
		}
		else { 
			this.fn = function(e, cal) { 
				var e = new Event(e);
				var el = e.target;
				var stop = false;
				while (el != document.body && el.nodeType == 1) {
					if (el == this.calendar) { stop = true; }
					this.calendars.each(function(kal) {
						if (kal.button == el || kal.els.contains(el)) { stop = true; }
					});
					if (stop) { 
						e.stop();
						return false;
					}
					else { el = el.parentNode; }
				}
				this.toggle(cal);
			}.create({ 'arguments': cal, 'bind': this, 'event': true });				
			document.addEvent('mousedown', this.fn);
			this.calendars.each(function(kal) {
				if (kal == cal) {
					kal.visible = true;
					kal.button.addClass(this.classes.active);
				}
				else {
					kal.visible = false;
					kal.button.removeClass(this.classes.active);
				}
			}, this);
			var size = window.getSize().scrollSize;
			var coord = cal.button.getCoordinates();
			var x = coord.right + this.options.tweak.x;
			var y = coord.top + this.options.tweak.y;
			if (!this.calendar.coord) { this.calendar.coord = this.calendar.getCoordinates(); }
			if (x + this.calendar.coord.width > size.x) { x -= (x + this.calendar.coord.width - size.x); }
			if (y + this.calendar.coord.height > size.y) { y -= (y + this.calendar.coord.height - size.y); }
			this.calendar.setStyles({ left: x + 'px', top: y + 'px' });
			if (window.ie6) { 
				this.iframe.setStyles({ height: this.calendar.coord.height + 'px', left: x + 'px', top: y + 'px', width: this.calendar.coord.width + 'px' }); 
			}
			this.display(cal);
			this.fx.start(0, 1);
		}
	},
	unformat: function(val, f) {
		f = f.escapeRegExp();
		var re = {
			d: '([0-9]{2})',
			j: '([0-9]{1,2})',
			D: '(' + this.options.days.map(function(day) { return day.substr(0, 3); }).join('|') + ')',					
			l: '(' + this.options.days.join('|') + ')',
			S: '(st|nd|rd|th)',
			F: '(' + this.options.months.join('|') + ')',
			m: '([0-9]{2})',
			M: '(' + this.options.months.map(function(month) { return month.substr(0, 3); }).join('|') + ')',					
			n: '([0-9]{1,2})',
			Y: '([0-9]{4})',
			y: '([0-9]{2})'
		}
		var arr = []; 
		var g = '';
		for (var i = 0; i < f.length; i++) {
			var c = f.charAt(i);
			if (re[c]) {
				arr.push(c);
				g += re[c];
			}
			else {
				g += c;
			}
		}
		var matches = val.match('^' + g + '$');
		var dates = new Array(3);
		if (matches) {
			matches = matches.slice(1);
			arr.each(function(c, i) {
				i = matches[i];
				switch(c) {
					case 'y':
						i = '19' + i; 
					case 'Y':
						dates[0] = i.toInt();
						break;
					case 'F':
						i = i.substr(0, 3);
					case 'M':
						i = this.options.months.map(function(month) { return month.substr(0, 3); }).indexOf(i) + 1;
					case 'm':
					case 'n':
						dates[1] = i.toInt() - 1;
						break;
					case 'd':
					case 'j':
						dates[2] = i.toInt();
						break;
				}
			}, this);
		}
		return dates;
	},
	value: function(cal) {
		var day = null;
		if (cal.val) {
			if (cal.year == cal.val.getFullYear() && cal.month == cal.val.getMonth()) { day = cal.val.getDate(); }
		}
		return day;
	},
	values: function(cal) {
		var years, months, days;
		cal.els.each(function(el) {	
			if (el.getTag() == 'select') {		
				if (el.format.test('(y|Y)')) { 
					years = [];
					el.getChildren().each(function(option) {
						var values = this.unformat(option.value, el.format);
						if (!years.contains(values[0])) { years.push(values[0]); } 
					}, this);
					years.sort(this.sort);
				}
				if (el.format.test('(F|m|M|n)')) { 
					months = []; 
					el.getChildren().each(function(option) { 
						var values = this.unformat(option.value, el.format);
						if ($type(values[0]) != 'number' || values[0] == cal.year) {
							if (!months.contains(values[1])) { months.push(values[1]); } 
						}
					}, this);
					months.sort(this.sort);
				}
				if (el.format.test('(d|j)') && !el.format.test('^(d|j)$')) { 
					days = []; 
					el.getChildren().each(function(option) { 
						var values = this.unformat(option.value, el.format);
						if (values[0] == cal.year && values[1] == cal.month) {
							if (!days.contains(values[2])) { days.push(values[2]); } 
						}
					}, this);
				}
			}
		}, this);
		var first = 1;
		var last = new Date(cal.year, cal.month + 1, 0).getDate(); 
		if (cal.year == cal.start.getFullYear()) {
			if (months == null && this.options.navigation == 2) {
				months = [];
				for (var i = 0; i < 12; i ++) { 
					if (i >= cal.start.getMonth()) { months.push(i); } 
				}
			}
		if (cal.month == cal.start.getMonth()) { 
				first = cal.start.getDate();
			}
		}		
		if (cal.year == cal.end.getFullYear()) {
			if (months == null && this.options.navigation == 2) {
				months = [];
				for (var i = 0; i < 12; i ++) { 
					if (i <= cal.end.getMonth()) { months.push(i); } 
				}
			}
			if (cal.month == cal.end.getMonth()) { 
				last = cal.end.getDate(); 
			}
		}
		var blocked = this.blocked(cal);
		if ($type(days) == 'array') { 
			days = days.filter(function(day) {
				if (day >= first && day <= last && !blocked.contains(day)) { return day; }
			});
		}
		else { 
			days = [];
			for (var i = first; i <= last; i++) { 
				if (!blocked.contains(i)) { days.push(i); }
			}
		}		
		days.sort(this.sort); 
		return { 'days': days, 'months': months, 'years': years };
	},
	write: function(cal) {
		this.rebuild(cal);
		cal.els.each(function(el) {	
			el.value = this.format(cal.val, el.format); 		
		}, this);
	}
});
Calendar.implement(new Events, new Options);