/*

[js] sticky package 19:09:39 22/02/12

15:41:29 09/03/11 - jquery.colorbox.js - 24K
14:58:17 27/08/10 - jquery.scrollto.js - 2K
14:58:17 27/08/10 - jquery.jcarousel.js - 14K
14:58:17 27/08/10 - jquery.form.js - 10K
14:58:17 27/08/10 - jquery.validate.js - 22K
14:58:17 27/08/10 - jquery.innerfade.js - 8K
10:50:06 21/11/11 - javalib.js - 17K

*/

/* jquery.colorbox.js */

// ColorBox v1.3.16 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
// Copyright (c) 2011 Jack Moore - jack@colorpowered.com
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
(function ($, document, window) {
	var
	// ColorBox Default Settings.	
	// See http://colorpowered.com/colorbox for details.
	defaults = {
		transition: "elastic",
		speed: 300,
		width: false,
		initialWidth: "600",
		innerWidth: false,
		maxWidth: false,
		height: false,
		initialHeight: "450",
		innerHeight: false,
		maxHeight: false,
		scalePhotos: true,
		scrolling: true,
		inline: false,
		html: false,
		iframe: false,
		fastIframe: true,
		photo: false,
		href: false,
		title: false,
		rel: false,
		opacity: 0.9,
		preloading: true,
		current: "image {current} of {total}",
		previous: "previous",
		next: "next",
		close: "close",
		open: false,
		returnFocus: true,
		loop: true,
		slideshow: false,
		slideshowAuto: true,
		slideshowSpeed: 2500,
		slideshowStart: "start slideshow",
		slideshowStop: "stop slideshow",
		onOpen: false,
		onLoad: false,
		onComplete: false,
		onCleanup: false,
		onClosed: false,
		overlayClose: true,		
		escKey: true,
		arrowKey: true
	},
	
	// Abstracting the HTML and event identifiers for easy rebranding
	colorbox = 'colorbox',
	prefix = 'cbox',
	
	// Events	
	event_open = prefix + '_open',
	event_load = prefix + '_load',
	event_complete = prefix + '_complete',
	event_cleanup = prefix + '_cleanup',
	event_closed = prefix + '_closed',
	event_purge = prefix + '_purge',
	
	// Special Handling for IE
	isIE = $.browser.msie && !$.support.opacity, // feature detection alone gave a false positive on at least one phone browser and on some development versions of Chrome.
	isIE6 = isIE && $.browser.version < 7,
	event_ie6 = prefix + '_IE6',

	// Cached jQuery Object Variables
	$overlay,
	$box,
	$wrap,
	$content,
	$topBorder,
	$leftBorder,
	$rightBorder,
	$bottomBorder,
	$related,
	$window,
	$loaded,
	$loadingBay,
	$loadingOverlay,
	$title,
	$current,
	$slideshow,
	$next,
	$prev,
	$close,
	$groupControls,

	// Variables for cached values or use across multiple functions
	settings = {},
	interfaceHeight,
	interfaceWidth,
	loadedHeight,
	loadedWidth,
	element,
	index,
	photo,
	open,
	active,
	closing = false,
	
	publicMethod,
	boxElement = prefix + 'Element';
	
	// ****************
	// HELPER FUNCTIONS
	// ****************

	// jQuery object generator to reduce code size
	function $div(id, cssText) { 
		var div = document.createElement('div');
		div.id = id ? prefix + id : false;
		div.style.cssText = cssText || false;
		return $(div);
	}

	// Convert % values to pixels
	function setSize(size, dimension) {
		dimension = dimension === 'x' ? $window.width() : $window.height();
		return (typeof size === 'string') ? Math.round((/%/.test(size) ? (dimension / 100) * parseInt(size, 10) : parseInt(size, 10))) : size;
	}
	
	// Checks an href to see if it is a photo.
	// There is a force photo option (photo: true) for hrefs that cannot be matched by this regex.
	function isImage(url) {
		return settings.photo || /\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(url);
	}
	
	// Assigns function results to their respective settings.  This allows functions to be used as values.
	function process(settings) {
		for (var i in settings) {
			if ($.isFunction(settings[i]) && i.substring(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time.
			    settings[i] = settings[i].call(element);
			}
		}
		settings.rel = settings.rel || element.rel || 'nofollow';
		settings.href = $.trim(settings.href || $(element).attr('href'));
		settings.title = settings.title || element.title;
	}

	function trigger(event, callback) {
		if (callback) {
			callback.call(element);
		}
		$.event.trigger(event);
	}

	// Slideshow functionality
	function slideshow() {
		var
		timeOut,
		className = prefix + "Slideshow_",
		click = "click." + prefix,
		start,
		stop,
		clear;
		
		if (settings.slideshow && $related[1]) {
			start = function () {
				$slideshow
					.text(settings.slideshowStop)
					.unbind(click)
					.bind(event_complete, function () {
						if (index < $related.length - 1 || settings.loop) {
							timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
						}
					})
					.bind(event_load, function () {
						clearTimeout(timeOut);
					})
					.one(click + ' ' + event_cleanup, stop);
				$box.removeClass(className + "off").addClass(className + "on");
				timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
			};
			
			stop = function () {
				clearTimeout(timeOut);
				$slideshow
					.text(settings.slideshowStart)
					.unbind([event_complete, event_load, event_cleanup, click].join(' '))
					.one(click, start);
				$box.removeClass(className + "on").addClass(className + "off");
			};
			
			if (settings.slideshowAuto) {
				start();
			} else {
				stop();
			}
		}
	}

	function launch(elem) {
		if (!closing) {
			
			element = elem;
			
			process($.extend(settings, $.data(element, colorbox)));
			
			$related = $(element);
			
			index = 0;
			
			if (settings.rel !== 'nofollow') {
				$related = $('.' + boxElement).filter(function () {
					var relRelated = $.data(this, colorbox).rel || this.rel;
					return (relRelated === settings.rel);
				});
				index = $related.index(element);
				
				// Check direct calls to ColorBox.
				if (index === -1) {
					$related = $related.add(element);
					index = $related.length - 1;
				}
			}
			
			if (!open) {
				open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
				
				$box.show();
				
				if (settings.returnFocus) {
					try {
						element.blur();
						$(element).one(event_closed, function () {
							try {
								this.focus();
							} catch (e) {
								// do nothing
							}
						});
					} catch (e) {
						// do nothing
					}
				}
				
				// +settings.opacity avoids a problem in IE when using non-zero-prefixed-string-values, like '.5'
				$overlay.css({"opacity": +settings.opacity, "cursor": settings.overlayClose ? "pointer" : "auto"}).show();
				
				// Opens inital empty ColorBox prior to content being loaded.
				settings.w = setSize(settings.initialWidth, 'x');
				settings.h = setSize(settings.initialHeight, 'y');
				publicMethod.position(0);
				
				if (isIE6) {
					$window.bind('resize.' + event_ie6 + ' scroll.' + event_ie6, function () {
						$overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()});
					}).trigger('resize.' + event_ie6);
				}
				
				trigger(event_open, settings.onOpen);
				
				$groupControls.add($title).hide();
				
				$close.html(settings.close).show();
			}
			
			publicMethod.load(true);
		}
	}

	// ****************
	// PUBLIC FUNCTIONS
	// Usage format: $.fn.colorbox.close();
	// Usage from within an iframe: parent.$.fn.colorbox.close();
	// ****************
	
	publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
		var $this = this, autoOpen;
		
		if (!$this[0] && $this.selector) { // if a selector was given and it didn't match any elements, go ahead and exit.
			return $this;
		}
		
		options = options || {};
		
		if (callback) {
			options.onComplete = callback;
		}
		
		if (!$this[0] || $this.selector === undefined) { // detects $.colorbox() and $.fn.colorbox()
			$this = $('<a/>');
			options.open = true; // assume an immediate open
		}
		
		$this.each(function () {
			$.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options));
			$(this).addClass(boxElement);
		});
		
		autoOpen = options.open;
		
		if ($.isFunction(autoOpen)) {
			autoOpen = autoOpen.call($this);
		}
		
		if (autoOpen) {
			launch($this[0]);
		}
		
		return $this;
	};

	// Initialize ColorBox: store common calculations, preload the interface graphics, append the html.
	// This preps colorbox for a speedy open when clicked, and lightens the burdon on the browser by only
	// having to run once, instead of each time colorbox is opened.
	publicMethod.init = function () {
		// Create & Append jQuery Objects
		$window = $(window);
		$box = $div().attr({id: colorbox, 'class': isIE ? prefix + (isIE6 ? 'IE6' : 'IE') : ''});
		$overlay = $div("Overlay", isIE6 ? 'position:absolute' : '').hide();
		
		$wrap = $div("Wrapper");
		$content = $div("Content").append(
			$loaded = $div("LoadedContent", 'width:0; height:0; overflow:hidden'),
			$loadingOverlay = $div("LoadingOverlay").add($div("LoadingGraphic")),
			$title = $div("Title"),
			$current = $div("Current"),
			$next = $div("Next"),
			$prev = $div("Previous"),
			$slideshow = $div("Slideshow").bind(event_open, slideshow),
			$close = $div("Close")
		);
		$wrap.append( // The 3x3 Grid that makes up ColorBox
			$div().append(
				$div("TopLeft"),
				$topBorder = $div("TopCenter"),
				$div("TopRight")
			),
			$div(false, 'clear:left').append(
				$leftBorder = $div("MiddleLeft"),
				$content,
				$rightBorder = $div("MiddleRight")
			),
			$div(false, 'clear:left').append(
				$div("BottomLeft"),
				$bottomBorder = $div("BottomCenter"),
				$div("BottomRight")
			)
		).children().children().css({'float': 'left'});
		
		$loadingBay = $div(false, 'position:absolute; width:9999px; visibility:hidden; display:none');
		
		$('body').prepend($overlay, $box.append($wrap, $loadingBay));
		
		$content.children()
		.hover(function () {
			$(this).addClass('hover');
		}, function () {
			$(this).removeClass('hover');
		}).addClass('hover');
		
		// Cache values needed for size calculations
		interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();//Subtraction needed for IE6
		interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
		loadedHeight = $loaded.outerHeight(true);
		loadedWidth = $loaded.outerWidth(true);
		
		// Setting padding to remove the need to do size conversions during the animation step.
		$box.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth}).hide();
		
                // Setup button events.
                $next.click(function () {
                        publicMethod.next();
                });
                $prev.click(function () {
                        publicMethod.prev();
                });
                $close.click(function () {
                        publicMethod.close();
                });
		
		$groupControls = $next.add($prev).add($current).add($slideshow);
		
		// Adding the 'hover' class allowed the browser to load the hover-state
		// background graphics.  The class can now can be removed.
		$content.children().removeClass('hover');
		
		$('.' + boxElement).live('click', function (e) {
			// checks to see if it was a non-left mouse-click and for clicks modified with ctrl, shift, or alt.
			if (!((e.button !== 0 && typeof e.button !== 'undefined') || e.ctrlKey || e.shiftKey || e.altKey)) {
				e.preventDefault();
				launch(this);
			}
		});
		
		$overlay.click(function () {
			if (settings.overlayClose) {
				publicMethod.close();
			}
		});
		
		// Set Navigation Key Bindings
		$(document).bind("keydown", function (e) {
			if (open && settings.escKey && e.keyCode === 27) {
				e.preventDefault();
				publicMethod.close();
			}
			if (open && settings.arrowKey && !active && $related[1]) {
				if (e.keyCode === 37 && (index || settings.loop)) {
					e.preventDefault();
					$prev.click();
				} else if (e.keyCode === 39 && (index < $related.length - 1 || settings.loop)) {
					e.preventDefault();
					$next.click();
				}
			}
		});
	};
	
	publicMethod.remove = function () {
		$box.add($overlay).remove();
		$('.' + boxElement).die('click').removeData(colorbox).removeClass(boxElement);
	};

	publicMethod.position = function (speed, loadedCallback) {
		var
		animate_speed,
		// keeps the top and left positions within the browser's viewport.
		posTop = Math.max(document.documentElement.clientHeight - settings.h - loadedHeight - interfaceHeight, 0) / 2 + $window.scrollTop(),
		posLeft = Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2 + $window.scrollLeft();
		
		// setting the speed to 0 to reduce the delay between same-sized content.
		animate_speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed;
		
		// this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
		// but it has to be shrank down around the size of div#colorbox when it's done.  If not,
		// it can invoke an obscure IE bug when using iframes.
		$wrap[0].style.width = $wrap[0].style.height = "9999px";
		
		function modalDimensions(that) {
			// loading overlay height has to be explicitly set for IE6.
			$topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
			$loadingOverlay[0].style.height = $loadingOverlay[1].style.height = $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height;
		}
		
		$box.dequeue().animate({width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: posTop, left: posLeft}, {
			duration: animate_speed,
			complete: function () {
				modalDimensions(this);
				
				active = false;
				
				// shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
				$wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
				$wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
				
				if (loadedCallback) {
					loadedCallback();
				}
			},
			step: function () {
				modalDimensions(this);
			}
		});
	};

	publicMethod.resize = function (options) {
		if (open) {
			options = options || {};
			
			if (options.width) {
				settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth;
			}
			if (options.innerWidth) {
				settings.w = setSize(options.innerWidth, 'x');
			}
			$loaded.css({width: settings.w});
			
			if (options.height) {
				settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight;
			}
			if (options.innerHeight) {
				settings.h = setSize(options.innerHeight, 'y');
			}
			if (!options.innerHeight && !options.height) {				
				var $child = $loaded.wrapInner("<div style='overflow:auto'></div>").children(); // temporary wrapper to get an accurate estimate of just how high the total content should be.
				settings.h = $child.height();
				$child.replaceWith($child.children()); // ditch the temporary wrapper div used in height calculation
			}
			$loaded.css({height: settings.h});
			
			publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
		}
	};

	publicMethod.prep = function (object) {
		if (!open) {
			return;
		}
		
		var speed = settings.transition === "none" ? 0 : settings.speed;
		
		$window.unbind('resize.' + prefix);
		$loaded.remove();
		$loaded = $div('LoadedContent').html(object);
		
		function getWidth() {
			settings.w = settings.w || $loaded.width();
			settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
			return settings.w;
		}
		function getHeight() {
			settings.h = settings.h || $loaded.height();
			settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
			return settings.h;
		}
		
		$loaded.hide()
		.appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
		.css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'})
		.css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
		.prependTo($content);
		
		$loadingBay.hide();
		
		// floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width.
		//$(photo).css({'float': 'none', marginLeft: 'auto', marginRight: 'auto'});
		
                $(photo).css({'float': 'none'});
                
		// Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay.
		if (isIE6) {
			$('select').not($box.find('select')).filter(function () {
				return this.style.visibility !== 'hidden';
			}).css({'visibility': 'hidden'}).one(event_cleanup, function () {
				this.style.visibility = 'inherit';
			});
		}
		
		function setPosition(s) {
			publicMethod.position(s, function () {
				var prev, prevSrc, next, nextSrc, total = $related.length, iframe, complete;
				
				if (!open) {
					return;
				}
				
				complete = function () {
					$loadingOverlay.hide();
					trigger(event_complete, settings.onComplete);
				};
				
				if (isIE) {
					//This fadeIn helps the bicubic resampling to kick-in.
					if (photo) {
						$loaded.fadeIn(100);
					}
				}
				
				$title.html(settings.title).add($loaded).show();
				
				if (total > 1) { // handle grouping
					if (typeof settings.current === "string") {
						$current.html(settings.current.replace(/\{current\}/, index + 1).replace(/\{total\}/, total)).show();
					}
					
					$next[(settings.loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
					$prev[(settings.loop || index) ? "show" : "hide"]().html(settings.previous);
					
					prev = index ? $related[index - 1] : $related[total - 1];
					next = index < total - 1 ? $related[index + 1] : $related[0];
					
					if (settings.slideshow) {
						$slideshow.show();
					}
					
					// Preloads images within a rel group
					if (settings.preloading) {
						nextSrc = $.data(next, colorbox).href || next.href;
						prevSrc = $.data(prev, colorbox).href || prev.href;
						
						nextSrc = $.isFunction(nextSrc) ? nextSrc.call(next) : nextSrc;
						prevSrc = $.isFunction(prevSrc) ? prevSrc.call(prev) : prevSrc;
						
						if (isImage(nextSrc)) {
							$('<img/>')[0].src = nextSrc;
						}
						
						if (isImage(prevSrc)) {
							$('<img/>')[0].src = prevSrc;
						}
					}
				} else {
					$groupControls.hide();
				}
				
				if (settings.iframe) {
					iframe = $('<iframe frameborder=0/>').addClass(prefix + 'Iframe')[0];
					
					if (settings.fastIframe) {
						complete();
					} else {
						$(iframe).load(complete);
					}
					iframe.name = prefix + (+new Date());
					iframe.src = settings.href;
					
					if (!settings.scrolling) {
						iframe.scrolling = "no";
					}
					
					if (isIE) {
						iframe.allowTransparency = "true";
					}
					
					$(iframe).appendTo($loaded).one(event_purge, function () {
						iframe.src = "//about:blank";
					});
				} else {
					complete();
				}
				
				if (settings.transition === 'fade') {
					$box.fadeTo(speed, 1, function () {
						$box[0].style.filter = "";
					});
				} else {
                                        $box[0].style.filter = "";
				}
				
				$window.bind('resize.' + prefix, function () {
					publicMethod.position(0);
				});
			});
		}
		
		if (settings.transition === 'fade') {
			$box.fadeTo(speed, 0, function () {
				setPosition(0);
			});
		} else {
			setPosition(speed);
		}
	};

	publicMethod.load = function (launched) {
		var href, setResize, prep = publicMethod.prep;
		
		active = true;
		
		photo = false;
		
		element = $related[index];
		
		if (!launched) {
			process($.extend(settings, $.data(element, colorbox)));
		}
		
		trigger(event_purge);
		
		trigger(event_load, settings.onLoad);
		
		settings.h = settings.height ?
				setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
				settings.innerHeight && setSize(settings.innerHeight, 'y');
		
		settings.w = settings.width ?
				setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
				settings.innerWidth && setSize(settings.innerWidth, 'x');
		
		// Sets the minimum dimensions for use in image scaling
		settings.mw = settings.w;
		settings.mh = settings.h;
		
		// Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
		// If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
		if (settings.maxWidth) {
			settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
			settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
		}
		if (settings.maxHeight) {
			settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
			settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
		}
		
		href = settings.href;
		
		$loadingOverlay.show();

		if (settings.inline) {
			// Inserts an empty placeholder where inline content is being pulled from.
			// An event is bound to put inline content back when ColorBox closes or loads new content.
			$div().hide().insertBefore($(href)[0]).one(event_purge, function () {
				$(this).replaceWith($loaded.children());
			});
			prep($(href));
		} else if (settings.iframe) {
			// IFrame element won't be added to the DOM until it is ready to be displayed,
			// to avoid problems with DOM-ready JS that might be trying to run in that iframe.
			prep(" ");
		} else if (settings.html) {
			prep(settings.html);
		} else if (isImage(href)) {
			$(photo = new Image())
			.addClass(prefix + 'Photo')
			.error(function () {
				settings.title = false;
				prep($div('Error').text('This image could not be loaded'));
			})
			.load(function () {
				var percent;
				photo.onload = null; //stops animated gifs from firing the onload repeatedly.
				
				if (settings.scalePhotos) {
					setResize = function () {
						photo.height -= photo.height * percent;
						photo.width -= photo.width * percent;	
					};
					if (settings.mw && photo.width > settings.mw) {
						percent = (photo.width - settings.mw) / photo.width;
						setResize();
					}
					if (settings.mh && photo.height > settings.mh) {
						percent = (photo.height - settings.mh) / photo.height;
						setResize();
					}
				}
				
				if (settings.h) {
					photo.style.marginTop = Math.max(settings.h - photo.height, 0) / 2 + 'px';
				}
				
				if ($related[1] && (index < $related.length - 1 || settings.loop)) {
					photo.style.cursor = 'pointer';
					photo.onclick = function () {
                                                publicMethod.next();
                                        };
				}
				
				if (isIE) {
					photo.style.msInterpolationMode = 'bicubic';
				}
				
				setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise.
					prep(photo);
				}, 1);
			});
			
			setTimeout(function () { // A pause because Opera 10.6+ will sometimes not run the onload function otherwise.
				photo.src = href;
			}, 1);
		} else if (href) {
			$loadingBay.load(href, function (data, status, xhr) {
				prep(status === 'error' ? $div('Error').text('Request unsuccessful: ' + xhr.statusText) : $(this).contents());
			});
		}
	};

	// Navigates to the next page/image in a set.
	publicMethod.next = function () {
		if (!active) {
			index = index < $related.length - 1 ? index + 1 : 0;
			publicMethod.load();
		}
	};
	
	publicMethod.prev = function () {
		if (!active) {
			index = index ? index - 1 : $related.length - 1;
			publicMethod.load();
		}
	};

	// Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close();
	publicMethod.close = function () {
		if (open && !closing) {
			
			closing = true;
			
			open = false;
			
			trigger(event_cleanup, settings.onCleanup);
			
			$window.unbind('.' + prefix + ' .' + event_ie6);
			
			$overlay.fadeTo(200, 0);
			
			$box.stop().fadeTo(300, 0, function () {
                                
				$box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
				
				trigger(event_purge);
				
				$loaded.remove();
				
				setTimeout(function () {
					closing = false;
					trigger(event_closed, settings.onClosed);
				}, 1);
			});
		}
	};

	// A method for fetching the current element ColorBox is referencing.
	// returns a jQuery object.
	publicMethod.element = function () {
		return $(element);
	};

	publicMethod.settings = defaults;

	// Initializes ColorBox when the DOM has loaded
	$(publicMethod.init);

}(jQuery, document, this));

/* jquery.scrollto.js */

(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
/* jquery.jcarousel.js */

(function($){$.fn.jcarousel=function(o){return this.each(function(){new $jc(this,o);});};var defaults={vertical:false,start:1,offset:1,size:null,scroll:3,visible:null,animation:'normal',easing:'swing',auto:0,wrap:null,initCallback:null,reloadCallback:null,itemLoadCallback:null,itemFirstInCallback:null,itemFirstOutCallback:null,itemLastInCallback:null,itemLastOutCallback:null,itemVisibleInCallback:null,itemVisibleOutCallback:null,buttonNextHTML:'<div></div>',buttonPrevHTML:'<div></div>',buttonNextEvent:'click',buttonPrevEvent:'click',buttonNextCallback:null,buttonPrevCallback:null};$.jcarousel=function(e,o){this.options=$.extend({},defaults,o||{});this.locked=false;this.container=null;this.clip=null;this.list=null;this.buttonNext=null;this.buttonPrev=null;this.wh=!this.options.vertical?'width':'height';this.lt=!this.options.vertical?'left':'top';var skin='',split=e.className.split(' ');for(var i=0;i<split.length;i++){if(split[i].indexOf('jcarousel-skin')!=-1){$(e).removeClass(split[i]);var skin=split[i];break;}}
if(e.nodeName=='UL'||e.nodeName=='OL'){this.list=$(e);this.container=this.list.parent();if(this.container.hasClass('jcarousel-clip')){if(!this.container.parent().hasClass('jcarousel-container'))
this.container=this.container.wrap('<div></div>');this.container=this.container.parent();}else if(!this.container.hasClass('jcarousel-container'))
this.container=this.list.wrap('<div></div>').parent();}else{this.container=$(e);this.list=$(e).find('>ul,>ol,div>ul,div>ol');}
if(skin!=''&&this.container.parent()[0].className.indexOf('jcarousel-skin')==-1)
this.container.wrap('<div class=" '+skin+'"></div>');this.clip=this.list.parent();if(!this.clip.length||!this.clip.hasClass('jcarousel-clip'))
this.clip=this.list.wrap('<div></div>').parent();this.buttonPrev=$('.jcarousel-prev',this.container);if(this.buttonPrev.size()==0&&this.options.buttonPrevHTML!=null)
this.buttonPrev=this.clip.before(this.options.buttonPrevHTML).prev();this.buttonPrev.addClass(this.className('jcarousel-prev'));this.buttonNext=$('.jcarousel-next',this.container);if(this.buttonNext.size()==0&&this.options.buttonNextHTML!=null)
this.buttonNext=this.clip.before(this.options.buttonNextHTML).prev();this.buttonNext.addClass(this.className('jcarousel-next'));this.clip.addClass(this.className('jcarousel-clip'));this.list.addClass(this.className('jcarousel-list'));this.container.addClass(this.className('jcarousel-container'));var di=this.options.visible!=null?Math.ceil(this.clipping()/this.options.visible):null;var li=this.list.children('li');var self=this;if(li.size()>0){var wh=0,i=this.options.offset;li.each(function(){self.format(this,i++);wh+=self.dimension(this,di);});this.list.css(this.wh,wh+'px');if(!o||o.size===undefined)
this.options.size=li.size();}
this.container.css('display','block');this.buttonNext.css('display','block');this.buttonPrev.css('display','block');this.funcNext=function(){self.next();};this.funcPrev=function(){self.prev();};this.funcResize=function(){self.reload();};if(this.options.initCallback!=null)
this.options.initCallback(this,'init');if($.browser.safari){this.buttons(false,false);$(window).bind('load',function(){self.setup();});}else
this.setup();};var $jc=$.jcarousel;$jc.fn=$jc.prototype={jcarousel:'0.2.3'};$jc.fn.extend=$jc.extend=$.extend;$jc.fn.extend({setup:function(){this.first=null;this.last=null;this.prevFirst=null;this.prevLast=null;this.animating=false;this.timer=null;this.tail=null;this.inTail=false;if(this.locked)
return;this.list.css(this.lt,this.pos(this.options.offset)+'px');var p=this.pos(this.options.start);this.prevFirst=this.prevLast=null;this.animate(p,false);$(window).unbind('resize',this.funcResize).bind('resize',this.funcResize);},reset:function(){this.list.empty();this.list.css(this.lt,'0px');this.list.css(this.wh,'10px');if(this.options.initCallback!=null)
this.options.initCallback(this,'reset');this.setup();},reload:function(){if(this.tail!=null&&this.inTail)
this.list.css(this.lt,$jc.intval(this.list.css(this.lt))+this.tail);this.tail=null;this.inTail=false;if(this.options.reloadCallback!=null)
this.options.reloadCallback(this);if(this.options.visible!=null){var self=this;var di=Math.ceil(this.clipping()/this.options.visible),wh=0,lt=0;$('li',this.list).each(function(i){wh+=self.dimension(this,di);if(i+1<self.first)
lt=wh;});this.list.css(this.wh,wh+'px');this.list.css(this.lt,-lt+'px');}
this.scroll(this.first,false);},lock:function(){this.locked=true;this.buttons();},unlock:function(){this.locked=false;this.buttons();},size:function(s){if(s!=undefined){this.options.size=s;if(!this.locked)
this.buttons();}
return this.options.size;},has:function(i,i2){if(i2==undefined||!i2)
i2=i;if(this.options.size!==null&&i2>this.options.size)
i2=this.options.size;for(var j=i;j<=i2;j++){var e=this.get(j);if(!e.length||e.hasClass('jcarousel-item-placeholder'))
return false;}
return true;},get:function(i){return $('.jcarousel-item-'+i,this.list);},add:function(i,s){var e=this.get(i),old=0,add=0;if(e.length==0){var c,e=this.create(i),j=$jc.intval(i);while(c=this.get(--j)){if(j<=0||c.length){j<=0?this.list.prepend(e):c.after(e);break;}}}else
old=this.dimension(e);e.removeClass(this.className('jcarousel-item-placeholder'));typeof s=='string'?e.html(s):e.empty().append(s);var di=this.options.visible!=null?Math.ceil(this.clipping()/this.options.visible):null;var wh=this.dimension(e,di)-old;if(i>0&&i<this.first)
this.list.css(this.lt,$jc.intval(this.list.css(this.lt))-wh+'px');this.list.css(this.wh,$jc.intval(this.list.css(this.wh))+wh+'px');return e;},remove:function(i){var e=this.get(i);if(!e.length||(i>=this.first&&i<=this.last))
return;var d=this.dimension(e);if(i<this.first)
this.list.css(this.lt,$jc.intval(this.list.css(this.lt))+d+'px');e.remove();this.list.css(this.wh,$jc.intval(this.list.css(this.wh))-d+'px');},next:function(){this.stopAuto();if(this.tail!=null&&!this.inTail)
this.scrollTail(false);else
this.scroll(((this.options.wrap=='both'||this.options.wrap=='last')&&this.options.size!=null&&this.last==this.options.size)?1:this.first+this.options.scroll);},prev:function(){this.stopAuto();if(this.tail!=null&&this.inTail)
this.scrollTail(true);else
this.scroll(((this.options.wrap=='both'||this.options.wrap=='first')&&this.options.size!=null&&this.first==1)?this.options.size:this.first-this.options.scroll);},scrollTail:function(b){if(this.locked||this.animating||!this.tail)
return;var pos=$jc.intval(this.list.css(this.lt));!b?pos-=this.tail:pos+=this.tail;this.inTail=!b;this.prevFirst=this.first;this.prevLast=this.last;this.animate(pos);},scroll:function(i,a){if(this.locked||this.animating)
return;this.animate(this.pos(i),a);},pos:function(i){if(this.locked||this.animating)
return;if(this.options.wrap!='circular')
i=i<1?1:(this.options.size&&i>this.options.size?this.options.size:i);var back=this.first>i;var pos=$jc.intval(this.list.css(this.lt));var f=this.options.wrap!='circular'&&this.first<=1?1:this.first;var c=back?this.get(f):this.get(this.last);var j=back?f:f-1;var e=null,l=0,p=false,d=0;while(back?--j>=i:++j<i){e=this.get(j);p=!e.length;if(e.length==0){e=this.create(j).addClass(this.className('jcarousel-item-placeholder'));c[back?'before':'after'](e);}
c=e;d=this.dimension(e);if(p)
l+=d;if(this.first!=null&&(this.options.wrap=='circular'||(j>=1&&(this.options.size==null||j<=this.options.size))))
pos=back?pos+d:pos-d;}
var clipping=this.clipping();var cache=[];var visible=0,j=i,v=0;var c=this.get(i-1);while(++visible){e=this.get(j);p=!e.length;if(e.length==0){e=this.create(j).addClass(this.className('jcarousel-item-placeholder'));c.length==0?this.list.prepend(e):c[back?'before':'after'](e);}
c=e;var d=this.dimension(e);if(d==0){return 0;}
if(this.options.wrap!='circular'&&this.options.size!==null&&j>this.options.size)
cache.push(e);else if(p)
l+=d;v+=d;if(v>=clipping)
break;j++;}
for(var x=0;x<cache.length;x++)
cache[x].remove();if(l>0){this.list.css(this.wh,this.dimension(this.list)+l+'px');if(back){pos-=l;this.list.css(this.lt,$jc.intval(this.list.css(this.lt))-l+'px');}}
var last=i+visible-1;if(this.options.wrap!='circular'&&this.options.size&&last>this.options.size)
last=this.options.size;if(j>last){visible=0,j=last,v=0;while(++visible){var e=this.get(j--);if(!e.length)
break;v+=this.dimension(e);if(v>=clipping)
break;}}
var first=last-visible+1;if(this.options.wrap!='circular'&&first<1)
first=1;if(this.inTail&&back){pos+=this.tail;this.inTail=false;}
this.tail=null;if(this.options.wrap!='circular'&&last==this.options.size&&(last-visible+1)>=1){var m=$jc.margin(this.get(last),!this.options.vertical?'marginRight':'marginBottom');if((v-m)>clipping)
this.tail=v-clipping-m;}
while(i-->first)
pos+=this.dimension(this.get(i));this.prevFirst=this.first;this.prevLast=this.last;this.first=first;this.last=last;return pos;},animate:function(p,a){if(this.locked||this.animating)
return;this.animating=true;var self=this;var scrolled=function(){self.animating=false;if(p==0)
self.list.css(self.lt,0);if(self.options.wrap=='both'||self.options.wrap=='last'||self.options.size==null||self.last<self.options.size)
self.startAuto();self.buttons();self.notify('onAfterAnimation');};this.notify('onBeforeAnimation');if(!this.options.animation||a==false){this.list.css(this.lt,p+'px');scrolled();}else{var o=!this.options.vertical?{'left':p}:{'top':p};this.list.animate(o,this.options.animation,this.options.easing,scrolled);}},startAuto:function(s){if(s!=undefined)
this.options.auto=s;if(this.options.auto==0)
return this.stopAuto();if(this.timer!=null)
return;var self=this;this.timer=setTimeout(function(){self.next();},this.options.auto*1000);},stopAuto:function(){if(this.timer==null)
return;clearTimeout(this.timer);this.timer=null;},buttons:function(n,p){if(n==undefined||n==null){var n=!this.locked&&this.options.size!==0&&((this.options.wrap&&this.options.wrap!='first')||this.options.size==null||this.last<this.options.size);if(!this.locked&&(!this.options.wrap||this.options.wrap=='first')&&this.options.size!=null&&this.last>=this.options.size)
n=this.tail!=null&&!this.inTail;}
if(p==undefined||p==null){var p=!this.locked&&this.options.size!==0&&((this.options.wrap&&this.options.wrap!='last')||this.first>1);if(!this.locked&&(!this.options.wrap||this.options.wrap=='last')&&this.options.size!=null&&this.first==1)
p=this.tail!=null&&this.inTail;}
var self=this;this.buttonNext[n?'bind':'unbind'](this.options.buttonNextEvent,this.funcNext)[n?'removeClass':'addClass'](this.className('jcarousel-next-disabled')).attr('disabled',n?false:true);this.buttonPrev[p?'bind':'unbind'](this.options.buttonPrevEvent,this.funcPrev)[p?'removeClass':'addClass'](this.className('jcarousel-prev-disabled')).attr('disabled',p?false:true);if(this.buttonNext.length>0&&(this.buttonNext[0].jcarouselstate==undefined||this.buttonNext[0].jcarouselstate!=n)&&this.options.buttonNextCallback!=null){this.buttonNext.each(function(){self.options.buttonNextCallback(self,this,n);});this.buttonNext[0].jcarouselstate=n;}
if(this.buttonPrev.length>0&&(this.buttonPrev[0].jcarouselstate==undefined||this.buttonPrev[0].jcarouselstate!=p)&&this.options.buttonPrevCallback!=null){this.buttonPrev.each(function(){self.options.buttonPrevCallback(self,this,p);});this.buttonPrev[0].jcarouselstate=p;}},notify:function(evt){var state=this.prevFirst==null?'init':(this.prevFirst<this.first?'next':'prev');this.callback('itemLoadCallback',evt,state);if(this.prevFirst!==this.first){this.callback('itemFirstInCallback',evt,state,this.first);this.callback('itemFirstOutCallback',evt,state,this.prevFirst);}
if(this.prevLast!==this.last){this.callback('itemLastInCallback',evt,state,this.last);this.callback('itemLastOutCallback',evt,state,this.prevLast);}
this.callback('itemVisibleInCallback',evt,state,this.first,this.last,this.prevFirst,this.prevLast);this.callback('itemVisibleOutCallback',evt,state,this.prevFirst,this.prevLast,this.first,this.last);},callback:function(cb,evt,state,i1,i2,i3,i4){if(this.options[cb]==undefined||(typeof this.options[cb]!='object'&&evt!='onAfterAnimation'))
return;var callback=typeof this.options[cb]=='object'?this.options[cb][evt]:this.options[cb];if(!$.isFunction(callback))
return;var self=this;if(i1===undefined)
callback(self,state,evt);else if(i2===undefined)
this.get(i1).each(function(){callback(self,this,i1,state,evt);});else{for(var i=i1;i<=i2;i++)
if(i!==null&&!(i>=i3&&i<=i4))
this.get(i).each(function(){callback(self,this,i,state,evt);});}},create:function(i){return this.format('<li></li>',i);},format:function(e,i){var $e=$(e).addClass(this.className('jcarousel-item')).addClass(this.className('jcarousel-item-'+i));$e.attr('jcarouselindex',i);return $e;},className:function(c){return c+' '+c+(!this.options.vertical?'-horizontal':'-vertical');},dimension:function(e,d){var el=e.jquery!=undefined?e[0]:e;var old=!this.options.vertical?el.offsetWidth+$jc.margin(el,'marginLeft')+$jc.margin(el,'marginRight'):el.offsetHeight+$jc.margin(el,'marginTop')+$jc.margin(el,'marginBottom');if(d==undefined||old==d)
return old;var w=!this.options.vertical?d-$jc.margin(el,'marginLeft')-$jc.margin(el,'marginRight'):d-$jc.margin(el,'marginTop')-$jc.margin(el,'marginBottom');$(el).css(this.wh,w+'px');return this.dimension(el);},clipping:function(){return!this.options.vertical?this.clip[0].offsetWidth-$jc.intval(this.clip.css('borderLeftWidth'))-$jc.intval(this.clip.css('borderRightWidth')):this.clip[0].offsetHeight-$jc.intval(this.clip.css('borderTopWidth'))-$jc.intval(this.clip.css('borderBottomWidth'));},index:function(i,s){if(s==undefined)
s=this.options.size;return Math.round((((i-1)/s)-Math.floor((i-1)/s))*s)+1;}});$jc.extend({defaults:function(d){return $.extend(defaults,d||{});},margin:function(e,p){if(!e)
return 0;var el=e.jquery!=undefined?e[0]:e;if(p=='marginRight'&&$.browser.safari){var old={'display':'block','float':'none','width':'auto'},oWidth,oWidth2;$.swap(el,old,function(){oWidth=el.offsetWidth;});old['marginRight']=0;$.swap(el,old,function(){oWidth2=el.offsetWidth;});return oWidth2-oWidth;}
return $jc.intval($.css(el,p));},intval:function(v){v=parseInt(v);return isNaN(v)?0:v;}});})(jQuery);
/* jquery.form.js */

/* 2.43 */ (function($){$.fn.ajaxSubmit=function(_1){if(!this.length){_2("ajaxSubmit: skipping submit process - no element selected");return this;}if(typeof _1=="function"){_1={success:_1};}var _3=$.trim(this.attr("action"));if(_3){_3=(_3.match(/^([^#]+)/)||[])[1];}_3=_3||window.location.href||"";_1=$.extend({url:_3,type:this.attr("method")||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},_1||{});var _4={};this.trigger("form-pre-serialize",[this,_1,_4]);if(_4.veto){_2("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this;}if(_1.beforeSerialize&&_1.beforeSerialize(this,_1)===false){_2("ajaxSubmit: submit aborted via beforeSerialize callback");return this;}var a=this.formToArray(_1.semantic);if(_1.data){_1.extraData=_1.data;for(var n in _1.data){if(_1.data[n] instanceof Array){for(var k in _1.data[n]){a.push({name:n,value:_1.data[n][k]});}}else{a.push({name:n,value:_1.data[n]});}}}if(_1.beforeSubmit&&_1.beforeSubmit(a,this,_1)===false){_2("ajaxSubmit: submit aborted via beforeSubmit callback");return this;}this.trigger("form-submit-validate",[a,this,_1,_4]);if(_4.veto){_2("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this;}var q=$.param(a);if(_1.type.toUpperCase()=="GET"){_1.url+=(_1.url.indexOf("?")>=0?"&":"?")+q;_1.data=null;}else{_1.data=q;}var _5=this,_6=[];if(_1.resetForm){_6.push(function(){_5.resetForm();});}if(_1.clearForm){_6.push(function(){_5.clearForm();});}if(!_1.dataType&&_1.target){var _7=_1.success||function(){};_6.push(function(_8){var fn=_1.replaceTarget?"replaceWith":"html";$(_1.target)[fn](_8).each(_7,arguments);});}else{if(_1.success){_6.push(_1.success);}}_1.success=function(_9,_a,_b){for(var i=0,_c=_6.length;i<_c;i++){_6[i].apply(_1,[_9,_a,_b||_5,_5]);}};var _d=$("input:file",this).fieldValue();var _e=false;for(var j=0;j<_d.length;j++){if(_d[j]){_e=true;}}var _f=false;if((_d.length&&_1.iframe!==false)||_1.iframe||_e||_f){if(_1.closeKeepAlive){$.get(_1.closeKeepAlive,_10);}else{_10();}}else{$.ajax(_1);}this.trigger("form-submit-notify",[this,_1]);return this;function _10(){var _11=_5[0];if($(":input[name=submit]",_11).length){alert("Error: Form elements must not be named \"submit\".");return;}var _12=$.extend({},$.ajaxSettings,_1);var s=$.extend(true,{},$.extend(true,{},$.ajaxSettings),_12);var id="jqFormIO"+(new Date().getTime());var $io=$("<iframe id=\""+id+"\" name=\""+id+"\" src=\""+_12.iframeSrc+"\" onload=\"(jQuery(this).data('form-plugin-onload'))()\" />");var io=$io[0];$io.css({position:"absolute",top:"-1000px",left:"-1000px"});var xhr={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;$io.attr("src",_12.iframeSrc);}};var g=_12.global;if(g&&!$.active++){$.event.trigger("ajaxStart");}if(g){$.event.trigger("ajaxSend",[xhr,_12]);}if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&$.active--;return;}if(xhr.aborted){return;}var _13=false;var _14=0;var sub=_11.clk;if(sub){var n=sub.name;if(n&&!sub.disabled){_12.extraData=_12.extraData||{};_12.extraData[n]=sub.value;if(sub.type=="image"){_12.extraData[n+".x"]=_11.clk_x;_12.extraData[n+".y"]=_11.clk_y;}}}function _15(){var t=_5.attr("target"),a=_5.attr("action");_11.setAttribute("target",id);if(_11.getAttribute("method")!="POST"){_11.setAttribute("method","POST");}if(_11.getAttribute("action")!=_12.url){_11.setAttribute("action",_12.url);}if(!_12.skipEncodingOverride){_5.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"});}if(_12.timeout){setTimeout(function(){_14=true;cb();},_12.timeout);}var _16=[];try{if(_12.extraData){for(var n in _12.extraData){_16.push($("<input type=\"hidden\" name=\""+n+"\" value=\""+_12.extraData[n]+"\" />").appendTo(_11)[0]);}}$io.appendTo("body");$io.data("form-plugin-onload",cb);_11.submit();}finally{_11.setAttribute("action",a);t?_11.setAttribute("target",t):_5.removeAttr("target");$(_16).remove();}};if(_12.forceSync){_15();}else{setTimeout(_15,10);}var _17=100;function cb(){if(_13){return;}var ok=true;try{if(_14){throw "timeout";}var _18,doc;doc=io.contentWindow?io.contentWindow.document:io.contentDocument?io.contentDocument:io.document;var _19=_12.dataType=="xml"||doc.XMLDocument||$.isXMLDoc(doc);_2("isXml="+_19);if(!_19&&(doc.body==null||doc.body.innerHTML=="")){if(--_17){_2("requeing onLoad callback, DOM not available");setTimeout(cb,250);return;}_2("Could not access iframe DOM after 100 tries.");return;}_2("response detected");_13=true;xhr.responseText=doc.body?doc.body.innerHTML:null;xhr.responseXML=doc.XMLDocument?doc.XMLDocument:doc;xhr.getResponseHeader=function(_1a){var _1b={"content-type":_12.dataType};return _1b[_1a];};if(_12.dataType=="json"||_12.dataType=="script"){var ta=doc.getElementsByTagName("textarea")[0];if(ta){xhr.responseText=ta.value;}else{var pre=doc.getElementsByTagName("pre")[0];if(pre){xhr.responseText=pre.innerHTML;}}}else{if(_12.dataType=="xml"&&!xhr.responseXML&&xhr.responseText!=null){xhr.responseXML=_1c(xhr.responseText);}}_18=$.httpData(xhr,_12.dataType);}catch(e){_2("error caught:",e);ok=false;xhr.error=e;$.handleError(_12,xhr,"error",e);}if(ok){_12.success(_18,"success");if(g){$.event.trigger("ajaxSuccess",[xhr,_12]);}}if(g){$.event.trigger("ajaxComplete",[xhr,_12]);}if(g&&!--$.active){$.event.trigger("ajaxStop");}if(_12.complete){_12.complete(xhr,ok?"success":"error");}setTimeout(function(){$io.removeData("form-plugin-onload");$io.remove();xhr.responseXML=null;},100);};function _1c(s,doc){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.tagName!="parsererror")?doc:null;};};};$.fn.ajaxForm=function(_1d){return this.ajaxFormUnbind().bind("submit.form-plugin",function(e){e.preventDefault();$(this).ajaxSubmit(_1d);}).bind("click.form-plugin",function(e){var _1e=e.target;var $el=$(_1e);if(!($el.is(":submit,input:image"))){var t=$el.closest(":submit");if(t.length==0){return;}_1e=t[0];}var _1f=this;_1f.clk=_1e;if(_1e.type=="image"){if(e.offsetX!=undefined){_1f.clk_x=e.offsetX;_1f.clk_y=e.offsetY;}else{if(typeof $.fn.offset=="function"){var _20=$el.offset();_1f.clk_x=e.pageX-_20.left;_1f.clk_y=e.pageY-_20.top;}else{_1f.clk_x=e.pageX-_1e.offsetLeft;_1f.clk_y=e.pageY-_1e.offsetTop;}}}setTimeout(function(){_1f.clk=_1f.clk_x=_1f.clk_y=null;},100);});};$.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin");};$.fn.formToArray=function(_21){var a=[];if(this.length==0){return a;}var _22=this[0];var els=_21?_22.getElementsByTagName("*"):_22.elements;if(!els){return a;}for(var i=0,max=els.length;i<max;i++){var el=els[i];var n=el.name;if(!n){continue;}if(_21&&_22.clk&&el.type=="image"){if(!el.disabled&&_22.clk==el){a.push({name:n,value:$(el).val()});a.push({name:n+".x",value:_22.clk_x},{name:n+".y",value:_22.clk_y});}continue;}var v=$.fieldValue(el,true);if(v&&v.constructor==Array){for(var j=0,_23=v.length;j<_23;j++){a.push({name:n,value:v[j]});}}else{if(v!==null&&typeof v!="undefined"){a.push({name:n,value:v});}}}if(!_21&&_22.clk){var _24=$(_22.clk),_25=_24[0],n=_25.name;if(n&&!_25.disabled&&_25.type=="image"){a.push({name:n,value:_24.val()});a.push({name:n+".x",value:_22.clk_x},{name:n+".y",value:_22.clk_y});}}return a;};$.fn.formSerialize=function(_26){return $.param(this.formToArray(_26));};$.fn.fieldSerialize=function(_27){var a=[];this.each(function(){var n=this.name;if(!n){return;}var v=$.fieldValue(this,_27);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});}}});return $.param(a);};$.fn.fieldValue=function(_28){for(var val=[],i=0,max=this.length;i<max;i++){var el=this[i];var v=$.fieldValue(el,_28);if(v===null||typeof v=="undefined"||(v.constructor==Array&&!v.length)){continue;}v.constructor==Array?$.merge(val,v):val.push(v);}return val;};$.fieldValue=function(el,_29){var n=el.name,t=el.type,tag=el.tagName.toLowerCase();if(typeof _29=="undefined"){_29=true;}if(_29&&(!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 _2a=el.selectedIndex;if(_2a<0){return null;}var a=[],ops=el.options;var one=(t=="select-one");var max=(one?_2a+1:ops.length);for(var i=(one?_2a:0);i<max;i++){var op=ops[i];if(op.selected){var v=op.value;if(!v){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.value;};$.fn.clearForm=function(){return this.each(function(){$("input,select,textarea",this).clearFields();});};$.fn.clearFields=$.fn.clearInputs=function(){return this.each(function(){var t=this.type,tag=this.tagName.toLowerCase();if(t=="text"||t=="password"||tag=="textarea"){this.value="";}else{if(t=="checkbox"||t=="radio"){this.checked=false;}else{if(tag=="select"){this.selectedIndex=-1;}}}});};$.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=="function"||(typeof this.reset=="object"&&!this.reset.nodeType)){this.reset();}});};$.fn.enable=function(b){if(b==undefined){b=true;}return this.each(function(){this.disabled=!b;});};$.fn.selected=function(_2b){if(_2b==undefined){_2b=true;}return this.each(function(){var t=this.type;if(t=="checkbox"||t=="radio"){this.checked=_2b;}else{if(this.tagName.toLowerCase()=="option"){var _2c=$(this).parent("select");if(_2b&&_2c[0]&&_2c[0].type=="select-one"){_2c.find("option").selected(false);}this.selected=_2b;}}});};function _2(){if($.fn.ajaxSubmit.debug){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.validate.js */

/* 1.7 */ (function($){$.extend($.fn,{validate:function(_1){if(!this.length){_1&&_1.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing");return;}var _2=$.data(this[0],"validator");if(_2){return _2;}_2=new $.validator(_1,this[0]);$.data(this[0],"validator",_2);if(_2.settings.onsubmit){this.find("input, button").filter(".cancel").click(function(){_2.cancelSubmit=true;});if(_2.settings.submitHandler){this.find("input, button").filter(":submit").click(function(){_2.submitButton=this;});}this.submit(function(_3){if(_2.settings.debug){_3.preventDefault();}function _4(){if(_2.settings.submitHandler){if(_2.submitButton){var _5=$("<input type='hidden'/>").attr("name",_2.submitButton.name).val(_2.submitButton.value).appendTo(_2.currentForm);}_2.settings.submitHandler.call(_2,_2.currentForm);if(_2.submitButton){_5.remove();}return false;}return true;};if(_2.cancelSubmit){_2.cancelSubmit=false;return _4();}if(_2.form()){if(_2.pendingRequest){_2.formSubmitted=true;return false;}return _4();}else{_2.focusInvalid();return false;}});}return _2;},valid:function(){if($(this[0]).is("form")){return this.validate().form();}else{var _6=true;var _7=$(this[0].form).validate();this.each(function(){_6&=_7.element(this);});return _6;}},removeAttrs:function(_8){var _9={},_a=this;$.each(_8.split(/\s/),function(_b,_c){_9[_c]=_a.attr(_c);_a.removeAttr(_c);});return _9;},rules:function(_d,_e){var _f=this[0];if(_d){var _10=$.data(_f.form,"validator").settings;var _11=_10.rules;var _12=$.validator.staticRules(_f);switch(_d){case "add":$.extend(_12,$.validator.normalizeRule(_e));_11[_f.name]=_12;if(_e.messages){_10.messages[_f.name]=$.extend(_10.messages[_f.name],_e.messages);}break;case "remove":if(!_e){delete _11[_f.name];return _12;}var _13={};$.each(_e.split(/\s/),function(_14,_15){_13[_15]=_12[_15];delete _12[_15];});return _13;}}var _16=$.validator.normalizeRules($.extend({},$.validator.metadataRules(_f),$.validator.classRules(_f),$.validator.attributeRules(_f),$.validator.staticRules(_f)),_f);if(_16.required){var _17=_16.required;delete _16.required;_16=$.extend({required:_17},_16);}return _16;}});$.extend($.expr[":"],{blank:function(a){return !$.trim(""+a.value);},filled:function(a){return !!$.trim(""+a.value);},unchecked:function(a){return !a.checked;}});$.validator=function(_18,_19){this.settings=$.extend(true,{},$.validator.defaults,_18);this.currentForm=_19;this.init();};$.validator.format=function(_1a,_1b){if(arguments.length==1){return function(){var _1c=$.makeArray(arguments);_1c.unshift(_1a);return $.validator.format.apply(this,_1c);};}if(arguments.length>2&&_1b.constructor!=Array){_1b=$.makeArray(arguments).slice(1);}if(_1b.constructor!=Array){_1b=[_1b];}$.each(_1b,function(i,n){_1a=_1a.replace(new RegExp("\\{"+i+"\\}","g"),n);});return _1a;};$.extend($.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:$([]),errorLabelContainer:$([]),onsubmit:true,ignore:[],ignoreTitle:false,onfocusin:function(_1d){this.lastActive=_1d;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,_1d,this.settings.errorClass,this.settings.validClass);this.errorsFor(_1d).hide();}},onfocusout:function(_1e){if(!this.checkable(_1e)&&(_1e.name in this.submitted||!this.optional(_1e))){this.element(_1e);}},onkeyup:function(_1f){if(_1f.name in this.submitted||_1f==this.lastElement){this.element(_1f);}},onclick:function(_20){if(_20.name in this.submitted){this.element(_20);}else{if(_20.parentNode.name in this.submitted){this.element(_20.parentNode);}}},highlight:function(_21,_22,_23){$(_21).addClass(_22).removeClass(_23);},unhighlight:function(_24,_25,_26){$(_24).removeClass(_25).addClass(_26);}},setDefaults:function(_27){$.extend($.validator.defaults,_27);},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:$.validator.format("Please enter no more than {0} characters."),minlength:$.validator.format("Please enter at least {0} characters."),rangelength:$.validator.format("Please enter a value between {0} and {1} characters long."),range:$.validator.format("Please enter a value between {0} and {1}."),max:$.validator.format("Please enter a value less than or equal to {0}."),min:$.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){this.labelContainer=$(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||$(this.currentForm);this.containers=$(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var _28=(this.groups={});$.each(this.settings.groups,function(key,_29){$.each(_29.split(/\s/),function(_2a,_2b){_28[_2b]=key;});});var _2c=this.settings.rules;$.each(_2c,function(key,_2d){_2c[key]=$.validator.normalizeRule(_2d);});function _2e(_2f){var _30=$.data(this[0].form,"validator"),_31="on"+_2f.type.replace(/^validate/,"");_30.settings[_31]&&_30.settings[_31].call(_30,this[0]);};$(this.currentForm).validateDelegate(":text, :password, :file, select, textarea","focusin focusout keyup",_2e).validateDelegate(":radio, :checkbox, select, option","click",_2e);if(this.settings.invalidHandler){$(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler);}},form:function(){this.checkForm();$.extend(this.submitted,this.errorMap);this.invalid=$.extend({},this.errorMap);if(!this.valid()){$(this.currentForm).triggerHandler("invalid-form",[this]);}this.showErrors();return this.valid();},checkForm:function(){this.prepareForm();for(var i=0,_32=(this.currentElements=this.elements());_32[i];i++){this.check(_32[i]);}return this.valid();},element:function(_33){_33=this.clean(_33);this.lastElement=_33;this.prepareElement(_33);this.currentElements=$(_33);var _34=this.check(_33);if(_34){delete this.invalid[_33.name];}else{this.invalid[_33.name]=true;}if(!this.numberOfInvalids()){this.toHide=this.toHide.add(this.containers);}this.showErrors();return _34;},showErrors:function(_35){if(_35){$.extend(this.errorMap,_35);this.errorList=[];for(var _36 in _35){this.errorList.push({message:_35[_36],element:this.findByName(_36)[0]});}this.successList=$.grep(this.successList,function(_37){return !(_37.name in _35);});}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors();},resetForm:function(){if($.fn.resetForm){$(this.currentForm).resetForm();}this.submitted={};this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass);},numberOfInvalids:function(){return this.objectLength(this.invalid);},objectLength:function(obj){var _38=0;for(var i in obj){_38++;}return _38;},hideErrors:function(){this.addWrapper(this.toHide).hide();},valid:function(){return this.size()==0;},size:function(){return this.errorList.length;},focusInvalid:function(){if(this.settings.focusInvalid){try{$(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin");}catch(e){}}},findLastActive:function(){var _39=this.lastActive;return _39&&$.grep(this.errorList,function(n){return n.element.name==_39.name;}).length==1&&_39;},elements:function(){var _3a=this,_3b={};return $([]).add(this.currentForm.elements).filter(":input").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&&_3a.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in _3b||!_3a.objectLength($(this).rules())){return false;}_3b[this.name]=true;return true;});},clean:function(_3c){return $(_3c)[0];},errors:function(){return $(this.settings.errorElement+"."+this.settings.errorClass,this.errorContext);},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=$([]);this.toHide=$([]);this.currentElements=$([]);},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers);},prepareElement:function(_3d){this.reset();this.toHide=this.errorsFor(_3d);},check:function(_3e){_3e=this.clean(_3e);if(this.checkable(_3e)){_3e=this.findByName(_3e.name)[0];}var _3f=$(_3e).rules();var _40=false;for(method in _3f){var _41={method:method,parameters:_3f[method]};try{var _42=$.validator.methods[method].call(this,_3e.value.replace(/\r/g,""),_3e,_41.parameters);if(_42=="dependency-mismatch"){_40=true;continue;}_40=false;if(_42=="pending"){this.toHide=this.toHide.not(this.errorsFor(_3e));return;}if(!_42){this.formatAndAdd(_3e,_41);return false;}}catch(e){this.settings.debug&&window.console&&console.log("exception occured when checking element "+_3e.id+", check the '"+_41.method+"' method",e);throw e;}}if(_40){return;}if(this.objectLength(_3f)){this.successList.push(_3e);}return true;},customMetaMessage:function(_43,_44){if(!$.metadata){return;}var _45=this.settings.meta?$(_43).metadata()[this.settings.meta]:$(_43).metadata();return _45&&_45.messages&&_45.messages[_44];},customMessage:function(_46,_47){var m=this.settings.messages[_46];return m&&(m.constructor==String?m:m[_47]);},findDefined:function(){for(var i=0;i<arguments.length;i++){if(arguments[i]!==undefined){return arguments[i];}}return undefined;},defaultMessage:function(_48,_49){return this.findDefined(this.customMessage(_48.name,_49),this.customMetaMessage(_48,_49),!this.settings.ignoreTitle&&_48.title||undefined,$.validator.messages[_49],"<strong>Warning: No message defined for "+_48.name+"</strong>");},formatAndAdd:function(_4a,_4b){var _4c=this.defaultMessage(_4a,_4b.method),_4d=/\$?\{(\d+)\}/g;if(typeof _4c=="function"){_4c=_4c.call(this,_4b.parameters,_4a);}else{if(_4d.test(_4c)){_4c=jQuery.format(_4c.replace(_4d,"{$1}"),_4b.parameters);}}this.errorList.push({message:_4c,element:_4a});this.errorMap[_4a.name]=_4c;this.submitted[_4a.name]=_4c;},addWrapper:function(_4e){if(this.settings.wrapper){_4e=_4e.add(_4e.parent(this.settings.wrapper));}return _4e;},defaultShowErrors:function(){for(var i=0;this.errorList[i];i++){var _4f=this.errorList[i];this.settings.highlight&&this.settings.highlight.call(this,_4f.element,this.settings.errorClass,this.settings.validClass);this.showLabel(_4f.element,_4f.message);}if(this.errorList.length){this.toShow=this.toShow.add(this.containers);}if(this.settings.success){for(var i=0;this.successList[i];i++){this.showLabel(this.successList[i]);}}if(this.settings.unhighlight){for(var i=0,_50=this.validElements();_50[i];i++){this.settings.unhighlight.call(this,_50[i],this.settings.errorClass,this.settings.validClass);}}this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show();},validElements:function(){return this.currentElements.not(this.invalidElements());},invalidElements:function(){return $(this.errorList).map(function(){return this.element;});},showLabel:function(_51,_52){var _53=this.errorsFor(_51);if(_53.length){_53.removeClass().addClass(this.settings.errorClass);_53.attr("generated")&&_53.html(_52);}else{_53=$("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(_51),generated:true}).addClass(this.settings.errorClass).html(_52||"");if(this.settings.wrapper){_53=_53.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();}if(!this.labelContainer.append(_53).length){this.settings.errorPlacement?this.settings.errorPlacement(_53,$(_51)):_53.insertAfter(_51);}}if(!_52&&this.settings.success){_53.text("");typeof this.settings.success=="string"?_53.addClass(this.settings.success):this.settings.success(_53);}this.toShow=this.toShow.add(_53);},errorsFor:function(_54){var _55=this.idOrName(_54);return this.errors().filter(function(){return $(this).attr("for")==_55;});},idOrName:function(_56){return this.groups[_56.name]||(this.checkable(_56)?_56.name:_56.id||_56.name);},checkable:function(_57){return /radio|checkbox/i.test(_57.type);},findByName:function(_58){var _59=this.currentForm;return $(document.getElementsByName(_58)).map(function(_5a,_5b){return _5b.form==_59&&_5b.name==_58&&_5b||null;});},getLength:function(_5c,_5d){switch(_5d.nodeName.toLowerCase()){case "select":return $("option:selected",_5d).length;case "input":if(this.checkable(_5d)){return this.findByName(_5d.name).filter(":checked").length;}}return _5c.length;},depend:function(_5e,_5f){return this.dependTypes[typeof _5e]?this.dependTypes[typeof _5e](_5e,_5f):true;},dependTypes:{"boolean":function(_60,_61){return _60;},"string":function(_62,_63){return !!$(_62,_63.form).length;},"function":function(_64,_65){return _64(_65);}},optional:function(_66){return !$.validator.methods.required.call(this,$.trim(_66.value),_66)&&"dependency-mismatch";},startRequest:function(_67){if(!this.pending[_67.name]){this.pendingRequest++;this.pending[_67.name]=true;}},stopRequest:function(_68,_69){this.pendingRequest--;if(this.pendingRequest<0){this.pendingRequest=0;}delete this.pending[_68.name];if(_69&&this.pendingRequest==0&&this.formSubmitted&&this.form()){$(this.currentForm).submit();this.formSubmitted=false;}else{if(!_69&&this.pendingRequest==0&&this.formSubmitted){$(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=false;}}},previousValue:function(_6a){return $.data(_6a,"previousValue")||$.data(_6a,"previousValue",{old:null,valid:true,message:this.defaultMessage(_6a,"remote")});}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(_6b,_6c){_6b.constructor==String?this.classRuleSettings[_6b]=_6c:$.extend(this.classRuleSettings,_6b);},classRules:function(_6d){var _6e={};var _6f=$(_6d).attr("class");_6f&&$.each(_6f.split(" "),function(){if(this in $.validator.classRuleSettings){$.extend(_6e,$.validator.classRuleSettings[this]);}});return _6e;},attributeRules:function(_70){var _71={};var _72=$(_70);for(method in $.validator.methods){var _73=_72.attr(method);if(_73){_71[method]=_73;}}if(_71.maxlength&&/-1|2147483647|524288/.test(_71.maxlength)){delete _71.maxlength;}return _71;},metadataRules:function(_74){if(!$.metadata){return {};}var _75=$.data(_74.form,"validator").settings.meta;return _75?$(_74).metadata()[_75]:$(_74).metadata();},staticRules:function(_76){var _77={};var _78=$.data(_76.form,"validator");if(_78.settings.rules){_77=$.validator.normalizeRule(_78.settings.rules[_76.name])||{};}return _77;},normalizeRules:function(_79,_7a){$.each(_79,function(_7b,val){if(val===false){delete _79[_7b];return;}if(val.param||val.depends){var _7c=true;switch(typeof val.depends){case "string":_7c=!!$(val.depends,_7a.form).length;break;case "function":_7c=val.depends.call(_7a,_7a);break;}if(_7c){_79[_7b]=val.param!==undefined?val.param:true;}else{delete _79[_7b];}}});$.each(_79,function(_7d,_7e){_79[_7d]=$.isFunction(_7e)?_7e(_7a):_7e;});$.each(["minlength","maxlength","min","max"],function(){if(_79[this]){_79[this]=Number(_79[this]);}});$.each(["rangelength","range"],function(){if(_79[this]){_79[this]=[Number(_79[this][0]),Number(_79[this][1])];}});if($.validator.autoCreateRanges){if(_79.min&&_79.max){_79.range=[_79.min,_79.max];delete _79.min;delete _79.max;}if(_79.minlength&&_79.maxlength){_79.rangelength=[_79.minlength,_79.maxlength];delete _79.minlength;delete _79.maxlength;}}if(_79.messages){delete _79.messages;}return _79;},normalizeRule:function(_7f){if(typeof _7f=="string"){var _80={};$.each(_7f.split(/\s/),function(){_80[this]=true;});_7f=_80;}return _7f;},addMethod:function(_81,_82,_83){$.validator.methods[_81]=_82;$.validator.messages[_81]=_83!=undefined?_83:$.validator.messages[_81];if(_82.length<3){$.validator.addClassRules(_81,$.validator.normalizeRule(_81));}},methods:{required:function(_84,_85,_86){if(!this.depend(_86,_85)){return "dependency-mismatch";}switch(_85.nodeName.toLowerCase()){case "select":var val=$(_85).val();return val&&val.length>0;case "input":if(this.checkable(_85)){return this.getLength(_84,_85)>0;}default:return $.trim(_84).length>0;}},remote:function(_87,_88,_89){if(this.optional(_88)){return "dependency-mismatch";}var _8a=this.previousValue(_88);if(!this.settings.messages[_88.name]){this.settings.messages[_88.name]={};}_8a.originalMessage=this.settings.messages[_88.name].remote;this.settings.messages[_88.name].remote=_8a.message;_89=typeof _89=="string"&&{url:_89}||_89;if(_8a.old!==_87){_8a.old=_87;var _8b=this;this.startRequest(_88);var _8c={};_8c[_88.name]=_87;$.ajax($.extend(true,{url:_89,mode:"abort",port:"validate"+_88.name,dataType:"json",data:_8c,success:function(_8d){_8b.settings.messages[_88.name].remote=_8a.originalMessage;var _8e=_8d===true;if(_8e){var _8f=_8b.formSubmitted;_8b.prepareElement(_88);_8b.formSubmitted=_8f;_8b.successList.push(_88);_8b.showErrors();}else{var _90={};var _91=(_8a.message=_8d||_8b.defaultMessage(_88,"remote"));_90[_88.name]=$.isFunction(_91)?_91(_87):_91;_8b.showErrors(_90);}_8a.valid=_8e;_8b.stopRequest(_88,_8e);}},_89));return "pending";}else{if(this.pending[_88.name]){return "pending";}}return _8a.valid;},minlength:function(_92,_93,_94){return this.optional(_93)||this.getLength($.trim(_92),_93)>=_94;},maxlength:function(_95,_96,_97){return this.optional(_96)||this.getLength($.trim(_95),_96)<=_97;},rangelength:function(_98,_99,_9a){var _9b=this.getLength($.trim(_98),_99);return this.optional(_99)||(_9b>=_9a[0]&&_9b<=_9a[1]);},min:function(_9c,_9d,_9e){return this.optional(_9d)||_9c>=_9e;},max:function(_9f,_a0,_a1){return this.optional(_a0)||_9f<=_a1;},range:function(_a2,_a3,_a4){return this.optional(_a3)||(_a2>=_a4[0]&&_a2<=_a4[1]);},email:function(_a5,_a6){return this.optional(_a6)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(_a5);},url:function(_a7,_a8){return this.optional(_a8)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(_a7);},date:function(_a9,_aa){return this.optional(_aa)||!/Invalid|NaN/.test(new Date(_a9));},dateISO:function(_ab,_ac){return this.optional(_ac)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(_ab);},number:function(_ad,_ae){return this.optional(_ae)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(_ad);},digits:function(_af,_b0){return this.optional(_b0)||/^\d+$/.test(_af);},creditcard:function(_b1,_b2){if(this.optional(_b2)){return "dependency-mismatch";}if(/[^0-9-]+/.test(_b1)){return false;}var _b3=0,_b4=0,_b5=false;_b1=_b1.replace(/\D/g,"");for(var n=_b1.length-1;n>=0;n--){var _b6=_b1.charAt(n);var _b4=parseInt(_b6,10);if(_b5){if((_b4*=2)>9){_b4-=9;}}_b3+=_b4;_b5=!_b5;}return (_b3%10)==0;},accept:function(_b7,_b8,_b9){_b9=typeof _b9=="string"?_b9.replace(/,/g,"|"):"png|jpe?g|gif";return this.optional(_b8)||_b7.match(new RegExp(".("+_b9+")$","i"));},equalTo:function(_ba,_bb,_bc){var _bd=$(_bc).unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){$(_bb).valid();});return _ba==_bd.val();}}});$.format=$.validator.format;})(jQuery);(function($){var _be=$.ajax;var _bf={};$.ajax=function(_c0){_c0=$.extend(_c0,$.extend({},$.ajaxSettings,_c0));var _c1=_c0.port;if(_c0.mode=="abort"){if(_bf[_c1]){_bf[_c1].abort();}return (_bf[_c1]=_be.apply(this,arguments));}return _be.apply(this,arguments);};})(jQuery);(function($){if(!jQuery.event.special.focusin&&!jQuery.event.special.focusout&&document.addEventListener){$.each({focus:"focusin",blur:"focusout"},function(_c2,fix){$.event.special[fix]={setup:function(){this.addEventListener(_c2,_c3,true);},teardown:function(){this.removeEventListener(_c2,_c3,true);},handler:function(e){arguments[0]=$.event.fix(e);arguments[0].type=fix;return $.event.handle.apply(this,arguments);}};function _c3(e){e=$.event.fix(e);e.type=fix;return $.event.handle.call(this,e);};});}$.extend($.fn,{validateDelegate:function(_c4,_c5,_c6){return this.bind(_c5,function(_c7){var _c8=$(_c7.target);if(_c8.is(_c4)){return _c6.apply(_c8,arguments);}});}});})(jQuery);
/* jquery.innerfade.js */

(function($){$.fn.innerfade=function(_1){var _2;var _3;var _4;var _5;var _6;return this.each(function(){$.innerfade(this,_1);});};jQuery.pause=function(){var _7=$("ul#"+settings.slide_ui_parent+" li");var _8=$("#"+settings.pause_button_id+" span").html();if(_8=="pause"){$("#"+settings.pause_button_id+" span").html("play");settings.slide_timer_on="no";$("#"+settings.pause_button_id).attr("class","paused_button");}else{$("#"+settings.pause_button_id+" span").html("pause");settings.slide_timer_on="yes";$("#"+settings.pause_button_id).attr("class","pause_button");button_class=$("#button_selected").attr("class");split_button_class_string=button_class.split("_");button_class_string=split_button_class_string.pop();curr_slide_id_number=parseFloat(button_class_string);next_slide_id_number=curr_slide_id_number-1;setTimeout(function(){$.innerfade.next(_7,settings,curr_slide_id_number,next_slide_id_number);},0);}};jQuery.next=function(){var _9=$("ul#"+settings.slide_ui_parent+" li");$("#"+settings.pause_button_id+" span").html("play");$("#"+settings.pause_button_id).attr("class","paused_button");button_class=$("#button_selected").attr("class");split_button_class_string=button_class.split("_");button_class_string=split_button_class_string.pop();curr_slide_id_number=parseFloat(button_class_string)+1;next_slide_id_number=curr_slide_id_number-1;settings.slide_timer_on="no";if((curr_slide_id_number)<_9.length){$.skip();}};jQuery.prev=function(){var _a=$("ul#"+settings.slide_ui_parent+" li");$("#"+settings.pause_button_id+" span").html("play");$("#"+settings.pause_button_id).attr("class","paused_button");button_class=$("#button_selected").attr("class");split_button_class_string=button_class.split("_");button_class_string=split_button_class_string.pop();curr_slide_id_number=parseFloat(button_class_string)-1;next_slide_id_number=curr_slide_id_number-1;settings.slide_timer_on="no";if((curr_slide_id_number)>=0){$.skip();}};jQuery.first=function(){$("#"+settings.pause_button_id+" span").html("play");$("#"+settings.pause_button_id).attr("class","paused_button");curr_slide_id_number=0;next_slide_id_number=curr_slide_id_number-1;settings.slide_timer_on="no";$.skip();};jQuery.last=function(){var _b=$("ul#"+settings.slide_ui_parent+" li");$("#"+settings.pause_button_id+" span").html("play");$("#"+settings.pause_button_id).attr("class","paused_button");curr_slide_id_number=_b.length-1;next_slide_id_number=curr_slide_id_number-1;settings.slide_timer_on="no";$.skip();};jQuery.setOptionsButtonEvent=function(){$("#"+settings.slide_nav_id+" li").each(function(){$(this).click(function(){$("#"+settings.pause_button_id+" span").html("play");$("#"+settings.pause_button_id).attr("class","paused_button");button_class=$(this).attr("class");split_button_class_string=button_class.split("_");button_class_string=split_button_class_string.pop();curr_slide_id_number=parseFloat(button_class_string);next_slide_id_number=curr_slide_id_number-1;settings.slide_timer_on="no";$.skip();});});};$.innerfade=function(_c,_d){settings={"animationtype":"fade","speed":"normal","type":"sequence","timeout":5000,"containerheight":"auto","runningclass":"innerfade","children":null,"slide_timer_on":"yes","slide_ui_parent":null,"slide_ui_text":null,"pause_button_id":null,"slide_nav_id":null};var _e;var _f;if(_d){$.extend(settings,_d);}if(settings.children===null){_e=$(_c).children();}else{_e=$(_c).children(settings.children);}if(_e.length>1){if(settings.slide_ui_text!="null"){_f=$("ul#"+settings.slide_ui_text+" li");}$(_c).css("position","relative").css("height",settings.containerheight).addClass(settings.runningclass);for(var i=0;i<_e.length;i++){$(_e[i]).css("z-index",String(_e.length-i)).css("position","absolute").hide();if(settings.slide_ui_text!="null"){$(_f[i]).css("z-index",String(_f.length-i)).css("position","absolute").hide();}}if(settings.type=="sequence"){setTimeout(function(){$.innerfade.next(_e,settings,1,0);},settings.timeout);$(_e[0]).show();if(settings.slide_ui_text!="null"){$(_f[0]).show();}if(settings.slide_nav_id!="null"){$("#"+settings.slide_nav_id+" li").removeAttr("id");$("#"+settings.slide_nav_id+" .slide_0").attr("id","button_selected");}}else{if(settings.type=="random"){next_slide_id_number=Math.floor(Math.random()*(_e.length));setTimeout(function(){do{curr_slide_id_number=Math.floor(Math.random()*(_e.length));}while(next_slide_id_number==curr_slide_id_number);$.innerfade.next(_e,settings,curr_slide_id_number,next_slide_id_number);},settings.timeout);$(_e[next_slide_id_number]).show();if(settings.slide_ui_text!="null"){$(_f[next_slide_id_number]).show();}}else{if(settings.type=="random_start"){settings.type="sequence";curr_slide_id_number=Math.floor(Math.random()*(_e.length));setTimeout(function(){$.innerfade.next(_e,settings,(curr_slide_id_number+1)%_e.length,curr_slide_id_number);},settings.timeout);$(_e[curr_slide_id_number]).show();if(settings.slide_ui_text!="null"){$(_f[curr_slide_id_number]).show();}}else{alert("Innerfade-Type must either be 'sequence', 'random' or 'random_start'");}}}}};$.skip=function(){var _10=$("ul#"+settings.slide_ui_parent+" li");if(settings.slide_ui_text!="null"){var _11=$("ul#"+settings.slide_ui_text+" li");}for(var i=0;i<_10.length;i++){if(settings.animationtype=="fade"){$(_10[i]).fadeOut(settings.speed);if(settings.slide_ui_text!="null"){$(_11[i]).fadeOut(settings.speed);}}else{$(_10[i]).slideUp(settings.speed);if(settings.slide_ui_text!="null"){$(_11[i]).slideUp(settings.speed);}}}if(settings.animationtype=="fade"){$(_10[curr_slide_id_number]).fadeIn(settings.speed,function(){removeFilter($(this)[0]);});if(settings.slide_ui_text!="null"){$(_11[curr_slide_id_number]).fadeIn(settings.speed,function(){removeFilter($(this)[0]);});}}else{$(_10[curr_slide_id_number]).slideDown(settings.speed,function(){removeFilter($(this)[0]);});if(settings.slide_ui_text!="null"){$(_11[curr_slide_id_number]).slideDown(settings.speed,function(){removeFilter($(this)[0]);});}}if(settings.slide_nav_id!="null"){$("#"+settings.slide_nav_id+" li").removeAttr("id");$("#"+settings.slide_nav_id+" .slide_"+curr_slide_id_number).attr("id","button_selected");}};$.innerfade.next=function(_12,_13,_14,_15){var _16;if(_13.slide_ui_text!="null"){_16=$("ul#"+_13.slide_ui_text+" li");}if(_13.slide_timer_on=="yes"){if(_13.animationtype=="slide"){$(_12[_15]).slideUp(_13.speed);$(_12[_14]).slideDown(_13.speed);$(_12[_15]).slideUp(_13.speed);if(_13.slide_ui_text!="null"){$(_16[_15]).slideUp(_13.speed);}$(_12[_14]).slideDown(_13.speed,function(){removeFilter($(this)[0]);});if(_13.slide_ui_text!="null"){$(_16[_14]).slideDown(_13.speed,function(){removeFilter($(this)[0]);});}if(_13.slide_nav_id!="null"){$("#"+_13.slide_nav_id+" li").removeAttr("id");$("#"+_13.slide_nav_id+" .slide_"+_14).attr("id","button_selected");}}else{if(_13.animationtype=="fade"){$(_12[_15]).fadeOut(_13.speed);if(_13.slide_ui_text!="null"){$(_16[_15]).fadeOut(_13.speed);}$(_12[_14]).fadeIn(_13.speed,function(){removeFilter($(this)[0]);});if(_13.slide_ui_text!="null"){$(_16[_14]).fadeIn(_13.speed,function(){removeFilter($(this)[0]);});}if(_13.slide_nav_id!="null"){$("#"+_13.slide_nav_id+" li").removeAttr("id");$("#"+_13.slide_nav_id+" .slide_"+_14).attr("id","button_selected");}}else{alert("Innerfade-animationtype must either be 'slide' or 'fade'");}}if(_13.type=="sequence"){if((_14+1)<_12.length){_14=_14+1;_15=_14-1;}else{_14=0;_15=_12.length-1;}}else{if(_13.type=="random"){_15=_14;while(_14==_15){_14=Math.floor(Math.random()*_12.length);}}else{alert("Innerfade-Type must either be 'sequence', 'random' or 'random_start'");}}setTimeout((function(){$.innerfade.next(_12,_13,_14,_15);}),_13.timeout);}};})(jQuery);function removeFilter(_17){if(_17.style.removeAttribute){_17.style.removeAttribute("filter");}};
/* javalib.js */

var clear="/shared/pngfix.gif" //path to clear.gif
pngfix=function(){var els=document.getElementsByTagName('*');var ip=/\.png/i;var i=els.length;while(i-- >0){var el=els[i];var es=el.style;if(el.src&&el.src.match(ip)&&!es.filter){es.height=el.height;es.width=el.width;es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"',sizingMethod='crop')";el.src=clear;}else{var elb=el.currentStyle.backgroundImage;if(elb.match(ip)){var path=elb.split('"');var rep=(el.currentStyle.backgroundRepeat=='no-repeat')?'crop':'scale';es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path[1]+"',sizingMethod='"+rep+"')";es.height=el.clientHeight+'px';es.backgroundImage='none';var elkids=el.getElementsByTagName('*');if (elkids){var j=elkids.length;if(el.currentStyle.position!="absolute")es.position='static';while (j-- >0)if(!elkids[j].style.position)elkids[j].style.position="relative";}}}}}

function redirect_url(url){
	window.location=url;
}

var image_zoom_timer = 0;
function image_zoom(id,speed,delay,w,h,step_w,step_h,div_w,div_h){
	var step_w = (step_w == null) ? 0 : step_w;
	var step_h = (step_h == null) ? 0 : step_h;
	var div_w  = (div_w == null) ? 0 : div_w;
	var div_h  = (div_h == null) ? 0 : div_h;
	var w = (w == null) ? 0 : w;
	var h = (h == null) ? 0 : h;
	if (!step_w) {
		w = $(id).width();	ow = w;
		h = $(id).height();	oh = h;
		if (!w) {
			setTimeout("image_zoom('"+id+"',"+speed+","+delay+")",2000);
			return;
		}
		ratio = w/h;
		if (w>h){
			step_w = 1;
			step_h = 1/ratio;
		} else {
			step_w = 1/ratio;
			step_h = 1;
		}
		step_w *= speed;
		step_h *= speed;
		div = $(id).parents("div").get(0).id;
		div_w = $('#'+div).width();
		div_h = $('#'+div).height();
		// firelog("image_zoom('"+id+"',"+speed+","+delay+","+w+","+h+","+step_w+","+step_h+","+div_w+","+div_h+")");
	}
	w = w - step_w;
	h = h - step_h;
	if (h>=div_h && w>=div_w) {
		$(id).width(w).height(h);
		window.status = "Img Zoom : timer : "+image_zoom_timer+" div_w "+div_w+" div_h "+div_h+" speed "+speed+" delay "+delay+ " w "+Math.floor(w)+"/"+ow+" h "+Math.floor(h)+"/"+oh+" step_w "+step_w+" step_h "+step_h+" ratio "+ratio;
		image_zoom_timer = setTimeout("image_zoom('"+id+"',"+speed+","+delay+","+w+","+h+","+step_w+","+step_h+","+div_w+","+div_h+")",delay);
	} else {
		//window.status = 'Zoom Complete';
	}
}

function image_zoom_cancel(){
	if (image_zoom_timer) {
		window.status = "Img Zoom : cancelled";
		clearTimeout(image_zoom_timer);
	}
}

function jcarousel_initCallback(carousel)
{
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
}

function highlight_inputs() {
	$(".input_button").live('mouseover', function(){
		$(this).addClass('input_button_selected');
	});
	$(".input_button").live('mouseout', function(){
		$(this).removeClass('input_button_selected');
	});
	elements = ".input_qty, .input_select, .input_text, .input_checkbox, .input_radio, .input_textarea";
	// detect IE not input_select, dissapears when you mouse off in IE */
	if (!$.support.leadingWhitespace) elements = ".input_qty, .input_text, .input_checkbox, .input_radio, .input_textarea";
	$(elements).live('mouseover', function(){ 
		$(this).addClass("input_hover");
	});
	$(elements).live('mouseout', function(){ 
		$(this).removeClass("input_hover");
	});
}

function firelog(s){
	if (typeof(console)!="undefined") console.log(s);
}

function checkId(id){
	if (!id) return;
	id = id.replace("#","");
	if (!id) return;
	c = $('#'+id).length;
	//firelog("checkId "+id+" "+c);
	return (c > 0);
}

auto_div_height_animating = new Array;
function auto_div_height(id,monitor){
	if (auto_div_height_animating[id]) return;
	if (!checkId(monitor)) {
		firelog("auto_div_height : "+monitor+' removed from dom');
		return;
	}
	//firelog("auto_div_height : ('"+id+"','"+monitor+"')");
	container = id.replace('#','')+"_container";
	cid = "#"+container;
	if (!checkId(cid)) $(id).wrap("<div id='"+container+"'></div>");
	ch = $(cid).height();
	c  = $(id).height();
	if (c != ch){
		auto_div_height_animating[id] = true;
		firelog("auto_div_height : animating c "+c+" ch "+ch+" monitor "+monitor);
		$(cid).animate(
			{ height : c }, 500,
			function() {
				firelog("auto_div_height : animation complete "+monitor);
				auto_div_height_animating[id] = false;
				if ($(id).css('display') == 'none') $(id).fadeIn();
				setTimeout("auto_div_height('"+id+"','"+monitor+"')",500);
			}	
		);
	} else {
		$(cid).css('backgroundImage','none');
		if ($(id).css('display') == 'none') $(id).fadeIn();
		//firelog("auto_div_height : c "+c+" ch "+ch+" id "+id+" cid "+cid+" "+monitor);
		setTimeout("auto_div_height('"+id+"','"+monitor+"')",500);
	}
}

// stop ajax forms being submitted for invalid forms
function check_form(formData, jqForm, options){ 
	valid = $(options.id).valid();
	if (options.fadeout){
		if (valid) $(options.target).fadeOut();
		//else $(options.target).effect("highlight", { color: '#F00' }, 3000);
	}
	return valid;
}

function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt) {
    var idx = carousel.index(i, mycarousel_itemList.length);
    carousel.add(i, mycarousel_itemList[idx - 1].html);
}

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt) {
    carousel.remove(i);
}

function datePicker(id) {
	$("#"+id).datepicker({ 
		dateFormat: 'dd/mm/yy', 
		changeMonth: true,
		changeYear: true,
		showAnim: 'slideDown'
	});
}
function datePickerIPTC(id) {
	$("#"+id).datepicker({ 
		dateFormat: 'yymmdd', 
		changeMonth: true,
		changeYear: true,
		showAnim: 'slideDown'
	});
}

function centerDiv(div) {
	divW = $(div).width();
	divH = $(div).height();
	width  = $(window).width();
	height = $(window).height();
	x = (width/2)-(divW/2);
	y = (height/2)-(divH/2)+$(window).scrollTop();
	$(div).css('top',y).css('left',x);
	$(div).fadeIn();
}

function popup_div(img) {
	$('#popup_div').fadeOut().html("<img id='popup_img' src='/tmp'+img+'>");
	setTimeout("centerDiv('#popup_div')",2000);
}

function popup_div_no_fade(img) {
	$('#popup_div_no_fade').hide().html("<img id='popup_img' src='/tmp"+img+"'>");
	centerDiv('#popup_div_no_fade');
}

// required for $('#id').load('page.php?params=have spaces in them')
function urlencode (str) {
    var hexStr = function (dec) {
        return '%' + dec.toString(16).toUpperCase();
    };
 
    var ret = '',
            unreserved = /[\w.-]/; // A-Za-z0-9_.- // Tilde is not here for historical reasons; to preserve it, use rawurlencode instead
    str = (str+'').toString();
 
    for (var i = 0, dl = str.length; i < dl; i++) {
        var ch = str.charAt(i);
        if (unreserved.test(ch)) {
            ret += ch;
        }
        else {
            var code = str.charCodeAt(i);
            // Reserved assumed to be in UTF-8, as in PHP
            if (code === 32) {
                ret += '+'; // %20 in rawurlencode
            }
            else if (code < 128) { // 1 byte
                ret += hexStr(code);
            }
            else if (code >= 128 && code < 2048) { // 2 bytes
                ret += hexStr((code >> 6) | 0xC0);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 2048 && code < 65536) { // 3 bytes
                ret += hexStr((code >> 12) | 0xE0);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
            else if (code >= 65536) { // 4 bytes
                ret += hexStr((code >> 18) | 0xF0);
                ret += hexStr(((code >> 12) & 0x3F) | 0x80);
                ret += hexStr(((code >> 6) & 0x3F) | 0x80);
                ret += hexStr((code & 0x3F) | 0x80);
            }
        }
    }
    return ret;
}

function id_check(){
	var allTags = document.body.getElementsByTagName('*');
	var ids = [];
	for (var tg = 0; tg< allTags.length; tg++) {
		var tag = allTags[tg];
		if (tag.id) {
			if (ids[tag.id] && tag.id != ',ilink' && tag.id != 'filename') ids.push(tag.id+'\n');
			else ids[tag.id] = 1;
		}
	}
	alert(ids);
}

function toggle_checkbox(id) {
	el = document.getElementById(id); 
	if (!el) {
		walert("Cannot set checkbox, no such id ["+id+"]");
		return;
	}
	el.value = 1-el.value;
}

function Height() {	return $(body).height(); }
function Width() {	return $(body).width(); }
function getHeight() { return Height(); }
function getWidth() { return Width(); }

function set_valid(nm,is_valid){
	return;
	e = document.getElementById("valid_"+nm);
	if (!e) {
		walert("Cannot find id to display error looking for valid_"+nm);
	} else {
		if (is_valid) e.innerHTML = "";
		else e.innerHTML = "<img alt='This field is required.' src='/shared/cart_warning.gif'>";
	}
}

function err_row(nm,s){
	set_valid(nm,false);
	nm = nm.replace('_',' ');
	return "<li>"+nm+" "+s+"</li>\n";
}

// validate + set_valid for old carts
function validate_form(formname){
	var txt = ""; 
	e = document.getElementById(formname);
	if (!e){
		walert("Cannot validate "+formname+" no such id.");
		return true;
	}
	check_password = false;
	fields = e.elements;
	password = confirm_password = "";
	for(i=0; i<fields.length; i++)
	{
		nm  = fields[i].name;
		id  = fields[i].id;
		val = fields[i].value;
//		txt = txt + id + " " + nm + " " + "[" + val + "]<br>";
		if (id.length<8) continue;
		s = id.slice(0,8);
		if (s!="id_valid") continue;
		set_valid(nm,true);
		fields[i].style.background='#FFFFFF';
		if (id=="id_valid_not_null" && val.length==0) {
			fields[i].style.background='#FF7777';
			txt = txt + err_row(nm,"is a mandatory field.");
		}
		if (id=="id_valid_email" && !echeck(val)){
			fields[i].style.background='#FF7777';
			txt = txt + err_row(nm,"is not a valid email address.");
		}
		if (id=="id_valid_credit_card" && !checkcreditcard(val)){
			fields[i].style.background='#FF7777';
			txt = txt + err_row(nm,"is not a valid credit card number.");
		}
		if (id=="id_valid_terms"){
			val = fields[i].checked;
			if (val==false){
				alert("You must accept our terms and conditions before you can place your order.");
				return;
			}
		}
		if (nm=="password") password = val;
		if (nm=="confirm_password") {
			check_password = true;
			confirm_password = val;
		}
	}
	if (check_password && (password != confirm_password)){
		txt = txt + err_row(nm,"your passwords do not match");
		set_valid("password",false);
		set_valid("confirm_password",false);
	}
	if (txt) {
		err.innerHTML=txt
		return false;
	} else err.innerHTML="";
	return true;
}

function saveFormId(fn){
	formId = document.getElementById(fn);
	if (formId) {
		$('#spinner').show();
		formId.submit();
	} else alert('cannot save: bad form id: '+fn);
}

function conf(s){
	return window.confirm(s);
}

var activeEditors = new Array()

function activateEditor(id) {
    //alert("activate "+id);
	activeEditors[activeEditors.length] = id;
    toggleEditor(id);
}

function deactivateEditors() {
	//alert('active '+activeEditors.length);
    for(x=0;x<activeEditors.length;x++) {
		walert("Removing editor "+x);
        toggleEditor(activeEditors[x])
    }
    activeEditors.length = 0;
}

// functions
function toggleEditor(id) {
	var elm = document.getElementById(id);
	if (!elm) {
		walert("no such id "+id);
		return;
	}
	if (tinyMCE.getInstanceById(id) == null){
		walert('add' + id);
		tinyMCE.execCommand('mceAddControl', false, id);
	} else {
		walert('focus' + id);
		tinyMCE.execCommand('mceFocus', false, id);
		walert('remove' + id);
		tinyMCE.execCommand('mceRemoveControl', false, id);
	}
} 

function popup(URL,w,h) {
	aWindow=window.open(URL, "thewindow", "toolbar=no, width="+w+", height="+h+", status=no, scrollbars=yes, resize=no, menubars=no");
}

function popup_full(URL,w,h) {
	aWindow=window.open(URL, "thewindow", "toolbar=no, width="+w+", height="+h+", status=yes, scrollbars=yes, resize=yes, menubars=no");
}

function popup_clean(URL,w,h) {
	aWindow=window.open(URL, "", "toolbar=no, width="+w+", height="+h+", status=no, scrollbars=no, resize=no, menubars=no");
}

function popup_scroll(URL,w,h) {
	aWindow=window.open(URL, "", "toolbar=no, width="+w+", height="+h+", status=no, scrollbars=yes, resize=no, menubars=no");
}

function putFocus(formInst, elementInst) {
	if (document.forms.length > 0) {
		if (document.forms[formInst].elements[elementInst]) {
			document.forms[formInst].elements[elementInst].focus();
		}
	}
}

function placeFocus() {
	if (document.forms.length > 0) {
		var field = document.forms[0];
		for (i = 0; i < field.length; i++) {
			if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
				document.forms[0].elements[i].focus();
				break;
			}
		}
	}
}

function checkcreditcard(object_value){
	if (object_value.length == 0)
		return false;
	var white_space = " -";
	var creditcard_string="";
	var check_char;

	for (var i = 0; i < object_value.length; i++)
	{
		check_char = white_space.indexOf(object_value.charAt(i));
		if (check_char < 0)
			creditcard_string += object_value.substring(i, (i + 1));
	}	

	if (creditcard_string.length < 13 || creditcard_string.length > 19)
		return false;

	if (creditcard_string.charAt(0) == "+")
		return false;

	if (!_CF_checkinteger(creditcard_string))
		return false;

	var doubledigit = creditcard_string.length % 2 == 1 ? false : true;
	var checkdigit = 0;
	var tempdigit;

	for (var i = 0; i < creditcard_string.length; i++)
	{
		tempdigit = eval(creditcard_string.charAt(i));

		if (doubledigit)
		{
			tempdigit *= 2;
			checkdigit += (tempdigit % 10);

			if ((tempdigit / 10) >= 1.0)
				checkdigit++;

			doubledigit = false;
		}
		else
		{
			checkdigit += tempdigit;
			doubledigit = true;
		}
	}	
	return (checkdigit % 10) == 0 ? true : false;
}

var debugId = false;	

function walert(s){	window.status = s; }

function malert(s){
	if (debugId==1) alert(s);
	if (debugId==2) walert(s);
}

function setDebugId(v){
	// 1 alert // 2 status bar
	walert("debugId ("+v+")");
	debugId=v;
}

function getId(id) {
	return $('#'+id);
}

var lastId = 0;	
function statId(id){
	if (debugId) alert("statId "+id);
	if (!checkId(id)) return;
	display = $(id).css('display');
	opacity = $(id).css('opacity');
	//firelog("statId "+id+" display "+display+" opacity "+opacity);
	if (display=="none" || opacity==0) return 0;
	else return 1;
}

function hideId(id){
	if (debugId) alert("hideId "+id);
	if (!checkId(id)) return;
	$('#'+id).hide();
}

function showId(id,mode){
	if (debugId) alert("showId "+id);
	if (!checkId(id)) return;
	var mode = (mode == null) ? 0 : mode;
	if (!mode) lastId = id;
	$('#'+id).show();
}

function toggleId(id,mode){
	if (debugId) malert("toggleId "+id);
	if (!checkId(id)) return;
	var mode = (mode == null) ? 0 : mode;
	if (!mode && lastId != id) hideId(lastId);
	$('#'+id).toggle();
}

function vislayer(){    
	this.lastId = '';
} 

vislayer.prototype.stat = function (id){
	if (!checkId(id)) return;
	opacity = $('#'+id).css('opacity');
	state   = $('#'+id).css('display');
	if (debugId) alert(id+" is display ["+state+"] opacity ["+opacity+"]");
	if (state=="block") return 1; else return 0;
}

vislayer.prototype.show = function (id,mode){
	if (debugId) malert("show "+id);
	if (!checkId(id)) return;
	var mode = (mode == null) ? 0 : mode;
	if (!mode) this.lastId = id;
	$('#'+id).show().css('opacity',1);
}

vislayer.prototype.hide = function (id){
	if (debugId) malert("hide "+id);
	if (!checkId(id)) return;
	$('#'+id).hide();
}

vislayer.prototype.toggle = function (id,mode){
	if (debugId) malert("toggle "+id);
	if (!checkId(id)) return;
	var mode = (mode == null) ? 0 : mode;
	if (!mode && this.lastId != id) this.hide(this.lastId);
	if (this.stat(id)) this.hide(id); else this.show(id,mode);
}

vislayer.prototype.slideDown = function (id,mode){
	if (debugId) malert("slideDown "+id);
	if (!checkId(id)) return;
	var mode = (mode == null) ? 0 : mode;
	if (!mode) this.lastId = id;
	$('#'+id).slideDown("slow").css('opacity',1);
}

vislayer.prototype.slideUp = function (id){
	if (debugId) malert("slideUp "+id);
	if (!checkId(id)) return;
	$('#'+id).slideUp("slow");
}

vislayer.prototype.slideUpDown = function (id,mode){
	if (debugId) malert("slideUpDown "+id);
	if (!checkId(id)) return;
	realthis = this;
	$('#'+this.lastId).slideUp("slow", function () { realthis.slideDown(id,mode); } );
}

vislayer.prototype.faderIn = function (id,mode){
	if (debugId) malert("fadeIn "+id);
	if (!checkId(id)) return;
	var mode = (mode == null) ? 0 : mode;
	if (!mode) this.lastId = id;
	alert("last "+this.lastId);
	$('#'+id).fadeIn().css('opacity',1);
}

vislayer.prototype.faderOut = function (id){
	if (debugId) malert("faderOut "+id+" busy "+this.busy);
	if (!checkId(id)) return;
	$('#'+id).fadeOut("slow", function () { this.busy = false; malert("faderOut "+id+" busy "+this.busy); } );
}

vislayer.prototype.faderInOut = function (id,mode){
	if (typeof(this.busy) == "undefined") this.busy = false;
	if (debugId) malert("faderInOut "+id+" busy "+this.busy);
	if (!checkId(id)) return;
	if (this.busy) return;
	realthis = this;
	previousId = this.lastId;
	if (previousId == id) $('#'+id).fadeIn("slow");
	else {
		this.busy = true;
		$('#'+id).fadeIn("slow", function () { realthis.faderOut(previousId,mode); walert("busy "+this.busy); } );
	}
	if (!mode) this.lastId = id;
}

vislayer.prototype.slideToggle = function (id,mode){
	if (debugId) malert("slideToggle "+id);
	if (!checkId(id)) return;
	var mode = (mode == null) ? 0 : mode;
	// a panel is open, and its not this one // close it first
	if (this.stat(this.lastId) && this.lastId != id) {
		this.slideUpDown(id,mode);
	} else {
		if (this.stat(id)) this.slideUp(id); else this.slideDown(id,mode);
	}
}

