


/*!
 * jQuery Form Plugin
 * version: 2.82 (15-JUN-2011)
 * @requires jQuery v1.3.2 or later
 *
 * Examples and documentation at: http://malsup.com/jquery/form/
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
;(function($) {

/*
	Usage Note:
	-----------
	Do not use both ajaxSubmit and ajaxForm on the same form.  These
	functions are intended to be exclusive.  Use ajaxSubmit if you want
	to bind your own submit handler to the form.  For example,

	$(document).ready(function() {
		$('#myForm').bind('submit', function(e) {
			e.preventDefault(); // <-- important
			$(this).ajaxSubmit({
				target: '#output'
			});
		});
	});

	Use ajaxForm when you want the plugin to manage all the event binding
	for you.  For example,

	$(document).ready(function() {
		$('#myForm').ajaxForm({
			target: '#output'
		});
	});

	When using ajaxForm, the ajaxSubmit function will be invoked for you
	at the appropriate time.
*/

/**
 * ajaxSubmit() provides a mechanism for immediately submitting
 * an HTML form using AJAX.
 */
$.fn.ajaxSubmit = function(options) {
	// fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
	if (!this.length) {
		log('ajaxSubmit: skipping submit process - no element selected');
		return this;
	}
	
	var method, action, url, $form = this;;

	if (typeof options == 'function') {
		options = { success: options };
	}

	method = this.attr('method');
	action = this.attr('action');
	url = (typeof action === 'string') ? $.trim(action) : '';
	url = url || window.location.href || '';
	if (url) {
		// clean url (don't include hash vaue)
		url = (url.match(/^([^#]+)/)||[])[1];
	}

	options = $.extend(true, {
		url:  url,
		success: $.ajaxSettings.success,
		type: method || 'GET',
		iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
	}, options);

	// hook for manipulating the form data before it is extracted;
	// convenient for use with rich editors like tinyMCE or FCKEditor
	var veto = {};
	this.trigger('form-pre-serialize', [this, options, veto]);
	if (veto.veto) {
		log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
		return this;
	}

	// provide opportunity to alter form data before it is serialized
	if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
		log('ajaxSubmit: submit aborted via beforeSerialize callback');
		return this;
	}

	var n,v,a = this.formToArray(options.semantic);
	if (options.data) {
		options.extraData = options.data;
		for (n in options.data) {
			if(options.data[n] instanceof Array) {
				for (var k in options.data[n]) {
					a.push( { name: n, value: options.data[n][k] } );
				}
			}
			else {
				v = options.data[n];
				v = $.isFunction(v) ? v() : v; // if value is fn, invoke it
				a.push( { name: n, value: v } );
			}
		}
	}

	// give pre-submit callback an opportunity to abort the submit
	if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
		log('ajaxSubmit: submit aborted via beforeSubmit callback');
		return this;
	}

	// fire vetoable 'validate' event
	this.trigger('form-submit-validate', [a, this, options, veto]);
	if (veto.veto) {
		log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
		return this;
	}

	var q = $.param(a);

	if (options.type.toUpperCase() == 'GET') {
		options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
		options.data = null;  // data is null for 'get'
	}
	else {
		options.data = q; // data is the query string for 'post'
	}

	var callbacks = [];
	if (options.resetForm) {
		callbacks.push(function() { $form.resetForm(); });
	}
	if (options.clearForm) {
		callbacks.push(function() { $form.clearForm(); });
	}

	// perform a load on the target only if dataType is not provided
	if (!options.dataType && options.target) {
		var oldSuccess = options.success || function(){};
		callbacks.push(function(data) {
			var fn = options.replaceTarget ? 'replaceWith' : 'html';
			$(options.target)[fn](data).each(oldSuccess, arguments);
		});
	}
	else if (options.success) {
		callbacks.push(options.success);
	}

	options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
		var context = options.context || options;   // jQuery 1.4+ supports scope context 
		for (var i=0, max=callbacks.length; i < max; i++) {
			callbacks[i].apply(context, [data, status, xhr || $form, $form]);
		}
	};

	// are there files to upload?
	var fileInputs = $('input:file', this).length > 0;
	var mp = 'multipart/form-data';
	var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);

	// options.iframe allows user to force iframe mode
	// 06-NOV-09: now defaulting to iframe mode if file input is detected
   if (options.iframe !== false && (fileInputs || options.iframe || multipart)) {
	   // hack to fix Safari hang (thanks to Tim Molendijk for this)
	   // see:  http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
	   if (options.closeKeepAlive) {
		   $.get(options.closeKeepAlive, function() { fileUpload(a); });
		}
	   else {
		   fileUpload(a);
		}
   }
   else {
		// IE7 massage (see issue 57)
		if ($.browser.msie && method == 'get') { 
			var ieMeth = $form[0].getAttribute('method');
			if (typeof ieMeth === 'string')
				options.type = ieMeth;
		}
		$.ajax(options);
   }

	// fire 'notify' event
	this.trigger('form-submit-notify', [this, options]);
	return this;


	// private function for handling file uploads (hat tip to YAHOO!)
	function fileUpload(a) {
		var form = $form[0], i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle;

        if (a) {
        	// ensure that every serialized input is still enabled
          	for (i=0; i < a.length; i++) {
            	$(form[a[i].name]).attr('disabled', false);
          	}
        }

		if ($(':input[name=submit],:input[id=submit]', form).length) {
			// if there is an input with a name or id of 'submit' then we won't be
			// able to invoke the submit fn on the form (at least not x-browser)
			alert('Error: Form elements must not have name or id of "submit".');
			return;
		}
		
		s = $.extend(true, {}, $.ajaxSettings, options);
		s.context = s.context || s;
		id = 'jqFormIO' + (new Date().getTime());
		if (s.iframeTarget) {
			$io = $(s.iframeTarget);
			n = $io.attr('name');
			if (n == null)
			 	$io.attr('name', id);
			else
				id = n;
		}
		else {
			$io = $('<iframe name="' + id + '" src="'+ s.iframeSrc +'" />');
			$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
		}
		io = $io[0];


		xhr = { // mock object
			aborted: 0,
			responseText: null,
			responseXML: null,
			status: 0,
			statusText: 'n/a',
			getAllResponseHeaders: function() {},
			getResponseHeader: function() {},
			setRequestHeader: function() {},
			abort: function(status) {
				var e = (status === 'timeout' ? 'timeout' : 'aborted');
				log('aborting upload... ' + e);
				this.aborted = 1;
				$io.attr('src', s.iframeSrc); // abort op in progress
				xhr.error = e;
				s.error && s.error.call(s.context, xhr, e, status);
				g && $.event.trigger("ajaxError", [xhr, s, e]);
				s.complete && s.complete.call(s.context, xhr, e);
			}
		};

		g = s.global;
		// trigger ajax global events so that activity/block indicators work like normal
		if (g && ! $.active++) {
			$.event.trigger("ajaxStart");
		}
		if (g) {
			$.event.trigger("ajaxSend", [xhr, s]);
		}

		if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
			if (s.global) {
				$.active--;
			}
			return;
		}
		if (xhr.aborted) {
			return;
		}

		// add submitting element to data if we know it
		sub = form.clk;
		if (sub) {
			n = sub.name;
			if (n && !sub.disabled) {
				s.extraData = s.extraData || {};
				s.extraData[n] = sub.value;
				if (sub.type == "image") {
					s.extraData[n+'.x'] = form.clk_x;
					s.extraData[n+'.y'] = form.clk_y;
				}
			}
		}
		
		var CLIENT_TIMEOUT_ABORT = 1;
		var SERVER_ABORT = 2;

		function getDoc(frame) {
			var doc = frame.contentWindow ? frame.contentWindow.document : frame.contentDocument ? frame.contentDocument : frame.document;
			return doc;
		}
		
		// take a breath so that pending repaints get some cpu time before the upload starts
		function doSubmit() {
			// make sure form attrs are set
			var t = $form.attr('target'), a = $form.attr('action');

			// update form attrs in IE friendly way
			form.setAttribute('target',id);
			if (!method) {
				form.setAttribute('method', 'POST');
			}
			if (a != s.url) {
				form.setAttribute('action', s.url);
			}

			// ie borks in some cases when setting encoding
			if (! s.skipEncodingOverride && (!method || /post/i.test(method))) {
				$form.attr({
					encoding: 'multipart/form-data',
					enctype:  'multipart/form-data'
				});
			}

			// support timout
			if (s.timeout) {
				timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout);
			}
			
			// look for server aborts
			function checkState() {
				try {
					var state = getDoc(io).readyState;
					log('state = ' + state);
					if (state.toLowerCase() == 'uninitialized')
						setTimeout(checkState,50);
				}
				catch(e) {
					log('Server abort: ' , e, ' (', e.name, ')');
					cb(SERVER_ABORT);
					timeoutHandle && clearTimeout(timeoutHandle);
					timeoutHandle = undefined;
				}
			}

			// add "extra" data to form if provided in options
			var extraInputs = [];
			try {
				if (s.extraData) {
					for (var n in s.extraData) {
						extraInputs.push(
							$('<input type="hidden" name="'+n+'" />').attr('value',s.extraData[n])
								.appendTo(form)[0]);
					}
				}

				if (!s.iframeTarget) {
					// add iframe to doc and submit the form
					$io.appendTo('body');
	                io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
				}
				setTimeout(checkState,15);
				form.submit();
			}
			finally {
				// reset attrs and remove "extra" input elements
				form.setAttribute('action',a);
				if(t) {
					form.setAttribute('target', t);
				} else {
					$form.removeAttr('target');
				}
				$(extraInputs).remove();
			}
		}

		if (s.forceSync) {
			doSubmit();
		}
		else {
			setTimeout(doSubmit, 10); // this lets dom updates render
		}

		var data, doc, domCheckCount = 50, callbackProcessed;

		function cb(e) {
			if (xhr.aborted || callbackProcessed) {
				return;
			}
			try {
				doc = getDoc(io);
			}
			catch(ex) {
				log('cannot access response document: ', ex);
				e = SERVER_ABORT;
			}
			if (e === CLIENT_TIMEOUT_ABORT && xhr) {
				xhr.abort('timeout');
				return;
			}
			else if (e == SERVER_ABORT && xhr) {
				xhr.abort('server abort');
				return;
			}

			if (!doc || doc.location.href == s.iframeSrc) {
				// response not received yet
				if (!timedOut)
					return;
			}
            io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);

			var status = 'success', errMsg;
			try {
				if (timedOut) {
					throw 'timeout';
				}

				var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
				log('isXml='+isXml);
				if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
					if (--domCheckCount) {
						// in some browsers (Opera) the iframe DOM is not always traversable when
						// the onload callback fires, so we loop a bit to accommodate
						log('requeing onLoad callback, DOM not available');
						setTimeout(cb, 250);
						return;
					}
					// let this fall through because server response could be an empty document
					//log('Could not access iframe DOM after mutiple tries.');
					//throw 'DOMException: not available';
				}

				//log('response detected');
                var docRoot = doc.body ? doc.body : doc.documentElement;
                xhr.responseText = docRoot ? docRoot.innerHTML : null;
				xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
				if (isXml)
					s.dataType = 'xml';
				xhr.getResponseHeader = function(header){
					var headers = {'content-type': s.dataType};
					return headers[header];
				};
                // support for XHR 'status' & 'statusText' emulation :
                if (docRoot) {
                    xhr.status = Number( docRoot.getAttribute('status') ) || xhr.status;
                    xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
                }

				var dt = s.dataType || '';
				var scr = /(json|script|text)/.test(dt.toLowerCase());
				if (scr || s.textarea) {
					// see if user embedded response in textarea
					var ta = doc.getElementsByTagName('textarea')[0];
					if (ta) {
						xhr.responseText = ta.value;
                        // support for XHR 'status' & 'statusText' emulation :
                        xhr.status = Number( ta.getAttribute('status') ) || xhr.status;
                        xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
					}
					else if (scr) {
						// account for browsers injecting pre around json response
						var pre = doc.getElementsByTagName('pre')[0];
						var b = doc.getElementsByTagName('body')[0];
						if (pre) {
							xhr.responseText = pre.textContent ? pre.textContent : pre.innerHTML;
						}
						else if (b) {
							xhr.responseText = b.innerHTML;
						}
					}
				}
				else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
					xhr.responseXML = toXml(xhr.responseText);
				}

                try {
                    data = httpData(xhr, s.dataType, s);
                }
                catch (e) {
                    status = 'parsererror';
                    xhr.error = errMsg = (e || status);
                }
			}
			catch (e) {
				log('error caught: ',e);
				status = 'error';
                xhr.error = errMsg = (e || status);
			}

			if (xhr.aborted) {
				log('upload aborted');
				status = null;
			}

            if (xhr.status) { // we've set xhr.status
                status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error';
            }

			// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
			if (status === 'success') {
				s.success && s.success.call(s.context, data, 'success', xhr);
				g && $.event.trigger("ajaxSuccess", [xhr, s]);
			}
            else if (status) {
				if (errMsg == undefined)
					errMsg = xhr.statusText;
				s.error && s.error.call(s.context, xhr, status, errMsg);
				g && $.event.trigger("ajaxError", [xhr, s, errMsg]);
            }

			g && $.event.trigger("ajaxComplete", [xhr, s]);

			if (g && ! --$.active) {
				$.event.trigger("ajaxStop");
			}

			s.complete && s.complete.call(s.context, xhr, status);

			callbackProcessed = true;
			if (s.timeout)
				clearTimeout(timeoutHandle);

			// clean up
			setTimeout(function() {
				if (!s.iframeTarget)
					$io.remove();
				xhr.responseXML = null;
			}, 100);
		}

		var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
			if (window.ActiveXObject) {
				doc = new ActiveXObject('Microsoft.XMLDOM');
				doc.async = 'false';
				doc.loadXML(s);
			}
			else {
				doc = (new DOMParser()).parseFromString(s, 'text/xml');
			}
			return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
		};
		var parseJSON = $.parseJSON || function(s) {
			return window['eval']('(' + s + ')');
		};

		var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4

			var ct = xhr.getResponseHeader('content-type') || '',
				xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
				data = xml ? xhr.responseXML : xhr.responseText;

			if (xml && data.documentElement.nodeName === 'parsererror') {
				$.error && $.error('parsererror');
			}
			if (s && s.dataFilter) {
				data = s.dataFilter(data, type);
			}
			if (typeof data === 'string') {
				if (type === 'json' || !type && ct.indexOf('json') >= 0) {
					data = parseJSON(data);
				} else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
					$.globalEval(data);
				}
			}
			return data;
		};
	}
};

/**
 * ajaxForm() provides a mechanism for fully automating form submission.
 *
 * The advantages of using this method instead of ajaxSubmit() are:
 *
 * 1: This method will include coordinates for <input type="image" /> elements (if the element
 *	is used to submit the form).
 * 2. This method will include the submit element's name/value data (for the element that was
 *	used to submit the form).
 * 3. This method binds the submit() method to the form for you.
 *
 * The options argument for ajaxForm works exactly as it does for ajaxSubmit.  ajaxForm merely
 * passes the options argument along after properly binding events for submit elements and
 * the form itself.
 */
$.fn.ajaxForm = function(options) {
	// in jQuery 1.3+ we can fix mistakes with the ready state
	if (this.length === 0) {
		var o = { s: this.selector, c: this.context };
		if (!$.isReady && o.s) {
			log('DOM not ready, queuing ajaxForm');
			$(function() {
				$(o.s,o.c).ajaxForm(options);
			});
			return this;
		}
		// is your DOM ready?  http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
		log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
		return this;
	}

	return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
		if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
			e.preventDefault();
			$(this).ajaxSubmit(options);
		}
	}).bind('click.form-plugin', function(e) {
		var target = e.target;
		var $el = $(target);
		if (!($el.is(":submit,input:image"))) {
			// is this a child element of the submit el?  (ex: a span within a button)
			var t = $el.closest(':submit');
			if (t.length == 0) {
				return;
			}
			target = t[0];
		}
		var form = this;
		form.clk = target;
		if (target.type == 'image') {
			if (e.offsetX != undefined) {
				form.clk_x = e.offsetX;
				form.clk_y = e.offsetY;
			} else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
				var offset = $el.offset();
				form.clk_x = e.pageX - offset.left;
				form.clk_y = e.pageY - offset.top;
			} else {
				form.clk_x = e.pageX - target.offsetLeft;
				form.clk_y = e.pageY - target.offsetTop;
			}
		}
		// clear form vars
		setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
	});
};

// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
$.fn.ajaxFormUnbind = function() {
	return this.unbind('submit.form-plugin click.form-plugin');
};

/**
 * formToArray() gathers form element data into an array of objects that can
 * be passed to any of the following ajax functions: $.get, $.post, or load.
 * Each object in the array has both a 'name' and 'value' property.  An example of
 * an array for a simple login form might be:
 *
 * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
 *
 * It is this array that is passed to pre-submit callback functions provided to the
 * ajaxSubmit() and ajaxForm() methods.
 */
$.fn.formToArray = function(semantic) {
	var a = [];
	if (this.length === 0) {
		return a;
	}

	var form = this[0];
	var els = semantic ? form.getElementsByTagName('*') : form.elements;
	if (!els) {
		return a;
	}

	var i,j,n,v,el,max,jmax;
	for(i=0, max=els.length; i < max; i++) {
		el = els[i];
		n = el.name;
		if (!n) {
			continue;
		}

		if (semantic && form.clk && el.type == "image") {
			// handle image inputs on the fly when semantic == true
			if(!el.disabled && form.clk == el) {
				a.push({name: n, value: $(el).val()});
				a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
			}
			continue;
		}

		v = $.fieldValue(el, true);
		if (v && v.constructor == Array) {
			for(j=0, jmax=v.length; j < jmax; j++) {
				a.push({name: n, value: v[j]});
			}
		}
		else if (v !== null && typeof v != 'undefined') {
			a.push({name: n, value: v});
		}
	}

	if (!semantic && form.clk) {
		// input type=='image' are not found in elements array! handle it here
		var $input = $(form.clk), input = $input[0];
		n = input.name;
		if (n && !input.disabled && input.type == 'image') {
			a.push({name: n, value: $input.val()});
			a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
		}
	}
	return a;
};

/**
 * Serializes form data into a 'submittable' string. This method will return a string
 * in the format: name1=value1&amp;name2=value2
 */
$.fn.formSerialize = function(semantic) {
	//hand off to jQuery.param for proper encoding
	return $.param(this.formToArray(semantic));
};

/**
 * Serializes all field elements in the jQuery object into a query string.
 * This method will return a string in the format: name1=value1&amp;name2=value2
 */
$.fn.fieldSerialize = function(successful) {
	var a = [];
	this.each(function() {
		var n = this.name;
		if (!n) {
			return;
		}
		var v = $.fieldValue(this, successful);
		if (v && v.constructor == Array) {
			for (var i=0,max=v.length; i < max; i++) {
				a.push({name: n, value: v[i]});
			}
		}
		else if (v !== null && typeof v != 'undefined') {
			a.push({name: this.name, value: v});
		}
	});
	//hand off to jQuery.param for proper encoding
	return $.param(a);
};

/**
 * Returns the value(s) of the element in the matched set.  For example, consider the following form:
 *
 *  <form><fieldset>
 *	  <input name="A" type="text" />
 *	  <input name="A" type="text" />
 *	  <input name="B" type="checkbox" value="B1" />
 *	  <input name="B" type="checkbox" value="B2"/>
 *	  <input name="C" type="radio" value="C1" />
 *	  <input name="C" type="radio" value="C2" />
 *  </fieldset></form>
 *
 *  var v = $(':text').fieldValue();
 *  // if no values are entered into the text inputs
 *  v == ['','']
 *  // if values entered into the text inputs are 'foo' and 'bar'
 *  v == ['foo','bar']
 *
 *  var v = $(':checkbox').fieldValue();
 *  // if neither checkbox is checked
 *  v === undefined
 *  // if both checkboxes are checked
 *  v == ['B1', 'B2']
 *
 *  var v = $(':radio').fieldValue();
 *  // if neither radio is checked
 *  v === undefined
 *  // if first radio is checked
 *  v == ['C1']
 *
 * The successful argument controls whether or not the field element must be 'successful'
 * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
 * The default value of the successful argument is true.  If this value is false the value(s)
 * for each element is returned.
 *
 * Note: This method *always* returns an array.  If no valid value can be determined the
 *	   array will be empty, otherwise it will contain one or more values.
 */
$.fn.fieldValue = function(successful) {
	for (var val=[], i=0, max=this.length; i < max; i++) {
		var el = this[i];
		var v = $.fieldValue(el, successful);
		if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
			continue;
		}
		v.constructor == Array ? $.merge(val, v) : val.push(v);
	}
	return val;
};

/**
 * Returns the value of the field element.
 */
$.fieldValue = function(el, successful) {
	var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
	if (successful === undefined) {
		successful = true;
	}

	if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
		(t == 'checkbox' || t == 'radio') && !el.checked ||
		(t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
		tag == 'select' && el.selectedIndex == -1)) {
			return null;
	}

	if (tag == 'select') {
		var index = el.selectedIndex;
		if (index < 0) {
			return null;
		}
		var a = [], ops = el.options;
		var one = (t == 'select-one');
		var max = (one ? index+1 : ops.length);
		for(var i=(one ? index : 0); i < max; i++) {
			var op = ops[i];
			if (op.selected) {
				var v = op.value;
				if (!v) { // extra pain for IE...
					v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
				}
				if (one) {
					return v;
				}
				a.push(v);
			}
		}
		return a;
	}
	return $(el).val();
};

/**
 * Clears the form data.  Takes the following actions on the form's input fields:
 *  - input text fields will have their 'value' property set to the empty string
 *  - select elements will have their 'selectedIndex' property set to -1
 *  - checkbox and radio inputs will have their 'checked' property set to false
 *  - inputs of type submit, button, reset, and hidden will *not* be effected
 *  - button elements will *not* be effected
 */
$.fn.clearForm = function() {
	return this.each(function() {
		$('input,select,textarea', this).clearFields();
	});
};

/**
 * Clears the selected form elements.
 */
$.fn.clearFields = $.fn.clearInputs = function() {
	var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list
	return this.each(function() {
		var t = this.type, tag = this.tagName.toLowerCase();
		if (re.test(t) || tag == 'textarea') {
			this.value = '';
		}
		else if (t == 'checkbox' || t == 'radio') {
			this.checked = false;
		}
		else if (tag == 'select') {
			this.selectedIndex = -1;
		}
	});
};

/**
 * Resets the form data.  Causes all form elements to be reset to their original value.
 */
$.fn.resetForm = function() {
	return this.each(function() {
		// guard against an input with the name of 'reset'
		// note that IE reports the reset function as an 'object'
		if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
			this.reset();
		}
	});
};

/**
 * Enables or disables any matching elements.
 */
$.fn.enable = function(b) {
	if (b === undefined) {
		b = true;
	}
	return this.each(function() {
		this.disabled = !b;
	});
};

/**
 * Checks/unchecks any matching checkboxes or radio buttons and
 * selects/deselects and matching option elements.
 */
$.fn.selected = function(select) {
	if (select === undefined) {
		select = true;
	}
	return this.each(function() {
		var t = this.type;
		if (t == 'checkbox' || t == 'radio') {
			this.checked = select;
		}
		else if (this.tagName.toLowerCase() == 'option') {
			var $sel = $(this).parent('select');
			if (select && $sel[0] && $sel[0].type == 'select-one') {
				// deselect all other options
				$sel.find('option').selected(false);
			}
			this.selected = select;
		}
	});
};

// helper fn for console logging
function log() {
	var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
	if (window.console && window.console.log) {
		window.console.log(msg);
	}
	else if (window.opera && window.opera.postError) {
		window.opera.postError(msg);
	}
};

})(jQuery);

/*
 * jquery.tools 1.1.2 - The missing UI library for the Web
 * 
 * [tools.tabs-1.0.4, tools.tabs.slideshow-1.0.2, tools.tabs.history-1.0.2, tools.tooltip-1.1.3, tools.tooltip.slide-1.0.0, tools.tooltip.dynamic-1.0.1, tools.scrollable-1.1.2, tools.scrollable.circular-0.5.1, tools.scrollable.autoscroll-1.0.1, tools.scrollable.navigator-1.0.2, tools.scrollable.mousewheel-1.0.1, tools.overlay-1.1.2]
 * 
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 * 
 * -----
 * 
 * jquery.event.wheel.js - rev 1 
 * Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)
 * Liscensed under the MIT License (MIT-LICENSE.txt)
 * http://www.opensource.org/licenses/mit-license.php
 * Created: 2008-07-01 | Updated: 2008-07-14
 * 
 * -----
 * 
 * File generated: Tue Feb 16 09:49:11 GMT 2010
 */
(function($) {
	eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('$.1r.1s=6(1I){7 4=$.22({},$.1r.1s.1E,1I);7 3=[\'16\',\'a\',\'b\',\'c\',\'d\',\'e\',\'f\',\'g\',\'h\',\'i\',\'j\',\'k\',\'l\',\'m\',\'n\',\'o\',\'p\',\'q\',\'r\',\'s\',\'t\',\'u\',\'v\',\'w\',\'x\',\'y\',\'z\',\'-\'];7 Z=L;4.13=$.23(4.13,6(n){K n.1h()});K 8.1K(6(){7 $O,B,$B,$3,$N,1b;1b=8.1b;$O=$(\'#\'+1b+\'-20\');$B=$(8);7 I={},1l=0,1f=C,2b=0,17=\'\';6 1D(){$O.1A(1H());$3=$(\'.5-3\',$O).S(0,1);2(4.R)$N=$(\'.5-F-D\',$O).S(0,1);1J();1x();2(4.1L)1y();1C();2(!4.1c)$B.Y();2(!4.1c)$(\'.12\',$3).1j();2(!4.1v)$(\'.16\',$3).1j();2(!4.28)$(\'.-\',$3).1j();$(\':1G\',$3).10(\'5-1G\');2($.15&&(4.11!=J)){7 1i=$.15(4.11);2(1i!=J)4.1d=1i}2(4.1d!=\'\'){Z=C;$(\'.\'+4.1d.1h(),$3).S(0,1).1p()}H{2(4.1c)$(\'.12\',$3).10(\'5-1a\');H{1w(7 i=((4.1v)?0:1);i<3.M;i++){2(I[3[i]]>0){Z=C;$(\'.\'+3[i],$3).S(0,1).1p();2d}}}}}6 1O(){$N.1W({1q:$(\'.a\',$3).S(0,1).2a({1m:L,25:C}).1q-$N.24({1m:C})})}6 1J(){7 T,A,1Z,Q,$8,1P=(4.13.M>0);$($B).G().1K(6(){$8=$(8),A=\'\',T=$.21($8.1R()).1h();2(T!=\'\'){2(1P){Q=T.1g(\' \');2((Q.M>1)&&($.2f(Q[0],4.13)>-1)){A=Q[1].1F(0);1k(A,$8,C)}}A=T.1F(0);1k(A,$8)}})}6 1k(A,$V,1z){2(/\\W/.2p(A))A=\'-\';2(!2q(A))A=\'16\';$V.10(\'5-\'+A);2(I[A]==1n)I[A]=0;I[A]++;2(!1z)1l++}6 1y(){1w(7 i=0;i<3.M;i++){2(I[3[i]]==1n)$(\'.\'+3[i],$3).10(\'5-2l\')}}6 1x(){$B.1A(\'<1B E="5-18-14" 1U="1Q:1V">\'+4.1N+\'</1B>\')}6 1o(V){2($(V).2g(\'12\'))K 1l;H{7 D=I[$(V).1T(\'E\').1g(\' \')[0]];K(D!=1n)?D:0}}6 1C(){2(4.R){$O.1X(6(){1O()})}2(4.R){$(\'a\',$3).1X(6(){7 U=$(8).1S().U;7 19=($(8).2i({1m:C})-1)+\'2h\';7 D=1o(8);$N.1W({U:U,19:19}).1R(D).Y()});$(\'a\',$3).2e(6(){$N.X()})}$(\'a\',$3).1p(6(){$(\'a.5-1a\',$3).2n(\'5-1a\');7 F=$(8).1T(\'E\').1g(\' \')[0];2(F==\'12\'){$B.G().Y();$B.G(\'.5-18-14\').X();1f=C}H{2(1f){$B.G().X();1f=L}H 2(17!=\'\')$B.G(\'.5-\'+17).X();7 D=1o(8);2(D>0){$B.G(\'.5-18-14\').X();$B.G(\'.5-\'+F).Y()}H $B.G(\'.5-18-14\').Y();17=F}2($.15&&(4.11!=J))$.15(4.11,F);$(8).10(\'5-1a\');$(8).2o();2(!Z&&(4.1t!=J))4.1t(F);H Z=L;K L})}6 1H(){7 P=[];1w(7 i=1;i<3.M;i++){2(P.M==0)P.1M(\'<a E="12" 1u="#">2j</a><a E="16" 1u="#">0-9</a>\');P.1M(\'<a E="\'+3[i]+\'" 1u="#">\'+((3[i]==\'-\')?\'...\':3[i].2c())+\'</a>\')}K\'<1e E="5-3">\'+P.1Y(\'\')+\'</1e>\'+((4.R)?\'<1e E="5-F-D" 1U="1Q:1V; 1S:2k; 1q:0; U:0; 19:2m;">0</1e>\':\'\')}1D()})};$.1r.1s.1E={1d:\'\',1c:C,2r:L,1v:C,1L:C,1N:\'29 26 27\',R:C,11:J,1t:J,13:[]};',62,152,'||if|letters|opts|ln|function|var|this||||||||||||||||||||||||||||firstChar|list|true|count|class|letter|children|else|counts|null|return|false|length|letterCount|wrapper|html|spl|showCounts|slice|str|left|el||hide|show|firstClick|addClass|cookieName|all|prefixes|match|cookie|_|prevLetter|no|width|selected|id|includeAll|initLetter|div|isAll|split|toLowerCase|cookieLetter|remove|addLetterClass|allCount|margin|undefined|getLetterCount|click|top|fn|listnav|onClick|href|includeNums|for|addNoMatchLI|addDisabledClass|isPrefix|append|li|bindHandlers|init|defaults|charAt|last|createLettersHtml|options|addClasses|each|flagDisabled|push|noMatchText|setLetterCountTop|hasPrefixes|display|text|position|attr|style|none|css|mouseover|join|firstWord|nav|trim|extend|map|outerHeight|border|matching|entries|includeOther|No|offset|numCount|toUpperCase|break|mouseout|inArray|hasClass|px|outerWidth|ALL|absolute|disabled|20px|removeClass|blur|test|isNaN|incudeOther'.split('|'),0,{}))
//	eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(8($){9 v=($.1A.2j&&$.1A.2k<7);9 w=$(1B.1C);9 y=$(y);9 z=F;$.3d.13=8(b){G 5.1Y(8(){9 a=5.3e.3f();A(a==\'a\'){Q 13(5,b)}})};13=8(g,h){9 j=2l;j=$(g).1D("13");A(j)G j;9 k=5;9 l=$.1E({},$.13.2m,h||{});k.3g=g;g.1p=$(g).R(\'1p\');g.1F=F;g.3h=F;g.1u=F;g.1h=F;g.1b={};g.2n=2l;g.14={};g.1G=F;$(g).D({\'3i-1i\':\'1v\',\'3j-3k\':\'1v\'});9 m=$("3l:3m(0)",g);g.V=$(g).R(\'V\');g.1Z=m.R(\'V\');9 n=($.1w(g.V).Y>0)?g.V:g.1Z;9 p=Q 2o(m);9 q=Q 2p();9 r=Q 2q();9 s=Q 2r();9 t=Q 2s();$(g).1H(\'2t\',8(e){e.2u();G F});9 u=[\'20\',\'1c\',\'1j\',\'1q\'];A($.3n($.1w(l.H),u)<0){l.H=\'20\'}$.1E(k,{21:8(){A($(".L",g).Y==0){g.L=$(\'<Z/>\').1I(\'L\');m.3o(g.L)}A(l.H==\'1j\'){l.15=p.w;l.16=p.h}A($(".22",g).Y==0){q.S()}A($(".23",g).Y==0){r.S()}A($(".2v",g).Y==0){t.S()}A(l.24||l.H==\'1c\'||l.1J){k.1K()}k.2w()},2w:8(){A(l.H==\'1c\'){$(".L",g).3p(8(){g.1G=17});$(".L",g).3q(8(){g.1G=F});1B.1C.3r=8(){G F};$(".L",g).D({1L:\'1r\'});$(".22",g).D({1L:\'3s\'})}A(l.H==\'1j\'){$(".1M",g).D({1L:\'3t\'})}$(".L",g).1H(\'3u 3v\',8(a){m.R(\'V\',\'\');$(g).R(\'V\',\'\');g.1F=17;p.1s();A(g.1h){k.25(a)}1k{k.1K()}});$(".L",g).1H(\'3w\',8(a){k.2x()});$(".L",g).1H(\'3x\',8(e){A(e.26>p.E.r||e.26<p.E.l||e.27<p.E.t||e.27>p.E.b){q.1N();G F}g.1F=17;A(g.1h&&!$(\'.23\',g).3y(\':2y\')){k.25(e)}A(g.1h&&(l.H!=\'1c\'||(l.H==\'1c\'&&g.1G))){q.1l(e)}});9 c=Q 2z();9 i=0;9 d=Q 2z();d=$(\'a\').3z(8(){9 a=Q 3A("3B[\\\\s]*:[\\\\s]*\'"+$.1w(g.1p)+"\'","i");9 b=$(5).R(\'1p\');A(a.3C(b)){G 5}});A(d.Y>0){9 f=d.3D(0,1);d.3E(f)}d.1Y(8(){A(l.24){9 a=$.1E({},1O("("+$.1w($(5).R(\'1p\'))+")"));c[i]=Q 28();c[i].1d=a.1x;i++}$(5).2t(8(e){A($(5).3F(\'29\')){G F}d.1Y(8(){$(5).3G(\'29\')});e.2u();k.2A(5);G F})})},1K:8(){A(g.1h==F&&g.1u==F){9 a=$(g).R(\'2B\');g.1u=17;s.2C(a)}},25:8(e){3H(g.2n);q.T();r.T()},2x:8(e){1P(l.H){1t\'1c\':W;1r:m.R(\'V\',g.1Z);$(g).R(\'V\',g.V);A(l.1J){q.1N()}1k{r.O();q.O()}W}g.1F=F},2A:8(a){g.1u=F;g.1h=F;9 b=Q 3I();b=$.1E({},1O("("+$.1w($(a).R(\'1p\'))+")"));A(b.1Q&&b.1x){9 c=b.1Q;9 d=b.1x;$(a).1I(\'29\');$(g).R(\'2B\',d);m.R(\'1d\',c);q.O();r.O();k.1K()}1k{2a(\'2D :: 2E 2F 1R 1x 2G 1Q.\');2b\'2D :: 2E 2F 1R 1x 2G 1Q.\';}G F}});A(m[0].3J){p.1s();A($(".L",g).Y==0)k.21()}8 2o(c){9 d=5;5.6=c[0];5.2H=8(){9 a=0;a=c.D(\'2c-B-P\');M=\'\';9 b=0;b=c.D(\'2c-C-P\');K=\'\';A(a){1R(i=0;i<3;i++){9 x=[];x=a.1S(i,1);A(2I(x)==F){M=M+\'\'+a.1S(i,1)}1k{W}}}A(b){1R(i=0;i<3;i++){A(!2I(b.1S(i,1))){K=K+b.1S(i,1)}1k{W}}}d.M=(M.Y>0)?1O(M):0;d.K=(K.Y>0)?1O(K):0};5.1s=8(){d.2H();d.w=c.P();d.h=c.12();d.1m=c.3K();d.1e=c.3L();d.E=c.1f();d.E.l=c.1f().C+d.K;d.E.t=c.1f().B+d.M;d.E.r=d.w+d.E.l;d.E.b=d.h+d.E.t;d.2J=c.1f().C+d.1m;d.3M=c.1f().B+d.1e};5.6.2K=8(){2a(\'1T 1U 1V X.\');2b\'1T 1U 1V X.\';};5.6.2L=8(){d.1s();A($(".L",g).Y==0)k.21()};G d};8 2s(){9 a=5;5.S=8(){5.6=$(\'<Z/>\').1I(\'2v\').D(\'2d\',\'2M\').2N(l.2O);$(\'.L\',g).S(5.6)};5.T=8(){5.6.B=(p.1e-5.6.12())/2;5.6.C=(p.1m-5.6.P())/2;5.6.D({B:5.6.B,C:5.6.C,11:\'18\',2d:\'2y\'})};5.O=8(){5.6.D(\'2d\',\'2M\')};G 5}8 2p(){9 d=5;5.6=$(\'<Z/>\').1I(\'22\');5.S=8(){$(\'.L\',g).S($(5.6).O());A(l.H==\'1q\'){5.X=Q 28();5.X.1d=p.6.1d;$(5.6).2e().S(5.X)}};5.2P=8(){5.6.w=(1W((l.15)/g.1b.x)>p.w)?p.w:(1W(l.15/g.1b.x));5.6.h=(1W((l.16)/g.1b.y)>p.h)?p.h:(1W(l.16/g.1b.y));5.6.B=(p.1e-5.6.h-2)/2;5.6.C=(p.1m-5.6.w-2)/2;5.6.D({B:0,C:0,P:5.6.w+\'I\',12:5.6.h+\'I\',11:\'18\',1g:\'1v\',2f:1+\'I\'});A(l.H==\'1q\'){5.X.1d=p.6.1d;$(5.6).D({\'2g\':1});$(5.X).D({11:\'18\',1g:\'1y\',C:-(5.6.C+1-p.K)+\'I\',B:-(5.6.B+1-p.M)+\'I\'})}};5.1N=8(){5.6.B=(p.1e-5.6.h-2)/2;5.6.C=(p.1m-5.6.w-2)/2;5.6.D({B:5.6.B,C:5.6.C});A(l.H==\'1q\'){$(5.X).D({11:\'18\',1g:\'1y\',C:-(5.6.C+1-p.K)+\'I\',B:-(5.6.B+1-p.M)+\'I\'})}s.1l()};5.1l=8(e){g.14.x=e.26;g.14.y=e.27;9 b=0;9 c=0;8 2Q(a){G g.14.x-(a.w)/2<p.E.l}8 2R(a){G g.14.x+(a.w)/2>p.E.r}8 2S(a){G g.14.y-(a.h)/2<p.E.t}8 2T(a){G g.14.y+(a.h)/2>p.E.b}b=g.14.x+p.K-p.E.l-(5.6.w+2)/2;c=g.14.y+p.M-p.E.t-(5.6.h+2)/2;A(2Q(5.6)){b=p.K-1}1k A(2R(5.6)){b=p.w+p.K-5.6.w-1}A(2S(5.6)){c=p.M-1}1k A(2T(5.6)){c=p.h+p.M-5.6.h-1}5.6.C=b;5.6.B=c;5.6.D({\'C\':b+\'I\',\'B\':c+\'I\'});A(l.H==\'1q\'){A($.1A.2j&&$.1A.2k>7){$(5.6).2e().S(5.X)}$(5.X).D({11:\'18\',1g:\'1y\',C:-(5.6.C+1-p.K)+\'I\',B:-(5.6.B+1-p.M)+\'I\'})}s.1l()};5.O=8(){m.D({\'2g\':1});5.6.O()};5.T=8(){A(l.H!=\'1j\'&&(l.2U||l.H==\'1c\')){5.6.T()}A(l.H==\'1q\'){m.D({\'2g\':l.2V})}};5.2h=8(){9 o={};o.C=d.6.C;o.B=d.6.B;G o};G 5};8 2q(){9 b=5;5.6=$("<Z 1z=\'23\'><Z 1z=\'1M\'><Z 1z=\'1X\'></Z><Z 1z=\'2i\'></Z></Z></Z>");5.U=$(\'<2W 1z="3N" 1d="3O:\\\'\\\';" 3P="0" 3Q="0" 3R="2X" 3S="3T" 3U="0" ></2W>\');5.1l=8(){5.6.1n=0;5.6.1o=0;A(l.H!=\'1j\'){1P(l.11){1t"C":5.6.1n=(p.E.l-p.K-J.N(l.19)-l.15>0)?(0-l.15-J.N(l.19)):(p.1m+J.N(l.19));5.6.1o=J.N(l.1a);W;1t"B":5.6.1n=J.N(l.19);5.6.1o=(p.E.t-p.M-J.N(l.1a)-l.16>0)?(0-l.16-J.N(l.1a)):(p.1e+J.N(l.1a));W;1t"2X":5.6.1n=J.N(l.19);5.6.1o=(p.E.t-p.M+p.1e+J.N(l.1a)+l.16<2Y.12)?(p.1e+J.N(l.1a)):(0-l.16-J.N(l.1a));W;1r:5.6.1n=(p.2J+J.N(l.19)+l.15<2Y.P)?(p.1m+J.N(l.19)):(0-l.15-J.N(l.19));5.6.1o=J.N(l.1a);W}}5.6.D({\'C\':5.6.1n+\'I\',\'B\':5.6.1o+\'I\'});G 5};5.S=8(){$(\'.L\',g).S(5.6);5.6.D({11:\'18\',1g:\'1v\',2Z:3V});A(l.H==\'1j\'){5.6.D({1L:\'1r\'});9 a=(p.K==0)?1:p.K;$(\'.1M\',5.6).D({2f:a+\'I\'})}$(\'.1M\',5.6).D({P:J.30(l.15)+\'I\',2f:a+\'I\'});$(\'.2i\',5.6).D({P:\'31%\',12:J.30(l.16)+\'I\'});$(\'.1X\',5.6).D({P:\'31%\',11:\'18\'});$(\'.1X\',5.6).O();A(l.V&&n.Y>0){$(\'.1X\',5.6).2N(n).T()}b.1l()};5.O=8(){1P(l.32){1t\'3W\':5.6.3X(l.33,8(){});W;1r:5.6.O();W}5.U.O()};5.T=8(){1P(l.34){1t\'3Y\':5.6.35();5.6.35(l.36,8(){});W;1r:5.6.T();W}A(v&&l.H!=\'1j\'){5.U.P=5.6.P();5.U.12=5.6.12();5.U.C=5.6.1n;5.U.B=5.6.1o;5.U.D({1g:\'1y\',11:"18",C:5.U.C,B:5.U.B,2Z:3Z,P:5.U.P+\'I\',12:5.U.12+\'I\'});$(\'.L\',g).S(5.U);5.U.T()}}};8 2r(){9 c=5;5.6=Q 28();5.2C=8(a){t.T();5.40=a;5.6.1i.11=\'18\';5.6.1i.2c=\'37\';5.6.1i.1g=\'1v\';5.6.1i.C=\'-41\';5.6.1i.B=\'37\';1B.1C.42(5.6);5.6.1d=a};5.1s=8(){9 a=$(5.6);9 b={};5.6.1i.1g=\'1y\';c.w=a.P();c.h=a.12();c.E=a.1f();c.E.l=a.1f().C;c.E.t=a.1f().B;c.E.r=c.w+c.E.l;c.E.b=c.h+c.E.t;b.x=(c.w/p.w);b.y=(c.h/p.h);g.1b=b;1B.1C.43(5.6);$(\'.2i\',g).2e().S(5.6);q.2P()};5.6.2K=8(){2a(\'1T 1U 1V 38 39 X.\');2b\'1T 1U 1V 38 39 X.\';};5.6.2L=8(){c.1s();t.O();g.1u=F;g.1h=17;A(l.H==\'1c\'||l.1J){q.T();r.T();q.1N()}};5.1l=8(){9 a=-g.1b.x*(q.2h().C-p.K+1);9 b=-g.1b.y*(q.2h().B-p.M+1);$(5.6).D({\'C\':a+\'I\',\'B\':b+\'I\'})};G 5};$(g).1D("13",k)};$.13={2m:{H:\'20\',15:3a,16:3a,19:10,1a:0,11:"44",24:17,2O:\'45 46\',V:17,2U:17,2V:0.4,1J:F,34:\'T\',32:\'O\',36:\'47\',33:\'48\'},3b:8(a){9 b=$(a).1D(\'13\');b.3b();G F},3c:8(a){9 b=$(a).1D(\'13\');b.3c();G F},49:8(a){z=17},4a:8(a){z=F}}})(4b);',62,260,'|||||this|node||function|var|||||||||||||||||||||||||||if|top|left|css|pos|false|return|zoomType|px|Math|bleft|zoomPad|btop|abs|hide|width|new|attr|append|show|ieframe|title|break|image|length|div||position|height|jqzoom|mousepos|zoomWidth|zoomHeight|true|absolute|xOffset|yOffset|scale|drag|src|oh|offset|display|largeimageloaded|style|innerzoom|else|setposition|ow|leftpos|toppos|rel|reverse|default|fetchdata|case|largeimageloading|none|trim|largeimage|block|class|browser|document|body|data|extend|zoom_active|mouseDown|bind|addClass|alwaysOn|load|cursor|zoomWrapper|setcenter|eval|switch|smallimage|for|substr|Problems|while|loading|parseInt|zoomWrapperTitle|each|imagetitle|standard|create|zoomPup|zoomWindow|preloadImages|activate|pageX|pageY|Image|zoomThumbActive|alert|throw|border|visibility|empty|borderWidth|opacity|getoffset|zoomWrapperImage|msie|version|null|defaults|timer|Smallimage|Lens|Stage|Largeimage|Loader|click|preventDefault|zoomPreload|init|deactivate|visible|Array|swapimage|href|loadimage|ERROR|Missing|parameter|or|findborder|isNaN|rightlimit|onerror|onload|hidden|html|preloadText|setdimensions|overleft|overright|overtop|overbottom|lens|imageOpacity|iframe|bottom|screen|zIndex|round|100|hideEffect|fadeoutSpeed|showEffect|fadeIn|fadeinSpeed|0px|the|big|300|disable|enable|fn|nodeName|toLowerCase|el|zoom_disabled|outline|text|decoration|img|eq|inArray|wrap|mousedown|mouseup|ondragstart|move|crosshair|mouseenter|mouseover|mouseleave|mousemove|is|filter|RegExp|gallery|test|splice|push|hasClass|removeClass|clearTimeout|Object|complete|outerWidth|outerHeight|bottomlimit|zoomIframe|javascript|marginwidth|marginheight|align|scrolling|no|frameborder|5001|fadeout|fadeOut|fadein|99|url|5000px|appendChild|removeChild|right|Loading|zoom|slow|2000|disableAll|enableAll|jQuery'.split('|'),0,{}))
})(jQuery);



/*
 * jqDnR - Minimalistic Drag'n'Resize for jQuery.
 *
 * Copyright (c) 2007 Brice Burgess <bhb@iceburg.net>, http://www.iceburg.net
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * $Version: 2007.08.19 +r2
 */

(function($){
$.fn.jqDrag=function(h){return i(this,h,'d');};
$.fn.jqResize=function(h){return i(this,h,'r');};
$.jqDnR={dnr:{},e:0,
drag:function(v){
 if(M.k == 'd')E.css({left:M.X+v.pageX-M.pX,top:M.Y+v.pageY-M.pY});
 else E.css({width:Math.max(v.pageX-M.pX+M.W,0),height:Math.max(v.pageY-M.pY+M.H,0)});
  return false;},
stop:function(){E.css('opacity',M.o);$().unbind('mousemove',J.drag).unbind('mouseup',J.stop);}
};
var J=$.jqDnR,M=J.dnr,E=J.e,
i=function(e,h,k){return e.each(function(){h=(h)?$(h,e):e;
 h.bind('mousedown',{e:e,k:k},function(v){var d=v.data,p={};E=d.e;
 // attempt utilization of dimensions plugin to fix IE issues
 if(E.css('position') != 'relative'){try{E.position(p);}catch(e){}}
 M={X:p.left||f('left')||0,Y:p.top||f('top')||0,W:f('width')||E[0].scrollWidth||0,H:f('height')||E[0].scrollHeight||0,pX:v.pageX,pY:v.pageY,k:d.k,o:E.css('opacity')};
 E.css({opacity:1});$().mousemove($.jqDnR.drag).mouseup($.jqDnR.stop);
 return false;
 });
});},
f=function(k){return parseInt(E.css(k))||false;};
})(jQuery);

/*
* jqModal - Minimalist Modaling with jQuery
* (http://dev.iceburg.net/jquery/jqModal/)
*
* Copyright (c) 2007,2008 Brice Burgess <bhb@iceburg.net>
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* $Version: 03/01/2009 +r14
*/
(function($) {
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('$.k.9=4(o){7 p={v:1o,1f:\'1H\',13:\'1G\',O:\'.1K\',D:F,1a:\'\',I:F,19:F,T:F,q:F,B:F,C:F};5 3.l(4(){2(3.8)5 H[3.8].c=$.16({},H[3.8].c,o);s++;3.8=s;H[s]={c:$.16(p,$.9.10,o),a:F,w:$(3).1e(\'1m\'+s),s:s};2(p.O)$(3).17(p.O)})};$.k.n=4(e){5 V(3,e,\'U\')};$.k.17=4(e){5 V(3,e,\'S\')};$.k.S=4(t){5 3.l(4(){t=t||15.14;$.9.12(3.8,t)})};$.k.U=4(t){5 3.l(4(){t=t||15.14;$.9.1g(3.8,t)})};$.9={1h:{},12:4(s,t){7 h=H[s],c=h.c,g=\'.\'+c.13,z=(1E(h.w.d(\'z-Q\'))),z=(z>0)?z:1C,o=$(\'<18></18>\').d({E:\'b%\',J:\'b%\',11:\'1d\',1D:0,1I:0,\'z-Q\':z-1,1n:c.v/b});2(h.a)5 F;h.t=t;h.a=1N;h.w.d(\'z-Q\',z);2(c.19){2(!A[0])L(\'1M\');A.1l(s)}j 2(c.v>0)h.w.n(o);j o=F;h.o=(o)?o.1e(c.1f).1J(\'x\'):F;2(N){$(\'K,x\').d({E:\'b%\',J:\'b%\'});2(o){o=o.d({11:\'1d\'})[0];R(7 y M{1O:1,1A:1})o.1i.1s(y.1t(),"(1k=(P.1r.1c"+y+" || P.x.1c"+y+"))+\'1p\'")}}2(c.D){7 r=c.I||h.w,u=c.D,r=(1u r==\'1P\')?$(r,h.w):$(r),u=(u.1y(0,1)==\'@\')?$(t).1x(u.1v(1)):u;r.K(c.1a).1L(u,4(){2(c.C)c.C.24(3,h);2(g)h.w.n($(g,h.w));e(h)})}j 2(g)h.w.n($(g,h.w));2(c.T&&h.o)h.w.25(\'<1b 26="W\'+h.w[0].8+\'"></1b>\').27(h.o);(c.q)?c.q(h):h.w.20();e(h);5 F},1g:4(s){7 h=H[s];2(!h.a)5 F;h.a=F;2(A[0]){A.1R();2(!A[0])L(\'1U\')}2(h.c.T&&h.o)$(\'#W\'+h.w[0].8).1W(h.w).Y();2(h.c.B)h.c.B(h);j{h.w.1Y();2(h.o)h.o.Y()}5 F},10:{}};7 s=0,H=$.9.1h,A=[],N=$.Z.1S&&($.Z.1Q=="6.0"),F=X,i=$(\'<G 28="29:X;P.22(\\\'\\\');" 1z="9"></G>\').d({1n:0}),e=4(h){2(N)2(h.o)h.o.K(\'<p 1i="J:b%;E:b%"/>\').1j(i);j 2(!$(\'G.9\',h.w)[0])h.w.1j(i);f(h)},f=4(h){1X{$(\':1Z:1V\',h.w)[0].1T()}21(1k){}},L=4(t){$()[t]("23",m)[t]("2a",m)[t]("1w",m)},m=4(e){7 h=H[A[A.1q-1]],r=(!$(e.I).1B(\'.1m\'+h.s)[0]);2(r)f(h);5!r},V=4(w,t,c){5 w.l(4(){7 s=3.8;$(t).l(4(){2(!3[c]){3[c]=[];$(3).1F(4(){R(7 i M{S:1,U:1})R(7 s M 3[i])2(H[3[i][s]])H[3[i][s]].w[i](3);5 F})}3[c].1l(s)})})};',62,135,'||if|this|function|return||var|_jqm|jqm||100||css|||cc|||else|fn|each||jqmAddClose|||onShow|||||overlay||body||||onHide|onLoad|ajax|height||iframe||target|width|html||in|ie6|trigger|document|index|for|jqmShow|toTop|jqmHide|hs|jqmP|false|remove|browser|params|position|open|closeClass|event|window|extend|jqmAddTrigger|div|modal|ajaxText|span|scroll|absolute|addClass|overlayClass|close|hash|style|prepend|_|push|jqmID|opacity|50|px|length|documentElement|setExpression|toLowerCase|typeof|substring|mousedown|attr|substr|class|Left|parents|3000|left|parseInt|click|jqmClose|jqmOverlay|top|prependTo|jqModal|load|bind|true|Top|string|version|pop|msie|focus|unbind|visible|after|try|hide|input|show|catch|write|keypress|call|before|id|insertAfter|src|javascript|keydown'.split('|'),0,{}))

})(jQuery);


/* Google Ads */
(function($) {
    $(window).load( function() 
    {
		 var $ads;
		 $('div[id^="adsref-"]').each(function() {
		 $ads = $('#ads-' + this.id.substr(7)).empty();
		 $('ins:first', this).appendTo($ads);
		 });
		}

    );   
    })(jQuery);

/*
 * Lazy Load - jQuery plugin for lazy loading images
 *
 * Copyright (c) 2007-2008 Mika Tuupola
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Project home:
 *   http://www.appelsiini.net/projects/lazyload
 *
 * Revision: $Id$
 * Version:  1.3.1
 *
 */
(function($){$.fn.lazyload=function(options){var settings={threshold:0,failurelimit:0,event:"scroll",effect:"show",container:window};if(options){$.extend(settings,options);}
var elements=this;if("scroll"==settings.event){$(settings.container).bind("scroll",function(event){var counter=0;elements.each(function(){if($.abovethetop(this,settings)||$.leftofbegin(this,settings)){}else if(!$.belowthefold(this,settings)&&!$.rightoffold(this,settings)){$(this).trigger("appear");}else{if(counter++>settings.failurelimit){return false;}}});var temp=$.grep(elements,function(element){return!element.loaded;});elements=$(temp);});}
this.each(function(){var self=this;if(undefined==$(self).attr("original")){$(self).attr("original",$(self).attr("src"));}
if("scroll"!=settings.event||undefined==$(self).attr("src")||settings.placeholder==$(self).attr("src")||($.abovethetop(self,settings)||$.leftofbegin(self,settings)||$.belowthefold(self,settings)||$.rightoffold(self,settings))){if(settings.placeholder){$(self).attr("src",settings.placeholder);}else{$(self).removeAttr("src");}
self.loaded=false;}else{self.loaded=true;}
$(self).one("appear",function(){if(!this.loaded){$("<img />").bind("load",function(){$(self).hide().attr("src",$(self).attr("original"))
[settings.effect](settings.effectspeed);self.loaded=true;}).attr("src",$(self).attr("original"));};});if("scroll"!=settings.event){$(self).bind(settings.event,function(event){if(!self.loaded){$(self).trigger("appear");}});}});$(settings.container).trigger(settings.event);return this;};$.belowthefold=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).height()+$(window).scrollTop();}else{var fold=$(settings.container).offset().top+$(settings.container).height();}
return fold<=$(element).offset().top-settings.threshold;};$.rightoffold=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).width()+$(window).scrollLeft();}else{var fold=$(settings.container).offset().left+$(settings.container).width();}
return fold<=$(element).offset().left-settings.threshold;};$.abovethetop=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).scrollTop();}else{var fold=$(settings.container).offset().top;}
return fold>=$(element).offset().top+settings.threshold+$(element).height();};$.leftofbegin=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).scrollLeft();}else{var fold=$(settings.container).offset().left;}
return fold>=$(element).offset().left+settings.threshold+$(element).width();};$.extend($.expr[':'],{"below-the-fold":"$.belowthefold(a, {threshold : 0, container: window})","above-the-fold":"!$.belowthefold(a, {threshold : 0, container: window})","right-of-fold":"$.rightoffold(a, {threshold : 0, container: window})","left-of-fold":"!$.rightoffold(a, {threshold : 0, container: window})"});})(jQuery);


// limit Text ( shoppingcart.aspx)
function limitText(limitField,limitCount,limitNum){if(limitField.value.length>limitNum){limitField.value=limitField.value.substring(0,limitNum);}
else{limitCount.value=limitNum-limitField.value.length;}}

//limit Text end


function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} 

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} 
return strTemp;

} 

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} 
return strTemp;
} 



var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var whitespace = " \t\n\r";

var decimalPointDelimiter = "."

var phoneNumberDelimiters = "()- ";

var validUSPhoneChars = digits + phoneNumberDelimiters;

var validWorldPhoneChars = digits + phoneNumberDelimiters + "+";

var SSNDelimiters = "- ";

var validSSNChars = digits + SSNDelimiters;

var digitsInSocialSecurityNumber = 9;

var digitsInUSPhoneNumber = 10;

var ZIPCodeDelimiters = "-";

var ZIPCodeDelimeter = "-"

var validZIPCodeChars = digits + ZIPCodeDelimiters

var digitsInZIPCode1 = 5
var digitsInZIPCode2 = 9

var creditCardDelimiters = " "

function isOkBag (s, bag)

{   var i;
    var returnString = "";

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) return false;
    }
    return true;
}

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isWhiteSpace (s)
{   var i;

    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    return true;
}

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}

function stripCharsNotInBag (s, bag)

{   var i;
    var returnString = "";

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) != -1) returnString += c;
    }

    return returnString;
}

function stripWhitespace (s)

{   return stripCharsInBag (s, whitespace)
}

function charInString (c, s)
{   for (i = 0; i < s.length; i++)
    {   if (s.charAt(i) == c) return true;
    }
    return false
}

function stripInitialWhitespace (s)

{   var i = 0;

    while ((i < s.length) && charInString (s.charAt(i), whitespace))
       i++;
    
    return s.substring (i, s.length);
}

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isLetterOrDigit (c)
{   return (isLetter(c) || isDigit(c))
}



function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);


    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    return true;
}

function isSignedInteger (s)

{   if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}

function isPositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isPositiveInteger.arguments.length > 1)
        secondArg = isPositiveInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
}

function isNonnegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
}


function isNegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNegativeInteger.arguments.length > 1)
        secondArg = isNegativeInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) < 0) ) );
}


function isNonpositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonpositiveInteger.arguments.length > 1)
        secondArg = isNonpositiveInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) <= 0) ) );
}


function isFloat (s)

{   var i;
    var seenDecimalPoint = false;

    if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isFloat.arguments[1] == true);

    if (s == decimalPointDelimiter) return false;


    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isDigit(c)) return false;
    }

    return true;
}


function isSignedFloat (s)

{   if (isEmpty(s)) 
       if (isSignedFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedFloat.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedFloat.arguments.length > 1)
            secondArg = isSignedFloat.arguments[1];

        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isFloat(s.substring(startPos, s.length), secondArg))
    }
}


function isAlphabetic (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphabetic.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (!isLetter(c))
        return false;
    }

    return true;
}

function isAlphanumeric (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphanumeric.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);

        if (! (isLetter(c) || isDigit(c) ) )
        return false;
    }

    return true;
}

function reformat (s)

{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

function reformatZIPCode (ZIPString)
{   if (ZIPString.length == 5) return ZIPString;
    else return (reformat (ZIPString, "", 5, "-", 4));
}

function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "(", 3, ") ", 3, "-", 4))
}

function reformatSSN (SSN)
{   return (reformat (SSN, "", 3, "-", 2, "-", 4))
}

function isLeapYear(argYear) {
	return ((argYear % 4 == 0) && (argYear % 100 != 0)) || (argYear % 400 == 0) 
}

function daysInMonth(argMonth, argYear) {
	switch (Number(argMonth)) {
		case 1:		// Jan
		case 3:		// Mar
		case 5:		// May
		case 7:		// Jul
		case 8:		// Aug
		case 10:		// Oct
		case 12:		// Dec
			return 31;
			break;
		
		case 4:		// Apr
		case 6:		// Jun
		case 9:		// Sep
		case 11:		// Nov
			return 30;
			break;
		
		case 2:		// Feb
			if (isLeapYear(argYear))
				return 29
			else
				return 28
			break;
		
		default:
			return 0;
	}
}

function getDateSeparator(argDate) {
	if ((argDate.indexOf('-') > 0) && (argDate.indexOf('/') > 0))
		return ' '

	if (argDate.indexOf('-') > 0)
		return '-'
	else
		if (argDate.indexOf('/') > 0)
			return '/'
		else
			return ' '
}

function getYear(argDate) {
	var dateSep = getDateSeparator(argDate)
	
	if (dateSep == ' ')
		return 0

	if(argDate.split(dateSep).length == 3)
		return argDate.split(dateSep)[2]
	else
		return 0
}

function getMonth(argDate) {
	var dateSep = getDateSeparator(argDate)
	
	if (dateSep == ' ')
		return 0

	if(argDate.split(dateSep).length == 3)
		return argDate.split(dateSep)[0]
	else
		return 0
}

function getDay(argDate) {
	var dateSep = getDateSeparator(argDate)
	
	if (dateSep == ' ')
		return 0

	if(argDate.split(dateSep).length == 3)
		return argDate.split(dateSep)[1]
	else
		return 0
}

function isProperDay(argDay, argMonth, argYear) {
	if ((isWhiteSpace(argDay)) || (argDay == 0))
		return false

	if ((argDay > 0) && (argDay < daysInMonth(argMonth, argYear) + 1))
		return true
	else 
		return false
}

function isProperMonth(argMonth) {
	if ((isWhiteSpace(argMonth)) || (argMonth == 0))
		return false
	
	if ((argMonth > 0) && (argMonth < 13))
		return true
	else
		return false
}

function isProperYear(argYear) {
	if ((isWhiteSpace(argYear)) || (argYear.toString().length > 4) || (argYear.toString().length == 3))
		return false
	
	switch (argYear.toString().length) {
		case 1:
			if (argYear >=0 && argYear < 10)
				return true
			else
				return false
			
		case 2:
			if (argYear >=0 && argYear < 100)
				return true
			else
				return false
			
		case 4:
			if (((argYear >=1900) || (argYear >=2000)) && ((argYear < 3000) || (argYear < 2000)))
				return true
			else
				return false
		
		default:
			return false
	}
}

function isProperDate(argDate) {
	var tmpDay = getDay(argDate)
	var tmpMon = getMonth(argDate)
	var tmpYear = getYear(argDate)

	return isProperDay(tmpDay, tmpMon, tmpYear) && isProperMonth(tmpMon) && isProperYear(tmpYear)
}

function charOccurences(argString, argChar) {
	var intCt = 0

	for(var intI=0; intI < argString.length; intI++)
		if (argString.charAt(intI) == argChar)
			intCt++
	
	return intCt
}

function isProperEmail(argEmail) {
	if (charOccurences(argEmail, '@') + charOccurences(argEmail, '.') < 2)
		return false

	var atPos = argEmail.indexOf('@')
	var dotPos = argEmail.indexOf('.')

	if((atPos == 0) || (atPos == (argEmail.length - 1)))
		return false

	if((dotPos == 0) || (dotPos == (argEmail.length - 1)))
		return false
	
	var checkTLD=1;
 
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
 
	var emailPat=/^(.+)@(.+)$/;
 
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
 
 
	var validChars="\[^\\s" + specialChars + "\]";
 
 
	var quotedUser="(\"[^\"]*\")";
 
 
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
 
 
	var atom=validChars + '+';
 
	var word="(" + atom + "|" + quotedUser + ")";
 
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
 
 
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
 
 
 
	var matchArray=argEmail.match(emailPat);
 
	if (matchArray==null)
		{
		return false;
		}
	var user=matchArray[1];
	var domain=matchArray[2];
 
	for (i=0; i<user.length; i++)
		{
		if (user.charCodeAt(i)>127)
			{
			return false;
			}
		}
	for (i=0; i<domain.length; i++)
		{
		if (domain.charCodeAt(i)>127)
			{
			return false;
			}
		}
 
	if (user.match(userPat)==null)
		{
		return false;
	}
 
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null)
		{
		for (var i=1;i<=4;i++)
			{
			if (IPArray[i]>255)
				{
				return false;
				}
			}
		return true;
		}
 
 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++)
		{
		if (domArr[i].search(atomPat)==-1)
			{
			return false;
			}
		}
 
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1)
		{
		return false;
		}
 
	if (len<2)
		{
		return false;
		}
 
	return true;
}

function isProperNumber(argNumber) {
	var numberValue = Number(argNumber)
	
	if (isNaN(numberValue)) 
		return false
	else
		return !isWhiteSpace(argNumber)
}
function getQuerystring(key, default_)
{
	  if (default_==null) default_=""; 
	  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
	  var qs = regex.exec(window.location.href);
	  if(qs == null)
		return default_;
	  else
		return qs[1];
}
function numbersonly(e, decimal) {
var key;
var keychar;

if (window.event) {
   key = window.event.keyCode;
}
else if (e) {
   key = e.which;
}
else {
   return true;
}
keychar = String.fromCharCode(key);

if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) ) {
   return true;
}
else if ((("0123456789").indexOf(keychar) > -1)) {
   return true;
}
else if (decimal && (keychar == ".")) { 
  return true;
}
else
   return false;
}


function isProperAlphabetic(argString) {
	var alphabets = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ"

	for(var intI=0; intI<argString.length; intI++)
		if (alphabets.indexOf(argString.charAt(intI)) == -1)
			return false
	
	return true
}

function objectValue(argFrm, argElem) {
	var intI
	var objElem = null

	for (intI=0; intI<argFrm.length; intI++)
		if (argFrm[intI].name == argElem) 
			objElem = argFrm[intI]

	switch (objElem.type) {
		case 'text':
		case 'hidden':
		case 'password':
			return objElem.value
			break;
		
		case 'select-one':
			if (objElem.length == 0)
				return ''
			else 
				return objElem.options[objElem.selectedIndex].value
			break;
		
		case 'radio':
			for (intI=0; intI<argFrm.length; intI++)
				if (argFrm[intI].name == argElem) 
					if (argFrm[intI].checked)
						return argFrm[intI].value

			return ''
			break;
	}
}

function objectFocus(argFrm, argElem) {
	var intI
	var objElem = null
	for (intI=0; intI<argFrm.length; intI++)
		if (argFrm[intI].name == argElem) 
			objElem = argFrm[intI]
	objElem.focus();
}

function isProperZip(argZip) {
	if ((argZip.length == 5) || (argZip.length == 9))
		return isProperNumber(argZip)
	
	if (argZip.length == 10)
		return (isProperNumber(argZip.substr(0, 5)) && isProperNumber(argZip.substr(6, 4)) & (argZip.charAt(5) == '-'))
}

function isProperUSPhone (argPhone)
{
	var argPhone2 = stripCharsNotInBag(argPhone,"0123456789")
    return (isOkBag(argPhone,"01234567890 -().") && isInteger(argPhone2) && argPhone2.length==digitsInUSPhoneNumber)
}

function isProperUSSSN(argSSN) {
	var argSSN2 = stripCharsNotInBag(argSSN,"0123456789")
    return (isOkBag(argSSN,"01234567890-") && isInteger(argSSN2) && argSSN2.length==11)
}


function actionFields(argActions) {
	this.email			= (argActions.indexOf('[email]') > -1)
	this.required		= (argActions.indexOf('[req]') > -1)
	this.checkDate		= (argActions.indexOf('[date]') > -1)
	this.checkZip		= (argActions.indexOf('[zip]') > -1)
	this.checkNumber	= (argActions.indexOf('[number]') > -1)
	this.checkAlphabetic= (argActions.indexOf('[alpha]') > -1)
	this.checkUSPhone	= (argActions.indexOf('[usphone]') > -1)
	this.checkUSSSN		= (argActions.indexOf('[usssn]') > -1)

	if (argActions.indexOf('[len=') > -1) {
		this.checkLength = true

		var lenToCheck = ''
		var bolCont = true

		for (var intI=(argActions.indexOf('[len=') +  5);((intI < argActions.length) && bolCont); intI++)
			if (argActions.charAt(intI) != ']')
				lenToCheck += argActions.charAt(intI)
			else
				bolCont = false
		this.lengthToCheck = lenToCheck
	}
	else
		this.checkLength = false

	if (argActions.indexOf('[blankalert=') > -1) {
		this.blankAlert = true

		var alertString = ''
		var bolCont = true

		for (var intI=(argActions.indexOf('[blankalert=') +  12);((intI < argActions.length) && bolCont); intI++)
			if (argActions.charAt(intI) != ']')
				alertString += argActions.charAt(intI)
			else
				bolCont = false
		this.blankAlertMessage = alertString
	}
	else
		this.blankAlert = false
	
	if (argActions.indexOf('[invalidalert=') > -1) {
		this.invalidAlert = true

		var alertString = ''
		var bolCont = true

		for (var intI=(argActions.indexOf('[invalidalert=') +  14);((intI < argActions.length) && bolCont); intI++)
			if (argActions.charAt(intI) != ']')
				alertString += argActions.charAt(intI)
			else
				bolCont = false
		this.invalidAlertMessage = alertString
	}
	else
		this.invalidAlert = false

	if (argActions.indexOf('[equals=') > -1) {
		this.shouldEqual = true

		var equalsString = ''
		var bolCont = true

		for (var intI=(argActions.indexOf('[equals=') +  8);((intI < argActions.length) && bolCont); intI++)
			if (argActions.charAt(intI) != ']')
				equalsString += argActions.charAt(intI)
			else
				bolCont = false
		this.shouldEqualString = equalsString
	}
	else
		this.shouldEqual = false

}


function validateForm(argForm)
	{
	var frmElements = argForm.elements
	var elemName
	var elemObj

	submitonce(argForm);

	for (var intI=0; intI < frmElements.length; intI++) {// *
		elemObj = frmElements[intI]
		elemName = elemObj.name

		if ((elemObj.type == 'hidden') && (elemName.length > 5))
			if (elemName.substr(elemName.length - 5).toLowerCase() == '_vldt') {// **
				var objAction = new actionFields(objectValue(frmElements, elemName))
				var actElem = elemName.substr(0, elemName.length - 5)
				
				if (objAction.required) {
					if (isWhiteSpace(objectValue(frmElements, actElem))) {// ***
						alert (objAction.blankAlert?objAction.blankAlertMessage:actElem + ' cannot be left blank')
						objectFocus(frmElements, actElem);
						submitenabled(argForm);
						return false
					} // ***
				}
				
				if ((objectValue(frmElements, actElem) > '') && (!isWhiteSpace(objectValue(frmElements, actElem)))){// ***
					if (objAction.checkDate)
						if (!isProperDate(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have an invalid date')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkNumber)
						if (!isProperNumber(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have an invalid number')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkZip)
						if (!isProperZip(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have an invalid zipcode')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkAlphabetic)
						if (!isProperAlphabetic(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have invalid characters')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkUSPhone)
						if (!isProperUSPhone(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have invalid characters')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.checkUSSSN)
						if (!isProperUSSSN(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have invalid characters')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****

					if (objAction.email)
						if (!isProperEmail(objectValue(frmElements, actElem))) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' cannot have invalid characters')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****



					if (objAction.checkLength)
						if (objectValue(frmElements, actElem).length < objAction.lengthToCheck) {// ****
							alert (objAction.invalidAlert?objAction.invalidAlertMessage:actElem + ' must be at least ' + objAction.lengthToCheck + ' characters long')
							objectFocus(frmElements, actElem);
							submitenabled(argForm);
							return false
						} // ****
				} // ***
			} // **
	} // *
		
	return true
}


function submitenabled(theform) {
    if (document.all || document.getElementById) {
        for (i = 0; i < theform.length; i++) {
            var tempobj = theform.elements[i];
            if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset") tempobj.disabled = false;
        }
    }
}


function submitonce(theform) {
    if (document.all || document.getElementById) {
        for (i = 0; i < theform.length; i++) {
            var tempobj = theform.elements[i];
            if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset") tempobj.disabled = true;
        }
    }
}
// ------------------------------------------------------------------------------------------
// Copyright AspDotNetStorefront.com, 1995-2009.  All Rights Reserved.
// http://www.aspdotnetstorefront.com
// For details on this license please visit  the product homepage at the URL above.
// THE ABOVE NOTICE MUST REMAIN INTACT. 
// ------------------------------------------------------------------------------------------

function makeHttpRequest(url, element, calltype) {
    var http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        alert('Browser doesn\'t support Ajax. Site will NOT FULLY function properly.');
        return false;
    }
    http_request.onreadystatechange = function () {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                loadXML(http_request.responseXML, calltype);
            } else {
                alert('There was a problem with the request. (Code: ' + http_request.status + ')');
            }
        }
    }
    http_request.open('GET', url, true);
    http_request.send(null);
}

function GetXmlHttpObject() {
    var xmlHttp = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }

    return xmlHttp;
}

function loadXML(xml, calltype) {
    if (calltype == 'shipping') {
        var string = '';
        document.getElementById('ChangeZip').style.display = "none";
        var root = xml.getElementsByTagName('Shipping')[0];
        for (i = 0; i < root.childNodes.length; i++) {
            var node = root.childNodes[i].tagName;
            string += root.getElementsByTagName(node)[0].childNodes[0].nodeValue;
        }
        if (document.getElementById('ShipQuote')) {
            document.getElementById('ShipQuote').innerHTML = string;
            document.getElementById('AjaxShippingZip').style.display = "none";
            document.getElementById('ChangeZip').style.display = "inline";
        }
        else {
            document.getElementById('ShipQuote').innerHTML = string;
            //document.getElementById('AjaxShippingZip').style.display="block";
            document.getElementById('ChangeZip').style.display = "none";
        }



    }
    if (calltype == 'pricing') {
        var prnode = xml.getElementsByTagName('PriceHTML')[0];
        var variantnode = xml.getElementsByTagName('VariantID')[0];
        var NewPrice = "Not Found";
        var VariantID = "0";
        if (prnode != undefined) {
            NewPrice = xml.getElementsByTagName('PriceHTML')[0].firstChild.data
        }
        if (variantnode != undefined) {
            VariantID = xml.getElementsByTagName('VariantID')[0].firstChild.data
        }
        //alert("VariantID=" + VariantID + ", NewPrice=" + NewPrice);
        if (document.getElementById('VariantPrice_' + VariantID)) {
            document.getElementById('VariantPrice_' + VariantID).innerHTML = NewPrice;
        }
    }
}
function getShipping() {
    if (document.getElementById('Quantity') == undefined || document.getElementById('VariantID') == undefined) {
        return;
    }
    var VariantID = document.getElementById('VariantID');
    var Quantity = document.getElementById('Quantity');
    if (Quantity == '') {
        Quantity = '1';
    }
    var Country = '';
    if (document.getElementById('Country').length > 0) {
        Country = document.getElementById('Country').options[document.getElementById('Country').selectedIndex].value;
    }
    else {
        Country = document.getElementById('Country').value;
    }
    var State = '';
    if (document.getElementById('State').length > 0) {
        State = document.getElementById('State').options[document.getElementById('State').selectedIndex].value;
    }
    else {
        State = document.getElementById('State').value;
    }
    var PostalCode = document.getElementById('PostalCode');
    var valid = "0123456789";

    if (Country.length > 0) {
        if (State.length > 0) {
            if (PostalCode.value.length > 4) {
                if (PostalCode.value.length != 5) {
                    alert("Please enter your 5 digit or 5 digit+4 zip code.");
                    return false;
                }
                for (var i = 0; i < PostalCode.value.length; i++) {
                    temp = "" + PostalCode.value.substring(i, i + 1);
                    if (temp == "-") hyphencount++;
                    if (valid.indexOf(temp) == "-1") {
                        alert("Invalid characters in your zip code.  Please try again.");
                        return false;
                    }
                }

                if (Quantity.value > 0) {
                    Cookies.create('countrycookie', Country, 99);
                    Cookies.create('statecookie', State, 99);
                    Cookies.create('postalcookie', PostalCode.value, 99);
                    var url = "ajaxShipping.aspx?VariantID=" + VariantID.value + "&Quantity=" + Quantity.value + "&Country=" + escape(Country) + "&State=" + escape(State) + "&PostalCode=" + escape(PostalCode.value);
                   // alert(url);
                    makeHttpRequest(url, undefined, 'shipping');
                } else {
                    Cookies.erase('countrycookie');
                    Cookies.erase('statecookie');
                    Cookies.erase('postalcookie');
                    Error('qty');
                }
            } else {
                Cookies.erase('countrycookie');
                Cookies.erase('statecookie');
                Cookies.erase('postalcookie');
                Error('postal');
            }
        } else {
            Cookies.erase('countrycookie');
            Cookies.erase('statecookie');
            Cookies.erase('postalcookie');
            Error('state');
        }
    } else {
        Cookies.erase('countrycookie');
        Cookies.erase('statecookie');
        Cookies.erase('postalcookie');
        Error('country');
    }
}


function getPricing(ProductID, VariantID) {
    //alert('VariantID=' + VariantID);
    if (ProductID == undefined || VariantID == undefined) {
        return;
    }

    var ChosenSize = "";
    //var ChosenSizeList = document.getElementById('Size');
    var ChosenSizeList = document.getElementById('AddToCartForm_' + ProductID + '_' + VariantID).Size;
    if (ChosenSizeList != undefined) {
        ChosenSize = ChosenSizeList.options[ChosenSizeList.selectedIndex].text;
    }

    var ChosenColor = "";
    //var ChosenColorList = document.getElementById('Color');
    var ChosenColorList = document.getElementById('AddToCartForm_' + ProductID + '_' + VariantID).Color
    if (ChosenColorList != undefined) {
        ChosenColor = ChosenColorList.options[ChosenColorList.selectedIndex].text;
    }

    var url = "ajaxPricing.aspx?ProductID=" + ProductID + "&VariantID=" + VariantID + "&size=" + escape(ChosenSize) + "&color=" + escape(ChosenColor);

    //alert("Ajax Url=" + url);
    makeHttpRequest(url, undefined, 'pricing');
}


function Error(type) {
    if (type == 'country') {
        document.getElementById('ShipQuote').innerHTML = "Select A Country";
    }
    if (type == 'state') {
        document.getElementById('ShipQuote').innerHTML = "Select A State";
    }
    if (type == 'postal') {
        document.getElementById('ShipQuote').innerHTML = "Please enter a valid US ZipCode";
    }
    if (type == 'qty') {
        document.getElementById('ShipQuote').innerHTML = "Enter A Quantity";
    }
}

var Cookies = {
    init: function () {
        var allCookies = document.cookie.split('; ');
        for (var i = 0; i < allCookies.length; i++) {
            var cookiePair = allCookies[i].split('=');
            this[cookiePair[0]] = cookiePair[1];
        }
    },
    create: function (name, value, days) {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires=" + date.toGMTString();
        }
        else var expires = "";
        document.cookie = name + "=" + value + expires + "; path=/";
        this[name] = value;
    },
    erase: function (name) {
        this.create(name, '', -1);
        this[name] = undefined;
    }
};
Cookies.init();

window.onload = function readCookies() {
    if (!document.getElementById) return false;
    var countrycookie = Cookies['countrycookie'];
    var statecookie = Cookies['statecookie'];
    var postalcookie = Cookies['postalcookie'];
    if (countrycookie) {
        if (statecookie) {
            if (postalcookie) {
                if (document.getElementById('Country') != null) {
                    document.getElementById('Country').value = Cookies['countrycookie'];
                    if (document.getElementById('State') != null) {
                        document.getElementById('State').value = Cookies['statecookie'];
                        if (document.getElementById('PostalCode') != null) {
                            document.getElementById('PostalCode').value = Cookies['postalcookie'];
                            if (document.getElementById('VariantID') != null) {
                                if (document.getElementById('Quantity') != null) {
                                    getShipping();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // Set Focus to SearchBox
    // if (document.topsearchform.SearchTerm) {
    //  document.topsearchform.SearchTerm.focus();
    //}
}

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

window.onload = function () {
    var $ads;	
    $('div[id^="adsref-"]').each(function() {
        $ads = $('#ads-' + this.id.substr(7)).empty();
        $('ins:first', this).appendTo($ads);		
    });
}



window.onload = function readCookies() {
    if (!document.getElementById) return false;
    var countrycookie = Cookies['countrycookie'];
    var statecookie = Cookies['statecookie'];
    var postalcookie = Cookies['postalcookie'];
    if (countrycookie) {
        if (statecookie) {
            if (postalcookie) {
                if (document.getElementById('Country') != null) {
                    document.getElementById('Country').value = Cookies['countrycookie'];
                    if (document.getElementById('State') != null) {
                        document.getElementById('State').value = Cookies['statecookie'];
                        if (document.getElementById('PostalCode') != null) {
                            document.getElementById('PostalCode').value = Cookies['postalcookie'];
                            if (document.getElementById('VariantID') != null) {
                                if (document.getElementById('Quantity') != null) {
                                    getShipping();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // Set Focus to SearchBox
    // if (document.topsearchform.SearchTerm) {
    //  document.topsearchform.SearchTerm.focus();
    //}
}


			/**
			 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
			 */

			function echeck(str) {

					var at="@"
					var dot="."
					var lat=str.indexOf(at)
					var lstr=str.length
					var ldot=str.indexOf(dot)
					if (str.indexOf(at)==-1){
					   alert("Invalid Email Address")
					   return false
					}

					if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
					   alert("Invalid Email Address")
					   return false
					}

					if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
						alert("Invalid Email Address")
						return false
					}

					 if (str.indexOf(at,(lat+1))!=-1){
						alert("Invalid Email Address")
						return false
					 }

					 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
						alert("Invalid Email Address")
						return false
					 }

					 if (str.indexOf(dot,(lat+2))==-1){
						alert("Invalid Email Address")
						return false
					 }
					
					 if (str.indexOf(" ")!=-1){
						alert("Invalid Email Address")
						return false
					 }
					  alert("Thank you!")
					 return true                                                                        
			}

			function ValidateEmailForm(){
				var emailID=document.AddEmailForm.AddEmail
				
				if ((emailID.value==null)||(emailID.value=="")){
								alert("Please Enter your Email Address")
								emailID.focus()
								return false
				}
				if (echeck(emailID.value)==false){
								emailID.value=""
								emailID.focus()
								return false
				}
				return true
			}


function echeck(str) {

    var at = "@"
    var dot = "."
    var lat = str.indexOf(at)
    var lstr = str.length
    var ldot = str.indexOf(dot)
    if (str.indexOf(at) == -1) {
        alert("Invalid E-mail ID")
        return false
    }

    if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {
        alert("Invalid E-mail ID1")
        return false
    }

    if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) {
        alert("Invalid E-mail ID2")
        return false
    }

    if (str.indexOf(at, (lat + 1)) != -1) {
        alert("Invalid E-mail ID3")
        return false
    }

    if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
        alert("Invalid E-mail ID4")
        return false
    }

    if (str.indexOf(dot, (lat + 2)) == -1) {
        alert("Invalid E-mail ID5")
        return false
    }

    if (str.indexOf(" ") != -1) {
        alert("Invalid E-mail ID6")
        return false
    }

    return true
}

/*function ValidateForm() {
    var emailID = document.AddEmailForm.AddEmail

    if ((emailID.value == null) || (emailID.value == "")) {
        alert("Please Enter your Email ID")
        emailID.focus()
        return false
    }
    if (echeck(emailID.value) == false) {
        emailID.value = ""
        emailID.focus()
        return false
    }
    return true
}*/


//Control used in the drop down ResultsPerPage in the category, manufacturer and search templates


/*
 * jQuery.validity v1.1.1
 * http://validity.thatscaptaintoyou.com/
 * http://code.google.com/p/validity/
 * 
 * Copyright (c) 2010 Wyatt Allen
 * Dual licensed under the MIT and GPL licenses.
 *
 * Date: 2010-08-16 (Tuesday, 16 August 2010)
 * Revision: 134
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){o h={Q:"1k",1K:"59",1S:1E,3j:1p,3r:"50 u",U:":1I, :3B, 4X, 3J, :2p, :35",1c:6(a){k a.3x?(a.4V()+1)+"/"+a.3x()+"/"+a.4U():a}};$.j={m:$.1Y(h,{}),2s:{3q:/^\\d+$/,2t:/^((0?\\d)|(1[3E]))\\/([3E]?\\d|30|31)\\/\\d{1,4}$/,2l:/^((([a-z]|\\d|[!#\\$%&\'\\*\\+\\-\\/=\\?\\^R`{\\|}~]|[\\C-\\D\\B-\\y\\E-\\x])+(\\.([a-z]|\\d|[!#\\$%&\'\\*\\+\\-\\/=\\?\\^R`{\\|}~]|[\\C-\\D\\B-\\y\\E-\\x])+)*)|((\\3F)((((\\1T|\\1F)*(\\2o\\3K))?(\\1T|\\1F)+)?(([\\2M-\\4S\\2S\\2U\\4R-\\4Q\\33]|\\4P|[\\4N-\\4M]|[\\4L-\\4H]|[\\C-\\D\\B-\\y\\E-\\x])|(\\\\([\\2M-\\1F\\2S\\2U\\2o-\\33]|[\\C-\\D\\B-\\y\\E-\\x]))))*(((\\1T|\\1F)*(\\2o\\3K))?(\\1T|\\1F)+)?(\\3F)))@((([a-z]|\\d|[\\C-\\D\\B-\\y\\E-\\x])|(([a-z]|\\d|[\\C-\\D\\B-\\y\\E-\\x])([a-z]|\\d|-|\\.|R|~|[\\C-\\D\\B-\\y\\E-\\x])*([a-z]|\\d|[\\C-\\D\\B-\\y\\E-\\x])))\\.)+(([a-z]|[\\C-\\D\\B-\\y\\E-\\x])|(([a-z]|[\\C-\\D\\B-\\y\\E-\\x])([a-z]|\\d|-|\\.|R|~|[\\C-\\D\\B-\\y\\E-\\x])*([a-z]|[\\C-\\D\\B-\\y\\E-\\x])))\\.?$/i,3p:/^\\$?(\\d{1,3},?(\\d{3},?)*\\d{3}(\\.\\d{0,2})?|\\d{1,3}(\\.\\d{0,2})?|\\.\\d{1,2}?)$/,3t:/^(4G?|4F):\\/\\/(((([a-z]|\\d|-|\\.|R|~|[\\C-\\D\\B-\\y\\E-\\x])|(%[\\1A-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|[\\C-\\D\\B-\\y\\E-\\x])|(([a-z]|\\d|[\\C-\\D\\B-\\y\\E-\\x])([a-z]|\\d|-|\\.|R|~|[\\C-\\D\\B-\\y\\E-\\x])*([a-z]|\\d|[\\C-\\D\\B-\\y\\E-\\x])))\\.)+(([a-z]|[\\C-\\D\\B-\\y\\E-\\x])|(([a-z]|[\\C-\\D\\B-\\y\\E-\\x])([a-z]|\\d|-|\\.|R|~|[\\C-\\D\\B-\\y\\E-\\x])*([a-z]|[\\C-\\D\\B-\\y\\E-\\x])))\\.?)(:\\d*)?)(\\/((([a-z]|\\d|-|\\.|R|~|[\\C-\\D\\B-\\y\\E-\\x])|(%[\\1A-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)+(\\/(([a-z]|\\d|-|\\.|R|~|[\\C-\\D\\B-\\y\\E-\\x])|(%[\\1A-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)*)*)?)?(\\?((([a-z]|\\d|-|\\.|R|~|[\\C-\\D\\B-\\y\\E-\\x])|(%[\\1A-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)|[\\4D-\\4C]|\\/|\\?)*)?(\\#((([a-z]|\\d|-|\\.|R|~|[\\C-\\D\\B-\\y\\E-\\x])|(%[\\1A-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)|\\/|\\?)*)?$/i,1M:/^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)([4B]\\d+)?$/,2R:/^\\d{5}(-\\d{4})?$/,2G:/^[2-9]\\d{2}-\\d{3}-\\d{4}$/,2J:/^(\\{?([0-28-29-F]){8}-(([0-28-29-F]){4}-){3}([0-28-29-F]){12}\\}?)$/,3a:/^[3d]?\\d:[0-5]\\d?\\s?[4A]\\.?[4z]\\.?$/,3k:/^(20|21|22|23|[3d]\\d|\\d)(([:][0-5]\\d){1,2})$/,1L:/^[^<>]*$/},v:{1W:"#{u} 1f 4u.",1o:"#{u} 1f 2v 3A 4t M.",3q:"#{u} I G a 4s, 4r 1M.",2t:"#{u} I G V W a 2t.",2l:"#{u} I G V W 3A 2l.",3p:"#{u} I G V W a 4q 4p 4o.",3t:"#{u} I G V W a 4m.",1M:"#{u} I G V W a 1M.",2R:"#{u} I G V W a 4l ##### 2c #####-####.",2G:"#{u} I G V W a 2G 1M ###-###-####.",2J:"#{u} I G V W a 2J 4k {4j-4i-4h-4d-4c}.",3k:"#{u} I G V W a 24 37 38: 23:39.",3a:"#{u} I G V W a 12 37 38: 12:39 4b/4a",1V:"#{u} I G 1R Y #{S}.",1D:"#{u} I G 1R Y 2c 1B 2q #{S}.",1Q:"#{u} I G 2r Y #{O}.",1y:"#{u} I G 2r Y 2c 1B 2q #{O}.",2u:"#{u} I G 49 #{O} 48 #{S}.",3u:"#{u} 1x G 47 Y #{S} 1n.",3z:"#{u} 1x G 46 Y #{O} 1n.",1L:"#{u} 1x 3L 44 1n.",1d:"#{u} 43 41 1n.",1h:"#{u} 1x 3I 40 Y #{O} #{1P} 1n.",2K:"#{u} 1x 3I 1R Y #{O} #{1P} 1n.",1B:"2N 2O\'t 1o.",2L:"A q 3Z 3Y.",1i:"2N 2O\'t 3W 2q #{1i}.",2b:"1O 1i 2Z 2d 32 I G 1R Y #{S}.",2e:"1O 1i 2Z 2d 32 I G 2r Y #{O}.",1s:"1O 3V q 1f 3T P.",2i:"3S."},1w:{3b:/\\w/g,3e:/\\d/g,3f:/[A-3g-2m-9]/g,3h:/[^A-3g-2m-9]/g},L:{},3R:6(a){7.m=$.1Y(7.m,a)},1g:1C,3n:6(){k!!7.1g},1b:6(){l(7.L[7.m.Q]&&7.L[7.m.Q].1b){7.L[7.m.Q].1b()}7.1g={1q:0,P:1p}},1a:6(){o a=7.1g||{1q:0,P:1p};7.1g=1C;l(7.L[7.m.Q]&&7.L[7.m.Q].1a){7.L[7.m.Q].1a(a)}k a},3Q:6(){7.1b();7.1a()}};$.3P.1Y({j:6(a){k 7.2x(6(){l(7.3O.2z()=="3w"){o f=1C;l(14(a)=="13"){f=6(){$(a).1W()}}18 l($.1J(a)){f=a}l(a){$(7).3N("3C",6(){$.j.1b();f();k $.j.1a().P})}}})},1W:6(d){k N(7,6(a){o b=$(a).2H();o c=b.r;k c},d||$.j.v.1W)},1o:6(b,c){l(!c){c=$.j.v.1o;l(14(b)==="13"&&$.j.v[b]){c=$.j.v[b]}}l(14(b)=="13"){b=$.j.2s[b]}k N(7,$.1J(b)?6(a){k!a.q.r||b(a.q)}:6(a){l(b.3M){b.45=0}k!a.q.r||b.1Z(a.q)},c)},2u:6(b,c,e){k N(7,b.1l&&c.1l?6(a){o d=H 1e(a.q);k d>=H 1e(b)&&d<=H 1e(c)}:b.15&&c.15&&K?6(a){o n=H K(a.q);k(n.1y(H K(b))&&n.1D(H K(c)))}:6(a){o f=1j(a.q);k f>=b&&f<=c},e||M($.j.v.2u,{O:$.j.m.1c(b),S:$.j.m.1c(c)}))},1Q:6(b,c){k N(7,b.1l?6(a){k H 1e(a.q)>b}:b.15&&K?6(a){k H K(a.q).1Q(H K(b))}:6(a){k 1j(a.q)>b},c||M($.j.v.1Q,{O:$.j.m.1c(b)}))},1y:6(b,c){k N(7,b.1l?6(a){k H 1e(a.q)>=b}:b.15&&K?6(a){k H K(a.q).1y(H K(b))}:6(a){k 1j(a.q)>=b},c||M($.j.v.1y,{O:$.j.m.1c(b)}))},1V:6(b,c){k N(7,b.1l?6(a){k H 1e(a.q)<b}:b.15&&K?6(a){k H K(a.q).1V(H K(b))}:6(a){k 1j(a.q)<b},c||M($.j.v.1V,{S:$.j.m.1c(b)}))},1D:6(b,c){k N(7,b.1l?6(a){k H 1e(a.q)<=b}:b.15&&K?6(a){k H K(a.q).1D(H K(b))}:6(a){k 1j(a.q)<=b},c||M($.j.v.1D,{S:$.j.m.1c(b)}))},1v:6(b,c){k N(7,6(a){k a.q.r<=b},c||M($.j.v.3u,{S:b}))},1t:6(b,c){k N(7,6(a){k a.q.r>=b},c||M($.j.v.3z,{O:b}))},1d:6(c,d){o e=[];k N(7,6(a){T(o b=0;b<a.q.r;++b){l(c.3U(a.q.2W(b))==-1){e.1X(a.q.2W(b));k 1E}}k 1p},d||M($.j.v.1d,{3X:e.2T(", ")}))},1h:6(b,c,d){l(14(b)=="13"){b=b.2z();l($.j.1w[b]){b=$.j.1w[b]}}k N(7,6(a){k(a.q.1o(b)||[]).r>=c},d||M($.j.v.1h,{O:c,1P:b}))},2K:6(b,c,d){l(14(b)=="13"){b=b.2z();l($.j.1w[b]){b=$.j.1w[b]}}k N(7,6(a){k(a.q.1o(b)||[]).r<=c},d||M($.j.v.2K,{S:c,1P:b}))},3B:6(a,b){a=$.1Y({1d:1C,1t:0,1v:0,2I:0,2F:0,2E:0,42:0},a);l(a.1d){7.1d(a.1d)}l(a.1t){7.1t(a.1t)}l(a.1v){7.1v(a.1v)}l(a.2I){7.1h("3h",a.2I)}l(a.2F){7.1h("3b",a.2F)}l(a.2E){7.1h("3e",a.2E)}l(a.3D){7.1h("3f",a.3D)}k 7},1L:6(b){k N(7,6(a){k $.j.2s.1L.1Z(a.q)},b||$.j.v.1L)},1B:6(b,c){o d=(7.J||7).Z($.j.m.U),1m=6(a){k a},16=$.j.v.1B;l(d.r){l($.1J(b)){1m=b;l(14(c)=="13"){16=c}}18 l(14(b)=="13"){16=b}o e=$.3s(d,6(a){k 1m(a.q)}),3c=e[0],P=1p;T(o i 2v e){l(e[i]!=3c){P=1E}}l(!P){X(d,16);7.J=$([])}}k 7},2L:6(b,c){o d=(7.J||7).Z($.j.m.U),1m=6(a){k a},16=$.j.v.2L,27=[],P=1p;l(d.r){l($.1J(b)){1m=b;l(14(c)=="13"){16=c}}18 l(14(b)=="13"){16=b}o e=$.3s(d,6(a){k 1m(a.q)});T(o f=0;f<e.r;++f){l(e[f].r){T(o g=0;g<27.r;++g){l(27[g]==e[f]){P=1E}}27.1X(e[f])}}l(!P){X(d,16);7.J=$([])}}k 7},1i:6(a,b){o c=(7.J||7).Z($.j.m.U);l(c.r&&a!=1N(c)){X(c,b||M($.j.v.1i,{1i:a}));7.J=$([])}k 7},2b:6(a,b){o c=(7.J||7).Z($.j.m.U);l(c.r&&a<1N(c)){X(c,b||M($.j.v.2b,{S:a}));7.J=$([])}k 7},2e:6(a,b){o c=(7.J||7).Z($.j.m.U);l(c.r&&a<1N(c)){X(c,b||M($.j.v.2e,{O:a}));7.J=$([])}k 7},1s:6(a,b){o c=(7.J||7).Z($.j.m.U);l(c.1f(":2p")&&c.34(":2g").2H()!=a){X(c,b||$.j.v.1s)}},4e:6(a,b){o c=(7.J||7).Z($.j.m.U);l(c.1f(":2p")&&c.Z(":2g").2H()==a){X(c,b||$.j.v.1s)}},4f:6(a){o b=(7.J||7).Z($.j.m.U);l(b.1f(":35")&&!b.1f(":2g")){X(b,a||$.j.v.1s)}},4g:6(a,b){o c=7.J||7;l(c.r){l($.1J(a)){k N(7,a,b||$.j.v.2i)}18 l(!a){X(c,b||$.j.v.2i);7.J=$([])}}k 7}});6 N(a,b,c){o d=(a.J||a).Z($.j.m.U),2f=[];d.2x(6(){l(b(7)){2f.1X(7)}18{2Y(7,M(c,{u:2X(7)}))}});a.J=$(2f);k a}6 2a(){l($.j.3n()){$.j.1g.1q++;$.j.1g.P=1E}}6 2Y(a,b){2a();l($.j.L[$.j.m.Q]&&$.j.L[$.j.m.Q].19){$.j.L[$.j.m.Q].19($(a),b)}}6 X(a,b){2a();l($.j.L[$.j.m.Q]&&$.j.L[$.j.m.Q].1G){$.j.L[$.j.m.Q].1G(a,b)}}6 1N(a){o b=0;a.2x(6(){o n=1j(7.q);b+=4n(n)?0:n});k b}6 M(a,b){T(o p 2v b){a=a.2P("#{"+p+"}",b[p])}k 2D(a)}6 2X(a){o b=$(a),1H=$.j.m.3r;l(b.11("3v").r){1H=b.11("3v")}18 l(/^([A-3o-9][a-z]*)+$/.1Z(a.17)){1H=a.17.2P(/([A-3o-9])[a-z]*/g," $&")}18 l(/^[a-2m-4v]*$/.1Z(a.17)){o c=a.17.4w("R");T(o i=0;i<c.r;++i){c[i]=2D(c[i])}1H=c.2T(" ")}k 1H}6 2D(a){k a.15?a.15(0,1).4x()+a.15(1,a.r):a}})(26);(6($){6 2k(a){k a.11(\'17\').r?a.11(\'17\'):a.11(\'4y\')}$.j.L.1k={1b:6(){$("1k."+$.j.m.1K).2j()},1a:6(a){l(!a.P&&$.j.m.1S){2h.2C=$("1k."+$.j.m.1K+":2A(0)").11(\'T\')}},19:6(a,b){o c="1k."+$.j.m.1K+"[T=\'"+2k(a)+"\']";l($(c).r){$(c).1I(b)}18{$("<1k/>").11("T",2k(a)).2y($.j.m.1K).1I(b).3y(6(){l(a.r){a[0].3J()}}).4E(a)}},1G:6(a,b){l(a.r){7.19($(a.2n(a.r-1)),b)}}}})(26);(6($){o d="j-3l-16",1u="4I";$.j.L.3l={1b:6(){$("."+d).2j()},1a:6(a){l(!a.P&&$.j.m.1S){2h.2C=$("."+d+":2A(0)").11(\'17\')}},19:6(a,b){l(a.r){o c=a.4J(),4K=a.2n(0),3i={36:3m(c.36+a.4O()+4,10)+"2V",2Q:3m(c.2Q-10,10)+"2V"};$("<2B/>").2y(d).4T(3i).1I(b).3y($.j.m.3j?6(){$(7).2j()}:1C).3G(1u)}},1G:6(a,b){l(a.r){7.19($(a.2n(a.r-1)),b)}}}})(26);(6($){o c=".j-2w-1u",1z="j-1z",1q="."+1z,3H="<4W/>",1r=[];$.j.L.2w={1b:6(){$(1q).4Y(1z);1r=[]},1a:6(a){$(c).4Z().34("1U").51(\'\');l(1r.r){T(o i=0;i<1r.r;++i){$(3H).1I(1r[i]).3G(c+" 1U")}$(c).52();l($.j.m.1S){2h.2C=$(1q+":2A(0)").11("17")}}},19:6(a,b){1r.1X(b);a.2y(1z)},1G:6(a,b){7.19(a,b)},1u:6(){53.54("<2B 55=\\"j-2w-1u\\">"+"1O 3w 56\'t 3C T 2d 57 58(s):"+"<1U></1U>"+"</2B>")}}})(26);',62,320,'||||||function|this||||||||||||validity|return|if|settings||var||value|length|||field|messages||uFFEF|uFDCF|||uF900|u00A0|uD7FF|uFDF0||be|new|must|reduction|Big|outputs|format|validate|min|valid|outputMode|_|max|for|elementSupport|formatted|as|raiseAggregateError|than|filter||attr||string|typeof|substring|msg|id|else|raise|end|start|argToString|alphabet|Date|is|report|minCharClass|sum|parseFloat|label|getTime|transform|characters|match|true|errors|buffer|radioChecked|minLength|container|maxLength|charClasses|cannot|greaterThanOrEqualTo|erroneous|da|equal|null|lessThanOrEqualTo|false|x09|raiseAggregate|ret|text|isFunction|cssClass|nonHtml|number|numericSum|The|charClass|greaterThan|less|scrollTo|x20|ul|lessThan|require|push|extend|test|||||||jQuery|subMap|9a|fA|addToReport|sumMax|or|the|sumMin|elements|checked|location|generic|remove|getIdentifier|email|z0|get|x0d|radio|to|greater|patterns|date|range|in|summary|each|addClass|toLowerCase|eq|div|hash|capitalize|minNumeric|minAlphabetical|phone|val|minSymbol|guid|maxCharClass|distinct|x01|Values|don|replace|top|zip|x0b|join|x0c|px|charAt|infer|raiseError|of|||values|x7f|find|checkbox|left|hour|time|00|time12|alphabetical|first|01|numeric|alphanumeric|Za|symbol|errorStyle|modalErrorsClickable|time24|modal|parseInt|isValidating|Z0|usd|integer|defaultFieldName|map|url|tooLong|title|form|getDate|click|tooShort|an|password|submit|minAlphanumeric|012|x22|appendTo|wrapper|have|select|x0a|contain|global|bind|tagName|fn|clear|setup|Invalid|not|indexOf|selected|add|chars|repeated|was|more|disallowed|minAlphaNumeric|contains|HTML|lastIndex|shorter|longer|and|between|PM|AM|0305E82C3301|9A0C|radioNotChecked|checkboxChecked|assert|11D3|4F89|3F2504E0|like|zipcode|URL|isNaN|amount|Dollar|US|whole|positive|invalid|required|9_|split|toUpperCase|name|mM|aApP|Ee|uF8FF|uE000|insertAfter|ftp|https|x7e|body|offset|obj|x5d|x5b|x23|width|x21|x1f|x0e|x08|css|getFullYear|getMonth|li|textarea|removeClass|hide|This|html|show|document|write|class|didn|following|reason|error'.split('|'),0,{}))

function loadPage(list) {
	location.href=list.options[list.selectedIndex].value
	};


function validateEmail(formData, jqForm, options) {
var emailValue = $('#AddEmailForm input[name=email]').fieldValue();
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if (!emailValue[0] ) 	
{
	$("#output1").empty().append("<div class=\"addemailerror\">Please enter an email address!</div>").show();
	return false;
}

if (!emailReg.test(emailValue[0]) ){
$("#output1").empty().append("<div class=\"addemailerror\">Please enter a <u>valid</u> email address!</div>").show();
	return false;
	}
}

function addEmailSuccess(formData, jqForm, options) {
	$("#output1").append("<span class=\"addemailok\">Thank you!!</span>").show();
}



jQuery(document).ready(function($){
	

	var myOpen = function(hash) { hash.w.fadeIn('2000'); };	
	var myClose = function(hash) {
	    hash.w.fadeOut('2000',function() { hash.o.remove(); });
		};
	$(document).keydown( function( e ) {
		if( e.which == 27) { // escape, close box
		$(".jqmWindow").jqmHide();
		}
		});	
	 $('#dialog').jqm({
		ajax: '@href', trigger: '.spic',
		overlay: 0, 	
		//overlayClass: 'whiteOverlay',  
		ajaxText: '<div style="height:243px ;width:352px" class="wraptocenter"><span></span><img  src="../skins/skin_5/images/modal-loader.gif" /></div>',
		modal: true,
		onHide: myClose,
		onShow: myOpen
		});		

	/*
	 var options = { 
        //target:        '#output1',   // target element(s) to be updated with server response 
        beforeSubmit:  validateEmail , // pre-submit callback 
		success:    function() { $('body').jqm({
		ajax: 'joinmailinglist.ashx'+ $('#useremail').fieldValue(), 
		overlay: 0, 	
		//overlayClass: 'whiteOverlay',  
		ajaxText: '<div style="height:243px ;width:352px" class="wraptocenter"><span></span><img  src="../skins/skin_5/images/modal-loader.gif" /></div>',
		modal: true,
		onHide: myClose,
		onShow: myOpen
		}).jqmShow();  }, 
 
        // other available options: 
       // url: 'joinmailinglist.ashx'+ $('#useremail').fieldValue(),      // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
		// $.ajax options can be used here too, for example: 
        //timeout:   3000 
    }; 
	*/
		
		/*
		$('#AddEmailForm').ajaxForm( { beforeSubmit: validateEmail } ).validity(function() { 
			$("#useremail").require() .match("email");    
			});	; 

		*/

		
	
  /*  $("input, textarea").addClass("idle");
        $("input, textarea").focus(function()
		{
            $(this).addClass("activeField").removeClass("idle");
    }).blur(function(){
            $(this).removeClass("activeField").addClass("idle");
    });
	*/

	 /*$("#PriceFilterForm").validate({ 
        rules: {           
			sMin: "required", 
			sMax: "required"  
		},            
        messages: { 
            sMin: "**",
			sMax: "**"            
        }, 
       
        // specifying a submitHandler prevents the default submit, good for the demo 
        submitHandler: function() { 
            alert("submitted!"); 
        }, 
        // set this class to error-labels to indicate valid fields 
        success: function(label) { 
            // set   as text for IE 
            label.html(" ").addClass("checked"); 
        } 
    }); */

// Focus auto-focus fields
$('.auto-focus:first').focus();
// Initialize auto-hint fields
$('INPUT.auto-hint, TEXTAREA.auto-hint').focus(function(){
if($(this).val() == $(this).attr('title')){
$(this).val('');
$(this).removeClass('auto-hint');
}
});
$('INPUT.auto-hint, TEXTAREA.auto-hint').blur(function(){
if($(this).val() == '' && $(this).attr('title') != ''){
$(this).val($(this).attr('title'));
$(this).addClass('auto-hint');
}
});
$('INPUT.auto-hint, TEXTAREA.auto-hint').each(function(){
if($(this).attr('title') == ''){ return; }
if($(this).val() == ''){ $(this).val($(this).attr('title')); }
else { $(this).removeClass('auto-hint'); }
}); 

	
$('#KitAddToCartForm .AddToCartButton').wrap('<div class="AddToCartButton-hover"></div>');
  $('input.AddToCartButton').hover(function() {
    $(this).stop().animate({ // Fade the button out when hovered
      'opacity': 0.01
    }, 500)
  }, function() {
    $(this).stop().animate({ // Fade it back in on mouseout
      'opacity': 1
    }, 500)
  });
   
/* $('.gridcontainer-inner').wrap('<div class="productcontainer-hover"></div>');
  $('.productcontainer-hover').hover(function() {
    $(this).stop().animate({ // Fade the button out when hovered
      'opacity': 1
    }, 500)
  }, function() {
    $(this).stop().animate({ // Fade it back in on mouseout
      'opacity': .01
    }, 500)
  });
*/

	    $(".ReviewOrderButton").mouseenter(function(){
    	$(this).removeClass().addClass("ReviewOrderButton-hover");
    }).mouseleave(function(){
    	$(this).removeClass().addClass("ReviewOrderButton");		
    });
	  $(".gridcontainer-inner").mouseenter(function(){
    	$(this).removeClass().addClass("gridcontainer-inner-hover");
    }).mouseleave(function(){
    	$(this).removeClass().addClass("gridcontainer-inner");		
    });
	

		  $(".CheckoutNowButton").mouseenter(function(){
    	$(this).removeClass().addClass("CheckoutNowButton-hover");
    }).mouseleave(function(){
    	$(this).removeClass().addClass("CheckoutNowButton");		
    });

		$(".ContinueShoppingButton").mouseenter(function(){
    	$(this).removeClass().addClass("ContinueShoppingButton-hover");
    }).mouseleave(function(){
    	$(this).removeClass().addClass("ContinueShoppingButton");		
    });

		$(".PaymentPageContinueCheckoutButton").mouseenter(function(){
    	$(this).removeClass().addClass("PaymentPageContinueCheckoutButton-hover");
    }).mouseleave(function(){
    	$(this).removeClass().addClass("PaymentPageContinueCheckoutButton");		
    });

		$(".ShippingPageContinueCheckoutButton").mouseenter(function(){
    	$(this).removeClass().addClass("ShippingPageContinueCheckoutButton-hover");
    }).mouseleave(function(){
    	$(this).removeClass().addClass("ShippingPageContinueCheckoutButton");		
    });

		$(".AccountPageContinueCheckoutButton").mouseenter(function(){
    	$(this).removeClass().addClass("AccountPageContinueCheckoutButton-hover");
    }).mouseleave(function(){
    	$(this).removeClass().addClass("AccountPageContinueCheckoutButton");		
    });
  
  

    $('#demoFour').listnav({
        initLetter: 'all',
        includeAll: true,
        includeOther: false,
        includeNums: false,
        flagDisabled: true,
        noMatchText: 'Nothing matched your filter, please click another letter.',
        showCounts: true,
        cookieName: 'mfg-list',
        //   onClick: function(letter){ alert('You clicked ' + letter); }, 
        prefixes: ['the', 'a']
    });
		

			$('.collapseMan').click(function() {
			$('.collapseMan').css("display","none");
			$('.expandMan').css("display","block");
			$('#ManContainer').css("display","none");
			$.cookie('ManContainer', 'collapsed');
		});
		// When the expand button is clicked:
		$('.expandMan').click(function() {
			$('.expandMan').css("display","none");
			$('.collapseMan').css("display","block");
			$('#ManContainer').css("display","block");
			$.cookie('ManContainer', 'expanded');
		});

	// cat container:
		// When the collapse button is clicked:
		$('.collapseCat').click(function() {
			$('.collapseCat').css("display","none");
			$('.expandCat').css("display","block");
			$('#CatContainer').css("display","none");
			$.cookie('CatContainer', 'collapsed');
		});
		// When the expand button is clicked:
		$('.expandCat').click(function() {
			$('.expandCat').css("display","none");
			$('.collapseCat').css("display","block");
			$('#CatContainer').css("display","block");
			$.cookie('CatContainer',  'expanded');
		});
	// COOKIES
		// man container state
		var ManContainer = $.cookie('ManContainer');
		// cat container state
		var CatContainer = $.cookie('CatContainer');
		// Set the user's selection for the man container
		if (ManContainer == 'collapsed') {
			$('.collapseMan').css("display","none");
			$('.expandMan').css("display","block");
			$('#ManContainer').css("display","none");
		};
		// Set the user's selection for the cat container

		//Reset the display attribute in order to prevent autoexpanding on page refresh
		if (CatContainer == 'expanded') {
				$('#CatContainer').removeAttr("display");
				$('#CatContainer').css("display","block");
				$('.expandCat').css("display","none");
				$('.collapseCat').css("display","block");
		};
		if (ManContainer == 'expanded') {
				$('#ManContainer').removeAttr("display");
				$('#ManContainer').css("display","block");
				$('.expandMan').css("display","none");
				$('.collapseMan').css("display","block");
		};
		if (CatContainer == 'collapsed') {
		
		//	$('.collapseCat').removeAttr("display");
		//	$('.expandCat').removeAttr("display");
			//$('#CatContainer').removeAttr("display");
		
			$('.collapseCat').css("display","none");
			$('.expandCat').css("display","block");
			$('#CatContainer').css("display","none");
		};
		$('#toggle_lostpwd').click(function() {		
		       $('#lostpwd').toggle(500);
		  });

});
//END DOCUMENT READY

