
/*
 * jQuery validation plug-in 1.5
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
 * http://docs.jquery.com/Plugins/Validation
 *
 * Copyright (c) 2006 - 2008 Jörn Zaefferer
 *
 * $Id: jquery.validate.js 5952 2008-11-25 19:12:30Z joern.zaefferer $
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

(function($) {

$.extend($.fn, {
	// http://docs.jquery.com/Plugins/Validation/validate
	validate: function( options ) {
		
		// if nothing is selected, return nothing; can't chain anyway
		if (!this.length) {
			options && options.debug && window.console && console.warn( "nothing selected, can't validate, returning nothing" );
			return;
		}
		
		// check if a validator for this form was already created
		var validator = $.data(this[0], 'validator');
		if ( validator ) {
			return validator;
		}
		
		validator = new $.validator( options, this[0] );
		$.data(this[0], 'validator', validator); 
		
		if ( validator.settings.onsubmit ) {
		
			// allow suppresing validation by adding a cancel class to the submit button
			this.find("input, button").filter(".cancel").click(function() {
				validator.cancelSubmit = true;
			});
		
			// validate the form on submit
			this.submit( function( event ) {
				if ( validator.settings.debug )
					// prevent form submit to be able to see console output
					event.preventDefault();
					
				function handle() {
					if ( validator.settings.submitHandler ) {
						validator.settings.submitHandler.call( validator, validator.currentForm );
						return false;
					}
					return true;
				}
					
				// prevent submit for invalid forms or custom submit handlers
				if ( validator.cancelSubmit ) {
					validator.cancelSubmit = false;
					return handle();
				}
				if ( validator.form() ) {
					if ( validator.pendingRequest ) {
						validator.formSubmitted = true;
						return false;
					}
					return handle();
				} else {
					validator.focusInvalid();
					return false;
				}
			});
		}
		
		return validator;
	},
	// http://docs.jquery.com/Plugins/Validation/valid
	valid: function() {
        if ( $(this[0]).is('form')) {
            return this.validate().form();
        } else {
            var valid = false;
            var validator = $(this[0].form).validate();
            this.each(function() {
				valid |= validator.element(this);
            });
            return valid;
        }
    },
	// attributes: space seperated list of attributes to retrieve and remove
	removeAttrs: function(attributes) {
		var result = {},
			$element = this;
		$.each(attributes.split(/\s/), function() {
			result[this] = $element.attr(this);
			$element.removeAttr(this);
		});
		return result;
	},
	// http://docs.jquery.com/Plugins/Validation/rules
	rules: function(command, argument) {
		var element = this[0];
		
		if (command) {
			var settings = $.data(element.form, 'validator').settings;
			var staticRules = settings.rules;
			var existingRules = $.validator.staticRules(element);
			switch(command) {
			case "add":
				$.extend(existingRules, $.validator.normalizeRule(argument));
				staticRules[element.name] = existingRules;
				if (argument.messages)
					settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
				break;
			case "remove":
				if (!argument) {
					delete staticRules[element.name];
					return existingRules;
				}
				var filtered = {};
				$.each(argument.split(/\s/), function(index, method) {
					filtered[method] = existingRules[method];
					delete existingRules[method];
				});
				return filtered;
			}
		}
		
		var data = $.validator.normalizeRules(
		$.extend(
			{},
			$.validator.metadataRules(element),
			$.validator.classRules(element),
			$.validator.attributeRules(element),
			$.validator.staticRules(element)
		), element);
		
		// make sure required is at front
		if (data.required) {
			var param = data.required;
			delete data.required;
			data = $.extend({required: param}, data);
		}
		
		return data;
	},
	// destructive add
	push: function( t ) {
		return this.setArray( this.add(t).get() );
	}
});

// Custom selectors
$.extend($.expr[":"], {
	// http://docs.jquery.com/Plugins/Validation/blank
	blank: function(a) {return !$.trim(a.value);},
	// http://docs.jquery.com/Plugins/Validation/filled
	filled: function(a) {return !!$.trim(a.value);},
	// http://docs.jquery.com/Plugins/Validation/unchecked
	unchecked: function(a) {return !a.checked;}
});


$.format = function(source, params) {
	if ( arguments.length == 1 ) 
		return function() {
			var args = $.makeArray(arguments);
			args.unshift(source);
			return $.format.apply( this, args );
		};
	if ( arguments.length > 2 && params.constructor != Array  ) {
		params = $.makeArray(arguments).slice(1);
	}
	if ( params.constructor != Array ) {
		params = [ params ];
	}
	$.each(params, function(i, n) {
		source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n);
	});
	return source;
};

// constructor for validator
$.validator = function( options, form ) {
	this.settings = $.extend( {}, $.validator.defaults, options );
	this.currentForm = form;
	this.init();
};

$.extend($.validator, {

	defaults: {
		messages: {},
		groups: {},
		rules: {},
		errorClass: "error",
		errorElement: "label",
		focusInvalid: true,
		errorContainer: $( [] ),
		errorLabelContainer: $( [] ),
		onsubmit: true,
		ignore: [],
		ignoreTitle: false,
		onfocusin: function(element) {
			this.lastActive = element;
				
			// hide error label and remove error class on focus if enabled
			if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
				this.settings.unhighlight && this.settings.unhighlight.call( this, element, this.settings.errorClass );
				this.errorsFor(element).hide();
			}
		},
		onfocusout: function(element) {
			if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
				this.element(element);
			}
		},
		onkeyup: function(element) {
			if ( element.name in this.submitted || element == this.lastElement ) {
				this.element(element);
			}
		},
		onclick: function(element) {
			if ( element.name in this.submitted )
				this.element(element);
		},
		highlight: function( element, errorClass ) {
			$( element ).addClass( errorClass );
		},
		unhighlight: function( element, errorClass ) {
			$( element ).removeClass( errorClass );
		}
	},

	// http://docs.jquery.com/Plugins/Validation/Validator/setDefaults
	setDefaults: function(settings) {
		$.extend( $.validator.defaults, settings );
	},

	messages: {
		required: "This field is required.",
		remote: "Please fix this field.",
		email: "Please enter a valid email address.",
		url: "Please enter a valid URL.",
		date: "Please enter a valid date.",
		dateISO: "Please enter a valid date (ISO).",
		dateDE: "Bitte geben Sie ein gültiges Datum ein.",
		number: "Please enter a valid number.",
		numberDE: "Bitte geben Sie eine Nummer ein.",
		digits: "Please enter only digits",
		creditcard: "Please enter a valid credit card number.",
		equalTo: "Please enter the same value again.",
		accept: "Please enter a value with a valid extension.",
		maxlength: $.format("Please enter no more than {0} characters."),
		minlength: $.format("Please enter at least {0} characters."),
		rangelength: $.format("Please enter a value between {0} and {1} characters long."),
		range: $.format("Please enter a value between {0} and {1}."),
		max: $.format("Please enter a value less than or equal to {0}."),
		min: $.format("Please enter a value greater than or equal to {0}.")
	},
	
	autoCreateRanges: false,
	
	prototype: {
		
		init: function() {
			this.labelContainer = $(this.settings.errorLabelContainer);
			this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
			this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer );
			this.submitted = {};
			this.valueCache = {};
			this.pendingRequest = 0;
			this.pending = {};
			this.invalid = {};
			this.reset();
			
			var groups = (this.groups = {});
			$.each(this.settings.groups, function(key, value) {
				$.each(value.split(/\s/), function(index, name) {
					groups[name] = key;
				});
			});
			var rules = this.settings.rules;
			$.each(rules, function(key, value) {
				rules[key] = $.validator.normalizeRule(value);
			});
			
			function delegate(event) {
				var validator = $.data(this[0].form, "validator");
				validator.settings["on" + event.type] && validator.settings["on" + event.type].call(validator, this[0] );
			}
			$(this.currentForm)
				.delegate("focusin focusout keyup", ":text, :password, :file, select, textarea", delegate)
				.delegate("click", ":radio, :checkbox", delegate);

			if (this.settings.invalidHandler)
				$(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
		},

		// http://docs.jquery.com/Plugins/Validation/Validator/form
		form: function() {
			this.checkForm();
			$.extend(this.submitted, this.errorMap);
			this.invalid = $.extend({}, this.errorMap);
			if (!this.valid())
				$(this.currentForm).triggerHandler("invalid-form", [this]);
			this.showErrors();
			return this.valid();
		},
		
		checkForm: function() {
			this.prepareForm();
			for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
				this.check( elements[i] );
			}
			return this.valid(); 
		},
		
		// http://docs.jquery.com/Plugins/Validation/Validator/element
		element: function( element ) {
			element = this.clean( element );
			this.lastElement = element;
			this.prepareElement( element );
			this.currentElements = $(element);
			var result = this.check( element );
			if ( result ) {
				delete this.invalid[element.name];
			} else {
				this.invalid[element.name] = true;
			}
			if ( !this.numberOfInvalids() ) {
				// Hide error containers on last error
				this.toHide.push( this.containers );
			}
			this.showErrors();
			return result;
		},

		// http://docs.jquery.com/Plugins/Validation/Validator/showErrors
		showErrors: function(errors) {
			if(errors) {
				// add items to error list and map
				$.extend( this.errorMap, errors );
				this.errorList = [];
				for ( var name in errors ) {
					this.errorList.push({
						message: errors[name],
						element: this.findByName(name)[0]
					});
				}
				// remove items from success list
				this.successList = $.grep( this.successList, function(element) {
					return !(element.name in errors);
				});
			}
			this.settings.showErrors
				? this.settings.showErrors.call( this, this.errorMap, this.errorList )
				: this.defaultShowErrors();
		},
		
		// http://docs.jquery.com/Plugins/Validation/Validator/resetForm
		resetForm: function() {
			if ( $.fn.resetForm )
				$( this.currentForm ).resetForm();
			this.submitted = {};
			this.prepareForm();
			this.hideErrors();
			this.elements().removeClass( this.settings.errorClass );
		},
		
		numberOfInvalids: function() {
			return this.objectLength(this.invalid);
		},
		
		objectLength: function( obj ) {
			var count = 0;
			for ( var i in obj )
				count++;
			return count;
		},
		
		hideErrors: function() {
			this.addWrapper( this.toHide ).hide();
		},
		
		valid: function() {
			return this.size() == 0;
		},
		
		size: function() {
			return this.errorList.length;
		},
		
		focusInvalid: function() {
			if( this.settings.focusInvalid ) {
				try {
					$(this.findLastActive() || this.errorList.length && this.errorList[0].element || []).filter(":visible").focus();
				} catch(e) {
					// ignore IE throwing errors when focusing hidden elements
				}
			}
		},
		
		findLastActive: function() {
			var lastActive = this.lastActive;
			return lastActive && $.grep(this.errorList, function(n) {
				return n.element.name == lastActive.name;
			}).length == 1 && lastActive;
		},
		
		elements: function() {
			var validator = this,
				rulesCache = {};
			
			// select all valid inputs inside the form (no submit or reset buttons)
			// workaround $Query([]).add until http://dev.jquery.com/ticket/2114 is solved
			return $([]).add(this.currentForm.elements)
			.filter(":input")
			.not(":submit, :reset, :image, [disabled]")
			.not( this.settings.ignore )
			.filter(function() {
				!this.name && validator.settings.debug && window.console && console.error( "%o has no name assigned", this);
			
				// select only the first element for each name, and only those with rules specified
				if ( this.name in rulesCache || !validator.objectLength($(this).rules()) )
					return false;
				
				rulesCache[this.name] = true;
				return true;
			});
		},
		
		clean: function( selector ) {
			return $( selector )[0];
		},
		
		errors: function() {
			return $( this.settings.errorElement + "." + this.settings.errorClass, this.errorContext );
		},
		
		reset: function() {
			this.successList = [];
			this.errorList = [];
			this.errorMap = {};
			this.toShow = $([]);
			this.toHide = $([]);
			this.formSubmitted = false;
			this.currentElements = $([]);
		},
		
		prepareForm: function() {
			this.reset();
			this.toHide = this.errors().push( this.containers );
		},
		
		prepareElement: function( element ) {
			this.reset();
			this.toHide = this.errorsFor(element);
		},
	
		check: function( element ) {
			element = this.clean( element );
			
			// if radio/checkbox, validate first element in group instead
			if (this.checkable(element)) {
				element = this.findByName( element.name )[0];
			}
			
			var rules = $(element).rules();
			var dependencyMismatch = false;
			for( method in rules ) {
				var rule = { method: method, parameters: rules[method] };
				try {
					var result = $.validator.methods[method].call( this, element.value, element, rule.parameters );
					
					// if a method indicates that the field is optional and therefore valid,
					// don't mark it as valid when there are no other rules
					if ( result == "dependency-mismatch" ) {
						dependencyMismatch = true;
						continue;
					}
					dependencyMismatch = false;
					
					if ( result == "pending" ) {
						this.toHide = this.toHide.not( this.errorsFor(element) );
						return;
					}
					
					if( !result ) {
						this.formatAndAdd( element, rule );
						return false;
					}
				} catch(e) {
					this.settings.debug && window.console && console.log("exception occured when checking element " + element.id
						 + ", check the '" + rule.method + "' method");
					throw e;
				}
			}
			if (dependencyMismatch)
				return;
			if ( this.objectLength(rules) )
				this.successList.push(element);
			return true;
		},
		
		// return the custom message for the given element and validation method
		// specified in the element's "messages" metadata
		customMetaMessage: function(element, method) {
			if (!$.metadata)
				return;
			
			var meta = this.settings.meta
				? $(element).metadata()[this.settings.meta]
				: $(element).metadata();
			
			return meta && meta.messages && meta.messages[method];
		},
		
		// return the custom message for the given element name and validation method
		customMessage: function( name, method ) {
			var m = this.settings.messages[name];
			return m && (m.constructor == String
				? m
				: m[method]);
		},
		
		// return the first defined argument, allowing empty strings
		findDefined: function() {
			for(var i = 0; i < arguments.length; i++) {
				if (arguments[i] !== undefined)
					return arguments[i];
			}
			return undefined;
		},
		
		defaultMessage: function( element, method) {
			return this.findDefined(
				this.customMessage( element.name, method ),
				this.customMetaMessage( element, method ),
				// title is never undefined, so handle empty string as undefined
				!this.settings.ignoreTitle && element.title || undefined,
				$.validator.messages[method],
				"<strong>Warning: No message defined for " + element.name + "</strong>"
			);
		},
		
		formatAndAdd: function( element, rule ) {
			var message = this.defaultMessage( element, rule.method );
			if ( typeof message == "function" ) 
				message = message.call(this, rule.parameters, element);
			this.errorList.push({
				message: message,
				element: element
			});
			this.errorMap[element.name] = message;
			this.submitted[element.name] = message;
		},
		
		addWrapper: function(toToggle) {
			if ( this.settings.wrapper )
				toToggle.push( toToggle.parents( this.settings.wrapper ) );
			return toToggle;
		},
		
		defaultShowErrors: function() {
			for ( var i = 0; this.errorList[i]; i++ ) {
				var error = this.errorList[i];
				this.settings.highlight && this.settings.highlight.call( this, error.element, this.settings.errorClass );
				this.showLabel( error.element, error.message );
			}
			if( this.errorList.length ) {
				this.toShow.push( this.containers );
			}
			if (this.settings.success) {
				for ( var i = 0; this.successList[i]; i++ ) {
					this.showLabel( this.successList[i] );
				}
			}
			if (this.settings.unhighlight) {
				for ( var i = 0, elements = this.validElements(); elements[i]; i++ ) {
					this.settings.unhighlight.call( this, elements[i], this.settings.errorClass );
				}
			}
			this.toHide = this.toHide.not( this.toShow );
			this.hideErrors();
			this.addWrapper( this.toShow ).show();
		},
		
		validElements: function() {
			return this.currentElements.not(this.invalidElements());
		},
		
		invalidElements: function() {
			return $(this.errorList).map(function() {
				return this.element;
			});
		},
		
		showLabel: function(element, message) {
			var label = this.errorsFor( element );
			if ( label.length ) {
				// refresh error/success class
				label.removeClass().addClass( this.settings.errorClass );
			
				// check if we have a generated label, replace the message then
				label.attr("generated") && label.html(message);
			} else {
				// create label
				label = $("<" + this.settings.errorElement + "/>")
					.attr({"for":  this.idOrName(element), generated: true})
					.addClass(this.settings.errorClass)
					.html(message || "");
				if ( this.settings.wrapper ) {
					// make sure the element is visible, even in IE
					// actually showing the wrapped element is handled elsewhere
					label = label.hide().show().wrap("<" + this.settings.wrapper + ">").parent();
				}
				if ( !this.labelContainer.append(label).length )
					this.settings.errorPlacement
						? this.settings.errorPlacement(label, $(element) )
						: label.insertAfter(element);
			}
			if ( !message && this.settings.success ) {
				label.text("");
				typeof this.settings.success == "string"
					? label.addClass( this.settings.success )
					: this.settings.success( label );
			}
			this.toShow.push(label);
		},
		
		errorsFor: function(element) {
			return this.errors().filter("[@for='" + this.idOrName(element) + "']");
		},
		
		idOrName: function(element) {
			return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);
		},

		checkable: function( element ) {
			return /radio|checkbox/i.test(element.type);
		},
		
		findByName: function( name ) {
			// select by name and filter by form for performance over form.find("[name=...]")
			var form = this.currentForm;
			return $(document.getElementsByName(name)).map(function(index, element) {
				return element.form == form && element.name == name && element  || null;
			});
		},
		
		getLength: function(value, element) {
			switch( element.nodeName.toLowerCase() ) {
			case 'select':
				return $("option:selected", element).length;
			case 'input':
				if( this.checkable( element) )
					return this.findByName(element.name).filter(':checked').length;
			}
			return value.length;
		},
	
		depend: function(param, element) {
			return this.dependTypes[typeof param]
				? this.dependTypes[typeof param](param, element)
				: true;
		},
	
		dependTypes: {
			"boolean": function(param, element) {
				return param;
			},
			"string": function(param, element) {
				return !!$(param, element.form).length;
			},
			"function": function(param, element) {
				return param(element);
			}
		},
		
		optional: function(element) {
			return !$.validator.methods.required.call(this, $.trim(element.value), element) && "dependency-mismatch";
		},
		
		startRequest: function(element) {
			if (!this.pending[element.name]) {
				this.pendingRequest++;
				this.pending[element.name] = true;
			}
		},
		
		stopRequest: function(element, valid) {
			this.pendingRequest--;
			// sometimes synchronization fails, make sure pendingRequest is never < 0
			if (this.pendingRequest < 0)
				this.pendingRequest = 0;
			delete this.pending[element.name];
			if ( valid && this.pendingRequest == 0 && this.formSubmitted && this.form() ) {
				$(this.currentForm).submit();
			} else if (!valid && this.pendingRequest == 0 && this.formSubmitted) {
				$(this.currentForm).triggerHandler("invalid-form", [this]);
			}
		},
		
		previousValue: function(element) {
			return $.data(element, "previousValue") || $.data(element, "previousValue", previous = {
				old: null,
				valid: true,
				message: this.defaultMessage( element, "remote" )
			});
		}
		
	},
	
	classRuleSettings: {
		required: {required: true},
		email: {email: true},
		url: {url: true},
		date: {date: true},
		dateISO: {dateISO: true},
		dateDE: {dateDE: true},
		number: {number: true},
		numberDE: {numberDE: true},
		digits: {digits: true},
		creditcard: {creditcard: true}
	},
	
	addClassRules: function(className, rules) {
		className.constructor == String ?
			this.classRuleSettings[className] = rules :
			$.extend(this.classRuleSettings, className);
	},
	
	classRules: function(element) {
		var rules = {};
		var classes = $(element).attr('class');
		classes && $.each(classes.split(' '), function() {
			if (this in $.validator.classRuleSettings) {
				$.extend(rules, $.validator.classRuleSettings[this]);
			}
		});
		return rules;
	},
	
	attributeRules: function(element) {
		var rules = {};
		var $element = $(element);
		
		for (method in $.validator.methods) {
			var value = $element.attr(method);
			if (value) {
				rules[method] = value;
			}
		}
		
		// maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs
		if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) {
			delete rules.maxlength;
		}
		
		return rules;
	},
	
	metadataRules: function(element) {
		if (!$.metadata) return {};
		
		var meta = $.data(element.form, 'validator').settings.meta;
		return meta ?
			$(element).metadata()[meta] :
			$(element).metadata();
	},
	
	staticRules: function(element) {
		var rules = {};
		var validator = $.data(element.form, 'validator');
		if (validator.settings.rules) {
			rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {};
		}
		return rules;
	},
	
	normalizeRules: function(rules, element) {
		// handle dependency check
		$.each(rules, function(prop, val) {
			// ignore rule when param is explicitly false, eg. required:false
			if (val === false) {
				delete rules[prop];
				return;
			}
			if (val.param || val.depends) {
				var keepRule = true;
				switch (typeof val.depends) {
					case "string":
						keepRule = !!$(val.depends, element.form).length;
						break;
					case "function":
						keepRule = val.depends.call(element, element);
						break;
				}
				if (keepRule) {
					rules[prop] = val.param !== undefined ? val.param : true;
				} else {
					delete rules[prop];
				}
			}
		});
		
		// evaluate parameters
		$.each(rules, function(rule, parameter) {
			rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
		});
		
		// clean number parameters
		$.each(['minlength', 'maxlength', 'min', 'max'], function() {
			if (rules[this]) {
				rules[this] = Number(rules[this]);
			}
		});
		$.each(['rangelength', 'range'], function() {
			if (rules[this]) {
				rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
			}
		});
		
		if ($.validator.autoCreateRanges) {
			// auto-create ranges
			if (rules.min && rules.max) {
				rules.range = [rules.min, rules.max];
				delete rules.min;
				delete rules.max;
			}
			if (rules.minlength && rules.maxlength) {
				rules.rangelength = [rules.minlength, rules.maxlength];
				delete rules.minlength;
				delete rules.maxlength;
			}
		}
		
		// To support custom messages in metadata ignore rule methods titled "messages"
		if (rules.messages) {
			delete rules.messages
		}
		
		return rules;
	},
	
	// Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
	normalizeRule: function(data) {
		if( typeof data == "string" ) {
			var transformed = {};
			$.each(data.split(/\s/), function() {
				transformed[this] = true;
			});
			data = transformed;
		}
		return data;
	},
	
	// http://docs.jquery.com/Plugins/Validation/Validator/addMethod
	addMethod: function(name, method, message) {
		$.validator.methods[name] = method;
		$.validator.messages[name] = message;
		if (method.length < 3) {
			$.validator.addClassRules(name, $.validator.normalizeRule(name));
		}
	},

	methods: {

		// http://docs.jquery.com/Plugins/Validation/Methods/required
		required: function(value, element, param) {
			// check if dependency is met
			if ( !this.depend(param, element) )
				return "dependency-mismatch";
			switch( element.nodeName.toLowerCase() ) {
			case 'select':
				var options = $("option:selected", element);
				return options.length > 0 && ( element.type == "select-multiple" || ($.browser.msie && !(options[0].attributes['value'].specified) ? options[0].text : options[0].value).length > 0);
			case 'input':
				if ( this.checkable(element) )
					return this.getLength(value, element) > 0;
			default:
				return $.trim(value).length > 0;
			}
		},
		
		// http://docs.jquery.com/Plugins/Validation/Methods/remote
		remote: function(value, element, param) {
			if ( this.optional(element) )
				return "dependency-mismatch";
			
			var previous = this.previousValue(element);
			
			if (!this.settings.messages[element.name] )
				this.settings.messages[element.name] = {};
			this.settings.messages[element.name].remote = typeof previous.message == "function" ? previous.message(value) : previous.message;
			
			param = typeof param == "string" && {url:param} || param; 
			
			if ( previous.old !== value ) {
				previous.old = value;
				var validator = this;
				this.startRequest(element);
				var data = {};
				data[element.name] = value;
				$.ajax($.extend(true, {
					url: param,
					mode: "abort",
					port: "validate" + element.name,
					dataType: "json",
					data: data,
					success: function(response) {
						if ( response ) {
							var submitted = validator.formSubmitted;
							validator.prepareElement(element);
							validator.formSubmitted = submitted;
							validator.successList.push(element);
							validator.showErrors();
						} else {
							var errors = {};
							errors[element.name] =  response || validator.defaultMessage( element, "remote" );
							validator.showErrors(errors);
						}
						previous.valid = response;
						validator.stopRequest(element, response);
					}
				}, param));
				return "pending";
			} else if( this.pending[element.name] ) {
				return "pending";
			}
			return previous.valid;
		},

		// http://docs.jquery.com/Plugins/Validation/Methods/minlength
		minlength: function(value, element, param) {
			return this.optional(element) || this.getLength(value, element) >= param;
		},
		
		// http://docs.jquery.com/Plugins/Validation/Methods/maxlength
		maxlength: function(value, element, param) {
			return this.optional(element) || this.getLength(value, element) <= param;
		},
		
		// http://docs.jquery.com/Plugins/Validation/Methods/rangelength
		rangelength: function(value, element, param) {
			var length = this.getLength(value, element);
			return this.optional(element) || ( length >= param[0] && length <= param[1] );
		},
		
		// http://docs.jquery.com/Plugins/Validation/Methods/min
		min: function( value, element, param ) {
			return this.optional(element) || value >= param;
		},
		
		// http://docs.jquery.com/Plugins/Validation/Methods/max
		max: function( value, element, param ) {
			return this.optional(element) || value <= param;
		},
		
		// http://docs.jquery.com/Plugins/Validation/Methods/range
		range: function( value, element, param ) {
			return this.optional(element) || ( value >= param[0] && value <= param[1] );
		},
		
		// http://docs.jquery.com/Plugins/Validation/Methods/email
		email: function(value, element) {
			// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
			return this.optional(element) || /^(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([,.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*$\.?$/i.test(value);
			//return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);
		},
	
		// http://docs.jquery.com/Plugins/Validation/Methods/url
		url: function(value, element) {
			// contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
			return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);
		},
        
		// http://docs.jquery.com/Plugins/Validation/Methods/date
		date: function(value, element) {
			return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
		},
	
		// http://docs.jquery.com/Plugins/Validation/Methods/dateISO
		dateISO: function(value, element) {
			return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);
		},
	
		// http://docs.jquery.com/Plugins/Validation/Methods/dateDE
		dateDE: function(value, element) {
			return this.optional(element) || /^\d\d?\.\d\d?\.\d\d\d?\d?$/.test(value);
		},
	
		// http://docs.jquery.com/Plugins/Validation/Methods/number
		number: function(value, element) {
			return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);
		},
	
		// http://docs.jquery.com/Plugins/Validation/Methods/numberDE
		numberDE: function(value, element) {
			return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:\.\d{3})+)(?:,\d+)?$/.test(value);
		},
		
		// http://docs.jquery.com/Plugins/Validation/Methods/digits
		digits: function(value, element) {
			return this.optional(element) || /^\d+$/.test(value);
		},
		
		// http://docs.jquery.com/Plugins/Validation/Methods/creditcard
		// based on http://en.wikipedia.org/wiki/Luhn
		creditcard: function(value, element) {
			if ( this.optional(element) )
				return "dependency-mismatch";
			// accept only digits and dashes
			if (/[^0-9-]+/.test(value))
				return false;
			var nCheck = 0,
				nDigit = 0,
				bEven = false;

			value = value.replace(/\D/g, "");

			for (n = value.length - 1; n >= 0; n--) {
				var cDigit = value.charAt(n);
				var nDigit = parseInt(cDigit, 10);
				if (bEven) {
					if ((nDigit *= 2) > 9)
						nDigit -= 9;
				}
				nCheck += nDigit;
				bEven = !bEven;
			}

			return (nCheck % 10) == 0;
		},
		
		// http://docs.jquery.com/Plugins/Validation/Methods/accept
		accept: function(value, element, param) {
			param = typeof param == "string" ? param : "png|jpe?g|gif";
			return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i")); 
		},
		
		// http://docs.jquery.com/Plugins/Validation/Methods/equalTo
		equalTo: function(value, element, param) {
			return value == $(param).val();
		}
		
	}
	
});

})(jQuery);

// ajax mode: abort
// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort() 
;(function($) {
	var ajax = $.ajax;
	var pendingRequests = {};
	$.ajax = function(settings) {
		// create settings for compatibility with ajaxSetup
		settings = $.extend(settings, $.extend({}, $.ajaxSettings, settings));
		var port = settings.port;
		if (settings.mode == "abort") {
			if ( pendingRequests[port] ) {
				pendingRequests[port].abort();
			}
			return (pendingRequests[port] = ajax.apply(this, arguments));
		}
		return ajax.apply(this, arguments);
	};
})(jQuery);

// provides cross-browser focusin and focusout events
// IE has native support, in other browsers, use event caputuring (neither bubbles)

// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target 

// provides triggerEvent(type: String, target: Element) to trigger delegated events
;(function($) {
	$.each({
		focus: 'focusin',
		blur: 'focusout'	
	}, function( original, fix ){
		$.event.special[fix] = {
			setup:function() {
				if ( $.browser.msie ) return false;
				this.addEventListener( original, $.event.special[fix].handler, true );
			},
			teardown:function() {
				if ( $.browser.msie ) return false;
				this.removeEventListener( original,
				$.event.special[fix].handler, true );
			},
			handler: function(e) {
				arguments[0] = $.event.fix(e);
				arguments[0].type = fix;
				return $.event.handle.apply(this, arguments);
			}
		};
	});
	$.extend($.fn, {
		delegate: function(type, delegate, handler) {
			return this.bind(type, function(event) {
				var target = $(event.target);
				if (target.is(delegate)) {
					return handler.apply(target, arguments);
				}
			});
		},
		triggerEvent: function(type, target) {
			return this.triggerHandler(type, [$.event.fix({ type: type, target: target })]);
		}
	})
})(jQuery);

/**
 * jQuery Form - A jQuery form handling and validation plugin
 * 
 * @version 1.0
 * @date    2008-07-16
 * 
 * Copyright (c) 2008 Trey Shugart (shugartweb.com/jquery/)
 * 
 * Dual licensed under: 
 *  MIT - (http://www.opensource.org/licenses/mit-license.php) 
 *  GPL - (http://www.gnu.org/licenses/gpl.txt)
 */
;(function($) {
	
	$.form = {};
	$.form.handlers = {};
	$.form.handlers.errors = {};
	$.form.handlers.submit = {};
	$.form.validators = {};
	
	$.form.setHandler = function(type, name, callback) {
		$.form.handlers[type][name] = {};
		$.form.handlers[type][name] = callback;
		return $.form.handlers[type][name];
	};
	
	$.form.setErrorHandler = function(name, callback) {
		$.form.setHandler('errors', name, callback);
	};
	
	$.form.setSubmitHandler = function(name, callback) {
		$.form.setHandler('submit', name, callback);
	};
	
	/**
	 * Adds a validation callback for a certain type of field and gives
	 * it an optional default message.
	 * 
	 * @param {String} type
	 * @param {Function} callback
	 * @param {String} defaultMessage
	 * @return {Object}
	 * @chainable false
	 */
	$.form.setValidator = function(type, callback, defaultMessage) {
		$.form.validators[type] = {};
		$.form.validators[type]['validator'] = callback;
		$.form.validators[type]['message'] = defaultMessage;
		return $.form.validators[type];
	};
	
	/**
	 * Removes a validatior
	 * 
	 * @param {String} type
	 * @return {Object}
	 * @chainable false
	 */
	$.form.removeValidator = function(type) {
		$.form.validators = $($.form.validators).filter(function() {
			$(this).get(0).type !== 'type';
		});
		return $.form.validators;
	};
	
	/**
	 * Initializes the form
	 * 
	 * @param {Object} options
	 * @return {Object}
	 * @chainable true
	 */
	$.fn.form = function(options) {
		var form = $(this);
		return form.formSetOptions(options);
	};
	
	/**
	 * Shortcut for initializing and validating all in one call
	 * 
	 * @param {Object} options
	 * @return {Boolean}
	 * @chainable false
	 */
	$.fn.formValidate = function(options) {
		var form = $(this).form(options);
		form.submit(function() {
			if (!form.formIsValid()) {
				form.formHandleErrors();
				return false;
			}
			return form.formHandleSubmit();
		});
		return form;
	};
	
	$.fn.formHandleErrors = function(name) {
		var func = typeof name !== 'undefined' ? name : $(this).formGetOptions().errorHandler;
		return $.isFunction(func) ? func(this) : $.form.handlers['errors'][func](this);
	};
	
	$.fn.formHandleSubmit = function(name) {
		var func = typeof name !== 'undefined' ? name : $(this).formGetOptions().submitHandler;
		return $.isFunction(func) ? func(this) : $.form.handlers['submit'][func](this);
	};
	
	/**
	 * Returns the form of the selected object
	 * 
	 * @return {Object}
	 * @chainable
	 */
	$.fn.formGetForm = function() {
		var t = $(this);
		return t.get(0).tagName.toLowerCase() === 'form' ? t : t.parents('form:first');
	};
	
	/**
	 * Builds a form object from the specified form's fields. If arguments are
	 * passed, they are expected to be strings of each form elements name that
	 * you want to return. If the first argument is an array, then that is
	 * expected to contain all of the names of the fields you want to return.
	 * 
	 * @return {Object}
	 * @chainable true
	 */
	$.fn.formFields = function(filterBy) {
		var form = $(this);
		if (filterBy.length) {
			var selectors = [];
			$.each(filterBy, function(i, el) {
				selectors[selectors.length] = ':input[@name="' + el + '"]';
			});
			return form.find(selectors.join(', '));
		}
	};
	
	/**
	 * Sets the type of the fields in the collection. If a type already
	 * exists, this will then be an additional type. If this type exists
	 * then it will be overwritten.
	 * 
	 * @param {String} type
	 * @param {Mixed} val
	 * @return {Object}
	 * @chainable true
	 */
	$.fn.formSetType = function(str) {
		return $(this).each(function(i, field) {
			var arr = typeof str === 'string' ? [str] : str;
			$.each(arr, function(ii, type) {
				_set(field, 'type', type);
			});
		});
	};
	
	/**
	 * Removes a type from the field
	 * 
	 * @param {String} type
	 * @return {Object}
	 * @chainable true
	 */
	$.fn.formRemoveType = function(str) {
		return $(this).each(function(i, field) {
			var arr = typeof str === 'string' ? [str] : str;
			$.each(arr, function(ii, type) {
				if ($(field).formGetForm().formGetOptions)
				_remove(field, 'type', type);
			});
		});
	};
	
	/**
	 * Returns the type of a single field
	 * 
	 * @return {Array}
	 * @chainable false
	 */
	$.fn.formGetTypes = function() {
		return _get(this, 'type');
	};
	
	/**
	 * Checks to see if the passed object is a given type
	 * 
	 * @param {String} type
	 * @return {Boolean}
	 * @chainable false
	 */
	$.fn.formIsType = function(type) {
		var arr = $(this).eq(0).data('form.type');
		return typeof arr !== 'undefined' && $.inArray(type, arr) !== -1;
	};
	
	/**
	 * Filters removes any fields that don't match the given type
	 * 
	 * @param {String} type
	 * @return {Object}
	 * @chainable true
	 */
	$.fn.formFilterByType = function(type) {
		return $(this).filter(function() {
			return $(this).isType(type);
		});
	};
	
	/**
	 * Retrieves all error messages associated with the specified form and returns
	 * an array.
	 * 
	 * @return {Array} - Array of Objects that contain the field object and error message
	 * @chainable false
	 */
	$.fn.formGetErrors = function() {
		var errors = [];
		$(this).find(':input').each(function(i, field) {
			var fieldErrors = $(field).formFieldGetErrors();
			if (typeof fieldErrors !== 'undefined') {
				$.each(fieldErrors, function(ii, error) {
					errors[errors.length] = {
						field: field,
						error: error
					};
				});
			}
		});
		return errors;
	};
	
	$.fn.formHasErrors = function() {
		return $(this).formGetErrors().length > 0 ? true : false;
	};
	
	/**
	 * Retrieves all error messages associated with a specific field
	 */
	$.fn.formFieldGetErrors = function() {
		var e = _get(this, 'errors');
		return typeof e === 'undefined' ? [] : e;
	};
	
	$.fn.formFieldHasErrors = function() {
		return $(this).formFieldGetErrors.length > 0 ? true : false;
	};
	
	/**
	 * Sets an error message for an object and it's specific type
	 * 
	 * @param {String} type
	 * @param {String} message
	 * @return {Object}
	 * @chainable true
	 */
	$.fn.formSetErrorMessage = function(type, message) {
		return _set($(this).get(0), 'errorMessages.' + type, message);
	};
	
	/**
	 * Retrieves error messages for a given type on the given object
	 * 
	 * @param {String} type
	 * @chainable false
	 */
	$.fn.formGetErrorMessages = function(type) {
		var field = $(this).eq(0);
		// messages are defined manually using .formSetErrorMessage, in the 
		// element's title attribute, or by using the default message supplied
		// by the validator
		var msg = _get(field, 'errorMessages.' + type),
			msg = typeof msg !== 'undefined' && msg !== '' ? msg : field.formGetOptions().useTitleAsError ? field.attr('title') : undefined,
			msg = typeof msg !== 'undefined' && msg !== '' ? msg : $.form.validators[ii].message;
		return msg;
	};
	
	/**
	 * Removes error messages for a given type on the given object
	 * 
	 * @param {String} type
	 * @chainable true
	 */
	$.fn.formRemoveErrorMessages = function(type) {
		return $(this).eq(0).removeData('errorMessages.' + type);
	};
	
	/**
	 * Checks to see if a form element is valid but only of the specified type
	 * 
	 * @param {Object} type
	 * @return {Boolean}
	 * @chainable false
	 */
	$.fn.formIs = function(type) {
		if (typeof $.form.validators[type] !== 'undefined') {
			var form = $(this).formGetForm();
			var o = form.formGetOptions();
			return $.form.validators[type].validator(form.get(0), this);
		}
		return true;
	};
	
	/**
	 * Checks to see if a form or specific fields are valid
	 * 
	 * @return {Boolean}
	 * @chainable false
	 */
	$.fn.formIsValid = function() {
		var errors = 0;
		var form = $(this).formGetForm();
		var options = form.formGetOptions();
		var fields = form.formFields();
		// check types and classes against validators
		fields.filter(options.filter).each(function(i, field) {
			$(field).removeData('form.errors');
			var curerrors = 0;
			for (ii in $.form.validators) {
				if ((form.formGetOptions().useClassAsType && $(field).hasClass(ii)) || $(field).formIsType(ii)) {
					if (!$(field).formIs(ii)) {
						var msg = $(field).formGetErrorMessages(ii);
						_set(field, 'errors', msg);
						curerrors++;
						errors++;
					}
				}
			}
		});
		// check dependencies if the current field is valid
		fields.each(function(i, field) {
			var dependencies = $(field).formGetDependencies();
			if (typeof dependencies !== 'undefined' && $(field).formFieldGetErrors().length === 0) {
				$.each(dependencies, function(ii, dependency) {
					if ($.isFunction(dependency.callback) && !dependency.callback(form.get(0), field)) {
						var msg = typeof dependency.errorMessage !== 'undefined' ? dependency.errorMessage : $(field).formGetErrorMessages(ii);
						_set(field, 'errors', msg);
						errors++;
					}
				});
			}
		});
		return errors === 0 ? true : false;
	};
	
	
	
	// DEPENDENCIES
	
	/**
	 * Sets a dependency callback (or callbacks) to be executed when and if the specified object
	 * passes all previous validation rules.
	 * 
	 * @param {Function} fn
	 * @param {String} msg
	 * @return {Object}
	 * @chainable true
	 */
	$.fn.formSetDependency = function(fn, msg) {
		return $(this).each(function(i, field) {
			_set(field, 'dependencies', {callback: fn, errorMessage: msg});
		});
	};
	
	/**
	 * Removes a dependency callback from an object
	 * 
	 * @param {Function} fn
	 * @return {Object}
	 * @chainable true
	 */
	$.fn.formRemoveDependency = function(fn) {
		return $(this).each(function(i, field) {
			if (typeof fn === 'undefined') {
				$(field).removeData('form.dependencies');
			} else {
				_remove(field, 'dependencies', fn);
			}
		});
	};
	
	/**
	 * Returns all dependency callbacks for an object as a an array
	 * 
	 * @return {Array}
	 * @chainable false
	 */
	$.fn.formGetDependencies = function() {
		return _get(this, 'dependencies');
	};
	
	
	
	// OPTIONS
	
	/**
	 * Returns the options for the form, or field's parent form
	 * 
	 * @return {Object}
	 * @chainable false
	 */
	$.fn.formGetOptions = function() {
		var f = $(this).formGetForm();
		return f.data('form.options');
	};
	
	/**
	 * Sets options for the form, or field's parent form
	 * 
	 * @param {Object} options
	 * @return {Object}
	 * @chainable true
	 */
	$.fn.formSetOptions = function(o) {
		var f = $(this).formGetForm();
		var currentOptions = typeof f.formGetOptions() !== 'undefined' ? o : {
			useClassAsType: true,
			useTitleAsError: true,
			filter: ':enabled',
			errorHandler: function() {},
			submitHandler: function() {},
			ignoreSelector: '.example-field',
			dateFormat: 'Y/m/d'
		};
		return f.data('form.options', $.extend(currentOptions, o));
	};
	
	
	
	// INTERNALS
	
	function _set(el, key, val) {
		return $(el).each(function(index, field) {
			var $field = $(field);
			var c = $field.data('form.' + key);
			c = typeof c === 'undefined' ? [] : c;
			c[c.length] = val;
			$field.data('form.' + key, c);
		});
	};
	
	function _remove(el, key, val) {
		return $(el).each(function(index, field) {
			var $field = $(field);
			var currentTypes = $field.data('form.' + key);
			if (typeof currentTypes === 'object') {
				var filtered = currentTypes.filter(function(t, i, arr) {
					return t !== val;
				});
				$field.data('form.' + key, filtered);
			}
		});
	};
	
	function _get(el, key) {
		return $(el).eq(0).data('form.' + key);
	};
	
	
	
	// BUILT IN VALIDATION METHODS
	
	$.form.setValidator('required', function(form, field) {
		var $form  = $(form),
			$field = $(field);
		if ($field.is($form.formGetOptions().ignoreSelector))
			return false;
		if (/^\s*$/g.test(($field.val() || '').toString()))
			return false;
		if ($field.is(':checkbox') && !$field.is(':checked'))
			return false;
		return true;
	}, 'This field is required');
	
	$.form.setValidator('email', function(form, field) {
		var $form  = $(form),
			$field = $(field);
		return 
			$field.is($form.formGetOptions().ignoreSelector)
			|| $field.val() === '' 
			|| /[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-\.]+\.[a-zA-Z]+/.test($field.val());
	}, 'Please enter a valid email address');
	
	/**
	 * Checks to see if the value is a number
	 */
	$.form.setValidator('number', function(form, field) {
		var $field = $(field);
		return $field.val() === '' || /\d/.test($field.val());
	}, 'Value must contain a number');
	
	/**
	 * Validates a minimum value
	 */
	$.form.setValidator('min', function(form, field) {
		var $field = $(field);
		var val = parseFloat(($field.val() || '').toString().replace(/[^\.^\-\d]/g, '') || 0);
		var min = $field.data('form.validators.min.min');
		min = parseFloat(typeof min === 'number' ? min : $(min).val());
		return val >= min;
	}, 'Value is too small');
	
	/**
	 * Validates a maximum value
	 */
	$.form.setValidator('max', function(form, field) {
		var $field = $(field);
		var val = parseFloat(($field.val() || '').toString().replace(/[^\.^\-\d]/g, '') || 0);
		var max = $field.data('form.valiators.max.max');
		max = parseFloat(typeof max === 'number' ? max : $(max).val());
		return val <= max;
	}, 'Value is to large');

})(jQuery);
(function(C){C.ui=C.ui||{};C.extend(C.ui,{plugin:{add:function(E,F,H){var G=C.ui[E].prototype;for(var D in H){G.plugins[D]=G.plugins[D]||[];G.plugins[D].push([F,H[D]])}},call:function(D,E,G){var H=D.plugins[E];if(!H){return }for(var F=0;F<H.length;F++){if(D.options[H[F][0]]){H[F][1].apply(D.element,G)}}}},cssCache:{},css:function(D){if(C.ui.cssCache[D]){return C.ui.cssCache[D]}var E=C('<div class="ui-resizable-gen">').addClass(D).css({position:"absolute",top:"-5000px",left:"-5000px",display:"block"}).appendTo("body");C.ui.cssCache[D]=!!((!/auto|default/.test(E.css("cursor"))||(/^[1-9]/).test(E.css("height"))||(/^[1-9]/).test(E.css("width"))||!(/none/).test(E.css("backgroundImage"))||!(/transparent|rgba\(0, 0, 0, 0\)/).test(E.css("backgroundColor"))));try{C("body").get(0).removeChild(E.get(0))}catch(F){}return C.ui.cssCache[D]},disableSelection:function(D){D.unselectable="on";D.onselectstart=function(){return false};if(D.style){D.style.MozUserSelect="none"}},enableSelection:function(D){D.unselectable="off";D.onselectstart=function(){return true};if(D.style){D.style.MozUserSelect=""}},hasScroll:function(G,E){var D=/top/.test(E||"top")?"scrollTop":"scrollLeft",F=false;if(G[D]>0){return true}G[D]=1;F=G[D]>0?true:false;G[D]=0;return F}});C.each(["Left","Top"],function(E,D){if(!C.fn["scroll"+D]){C.fn["scroll"+D]=function(F){return F!=undefined?this.each(function(){this==window||this==document?window.scrollTo(D=="Left"?F:C(window)["scrollLeft"](),D=="Top"?F:C(window)["scrollTop"]()):this["scroll"+D]=F}):this[0]==window||this[0]==document?self[(D=="Left"?"pageXOffset":"pageYOffset")]||C.boxModel&&document.documentElement["scroll"+D]||document.body["scroll"+D]:this[0]["scroll"+D]}}});var B=C.fn.remove;C.fn.extend({position:function(){var F=this.offset();var E=this.offsetParent();var D=E.offset();return{top:F.top-A(this[0],"marginTop")-D.top-A(E,"borderTopWidth"),left:F.left-A(this[0],"marginLeft")-D.left-A(E,"borderLeftWidth")}},offsetParent:function(){var D=this[0].offsetParent;while(D&&(!/^body|html$/i.test(D.tagName)&&C.css(D,"position")=="static")){D=D.offsetParent}return C(D)},mouseInteraction:function(D){return this.each(function(){new C.ui.mouseInteraction(this,D)})},removeMouseInteraction:function(D){return this.each(function(){if(C.data(this,"ui-mouse")){C.data(this,"ui-mouse").destroy()}})},remove:function(){jQuery("*",this).add(this).trigger("remove");return B.apply(this,arguments)}});function A(D,E){return parseInt(C.curCSS(D.jquery?D[0]:D,E,true))||0}C.ui.mouseInteraction=function(F,E){var D=this;this.element=F;C.data(this.element,"ui-mouse",this);this.options=C.extend({},E);C(F).bind("mousedown.draggable",function(){return D.click.apply(D,arguments)});if(C.browser.msie){C(F).attr("unselectable","on")}C(F).mouseup(function(){if(D.timer){clearInterval(D.timer)}})};C.extend(C.ui.mouseInteraction.prototype,{destroy:function(){C(this.element).unbind("mousedown.draggable")},trigger:function(){return this.click.apply(this,arguments)},click:function(F){if(F.which!=1||C.inArray(F.target.nodeName.toLowerCase(),this.options.dragPrevention||[])!=-1||(this.options.condition&&!this.options.condition.apply(this.options.executor||this,[F,this.element]))){return true}var E=this;var D=function(){E._MP={left:F.pageX,top:F.pageY};C(document).bind("mouseup.draggable",function(){return E.stop.apply(E,arguments)});C(document).bind("mousemove.draggable",function(){return E.drag.apply(E,arguments)});if(!E.initalized&&Math.abs(E._MP.left-F.pageX)>=E.options.distance||Math.abs(E._MP.top-F.pageY)>=E.options.distance){if(E.options.start){E.options.start.call(E.options.executor||E,F,E.element)}if(E.options.drag){E.options.drag.call(E.options.executor||E,F,this.element)}E.initialized=true}};if(this.options.delay){if(this.timer){clearInterval(this.timer)}this.timer=setTimeout(D,this.options.delay)}else{D()}return false},stop:function(D){var E=this.options;if(!this.initialized){return C(document).unbind("mouseup.draggable").unbind("mousemove.draggable")}if(this.options.stop){this.options.stop.call(this.options.executor||this,D,this.element)}C(document).unbind("mouseup.draggable").unbind("mousemove.draggable");this.initialized=false;return false},drag:function(D){var E=this.options;if(C.browser.msie&&!D.button){return this.stop.apply(this,[D])}if(!this.initialized&&(Math.abs(this._MP.left-D.pageX)>=E.distance||Math.abs(this._MP.top-D.pageY)>=E.distance)){if(this.options.start){this.options.start.call(this.options.executor||this,D,this.element)}this.initialized=true}else{if(!this.initialized){return false}}if(E.drag){E.drag.call(this.options.executor||this,D,this.element)}return false}})})(jQuery);
(function(A){A.fn.tabs=function(){var C=typeof arguments[0]=="string"&&arguments[0];var B=C&&Array.prototype.slice.call(arguments,1)||arguments;return C=="length"?A.data(this[0],"tabs").$tabs.length:this.each(function(){if(C){var D=A.data(this,"tabs");if(D){D[C].apply(D,B)}}else{new A.ui.tabs(this,B[0]||{})}})};A.ui.tabs=function(D,C){var B=this;this.options=A.extend({},A.ui.tabs.defaults,C);this.element=D;if(C.selected===null){this.options.selected=null}this.options.event+=".tabs";A(D).bind("setData.tabs",function(F,E,G){if((/^selected/).test(E)){B.select(G)}else{B.options[E]=G;B.tabify()}}).bind("getData.tabs",function(F,E){return B.options[E]});A.data(D,"tabs",this);this.tabify(true)};A.ui.tabs.defaults={selected:0,unselect:false,event:"click",disabled:[],cookie:null,spinner:"Loading&#8230;",cache:false,idPrefix:"ui-tabs-",ajaxOptions:{},fx:null,tabTemplate:'<li><a href="#{href}"><span>#{label}</span></a></li>',panelTemplate:"<div></div>",navClass:"ui-tabs-nav",selectedClass:"ui-tabs-selected",unselectClass:"ui-tabs-unselect",disabledClass:"ui-tabs-disabled",panelClass:"ui-tabs-panel",hideClass:"ui-tabs-hide",loadingClass:"ui-tabs-loading"};A.extend(A.ui.tabs.prototype,{tabId:function(B){return B.title&&B.title.replace(/\s/g,"_").replace(/[^A-Za-z0-9\-_:\.]/g,"")||this.options.idPrefix+A.data(B)},ui:function(C,B){return{instance:this,options:this.options,tab:C,panel:B}},tabify:function(N){this.$lis=A("li:has(a[href])",this.element);this.$tabs=this.$lis.map(function(){return A("a",this)[0]});this.$panels=A([]);var O=this,E=this.options;this.$tabs.each(function(Q,P){if(P.hash&&P.hash.replace("#","")){O.$panels=O.$panels.add(P.hash)}else{if(A(P).attr("href")!="#"){A.data(P,"href.tabs",P.href);A.data(P,"load.tabs",P.href);var S=O.tabId(P);P.href="#"+S;var R=A("#"+S);if(!R.length){R=A(E.panelTemplate).attr("id",S).addClass(E.panelClass).insertAfter(O.$panels[Q-1]||O.element);R.data("destroy.tabs",true)}O.$panels=O.$panels.add(R)}else{E.disabled.push(Q+1)}}});if(N){A(this.element).hasClass(E.navClass)||A(this.element).addClass(E.navClass);this.$panels.each(function(){var P=A(this);P.hasClass(E.panelClass)||P.addClass(E.panelClass)});this.$tabs.each(function(S,P){if(location.hash){if(P.hash==location.hash){E.selected=S;if(A.browser.msie||A.browser.opera){var R=A(location.hash),T=R.attr("id");R.attr("id","");setTimeout(function(){R.attr("id",T)},500)}scrollTo(0,0);return false}}else{if(E.cookie){var Q=parseInt(A.cookie("ui-tabs"+A.data(O.element)),10);if(Q&&O.$tabs[Q]){E.selected=Q;return false}}else{if(O.$lis.eq(S).hasClass(E.selectedClass)){E.selected=S;return false}}}});this.$panels.addClass(E.hideClass);this.$lis.removeClass(E.selectedClass);if(E.selected!==null){this.$panels.eq(E.selected).show().removeClass(E.hideClass);this.$lis.eq(E.selected).addClass(E.selectedClass)}var D=E.selected!==null&&A.data(this.$tabs[E.selected],"load.tabs");if(D){this.load(E.selected)}E.disabled=A.unique(E.disabled.concat(A.map(this.$lis.filter("."+E.disabledClass),function(Q,P){return O.$lis.index(Q)}))).sort();A(window).bind("unload",function(){O.$tabs.unbind(".tabs");O.$lis=O.$tabs=O.$panels=null})}for(var H=0,M;M=this.$lis[H];H++){A(M)[A.inArray(H,E.disabled)!=-1&&!A(M).hasClass(E.selectedClass)?"addClass":"removeClass"](E.disabledClass)}if(E.cache===false){this.$tabs.removeData("cache.tabs")}var C,J,B={"min-width":0,duration:1},F="normal";if(E.fx&&E.fx.constructor==Array){C=E.fx[0]||B,J=E.fx[1]||B}else{C=J=E.fx||B}var I={display:"",overflow:"",height:""};if(!A.browser.msie){I.opacity=""}function L(Q,P,R){P.animate(C,C.duration||F,function(){P.addClass(E.hideClass).css(I);if(A.browser.msie&&C.opacity){P[0].style.filter=""}if(R){K(Q,R,P)}})}function K(Q,R,P){if(J===B){R.css("display","block")}R.animate(J,J.duration||F,function(){R.removeClass(E.hideClass).css(I);if(A.browser.msie&&J.opacity){R[0].style.filter=""}A(O.element).triggerHandler("tabsshow",[O.ui(Q,R[0])],E.show)})}function G(Q,S,P,R){S.addClass(E.selectedClass).siblings().removeClass(E.selectedClass);L(Q,P,R)}this.$tabs.unbind(".tabs").bind(E.event,function(){var S=A(this).parents("li:eq(0)"),P=O.$panels.filter(":visible"),R=A(this.hash);if((S.hasClass(E.selectedClass)&&!E.unselect)||S.hasClass(E.disabledClass)||A(this).hasClass(E.loadingClass)||A(O.element).triggerHandler("tabsselect",[O.ui(this,R[0])],E.select)===false){this.blur();return false}O.options.selected=O.$tabs.index(this);if(E.unselect){if(S.hasClass(E.selectedClass)){O.options.selected=null;S.removeClass(E.selectedClass);O.$panels.stop();L(this,P);this.blur();return false}else{if(!P.length){O.$panels.stop();var Q=this;O.load(O.$tabs.index(this),function(){S.addClass(E.selectedClass).addClass(E.unselectClass);K(Q,R)});this.blur();return false}}}if(E.cookie){A.cookie("ui-tabs"+A.data(O.element),O.options.selected,E.cookie)}O.$panels.stop();if(R.length){var Q=this;O.load(O.$tabs.index(this),P.length?function(){G(Q,S,P,R)}:function(){S.addClass(E.selectedClass);K(Q,R)})}else{throw"jQuery UI Tabs: Mismatching fragment identifier."}if(A.browser.msie){this.blur()}return false});if(!(/^click/).test(E.event)){this.$tabs.bind("click.tabs",function(){return false})}},add:function(E,D,C){if(C==undefined){C=this.$tabs.length}var G=this.options;var I=A(G.tabTemplate.replace(/#\{href\}/,E).replace(/#\{label\}/,D));I.data("destroy.tabs",true);var H=E.indexOf("#")==0?E.replace("#",""):this.tabId(A("a:first-child",I)[0]);var F=A("#"+H);if(!F.length){F=A(G.panelTemplate).attr("id",H).addClass(G.panelClass).addClass(G.hideClass);F.data("destroy.tabs",true)}if(C>=this.$lis.length){I.appendTo(this.element);F.appendTo(this.element.parentNode)}else{I.insertBefore(this.$lis[C]);F.insertBefore(this.$panels[C])}G.disabled=A.map(G.disabled,function(K,J){return K>=C?++K:K});this.tabify();if(this.$tabs.length==1){I.addClass(G.selectedClass);F.removeClass(G.hideClass);var B=A.data(this.$tabs[0],"load.tabs");if(B){this.load(C,B)}}A(this.element).triggerHandler("tabsadd",[this.ui(this.$tabs[C],this.$panels[C])],G.add)},remove:function(B){var D=this.options,E=this.$lis.eq(B).remove(),C=this.$panels.eq(B).remove();if(E.hasClass(D.selectedClass)&&this.$tabs.length>1){this.select(B+(B+1<this.$tabs.length?1:-1))}D.disabled=A.map(A.grep(D.disabled,function(G,F){return G!=B}),function(G,F){return G>=B?--G:G});this.tabify();A(this.element).triggerHandler("tabsremove",[this.ui(E.find("a")[0],C[0])],D.remove)},enable:function(B){var C=this.options;if(A.inArray(B,C.disabled)==-1){return }var D=this.$lis.eq(B).removeClass(C.disabledClass);if(A.browser.safari){D.css("display","inline-block");setTimeout(function(){D.css("display","block")},0)}C.disabled=A.grep(C.disabled,function(F,E){return F!=B});A(this.element).triggerHandler("tabsenable",[this.ui(this.$tabs[B],this.$panels[B])],C.enable)},disable:function(C){var B=this,D=this.options;if(C!=D.selected){this.$lis.eq(C).addClass(D.disabledClass);D.disabled.push(C);D.disabled.sort();A(this.element).triggerHandler("tabsdisable",[this.ui(this.$tabs[C],this.$panels[C])],D.disable)}},select:function(B){if(typeof B=="string"){B=this.$tabs.index(this.$tabs.filter("[href$="+B+"]")[0])}this.$tabs.eq(B).trigger(this.options.event)},load:function(F,K){var L=this,C=this.options,D=this.$tabs.eq(F),J=D[0],G=K==undefined||K===false,B=D.data("load.tabs");K=K||function(){};if(!B||(A.data(J,"cache.tabs")&&!G)){K();return }if(C.spinner){var H=A("span",J);H.data("label.tabs",H.html()).html("<em>"+C.spinner+"</em>")}var I=function(){L.$tabs.filter("."+C.loadingClass).each(function(){A(this).removeClass(C.loadingClass);if(C.spinner){var M=A("span",this);M.html(M.data("label.tabs")).removeData("label.tabs")}});L.xhr=null};var E=A.extend({},C.ajaxOptions,{url:B,success:function(N,M){A(J.hash).html(N);I();K();if(C.cache){A.data(J,"cache.tabs",true)}A(L.element).triggerHandler("tabsload",[L.ui(L.$tabs[F],L.$panels[F])],C.load);C.ajaxOptions.success&&C.ajaxOptions.success(N,M)}});if(this.xhr){this.xhr.abort();I()}D.addClass(C.loadingClass);setTimeout(function(){L.xhr=A.ajax(E)},0)},url:function(C,B){this.$tabs.eq(C).removeData("cache.tabs").data("load.tabs",B)},destroy:function(){var B=this.options;A(this.element).unbind(".tabs").removeClass(B.navClass).removeData("tabs");this.$tabs.each(function(){var C=A.data(this,"href.tabs");if(C){this.href=C}var D=A(this).unbind(".tabs");A.each(["href","load","cache"],function(E,F){D.removeData(F+".tabs")})});this.$lis.add(this.$panels).each(function(){if(A.data(this,"destroy.tabs")){A(this).remove()}else{A(this).removeClass([B.selectedClass,B.unselectClass,B.disabledClass,B.panelClass,B.hideClass].join(" "))}})}});A.extend(A.ui.tabs.prototype,{rotation:null,rotate:function(C,F){F=F||false;var B=this,E=this.options.selected;function G(){B.rotation=setInterval(function(){E=++E<B.$tabs.length?E:0;B.select(E)},C)}function D(H){if(!H||H.clientX){clearInterval(B.rotation)}}if(C){G();if(!F){this.$tabs.bind(this.options.event,D)}else{this.$tabs.bind(this.options.event,function(){D();E=B.options.selected;G()})}}else{D();this.$tabs.unbind(this.options.event,D)}}})})(jQuery);
/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Date: 2/19/2008
 * @author Ariel Flesler
 * @version 1.3.3
 */
;(function($){var o=$.scrollTo=function(a,b,c){o.window().scrollTo(a,b,c)};o.defaults={axis:'y',duration:1};o.window=function(){return $($.browser.safari?'body':'html')};$.fn.scrollTo=function(l,m,n){if(typeof m=='object'){n=m;m=0}n=$.extend({},o.defaults,n);m=m||n.speed||n.duration;n.queue=n.queue&&n.axis.length>1;if(n.queue)m/=2;n.offset=j(n.offset);n.over=j(n.over);return this.each(function(){var a=this,b=$(a),t=l,c,d={},w=b.is('html,body');switch(typeof t){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(t)){t=j(t);break}t=$(t,this);case'object':if(t.is||t.style)c=(t=$(t)).offset()}$.each(n.axis.split(''),function(i,f){var P=f=='x'?'Left':'Top',p=P.toLowerCase(),k='scroll'+P,e=a[k],D=f=='x'?'Width':'Height';if(c){d[k]=c[p]+(w?0:e-b.offset()[p]);if(n.margin){d[k]-=parseInt(t.css('margin'+P))||0;d[k]-=parseInt(t.css('border'+P+'Width'))||0}d[k]+=n.offset[p]||0;if(n.over[p])d[k]+=t[D.toLowerCase()]()*n.over[p]}else d[k]=t[p];if(/^\d+$/.test(d[k]))d[k]=d[k]<=0?0:Math.min(d[k],h(D));if(!i&&n.queue){if(e!=d[k])g(n.onAfterFirst);delete d[k]}});g(n.onAfter);function g(a){b.animate(d,m,n.easing,a&&function(){a.call(this,l)})};function h(D){var b=w?$.browser.opera?document.body:document.documentElement:a;return b['scroll'+D]-b['client'+D]}})};function j(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
var DATACARD={navigation_delay:45,navigation_scaling:150,tabIds:[],init:function(){$(".tabs .tabs-nav").tabs();DATACARD.expandableContents();DATACARD.updateProductsNumbers();DATACARD.sidebarPromo();DATACARD.formFieldsFocus();DATACARD.lastTabWidth();DATACARD.topSearch();DATACARD.navigation();DATACARD.checkBrowseProductsTab();DATACARD.setTabLinks();DATACARD.designASolutionHelp();DATACARD.clickable();DATACARD.checkAutoCompleteLength();$.browser.msie&&DATACARD.fixIE6flicker(true);$("a.anchor").remove().prependTo("body")},checkAutoCompleteLength:function(){$("#autocompletesubmit").click(function(){if($("#suggest1").attr("value").length<2||$("#suggest1").attr("value")=="Enter Product Name or Number"){alert("Please select a valid product name or number");return false}})},setTabLinks:function(){$("a.tab-link").click(function(){document.location=$(this).attr("href");DATACARD.checkBrowseProductsTab()})},expandableContents:function(){var scrolling_duration=40,scrolling_offset=-20,expanding_duration=100,collapsing_all_duration=100;$(".expandable h2 a,.tabs-products .top-nav li a, .panel1 .list1 a, .panel1 .list2 a").not(".home").click(function(){var link=$(this),id=link.attr("href").replace("#",""),id_array=link.attr("href").split("#");if(id.length>0)id=id_array[1];var expandable=$("#"+id),is_closed=expandable.hasClass("expandable-closed"),expandable_inner=expandable.find(".expandable-inner");$(".tabs-products .top-nav li a").removeClass("current");var expandableHeader=$("#"+id+"Header");if(is_closed){expandableHeader.addClass("current");$(".expandable-inner").parent().addClass("expandable-closed");$(".expandable-inner").slideUp(collapsing_all_duration);expandable_inner.slideDown(expanding_duration);expandable.removeClass("expandable-closed")}else{expandableHeader.removeClass("current");$(".expandable-inner").parent().addClass("expandable-closed");$(".expandable-inner").slideUp(collapsing_all_duration);expandable.addClass("expandable-closed")}return false});$(".instructions-expandable h2 a").click(function(){var link=$(this),expandable=$(link).parents(".instructions-expandable"),expandable_inner=expandable.find(".instructions-expandable-inner"),is_closed=expandable.hasClass("instructions-expandable-closed");if(is_closed)if($.browser.opera){expandable_inner.slideDown(expanding_duration);expandable.removeClass("instructions-expandable-closed")}else $.scrollTo(link,scrolling_duration,{offset:scrolling_offset,onAfter:function(){expandable_inner.slideDown(expanding_duration);expandable.removeClass("instructions-expandable-closed")}});else expandable_inner.slideUp(expanding_duration,function(){expandable.addClass("instructions-expandable-closed")});return false});$(".expandable .view-all a").click(function(){var id=$(this).parents(".expandable").attr("id"),expandable=$("#"+id),additional_products=expandable.find(".additional-products");if($.browser.opera)additional_products.slideDown(expanding_duration,function(){expandable.find(".view-all").slideUp(expanding_duration)});else $.scrollTo($(expandable),scrolling_duration,{offset:scrolling_offset,onAfter:function(){additional_products.slideDown(expanding_duration,function(){expandable.find(".view-all").slideUp(expanding_duration)})}});return false})},updateProductsNumbers:function(){$(".expandable").each(function(i){var number;if($(this).find(".product").length)number=$(this).find(".product").length;else number=$(this).find(".item").length;$(this).find(".number").text(number)})},sidebarPromo:function(){$("img.next").bind("click",function(){$("div.selected").fadeOut("fast");$("div.selected").next().fadeIn("slow");$("div.selected").removeClass("selected").next().addClass("selected")});$("img.prev").bind("click",function(){$("div.selected").fadeOut("fast");$("div.selected").prev().fadeIn("slow");$("div.selected").removeClass("selected").prev().addClass("selected")})},lastTabWidth:function(){var tabs_width=0;$(".tabs-nav > li").each(function(i){tabs_width+=$(this).width()});if(tabs_width<669){var padding_right=17+(669-tabs_width);$(".tabs-nav #last-tab a").css("padding-right",padding_right)}},formFieldsFocus:function(){if($("body").hasClass("dealer-form")==false){$(":text:not(.search-text)").addClass("text-input");$("select").focus(function(){$(this).addClass("focus")});$(":text:not(.search-text), textarea").each(function(i){var initial_value=$(this).attr("value");$(this).focus(function(){$(this).addClass("focus");$(this).attr("value")===initial_value&&$(this).attr("value","")})});$(":text, select, textarea").blur(function(){$(this).removeClass("focus")})}},topSearch:function(){$("#top-tools-search .search-text").focus(function(){$(this).addClass("search-focus");$(this).attr("value","")})},navigation:function(){$("#nav > li, .top-tools #tool1, .top-tools #tool2, .top-tools #country-select").hoverIntent({sensitivity:7,interval:DATACARD.navigation_delay,over:expand,timeout:0,out:collapse});function expand(){var panel=$(this).find(".panel");panel.find("iframe").height(panel.height());panel.css("z-index",150);$(this).addClass("hover");panel.slideDown(DATACARD.navigation_scaling)}function collapse(){var panel=$(this).find(".panel");panel.css("z-index",100);panel.slideUp(DATACARD.navigation_scaling,function(){$(this).parent().removeClass("hover")})}},designASolutionHelp:function(){$(".design-solution #top-radio a.help").hover(function(){$(".design-solution #top-radio .balloon").parent().css("z-index",14000);$(this).parent().children(".balloon").fadeIn("250")},function(){$(this).parent().css("z-index",0);$(this).children().css("z-index",0);$(this).parent().children(".balloon").fadeOut("100")});$(".design-solution a.help").hover(function(){$(this).parent().children(".balloon").fadeIn("250")},function(){$(this).parent().children(".balloon").fadeOut("100")})},fixIE6flicker:function(fix){try{document.execCommand("BackgroundImageCache",false,fix)}catch(err){}},clickable:function(){var url=window.location,anchor=url.hash,anchor2=url.hash.substring(1);$(".clickable").click(function(){window.location=$(this).attr("href");if(anchor=="#applications"){$("#applicationsSubNav").show();$("#applicationsTab").click()}if(anchor=="#industry-topics"){$("#industrytopicsSubNav").show();$("#industryTopicsTab").click()}event.preventDefault();return false});if(anchor=="#industry-topics"||anchor=="#case-studies"||anchor=="#why-datacard"||anchor=="#white-papers"){$("#applicationsSubNav").hide();$("#industrytopicsSubNav").show();$(".subTabContent").show()}(anchor==""||anchor=="#overview")&&$(".subTabContent").show();if(anchor=="#applications"){$("#industrytopicsSubNav").hide();$("#applicationsSubNav").show();$(".subTabContent").show()}$("#financialTabs #industryTopicsTab").click(function(){$("#industrytopicsSubNav").show();$("#applicationsSubNav").hide();$("#relatedProductsContent").hide()});$("#financialTabs #applicationsTab").click(function(){$("#applicationsSubNav").show();$("#industrytopicsSubNav").hide();$("#relatedProductsContent").hide()});$("#financialTabs #overviewTab,#financialTabs #caseStudiesTab,#financialTabs #whitePapersTab,#financialTabs #whyDatacardTab").click(function(){$("#relatedProductsContent").hide();$(".tabs-subnav").hide()});$("#financialTabs #related-products-id").click(function(){$(".subTabContent").hide();$("#relatedProductsContent").show()});$("#financialTabs .back-to-applications").click(function(){$(".subTabContent").show();$("#relatedProductsContent").hide()});$("#financialTabs #applicationsTab,#financialTabs #whyDatacardTab,#financialTabs #overviewTab,#financialTabs #caseStudiesTab,#financialTabs #whitePapersTab,#financialTabs #whyDatacardTab").click(function(){$(".subTabContent").show()});$("#marketTabs #related-products-id").click(function(){$("#applications").hide();var applicationTitle=$(this).attr("href").split("#");$(".back-to-related-products-link").html(applicationTitle[1]);$("#related-products").show()});$("#marketTabs .back-to-applications").click(function(){$("#related-products").hide();$("#applications").show();$("#applicationsTab").click()});anchor=="#market-drivers"&&$("#marketDriversTab").click()},rollovers:function(){$(".rollover").hover(function(){var rollover_src=$(this).attr("src").replace(/.png/,"_over.png");if($.browser.msie)$(this).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+rollover_src+"', sizingMethod='scale');");else $(this).attr("src",rollover_src)},function(){$(this).attr("src",$(this).attr("src").replace(/_over.png/,".png"))})},preloadImages:function(images){for(var i=0;i<images.length;i++){var image=new Image;image.src="/"+images[i]}},checkBrowseProductsTab:function(){var loc=document.location.toString(),start_index=loc.indexOf("#"),end_index=loc.length;if(start_index>-1){var anchor_text=loc.substring(start_index,end_index),numTabIds=DATACARD.tabIds.length,isMatch=false,isMatchTabIndex=0,browseAllRegex=new RegExp("browse-all"),isBrowseAllLink=browseAllRegex.test(anchor_text);if(isBrowseAllLink){var minMSIEVersion=8,uBrowser,uVersion;jQuery.each(jQuery.browser,function(i,val){if(i=="msie"&&val==true)uBrowser=i;else if(i=="mozilla"&&val==true)uBrowser=i;else if(i=="safari"&&val==true)uBrowser=i;else if(i=="opera"&&val==true)uBrowser=i;uVersion=new Number(jQuery.browser.version.substr(0,3))});if(anchor_text=="#standard-browse-all"){$(".tabs .tabs-nav").tabs("select",0);$("#standard-products .top-nav li a").removeClass("current");!(uBrowser=="msie"&&uVersion==7)&&$("#standard-products .expandable").each(function(){$(this).find(".expandable-inner").slideDown(0);$(this).removeClass("expandable-closed")})}else if(anchor_text=="#enterprise-browse-all"){$(".tabs .tabs-nav").tabs("select",1);$("#enterprise-products .top-nav li a").removeClass("current");!(uBrowser=="msie"&&uVersion==7)&&$("#enterprise-products .expandable").each(function(){$(this).find(".expandable-inner").slideDown(0);$(this).removeClass("expandable-closed")})}}else{for(var i=0;i<numTabIds;i++)if($(anchor_text).parents(DATACARD.tabIds[i]).length>0){isMatch=true;isMatchTabIndex=i;break}if(isMatch==true){$(".tabs .tabs-nav").tabs("select",isMatchTabIndex);var a=$(".top-nav li a[href="+anchor_text+"]");a.click()}}}}};function showhide(id){if(document.getElementById){obj=document.getElementById(id);if(obj.style.display=="none")obj.style.display="";else obj.style.display="none"}}var page={init:function(){$(".cardFeatureLink,.cardGalleryLink,.videoLink,.workflowLink").click(function(){var href=$(this).attr("href");href=href.replace(/;jsessionid=([A-Z0-9]*)/,"");href=href.replace(/\//,"");var strings=href.split("-"),featureID=strings[0],slideIndex=strings[1];page.modal.open(featureID,slideIndex-1);return false});$("#modalContainer .close").click(function(){page.modal.close()});$("#modalTrigger").click(function(){page.modal.close()});$(window).resize(function(){page.modal.onWindowResize()});jQuery.browser.msie&&jQuery.browser.version==6&&$("body").height($(document).height()+150+"px")},getQuerystringParameter:function(querystring,name){for(var value="",nameValuePairs=querystring.split("&"),nameValuePairsCount=nameValuePairs.length,i=0;i<nameValuePairsCount;i++){var strings=nameValuePairs[i].split("=");if(strings[0]===name){value=strings[1];break}}return value}};page.modal={featuresPath:"/icf/",close:function(){$("#modalWrapper").animate({opacity:0},1e3,function(){$("#modalWrapper").css("display","none")});$("#flashContainer").remove();$("div#overlay").animate({opacity:0},1e3,function(){$("div#overlay").remove()})},open:function(featureID,slideIndex){var isFirefoxLessThan3=false;if($.browser.mozilla){var numbers=$.browser.version.split(".");if(numbers[1]<9)isFirefoxLessThan3=true}!isFirefoxLessThan3&&$("<div />").attr("id","overlay").appendTo("body").show();var swf=page.modal.featuresPath+"datacard_slideshow.swf",flashHeight="546",flashWidth="858";switch(featureID){case "driverslicense":showHideModalHeader("#title-drivers-license-features-tour");googleTrackingPrefix="cardfeatures";break;case "fips":showHideModalHeader("#title-fips-features-tour");googleTrackingPrefix="cardfeatures";break;case "nationalid":showHideModalHeader("#title-national-id-features-tour");googleTrackingPrefix="cardfeatures";break;case "laserpassport":showHideModalHeader("#title-passport-features-tour");googleTrackingPrefix="cardfeatures";break;case "accesscontrol":showHideModalHeader("#title-access-control-gallery");googleTrackingPrefix="cardgalleries";break;case "creditdebit":showHideModalHeader("#title-credit-debit-gallery");googleTrackingPrefix="cardgalleries";break;case "directmail":showHideModalHeader("#title-direct-mail-gallery");googleTrackingPrefix="cardgalleries";break;case "employeeid":showHideModalHeader("#title-employee-id-gallery");googleTrackingPrefix="cardgalleries";break;case "giftprepaid":showHideModalHeader("#title-gift-prepaid-gallery");googleTrackingPrefix="cardgalleries";break;case "loyalty":showHideModalHeader("#title-loyalty-gallery");googleTrackingPrefix="cardgalleries";break;case "membership":showHideModalHeader("#title-membership-gallery");googleTrackingPrefix="cardgalleries";break;case "university":showHideModalHeader("#title-university-gallery");googleTrackingPrefix="cardgalleries";break;case "wfadvocate":showHideModalHeader("#title-advocate-workflow");googleTrackingPrefix="workflows";swf=page.modal.featuresPath+featureID+"/EndToEnd_Advocate.swf";flashHeight="544";flashWidth="850";break;case "wfdriverslicense":showHideModalHeader("#title-driverslicense-workflow");googleTrackingPrefix="workflows";swf=page.modal.featuresPath+featureID+"/EndToEnd_DriversLicense.swf";flashHeight="544";flashWidth="850";break;case "wffinancial":showHideModalHeader("#title-financial-workflow");googleTrackingPrefix="workflows";swf=page.modal.featuresPath+featureID+"/EndToEnd_Financial.swf";flashHeight="544";flashWidth="850";break;case "wfmilitaryid":showHideModalHeader("#title-militaryid-workflow");googleTrackingPrefix="workflows";swf=page.modal.featuresPath+featureID+"/EndToEndGovernmentGID.swf";flashHeight="544";flashWidth="850";break;case "wfnationalid":showHideModalHeader("#title-nationalid-workflow");googleTrackingPrefix="workflows";swf=page.modal.featuresPath+featureID+"/EndToEndGovernmentNatID.swf";flashHeight="544";flashWidth="850";break;case "wfpassport":showHideModalHeader("#title-passport-workflow");googleTrackingPrefix="workflows";swf=page.modal.featuresPath+featureID+"/EndToEndGovernmentPASS.swf";flashHeight="544";flashWidth="850";break;case "sd260features":showHideModalHeader("#title-sd260-features");googleTrackingPrefix="cardgalleries";break;case "sd360features":showHideModalHeader("#title-sd360-features");googleTrackingPrefix="cardgalleries";break;case "cd800features":showHideModalHeader("#title-cd800-features");googleTrackingPrefix="cardgalleries";break;case "mxdfeatures":showHideModalHeader("#title-mxd-features");googleTrackingPrefix="mxdfeatures";break;default:showHideModalHeader("#title-"+featureID);googleTrackingPrefix=featureID;swf=page.modal.featuresPath+"video/content/"+featureID+".swf";flashHeight="500";flashWidth="790";break}typeof window["_gaq"]!="undefined"&&_gaq.push(["_trackPageview","/"+googleTrackingPrefix+"/"+featureID]);$("#flashContainer").remove();$("<div />").attr("id","flashContainer").appendTo("#modalContainer").show();var html="";html+='<p><a href="http://get.adobe.com/flashplayer/">Install Adobe Flash Player</a></p>';$("#flashContainer").html(html);var flashvars={},params={x_features_path:"",x_feature_directory:"",start_slide:0},attributes={};params.x_features_path=page.modal.featuresPath;params.x_feature_directory=featureID;params.start_slide=slideIndex;swfobject.embedSWF(swf,"flashContainer",flashWidth,flashHeight,"8.0.0",flashvars,params,attributes);$("#modalWrapper").css("height",$(document).height()+"px");$("#modalTrigger").css("height",$(document).height()+"px");$("#modalContainer").css("top",$(window).scrollTop()+"px");this.setPosition();$("#modalWrapper").css("display","block");$("#modalWrapper").animate({opacity:1},1e3,function(){})},onWindowResize:function(){$("#modalWrapper").css("height",$(document).height()+"px");$("#modalTrigger").css("height",$(document).height()+"px");this.setPosition()},setPosition:function(){var windowCenter=$(window).width()*.5,modalCenter=442,offset=windowCenter-modalCenter;$("#modalContainer").css("left",offset+"px")}};function showHideModalHeader(modalName){$(modalName).show();$(modalName).animate({opacity:1},0);$("#title-advocate-workflow,#title-driverslicense-workflow,#title-financial-workflow,#title-militaryid-workflow,#title-nationalid-workflow,#title-passport-workflow,#title-videosd260,#title-videogovernmentsolutions,#title-videomx6000overview,#title-videomxdmaileroverview,#title-videomaxsysoverview,#title-videoattachersystems,#title-videoattachergift,#title-videoartistafin,#title-videoartistagov,#title-videogv300overview,#title-videogv300inserter,#title-videogv500carrier,#title-videomj7500overview,#title-videomxdliteoverview,#title-drivers-license-features-tour,#title-card-features-tour,#title-fips-features-tour,#title-national-id-features-tour,#title-passport-features-tour,#title-credit-debit-gallery,#title-university-gallery,#title-gift-prepaid-gallery,#title-access-control-gallery,#title-employee-id-gallery,#title-loyalty-gallery,#title-membership-gallery,#title-direct-mail-gallery,#title-sd260-features,#title-videopb6500,#title-sd360-features,#title-videosd360overview,#title-cd800-features,#title-mxd-features,#title-videogogreen,#title-videoinstantissuance,#title-videocorporateoverview,#title-videomx6000modularity,#title-videocd800,#title-videomx6000barrel,#title-videoenhancedmxd,#title-videomx1000government,#title-videomx1000financial,#title-videosecureissuanceanywhere").not(modalName).animate({opacity:0},0).hide()}function openWindow(url){var re=/\?/g;url=url.replace(re,"---");re=/\&/g;url=url.replace(re,"___");re=/\=/g;url=url.replace(re,"~~~");remote=window.open("/includes/redirect.jhtml?url="+url,"datacardredirect","width=10000,height=10000menubar=yes,toolbar=yes,resizable=yes,scrollbars=yes,location=yes,directories=yes,status=yes,left=50,top=50");remote.focus()}DatacardHomeSlide={CurrentSlide:null,SlidesSrc:null,Slides:null,Navs:null,R:null,BtnNext:null,BtnBack:null,Interval:null,AutoPlay:true,Init:function(){this.SlidesSrc=[];var slide1=[{path:"/images/home_page/home_slideshow/banner_1.jpg",x:0,y:0,w:932,h:328,href:null,title:null},{path:"/images/home_page/home_slideshow/banner_1_text.png",x:70,y:133,w:411,h:72,href:null,title:""}],slide2=[{path:"/images/home_page/home_slideshow/banner_6.jpg",x:0,y:0,w:932,h:328,href:null},{path:"/images/home_page/home_slideshow/banner_6_text.png",x:70,y:77,w:410,h:141,href:null,title:null},{path:"/images/home_page/home_slideshow/banner_6_link_1.png",x:70,y:234,w:148,h:18,href:"/datacard-news/strategic-partnership-with-devicefidelity",title:""}],slide6=[{path:"/images/home_page/home_slideshow/banner_2.jpg",x:0,y:0,w:932,h:328,href:null,title:null},{path:"/images/home_page/home_slideshow/banner_2_text.png",x:70,y:109,w:440,h:116,href:"http://www.secureissuanceanywhere.com",title:""}],slide3=[{path:"/images/home_page/home_slideshow/banner_3.jpg",x:0,y:0,w:932,h:328,href:null,title:null},{path:"/images/home_page/home_slideshow/banner_3_text.png",x:70,y:37,w:411,h:124,href:null,title:null},{path:"/images/home_page/home_slideshow/banner_3_link_1.png",x:70,y:196,w:279,h:20,href:"/financial/credit-and-debit-cards",title:"Credit & Debit Cards"},{path:"/images/home_page/home_slideshow/banner_3_link_2.png",x:70,y:220,w:276,h:20,href:"/financial/gift-and-prepaid-cards",title:"Gift Cards & Prepaid Cards"},{path:"/images/home_page/home_slideshow/banner_3_link_3.png",x:70,y:244,w:276,h:20,href:"/retail/affinity",title:"Co-Branded/Affinity Cards"}],slide4=[{path:"/images/home_page/home_slideshow/banner_4.jpg",x:0,y:0,w:932,h:328,href:null},{path:"/images/home_page/home_slideshow/banner_4_text.png",x:70,y:37,w:411,h:124,href:null},{path:"/images/home_page/home_slideshow/banner_4_link_1.png",x:70,y:196,w:276,h:20,href:"/government/travel-id-and-passport",title:"Travel IDs & Passports"},{path:"/images/home_page/home_slideshow/banner_4_link_2.png",x:70,y:220,w:276,h:20,href:"/government/national-id",title:"National IDs"},{path:"/images/home_page/home_slideshow/banner_4_link_3.png",x:70,y:244,w:276,h:20,href:"/government/drivers-license",title:"Driver's Licenses"}],slide5=[{path:"/images/home_page/home_slideshow/banner_5.jpg",x:0,y:0,w:932,h:328,href:null},{path:"/images/home_page/home_slideshow/banner_5_text.png",x:70,y:37,w:411,h:124,href:null},{path:"/images/home_page/home_slideshow/banner_5_link_1.png",x:70,y:196,w:276,h:20,href:"/corporate/employee-ids",title:"Employee ID Cards"},{path:"/images/home_page/home_slideshow/banner_5_link_2.png",x:70,y:220,w:276,h:20,href:"/education/college-and-university-campus-cards",title:"College & University Campus Cards"},{path:"/images/home_page/home_slideshow/banner_5_link_3.png",x:70,y:244,w:276,h:20,href:"/healthcare/patient-and-visitor-id-cards",title:"Patient & Visitor UD Cards"}];this.SlidesSrc.push(slide1,slide2,slide3,slide4,slide5,slide6);this.R=Raphael("homepage-holder",932,328);this.CurrentSlide=0;this.Slides=[];for(var s=0;s<this.SlidesSrc.length;s++){for(var assets=this.SlidesSrc[s],set=[],p=0;p<assets.length;p++){var a=assets[p],img=this.R.image(assets[p].path,assets[p].x+932*s,assets[p].y,assets[p].w,assets[p].h);img._offset=assets[p].x;img._href=assets[p].href;if(assets[p].href==null)img.mouseover(this.ShowArrows).mouseout(this.HideArrows);else{img.attr({cursor:"pointer",title:assets[p].title});img.click(function(){document.location=this._href})}set.push(img)}this.Slides.push(set)}this.Navs=[];for(var a=Math.floor(this.Slides.length/2)*34,b=932/2-a,s=0;s<this.Slides.length;s++){var opac=s==0?1:.3,n=this.R.circle(b+s*40,305,5).attr({stroke:null,fill:"#fff",opacity:opac,cursor:"pointer"});n._index=s;n.click(this.Go);this.Navs.push(n)}this.BtnNext=this.R.image("/images/home_page/home_slideshow/arrow_next.png",891,150,44,42).attr({cursor:"pointer"}).mouseover(this.NextOver).show().click(this.Go);this.BtnNext._index=-1;this.BtnBack=this.R.image("/images/home_page/home_slideshow/arrow_back.png",-3,150,44,42).attr({cursor:"pointer"}).mouseover(this.BackOver).hide().click(this.Go);this.BtnBack._index=-2;var bot=this.R.image("/images/home_page/home_slideshow/mask.png",0,0,932,5).clone();if(Raphael.type=="VML")bot.attr({y:322,x:-1}).transform("r180");else bot.attr({y:323}).transform("r180");this.Interval=setInterval(this.Go,1e4,"auto")},Go:function(auto){var d=DatacardHomeSlide;if(auto!="auto"||auto!=undefined){clearInterval(d.Interval);d.Interval=setInterval(d.Go,8e3,"auto")}if(auto=="auto"||auto==undefined){d.CurrentSlide++;if(d.CurrentSlide>=d.Slides.length)d.CurrentSlide=0}else if(this._index==-1&&d.CurrentSlide==d.Slides.length-1)return;else if(this._index==-2&&d.CurrentSlide==0)return;else if(this._index==-1)d.CurrentSlide++;else if(this._index==-2)d.CurrentSlide--;else d.CurrentSlide=this._index;for(var b=d.CurrentSlide*932*-1,s=0;s<d.Slides.length;s++)for(var elements=d.Slides[s],_x=b+932*s,e=0;e<elements.length;e++)elements[e].animate({x:_x+elements[e]._offset},1e3,"<>");for(var n=0;n<d.Navs.length;n++)if(n!=d.CurrentSlide)d.Navs[n].animate({opacity:.3},500,"<>");else d.Navs[n].animate({opacity:1},500,"<>");if(d.CurrentSlide==d.Slides.length-1){d.BtnBack.show();d.BtnNext.hide()}else if(d.CurrentSlide==0){d.BtnNext.show();d.BtnBack.hide()}else{d.BtnNext.show();d.BtnBack.show()}}}
var minMSIEVersion=8,uBrowser,uVersion;jQuery.each(jQuery.browser,function(i,val){if(i=="msie"&&val==true)uBrowser=i;else if(i=="mozilla"&&val==true)uBrowser=i;else if(i=="safari"&&val==true)uBrowser=i;else if(i=="opera"&&val==true)uBrowser=i;uVersion=new Number(jQuery.browser.version.substr(0,3))});var DesignSolution=function($){function addProduct(e){if($(e).children("a").attr("class")=="remove-solution")removeProduct(e);else{$(e).children("a").html("Remove from solution");$(e).children("a").addClass("remove-solution");$(e).children("a").removeClass("add-to-solutions");$("#addproduct img").attr("src","/images/buttons/remove-this-h.png");$("#removeproduct img").attr("src","/images/buttons/remove-this-h.png");if(uBrowser=="safari"||uBrowser=="mozilla"||uBrowser=="opera"||uBrowser=="msie"&&uVersion>7)$(e).parent("ul").parent("div").fadeTo(300,.5);else if(uBrowser=="msie"&&uVersion==7){$(e).parent("ul").parent("div").children("span.img-wrapper").fadeTo(300,.5);$(e).parent("ul").parent("div").children("h3").children("a").css("color","#90adcf");$(e).children("a").css("color","#aaa");$(e).parent("ul").children("li.quickview").children("a").css("color","#aaa")}else if(uBrowser=="msie"&&uVersion<7){$(e).parent("ul").parent("div").children("span.img-wrapper").fadeTo(300,.5);$(e).parent("ul").parent("div").children("h3").children("a").css("color","#90adcf");$(e).children("a").css("color","#aaa");$(e).parent("ul").children("li.quickview").children("a").css("color","#aaa")}}}function removeProduct(e){$(e).children("a").html("Add to my solution");$(e).children("a").addClass("add-to-solutions");$(e).children("a").removeClass("remove-solution");$(e).parent("ul").parent("div").removeClass("insolution");$("#removeproduct img").attr("src","/images/buttons/add-solution.png");$("#addproduct img").attr("src","/images/buttons/add-solution.png");if(uBrowser=="safari"||uBrowser=="mozilla"||uBrowser=="opera"||uBrowser=="msie"&&uVersion>7)$(e).parent("ul").parent("div").fadeTo("fast",1);else if(uBrowser=="msie"&&uVersion==7){$(e).parent("ul").parent("div").children("span.img-wrapper").fadeTo("fast",1);$(e).parent("ul").parent("div").children("h3").children("a").css("color","#225b9f");$(e).children("a").css("color","#555");$(e).parent("ul").children("li.quickview").children("a").css("color","#555")}else if(uBrowser=="msie"&&uVersion<7){$(e).parent("ul").parent("div").children("span.img-wrapper").fadeTo("fast",1);$(e).parent("ul").parent("div").children("h3").children("a").css("color","#225b9f");$(e).children("a").css("color","#555");$(e).parent("ul").children("li.quickview").children("a").css("color","#555")}}function updateEvent(){$(":radio").each(function(i){$(this).click(function(){subUpdateEvent();$(":radio").each(function(i){$(this).click(function(){subUpdateEvent()})});$(this).unbind()})})}function subUpdateEvent(){$(".design-options").fadeOut(200,function(){if(document.getElementById("design-count").innerHTML!="0"){$(".inner-box").find("p").show();$(".design-solution").removeClass("zero-products")}else $(".inner-box").find("p").hide();$(".step1").hide();$(".step2").show();$(".reset-button").show()})}function reviewSolution(){var img1=new Image,img2=new Image;img1.src="/images/buttons/review.png";img2.src="/images/buttons/close.png";if($(".solution-box").attr("class")=="solution-box collapsed")openReviewBox();else closeReviewBox()}function openReviewBox(){$("a.review-button").html('<span></span><img src="/images/buttons/close.png" alt="CLOSE" width="55" height="26" />');$("a.review-button").addClass("review-button-close");if(document.getElementById("design-count")!=null){var s=document.getElementById("design-count").innerHTML;s=s.trim();$("#design-count").html(s);if(document.getElementById("design-count").innerHTML!="0"){$(".solution-box").removeClass("collapsed").addClass("expanded");$(".product-review-box").slideDown("450");$(".solution-box-b").slideDown("450");$(".design-solution").removeClass("zero-products")}else $(".design-solution").addClass("zero-products");$("#design-count").length>0&&$(".revise-this-design").show()}}function closeReviewBox(){$("a.review-button").html('<span></span><img src="/images/buttons/review.png" alt="REVIEW" width="55" height="26" />');$("a.review-button").removeClass("review-button-close");$(".solution-box").removeClass("expanded").addClass("collapsed");$(".product-review-box").slideUp("450");$(".solution-box-b").slideUp("450");if(document.getElementById("design-count")!=null){var s=document.getElementById("design-count").innerHTML;s=s.trim();$("#design-count").html(s);if(document.getElementById("design-count").innerHTML!="0")$(".design-solution").removeClass("zero-products");else{$(".design-solution").addClass("zero-products");if($("#design-count").length>0){$("#widget2").hide();$("#widget1").show()}}if($("#design-count").length>0){$(".revise-this-design").hide();$(".design-solution").addClass("zero-products");$(".revise-this-design").hide()}}}function sliderEvent(){$("#slider1").slider({steps:3,range:false,change:function(e,ui){sendDesignASolutionFormValuesToServer(ui,"slider1")}});$("#slider2").slider({steps:3,range:false,change:function(e,ui){sendDesignASolutionFormValuesToServer(ui,"slider2")}});$("#slider3").slider({steps:3,range:false,change:function(e,ui){sendDesignASolutionFormValuesToServer(ui,"slider3")}})}function helpHover(){$(".design-solution a.help").hover(function(){},function(){})}function quickViewHover(){$(".quickview a").hoverIntent({sensitivity:7,interval:175,over:function(){$(this).siblings(".balloon").fadeIn("100")},timeout:100,out:function(){$(this).siblings(".balloon").fadeOut("250")}})}function shareClick(){$(".design-solution .share-button").click(function(){if(parseInt($("div.inner-box h3 span").html())>0){$(this).html('<span></span><img src="/images/buttons/share-disabled.png" alt="SHARE" width="50" height="26" />');$("select").hide();$("#site_overlay").css({filter:"alpha(opacity=60)"}).fadeIn(300,function(){$("#share_window").fadeIn(300)})}})}function imageGalleryClick(){$(".image-gallery").click(function(){$("#image_gallery_site_overlay").css({filter:"alpha(opacity=60)"}).fadeIn(300,function(){$("#image_gallery_window").fadeIn(300)})})}function relatedProductsClick(){$(".related-products").click(function(){$("#relatedProductsTab").click()})}function cancelClick(){$("#share_window a.cancel").click(function(){$("#share_window").fadeOut(300);$("select").show();$("#site_overlay").fadeOut(300);$(".design-solution .share-button").html('<span></span><img src="/images/buttons/share.png" alt="SHARE" width="50" height="26" />')})}function imageGalleryCancelClick(){$("#image_gallery_window a.cancel").click(function(){$("#image_gallery_window").fadeOut(300);$("select").show();$("#image_gallery_site_overlay").fadeOut(300)})}return {init:function(){updateEvent();quickViewHover();shareClick();imageGalleryClick();relatedProductsClick();cancelClick();imageGalleryCancelClick()},p_reviewSolution:function(){reviewSolution()},p_sliderEvent:function(){sliderEvent()},p_removeProduct:function(e){removeProduct(e)},p_closeReviewBox:function(){closeReviewBox()},p_subUpdateEvent:function(){subUpdateEvent()},p_addProduct:function(e){addProduct(e)},p_cancelClick:function(){cancelClick()}}}(jQuery);$(document).ready(function(){DATACARD.init();DesignSolution.init();page.init();$(".design-solution a.help").click(function(){return false})});var isBrowserIE=jQuery.browser.msie,xmlHttpReq=false,xmlHttpReqRefreshProductsUrl=false,setFormValuesUrl;function clearForm(){$("form#solution-form").reset();$("#one-sided").checked=false;$(".slider-ui").slider("moveTo",0);sendDesignASolutionFormValuesToServer(this,"emptyformvalues")}function replaceHtml(el,html){var oldEl=el;oldEl.innerHTML=html;return oldEl;var newEl=oldEl.cloneNode(false);newEl.innerHTML=html;oldEl.parentNode.replaceChild(newEl,oldEl);return true}function updateDesignASolution(labelName,ui){var labelObject=document.getElementById(labelName);sendDesignASolutionFormValuesToServer(labelObject,labelName)}function sendDesignASolutionFormValuesToServer(ui,labelName){$("#updating-solutions").show().fadeIn(200);var setFormValuesUrl="";if(ui!=""){var sliderValue=Math.round(ui.value);setFormValuesUrl="/id/design_a_solution/design_a_solution_set_form_values.jhtml?sliderName="+labelName+"&sliderValue="+sliderValue}else setFormValuesUrl="/id/design_a_solution/design_a_solution_set_form_values.jhtml?sliderName="+labelName+"&sliderValue=empty";$.ajax({url:setFormValuesUrl,cache:false,success:function(){refreshDesignASolutionProducts()}})}function refreshDesignASolutionProducts(){$.ajax({url:"/id/design_a_solution/design_a_solution_ajax.jhtml",cache:false,success:function(html){var el=document.getElementById("ajaxsection");replaceHtml(el,html);refreshDesignASolutionProductsAjax()}})}function refreshDesignASolutionProductsAjax(){$("#updating-solutions").hide().fadeOut("fast");if(isBrowserIE){DesignSolution.p_subUpdateEvent();$(".tabs .tabs-nav").tabs();DATACARD.expandableContents();DATACARD.checkBrowseProductsTab();DATACARD.setTabLinks();DATACARD.updateProductsNumbers();DesignSolution.init();var sp=document.getElementById("sp"),ep=document.getElementById("ep");if(document.getElementById("design-count")!=null){var s=document.getElementById("design-count").innerHTML;s=s.trim();$("#design-count").html(s);sp.innerHTML=="(0)"&&ep.innerHTML!="(0)"&&document.getElementById("ep").click();if(document.getElementById("design-count").innerHTML!="0")$(".inner-box").find("p").show();else{DesignSolution.p_closeReviewBox();$(".inner-box").find("p").hide()}}}else if(isBrowserIE==false){DesignSolution.p_subUpdateEvent();$(".tabs .tabs-nav").tabs();DATACARD.expandableContents();DATACARD.checkBrowseProductsTab();DATACARD.setTabLinks();DATACARD.updateProductsNumbers();DesignSolution.init();var sp=document.getElementById("sp"),ep=document.getElementById("ep"),op=document.getElementById("op");if(sp.innerHTML=="(0)"&&ep.innerHTML!="(0)"){$(".tabs .tabs-nav").tabs("select",1);$("#enterprise-products .top-nav li a").removeClass("current");!(isBrowserIE&&jQuery.browser.ver==7)&&$("#enterprise-products .expandable").each(function(){$(this).find(".expandable-inner").slideDown(0);$(this).removeClass("expandable-closed")})}if(sp.innerHTML=="(0)"&&ep.innerHTML=="(0)"&&op.innerHTML!="(0)"){$(".tabs .tabs-nav").tabs("select",2);$("#enterprise-products .top-nav li a").removeClass("current");!(isBrowserIE&&jQuery.browser.ver==7)&&$("#enterprise-products .expandable").each(function(){$(this).find(".expandable-inner").slideDown(0);$(this).removeClass("expandable-closed")})}if(document.getElementById("design-count")!=null){var s=document.getElementById("design-count").innerHTML;s=s.trim();$("#design-count").html(s)}if(document.getElementById("design-count").innerHTML!="0")$(".inner-box").find("p").show();else{DesignSolution.p_closeReviewBox();$(".inner-box").find("p").hide()}}$("#updating-solutions-firstload").hide();document.getElementById("industry")!=null&&document.getElementById("industry").value!="select-industry"&&$("#industryHeader").html(document.getElementById("industry").value)}var contentIdTemp="",cartClickTemp="";function addToMySolution(contentId,cartClick){contentIdTemp=contentId;cartClickTemp=cartClick;var e="#"+contentId;if(cartClick=="true")DesignSolution.p_removeProduct(e);else DesignSolution.p_addProduct(e);designASolutionCartUrl="/id/design_a_solution/design_a_solution_models.jhtml?contentId="+contentId;if(window.XMLHttpRequest)xmlHttpReq=new XMLHttpRequest;else if(window.ActiveXObject)xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP");if(xmlHttpReq){xmlHttpReq.onreadystatechange=addToMySolutionSub;xmlHttpReq.open("GET",designASolutionCartUrl,true);xmlHttpReq.send(null)}}function addToMySolutionSub(){if(xmlHttpReq.readyState==4)if(xmlHttpReq.status==200){$("#left-content").html(xmlHttpReq.responseText);var designASolutionCartUrl="/id/design_a_solution/design_a_solution_models_count.jhtml",designASolutionCart=document.getElementById("designASolutionCart");$.ajax({url:designASolutionCartUrl,cache:false,success:function(html){var s=html;s=s.trim();$("#design-count").html(s);if(document.getElementById("design-count").innerHTML!="0"){$(".inner-box").find("p").show();if($("#widget1").length>0){$("#widget2").show();$("#widget1").hide();if(contentIdTemp==$("#contentIdTemp").html()&&cartClickTemp=="false"){$("#removeproduct").show();$("#addproduct").hide()}if(contentIdTemp==$("#contentIdTemp").html()&&cartClickTemp=="true"){$("#removeproduct").hide();$("#addproduct").show()}}}else{DesignSolution.p_closeReviewBox();$(".inner-box").find("p").hide();$("#widget1").length>0&&$("#addproductemptybox").show()}}})}}String.prototype.trim=function(){return this.replace(/^\s*/,"").replace(/\s*$/,"")};
/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-07-22 01:45:56 +0200 (Son, 22 Jul 2007) $
 * $Rev: 2447 $
 *
 * Version 2.1.1
 */
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);
(function($){var ajax=$.ajax,pendingRequests={},synced=[],syncedData=[];$.ajax=function(settings){settings=jQuery.extend(settings,jQuery.extend({},jQuery.ajaxSettings,settings));var port=settings.port;switch(settings.mode){case "abort":pendingRequests[port]&&pendingRequests[port].abort();return pendingRequests[port]=ajax.apply(this,arguments);case "queue":var _old=settings.complete;settings.complete=function(){_old&&_old.apply(this,arguments);jQuery([ajax]).dequeue("ajax"+port)};jQuery([ajax]).queue("ajax"+port,function(){ajax(settings)});return;case "sync":var pos=synced.length;synced[pos]={error:settings.error,success:settings.success,complete:settings.complete,done:false};syncedData[pos]={error:[],success:[],complete:[]};settings.error=function(){syncedData[pos].error=arguments};settings.success=function(){syncedData[pos].success=arguments};settings.complete=function(){syncedData[pos].complete=arguments;synced[pos].done=true;if(pos==0||!synced[pos-1])for(var i=pos;i<synced.length&&synced[i].done;i++){synced[i].error&&synced[i].error.apply(jQuery,syncedData[i].error);synced[i].success&&synced[i].success.apply(jQuery,syncedData[i].success);synced[i].complete&&synced[i].complete.apply(jQuery,syncedData[i].complete);synced[i]=null;syncedData[i]=null}}}return ajax.apply(this,arguments)}})(jQuery)
/*
 * Autocomplete - jQuery plugin 1.0.2
 *
 * Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.autocomplete.js 5747 2008-06-25 18:30:55Z joern.zaefferer $
 *
 */;(function($){$.fn.extend({autocomplete:function(urlOrData,options){var isUrl=typeof urlOrData=="string";options=$.extend({},$.Autocompleter.defaults,{url:isUrl?urlOrData:null,data:isUrl?null:urlOrData,delay:isUrl?$.Autocompleter.defaults.delay:10,max:options&&!options.scroll?10:150},options);options.highlight=options.highlight||function(value){return value;};options.formatMatch=options.formatMatch||options.formatItem;return this.each(function(){new $.Autocompleter(this,options);});},result:function(handler){return this.bind("result",handler);},search:function(handler){return this.trigger("search",[handler]);},flushCache:function(){return this.trigger("flushCache");},setOptions:function(options){return this.trigger("setOptions",[options]);},unautocomplete:function(){return this.trigger("unautocomplete");}});$.Autocompleter=function(input,options){var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var $input=$(input).attr("autocomplete","off").addClass(options.inputClass);var timeout;var previousValue="";var cache=$.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var config={mouseDownOnSelect:false};var select=$.Autocompleter.Select(options,input,selectCurrent,config);var blockSubmit;$.browser.opera&&$(input.form).bind("submit.autocomplete",function(){if(blockSubmit){blockSubmit=false;return false;}});$input.bind(($.browser.opera?"keypress":"keydown")+".autocomplete",function(event){lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev();}else{onChange(0,true);}break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next();}else{onChange(0,true);}break;case KEY.PAGEUP:event.preventDefault();if(select.visible()){select.pageUp();}else{onChange(0,true);}break;case KEY.PAGEDOWN:event.preventDefault();if(select.visible()){select.pageDown();}else{onChange(0,true);}break;case options.multiple&&$.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(selectCurrent()){event.preventDefault();blockSubmit=true;return false;}break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break;}}).focus(function(){hasFocus++;}).blur(function(){hasFocus=0;if(!config.mouseDownOnSelect){hideResults();}}).click(function(){if(hasFocus++>1&&!select.visible()){onChange(0,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i<data.length;i++){if(data[i].result.toLowerCase()==q.toLowerCase()){result=data[i];break;}}}if(typeof fn=="function")fn(result);else $input.trigger("result",result&&[result.data,result.value]);}$.each(trimWords($input.val()),function(i,value){request(value,findValueCallback,findValueCallback);});}).bind("flushCache",function(){cache.flush();}).bind("setOptions",function(){$.extend(options,arguments[1]);if("data"in arguments[1])cache.populate();}).bind("unautocomplete",function(){select.unbind();$input.unbind();$(input.form).unbind(".autocomplete");});function selectCurrent(){var selected=select.selected();if(!selected)return false;var v=selected.result;previousValue=v;if(options.multiple){var words=trimWords($input.val());if(words.length>1){v=words.slice(0,words.length-1).join(options.multipleSeparator)+options.multipleSeparator+v;}v+=options.multipleSeparator;}$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true;}function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return;}var currentValue=$input.val();if(!skipPrevCheck&&currentValue==previousValue)return;previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase)currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value){if(!value){return[""];}var words=value.split(options.multipleSeparator);var result=[];$.each(words,function(i,value){if($.trim(value))result[i]=$.trim(value);});return result;}function lastWord(value){if(!options.multiple)return value;var words=trimWords(value);return words[words.length-1];}function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$.Autocompleter.Selection(input,previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""));}else
$input.val("");}});}if(wasVisible)$.Autocompleter.Selection(input,input.value.length,input.value.length);};function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show();}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase)term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param;});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);}});}else{select.emptyList();failure(term);}};function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i<rows.length;i++){var row=$.trim(rows[i]);if(row){row=row.split("|");parsed[parsed.length]={data:row,value:row[0],result:options.formatResult&&options.formatResult(row,row[0])||row[0]};}}return parsed;};function stopLoading(){$input.removeClass(options.loadingClass);};};$.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:true,extraParams:{},selectFirst:true,formatItem:function(row){return row[0];},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(value,term){return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>");},scroll:true,scrollHeight:180};$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase)s=s.toLowerCase();var i=s.indexOf(sub);if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();}if(!data[q]){length++;}data[q]=value;}function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];for(var i=0,ol=options.data.length;i<ol;i++){var rawValue=options.data[i];rawValue=(typeof rawValue=="string")?[rawValue]:rawValue;var value=options.formatMatch(rawValue,i+1,options.data.length);if(value===false)continue;var firstChar=value.charAt(0).toLowerCase();if(!stMatchSets[firstChar])stMatchSets[firstChar]=[];var row={value:value,data:rawValue,result:options.formatResult&&options.formatResult(rawValue)||value};stMatchSets[firstChar].push(row);if(nullData++<options.max){stMatchSets[""].push(row);}};$.each(stMatchSets,function(i,value){options.cacheLength++;add(i,value);});}setTimeout(populate,25);function flush(){data={};length=0;}return{flush:flush,add:add,populate:populate,load:function(q){if(!options.cacheLength||!length)return null;if(!options.url&&options.matchContains){var csub=[];for(var k in data){if(k.length>0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x);}});}}return csub;}else
if(data[q]){return data[q];}else
if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x;}});return csub;}}}return null;}};};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit)return;element=$("<div/>").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("<ul/>").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=='LI'){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE);}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;}).mousedown(function(){config.mouseDownOnSelect=true;}).mouseup(function(){config.mouseDownOnSelect=false;});if(options.width>0)element.css("width",options.width);needsInit=false;}function target(event){var element=event.target;while(element&&element.tagName!="LI")element=element.parentNode;if(!element)return[];return element;}function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight;});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight());}else if(offset<list.scrollTop()){list.scrollTop(offset);}}};function movePosition(step){active+=step;if(active<0){active=listItems.size()-1;}else if(active>=listItems.size()){active=0;}}function limitNumberOfItems(available){return options.max&&options.max<available?options.max:available;}function fillList(){list.empty();var max=limitNumberOfItems(data.length);for(var i=0;i<max;i++){if(!data[i])continue;var formatted=options.formatItem(data[i].data,i+1,max,data[i].value,term);if(formatted===false)continue;var li=$("<li/>").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];$.data(li,"ac_data",data[i]);}listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0;}if($.fn.bgiframe)list.bgiframe();}return{display:function(d,q){init();data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active);}else{moveSelect(-8);}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active);}else{moveSelect(8);}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1;},visible:function(){return element&&element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:'auto'});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight;});var scrollbarsVisible=listHeight>options.scrollHeight;list.css('height',scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")));}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ac_data");},emptyList:function(){list&&list.empty();},unbind:function(){element&&element.remove();}};};$.Autocompleter.Selection=function(field,start,end){if(field.createTextRange){var selRange=field.createTextRange();selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}else if(field.setSelectionRange){field.setSelectionRange(start,end);}else{if(field.selectionStart){field.selectionStart=start;field.selectionEnd=end;}}field.focus();};})(jQuery);
(function($) {

	$.fn.extend({
		slider: function(options) {
			var args = Array.prototype.slice.call(arguments, 1);
			
			if ( options == "value" )
				return $.data(this[0], "ui-slider").value(arguments[1]);
			
			return this.each(function() {
				if (typeof options == "string") {
					var slider = $.data(this, "ui-slider");
					slider[options].apply(slider, args);

				} else if(!$.data(this, "ui-slider"))
					new $.ui.slider(this, options);
			});
		}
	});
	
	$.ui.slider = function(element, options) {

		//Initialize needed constants
		var self = this;
		this.element = $(element);
		$.data(element, "ui-slider", this);
		this.element.addClass("ui-slider");
		
		//Prepare the passed options
		this.options = $.extend({}, options);
		var o = this.options;
		$.extend(o, {
			axis: o.axis || (element.offsetWidth < element.offsetHeight ? 'vertical' : 'horizontal'),
			maxValue: !isNaN(parseInt(o.maxValue,10)) ? parseInt(o.maxValue,10) :  100,
			minValue: parseInt(o.minValue,10) || 0,
			startValue: parseInt(o.startValue,10) || 'none'		
		});
		
		//Prepare the real maxValue
		o.realMaxValue = o.maxValue - o.minValue;
		
		//Calculate stepping based on steps
		o.stepping = parseInt(o.stepping,10) || (o.steps ? o.realMaxValue/o.steps : 0);
		
		$(element).bind("setData.slider", function(event, key, value){
			self.options[key] = value;
		}).bind("getData.slider", function(event, key){
			return self.options[key];
		});

		//Initialize mouse and key events for interaction
		this.handle = o.handle ? $(o.handle, element) : $('> *', element);
		$(this.handle)
			.mouseInteraction({
				executor: this,
				delay: o.delay,
				distance: o.distance || 0,
				dragPrevention: o.prevention ? o.prevention.toLowerCase().split(',') : ['input','textarea','button','select','option'],
				start: this.start,
				stop: this.stop,
				drag: this.drag,
				condition: function(e, handle) {
					if(!this.disabled) {
						if(this.currentHandle) this.blur(this.currentHandle);
						this.focus(handle,1);
						return !this.disabled;
					}
				}
			})
			.wrap('<a href="javascript:void(0)"></a>')
			.parent()
				.bind('focus', function(e) { self.focus(this.firstChild); })
				.bind('blur', function(e) { self.blur(this.firstChild); })
				.bind('keydown', function(e) {
					if(/(37|39)/.test(e.keyCode))
						self.moveTo((e.keyCode == 37 ? '-' : '+')+'='+(self.options.stepping ? self.options.stepping : (self.options.realMaxValue / self.size)*5),this.firstChild);
				})
		;
		
		//Position the node
		if(o.helper == 'original' && (this.element.css('position') == 'static' || this.element.css('position') == '')) this.element.css('position', 'relative');
		
		//Prepare dynamic properties for later use
		if(o.axis == 'horizontal') {
			this.size = this.element.outerWidth();
			this.properties = ['left', 'width'];
		} else {
			this.size = this.element.outerHeight();
			this.properties = ['top', 'height'];
		}
		
		//Bind the click to the slider itself
		this.element.bind('click', function(e) { self.click.apply(self, [e]); });
		
		//Move the first handle to the startValue
		if(!isNaN(o.startValue)) this.moveTo(o.startValue, 0);
		
		//If we only have one handle, set the previous handle to this one to allow clicking before selecting the handle
		if(this.handle.length == 1) this.previousHandle = this.handle;
		
		
		if(this.handle.length == 2 && o.range) this.createRange();
	
	};
	
	$.extend($.ui.slider.prototype, {
		plugins: {},
		createRange: function() {
			this.rangeElement = $('<div></div>')
				.addClass('ui-slider-range')
				.css({ position: 'absolute' })
				.css(this.properties[0], parseInt($(this.handle[0]).css(this.properties[0]),10) + this.handleSize(0)/2)
				.css(this.properties[1], parseInt($(this.handle[1]).css(this.properties[0]),10) - parseInt($(this.handle[0]).css(this.properties[0]),10))
				.appendTo(this.element);
		},
		updateRange: function() {
				this.rangeElement.css(this.properties[0], parseInt($(this.handle[0]).css(this.properties[0]),10) + this.handleSize(0)/2);
				this.rangeElement.css(this.properties[1], parseInt($(this.handle[1]).css(this.properties[0]),10) - parseInt($(this.handle[0]).css(this.properties[0]),10));
		},
		getRange: function() {
			return this.rangeElement ? this.convertValue(parseInt(this.rangeElement.css(this.properties[1]),10)) : null;
		},
		ui: function(e) {
			return {
				instance: this,
				options: this.options,
				handle: this.currentHandle,
				value: this.value(),
				range: this.getRange()
			};
		},
		propagate: function(n,e) {
			$.ui.plugin.call(this, n, [e, this.ui()]);
			this.element.triggerHandler(n == "slide" ? n : "slide"+n, [e, this.ui()], this.options[n]);
		},
		destroy: function() {
			this.element
				.removeClass("ui-slider ui-slider-disabled")
				.removeData("ul-slider")
				.unbind(".slider");
			this.handles.removeMouseInteraction();
		},
		enable: function() {
			this.element.removeClass("ui-slider-disabled");
			this.disabled = false;
		},
		disable: function() {
			this.element.addClass("ui-slider-disabled");
			this.disabled = true;
		},
		focus: function(handle,hard) {
			this.currentHandle = $(handle).addClass('ui-slider-handle-active');
			if(hard) this.currentHandle.parent()[0].focus();
		},
		blur: function(handle) {
			$(handle).removeClass('ui-slider-handle-active');
			if(this.currentHandle && this.currentHandle[0] == handle) { this.previousHandle = this.currentHandle; this.currentHandle = null; };
		},
		value: function(handle) {
			if(this.handle.length == 1) this.currentHandle = this.handle;
			return ((parseInt($(handle != undefined ? this.handle[handle] || handle : this.currentHandle).css(this.properties[0]),10) / (this.size - this.handleSize())) * this.options.realMaxValue) + this.options.minValue;
		},
		convertValue: function(value) {
			return (value / (this.size - this.handleSize())) * this.options.realMaxValue;
		},
		translateValue: function(value) {
			return ((value - this.options.minValue) / this.options.realMaxValue) * (this.size - this.handleSize());
		},
		handleSize: function(handle) {
			return $(handle != undefined ? this.handle[handle] : this.currentHandle)['outer'+this.properties[1].substr(0,1).toUpperCase()+this.properties[1].substr(1)]();	
		},
		click: function(e) {
		
			// This method is only used if:
			// - The user didn't click a handle
			// - The Slider is not disabled
			// - There is a current, or previous selected handle (otherwise we wouldn't know which one to move)
			var pointer = [e.pageX,e.pageY];
			var clickedHandle = false; this.handle.each(function() { if(this == e.target) clickedHandle = true;  });
			if(clickedHandle || this.disabled || !(this.currentHandle || this.previousHandle)) return;

			//If a previous handle was focussed, focus it again
			if(this.previousHandle) this.focus(this.previousHandle, 1);
			
			//Move focussed handle to the clicked position
			this.offset = this.element.offset();
			this.moveTo(this.convertValue(e[this.properties[0] == 'top' ? 'pageY' : 'pageX'] - this.offset[this.properties[0]] - this.handleSize()/2));
			
		},
		start: function(e, handle) {
			
			var o = this.options;
			
			this.offset = this.element.offset();
			this.handleOffset = this.currentHandle.offset();
			this.clickOffset = { top: e.pageY - this.handleOffset.top, left: e.pageX - this.handleOffset.left };
			this.firstValue = this.value();
			
			this.propagate('start', e);
			return false;
						
		},
		stop: function(e) {
			this.propagate('stop', e);
			if(this.firstValue != this.value()) this.propagate('change', e);
			return false;
		},
		drag: function(e, handle) {

			var o = this.options;
			var position = { top: e.pageY - this.offset.top - this.clickOffset.top, left: e.pageX - this.offset.left - this.clickOffset.left};

			var modifier = position[this.properties[0]];			
			if(modifier >= this.size - this.handleSize()) modifier = this.size - this.handleSize();
			if(modifier <= 0) modifier = 0;
			
			if(o.stepping) {
				var value = this.convertValue(modifier);
				value = Math.round(value / o.stepping) * o.stepping;
				modifier = this.translateValue(value);	
			}

			if(this.rangeElement) {
				if(this.currentHandle[0] == this.handle[0] && modifier >= this.translateValue(this.value(1))) modifier = this.translateValue(this.value(1));
				if(this.currentHandle[0] == this.handle[1] && modifier <= this.translateValue(this.value(0))) modifier = this.translateValue(this.value(0));
			}	
			
			this.currentHandle.css(this.properties[0], modifier);
			if(this.rangeElement) this.updateRange();
			this.propagate('slide', e);
			return false;
			
		},
		moveTo: function(value, handle) {

			var o = this.options;
			if(handle == undefined && !this.currentHandle && this.handle.length != 1) return false; //If no handle has been passed, no current handle is available and we have multiple handles, return false
			if(handle == undefined && !this.currentHandle) handle = 0; //If only one handle is available, use it
			if(handle != undefined) this.currentHandle = this.previousHandle = $(this.handle[handle] || handle);

			if(value.constructor == String) value = /\-\=/.test(value) ? this.value() - parseInt(value.replace('-=', ''),10) : this.value() + parseInt(value.replace('+=', ''),10);
			if(o.stepping) value = Math.round(value / o.stepping) * o.stepping;
			value = this.translateValue(value);

			if(value >= this.size - this.handleSize()) value = this.size - this.handleSize();
			if(value <= 0) value = 0;
			if(this.rangeElement) {
				if(this.currentHandle[0] == this.handle[0] && value >= this.translateValue(this.value(1))) value = this.translateValue(this.value(1));
				if(this.currentHandle[0] == this.handle[1] && value <= this.translateValue(this.value(0))) value = this.translateValue(this.value(0));
			}
			
			this.currentHandle.css(this.properties[0], value);
			if(this.rangeElement) this.updateRange();
			
			this.propagate('start', null);
			this.propagate('stop', null);
			this.propagate('change', null);

		}
	});

})(jQuery);
jQuery.fn.reset = function() {
	this.each(function(){
		if($(this).is('form')) {
			var button = jQuery(jQuery('<input type="reset" />'));
			button.hide();
			$(this).append(button);
			button.click().remove();
		} else if($(this).parent('form').size()) {
			var button = jQuery(jQuery('<input type="reset" />'));
			button.hide();
			$(this).parent('form').append(button);
			button.click().remove();
		} else if($(this).find('form').size()) {
			$(this).find('form').each(function(){
				var button = jQuery(jQuery('<input type="reset" />'));
				button.hide();
				$(this).append(button);
				button.click().remove();
			});
		}
	})
	return this;
};
