/*

[js] sticky package 21:39:11 22/02/12

14:23:07 27/08/10 - jquery.tools.js - 14K
13:52:36 18/02/11 - jquery.colorbox.js - 23K
14:23:07 27/08/10 - jquery.validate.js - 22K
14:23:07 27/08/10 - javalib.js - 17K

*/

/* jquery.tools.js */

/*
 * jquery.tools 1.1.2 - The missing UI library for the Web
 * 
 * [tools.tabs-1.0.4, tools.tooltip-1.1.3, tools.tooltip.dynamic-1.0.1, tools.overlay-1.1.2, tools.expose-1.0.5]
 * 
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 * 
 * -----
 * 
 * File generated: Sun Feb 14 11:28:25 GMT 2010
 */
(function(d){d.tools=d.tools||{};d.tools.tabs={version:"1.0.4",conf:{tabs:"a",current:"current",onBeforeClick:null,onClick:null,effect:"default",initialIndex:0,event:"click",api:false,rotate:false},addEffect:function(e,f){c[e]=f}};var c={"default":function(f,e){this.getPanes().hide().eq(f).show();e.call()},fade:function(g,e){var f=this.getConf(),j=f.fadeOutSpeed,h=this.getPanes();if(j){h.fadeOut(j)}else{h.hide()}h.eq(g).fadeIn(f.fadeInSpeed,e)},slide:function(f,e){this.getPanes().slideUp(200);this.getPanes().eq(f).slideDown(400,e)},ajax:function(f,e){this.getPanes().eq(0).load(this.getTabs().eq(f).attr("href"),e)}};var b;d.tools.tabs.addEffect("horizontal",function(f,e){if(!b){b=this.getPanes().eq(0).width()}this.getCurrentPane().animate({width:0},function(){d(this).hide()});this.getPanes().eq(f).animate({width:b},function(){d(this).show();e.call()})});function a(g,h,f){var e=this,j=d(this),i;d.each(f,function(k,l){if(d.isFunction(l)){j.bind(k,l)}});d.extend(this,{click:function(k,n){var o=e.getCurrentPane();var l=g.eq(k);if(typeof k=="string"&&k.replace("#","")){l=g.filter("[href*="+k.replace("#","")+"]");k=Math.max(g.index(l),0)}if(f.rotate){var m=g.length-1;if(k<0){return e.click(m,n)}if(k>m){return e.click(0,n)}}if(!l.length){if(i>=0){return e}k=f.initialIndex;l=g.eq(k)}if(k===i){return e}n=n||d.Event();n.type="onBeforeClick";j.trigger(n,[k]);if(n.isDefaultPrevented()){return}c[f.effect].call(e,k,function(){n.type="onClick";j.trigger(n,[k])});n.type="onStart";j.trigger(n,[k]);if(n.isDefaultPrevented()){return}i=k;g.removeClass(f.current);l.addClass(f.current);return e},getConf:function(){return f},getTabs:function(){return g},getPanes:function(){return h},getCurrentPane:function(){return h.eq(i)},getCurrentTab:function(){return g.eq(i)},getIndex:function(){return i},next:function(){return e.click(i+1)},prev:function(){return e.click(i-1)},bind:function(k,l){j.bind(k,l);return e},onBeforeClick:function(k){return this.bind("onBeforeClick",k)},onClick:function(k){return this.bind("onClick",k)},unbind:function(k){j.unbind(k);return e}});g.each(function(k){d(this).bind(f.event,function(l){e.click(k,l);return false})});if(location.hash){e.click(location.hash)}else{if(f.initialIndex===0||f.initialIndex>0){e.click(f.initialIndex)}}h.find("a[href^=#]").click(function(k){e.click(d(this).attr("href"),k)})}d.fn.tabs=function(i,f){var g=this.eq(typeof f=="number"?f:0).data("tabs");if(g){return g}if(d.isFunction(f)){f={onBeforeClick:f}}var h=d.extend({},d.tools.tabs.conf),e=this.length;f=d.extend(h,f);this.each(function(l){var j=d(this);var k=j.find(f.tabs);if(!k.length){k=j.children()}var m=i.jquery?i:j.children(i);if(!m.length){m=e==1?d(i):j.parent().find(i)}g=new a(k,m,f);j.data("tabs",g)});return f.api?g:this}})(jQuery);
(function(c){var d=[];c.tools=c.tools||{};c.tools.tooltip={version:"1.1.3",conf:{effect:"toggle",fadeOutSpeed:"fast",tip:null,predelay:0,delay:30,opacity:1,lazy:undefined,position:["top","center"],offset:[0,0],cancelDefault:true,relative:false,oneInstance:true,events:{def:"mouseover,mouseout",input:"focus,blur",widget:"focus mouseover,blur mouseout",tooltip:"mouseover,mouseout"},api:false},addEffect:function(e,g,f){b[e]=[g,f]}};var b={toggle:[function(e){var f=this.getConf(),g=this.getTip(),h=f.opacity;if(h<1){g.css({opacity:h})}g.show();e.call()},function(e){this.getTip().hide();e.call()}],fade:[function(e){this.getTip().fadeIn(this.getConf().fadeInSpeed,e)},function(e){this.getTip().fadeOut(this.getConf().fadeOutSpeed,e)}]};function a(f,g){var p=this,k=c(this);f.data("tooltip",p);var l=f.next();if(g.tip){l=c(g.tip);if(l.length>1){l=f.nextAll(g.tip).eq(0);if(!l.length){l=f.parent().nextAll(g.tip).eq(0)}}}function o(u){var t=g.relative?f.position().top:f.offset().top,s=g.relative?f.position().left:f.offset().left,v=g.position[0];t-=l.outerHeight()-g.offset[0];s+=f.outerWidth()+g.offset[1];var q=l.outerHeight()+f.outerHeight();if(v=="center"){t+=q/2}if(v=="bottom"){t+=q}v=g.position[1];var r=l.outerWidth()+f.outerWidth();if(v=="center"){s-=r/2}if(v=="left"){s-=r}return{top:t,left:s}}var i=f.is(":input"),e=i&&f.is(":checkbox, :radio, select, :button"),h=f.attr("type"),n=g.events[h]||g.events[i?(e?"widget":"input"):"def"];n=n.split(/,\s*/);if(n.length!=2){throw"Tooltip: bad events configuration for "+h}f.bind(n[0],function(r){if(g.oneInstance){c.each(d,function(){this.hide()})}var q=l.data("trigger");if(q&&q[0]!=this){l.hide().stop(true,true)}r.target=this;p.show(r);n=g.events.tooltip.split(/,\s*/);l.bind(n[0],function(){p.show(r)});if(n[1]){l.bind(n[1],function(){p.hide(r)})}});f.bind(n[1],function(q){p.hide(q)});if(!c.browser.msie&&!i&&!g.predelay){f.mousemove(function(){if(!p.isShown()){f.triggerHandler("mouseover")}})}if(g.opacity<1){l.css("opacity",g.opacity)}var m=0,j=f.attr("title");if(j&&g.cancelDefault){f.removeAttr("title");f.data("title",j)}c.extend(p,{show:function(r){if(r){f=c(r.target)}clearTimeout(l.data("timer"));if(l.is(":animated")||l.is(":visible")){return p}function q(){l.data("trigger",f);var t=o(r);if(g.tip&&j){l.html(f.data("title"))}r=r||c.Event();r.type="onBeforeShow";k.trigger(r,[t]);if(r.isDefaultPrevented()){return p}t=o(r);l.css({position:"absolute",top:t.top,left:t.left});var s=b[g.effect];if(!s){throw'Nonexistent effect "'+g.effect+'"'}s[0].call(p,function(){r.type="onShow";k.trigger(r)})}if(g.predelay){clearTimeout(m);m=setTimeout(q,g.predelay)}else{q()}return p},hide:function(r){clearTimeout(l.data("timer"));clearTimeout(m);if(!l.is(":visible")){return}function q(){r=r||c.Event();r.type="onBeforeHide";k.trigger(r);if(r.isDefaultPrevented()){return}b[g.effect][1].call(p,function(){r.type="onHide";k.trigger(r)})}if(g.delay&&r){l.data("timer",setTimeout(q,g.delay))}else{q()}return p},isShown:function(){return l.is(":visible, :animated")},getConf:function(){return g},getTip:function(){return l},getTrigger:function(){return f},bind:function(q,r){k.bind(q,r);return p},onHide:function(q){return this.bind("onHide",q)},onBeforeShow:function(q){return this.bind("onBeforeShow",q)},onShow:function(q){return this.bind("onShow",q)},onBeforeHide:function(q){return this.bind("onBeforeHide",q)},unbind:function(q){k.unbind(q);return p}});c.each(g,function(q,r){if(c.isFunction(r)){p.bind(q,r)}})}c.prototype.tooltip=function(e){var f=this.eq(typeof e=="number"?e:0).data("tooltip");if(f){return f}var g=c.extend(true,{},c.tools.tooltip.conf);if(c.isFunction(e)){e={onBeforeShow:e}}else{if(typeof e=="string"){e={tip:e}}}e=c.extend(true,g,e);if(typeof e.position=="string"){e.position=e.position.split(/,?\s/)}if(e.lazy!==false&&(e.lazy===true||this.length>20)){this.one("mouseover",function(h){f=new a(c(this),e);f.show(h);d.push(f)})}else{this.each(function(){f=new a(c(this),e);d.push(f)})}return e.api?f:this}})(jQuery);
(function(d){var c=d.tools.tooltip;c.plugins=c.plugins||{};c.plugins.dynamic={version:"1.0.1",conf:{api:false,classNames:"top right bottom left"}};function b(h){var e=d(window);var g=e.width()+e.scrollLeft();var f=e.height()+e.scrollTop();return[h.offset().top<=e.scrollTop(),g<=h.offset().left+h.width(),f<=h.offset().top+h.height(),e.scrollLeft()>=h.offset().left]}function a(f){var e=f.length;while(e--){if(f[e]){return false}}return true}d.fn.dynamic=function(g){var h=d.extend({},c.plugins.dynamic.conf),f;if(typeof g=="number"){g={speed:g}}g=d.extend(h,g);var e=g.classNames.split(/\s/),i;this.each(function(){if(d(this).tooltip().jquery){throw"Lazy feature not supported by dynamic plugin. set lazy: false for tooltip"}var j=d(this).tooltip().onBeforeShow(function(n,o){var m=this.getTip(),l=this.getConf();if(!i){i=[l.position[0],l.position[1],l.offset[0],l.offset[1],d.extend({},l)]}d.extend(l,i[4]);l.position=[i[0],i[1]];l.offset=[i[2],i[3]];m.css({visibility:"hidden",position:"absolute",top:o.top,left:o.left}).show();var k=b(m);if(!a(k)){if(k[2]){d.extend(l,g.top);l.position[0]="top";m.addClass(e[0])}if(k[3]){d.extend(l,g.right);l.position[1]="right";m.addClass(e[1])}if(k[0]){d.extend(l,g.bottom);l.position[0]="bottom";m.addClass(e[2])}if(k[1]){d.extend(l,g.left);l.position[1]="left";m.addClass(e[3])}if(k[0]||k[2]){l.offset[0]*=-1}if(k[1]||k[3]){l.offset[1]*=-1}}m.css({visibility:"visible"}).hide()});j.onShow(function(){var l=this.getConf(),k=this.getTip();l.position=[i[0],i[1]];l.offset=[i[2],i[3]]});j.onHide(function(){var k=this.getTip();k.removeClass(g.classNames)});f=j});return g.api?f:this}})(jQuery);
(function(c){c.tools=c.tools||{};c.tools.overlay={version:"1.1.2",addEffect:function(e,f,g){b[e]=[f,g]},conf:{top:"10%",left:"center",absolute:false,speed:"normal",closeSpeed:"fast",effect:"default",close:null,oneInstance:true,closeOnClick:true,closeOnEsc:true,api:false,expose:null,target:null}};var b={};c.tools.overlay.addEffect("default",function(e){this.getOverlay().fadeIn(this.getConf().speed,e)},function(e){this.getOverlay().fadeOut(this.getConf().closeSpeed,e)});var d=[];function a(g,k){var o=this,m=c(this),n=c(window),j,i,h,e=k.expose&&c.tools.expose.version;var f=k.target||g.attr("rel");i=f?c(f):null||g;if(!i.length){throw"Could not find Overlay: "+f}if(g&&g.index(i)==-1){g.click(function(p){o.load(p);return p.preventDefault()})}c.each(k,function(p,q){if(c.isFunction(q)){m.bind(p,q)}});c.extend(o,{load:function(u){if(o.isOpened()){return o}var r=b[k.effect];if(!r){throw'Overlay: cannot find effect : "'+k.effect+'"'}if(k.oneInstance){c.each(d,function(){this.close(u)})}u=u||c.Event();u.type="onBeforeLoad";m.trigger(u);if(u.isDefaultPrevented()){return o}h=true;if(e){i.expose().load(u)}var t=k.top;var s=k.left;var p=i.outerWidth({margin:true});var q=i.outerHeight({margin:true});if(typeof t=="string"){t=t=="center"?Math.max((n.height()-q)/2,0):parseInt(t,10)/100*n.height()}if(s=="center"){s=Math.max((n.width()-p)/2,0)}if(!k.absolute){t+=n.scrollTop();s+=n.scrollLeft()}i.css({top:t,left:s,position:"absolute"});u.type="onStart";m.trigger(u);r[0].call(o,function(){if(h){u.type="onLoad";m.trigger(u)}});if(k.closeOnClick){c(document).bind("click.overlay",function(w){if(!o.isOpened()){return}var v=c(w.target);if(v.parents(i).length>1){return}c.each(d,function(){this.close(w)})})}if(k.closeOnEsc){c(document).unbind("keydown.overlay").bind("keydown.overlay",function(v){if(v.keyCode==27){c.each(d,function(){this.close(v)})}})}return o},close:function(q){if(!o.isOpened()){return o}q=q||c.Event();q.type="onBeforeClose";m.trigger(q);if(q.isDefaultPrevented()){return}h=false;b[k.effect][1].call(o,function(){q.type="onClose";m.trigger(q)});var p=true;c.each(d,function(){if(this.isOpened()){p=false}});if(p){c(document).unbind("click.overlay").unbind("keydown.overlay")}return o},getContent:function(){return i},getOverlay:function(){return i},getTrigger:function(){return g},getClosers:function(){return j},isOpened:function(){return h},getConf:function(){return k},bind:function(p,q){m.bind(p,q);return o},unbind:function(p){m.unbind(p);return o}});c.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(p,q){o[q]=function(r){return o.bind(q,r)}});if(e){if(typeof k.expose=="string"){k.expose={color:k.expose}}c.extend(k.expose,{api:true,closeOnClick:k.closeOnClick,closeOnEsc:false});var l=i.expose(k.expose);l.onBeforeClose(function(p){o.close(p)});o.onClose(function(p){l.close(p)})}j=i.find(k.close||".close");if(!j.length&&!k.close){j=c('<div class="close"></div>');i.prepend(j)}j.click(function(p){o.close(p)})}c.fn.overlay=function(e){var f=this.eq(typeof e=="number"?e:0).data("overlay");if(f){return f}if(c.isFunction(e)){e={onBeforeLoad:e}}var g=c.extend({},c.tools.overlay.conf);e=c.extend(true,g,e);this.each(function(){f=new a(c(this),e);d.push(f);c(this).data("overlay",f)});return e.api?f:this}})(jQuery);
(function(b){b.tools=b.tools||{};b.tools.expose={version:"1.0.5",conf:{maskId:null,loadSpeed:"slow",closeSpeed:"fast",closeOnClick:true,closeOnEsc:true,zIndex:9998,opacity:0.8,color:"#456",api:false}};function a(){if(b.browser.msie){var f=b(document).height(),e=b(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,f-e<20?e:f]}return[b(window).width(),b(document).height()]}function c(h,g){var e=this,j=b(this),d=null,f=false,i=0;b.each(g,function(k,l){if(b.isFunction(l)){j.bind(k,l)}});b(window).resize(function(){e.fit()});b.extend(this,{getMask:function(){return d},getExposed:function(){return h},getConf:function(){return g},isLoaded:function(){return f},load:function(n){if(f){return e}i=h.eq(0).css("zIndex");if(g.maskId){d=b("#"+g.maskId)}if(!d||!d.length){var l=a();d=b("<div/>").css({position:"absolute",top:0,left:0,width:l[0],height:l[1],display:"none",opacity:0,zIndex:g.zIndex});if(g.maskId){d.attr("id",g.maskId)}b("body").append(d);var k=d.css("backgroundColor");if(!k||k=="transparent"||k=="rgba(0, 0, 0, 0)"){d.css("backgroundColor",g.color)}if(g.closeOnEsc){b(document).bind("keydown.unexpose",function(o){if(o.keyCode==27){e.close()}})}if(g.closeOnClick){d.bind("click.unexpose",function(o){e.close(o)})}}n=n||b.Event();n.type="onBeforeLoad";j.trigger(n);if(n.isDefaultPrevented()){return e}b.each(h,function(){var o=b(this);if(!/relative|absolute|fixed/i.test(o.css("position"))){o.css("position","relative")}});h.css({zIndex:Math.max(g.zIndex+1,i=="auto"?0:i)});var m=d.height();if(!this.isLoaded()){d.css({opacity:0,display:"block"}).fadeTo(g.loadSpeed,g.opacity,function(){if(d.height()!=m){d.css("height",m)}n.type="onLoad";j.trigger(n)})}f=true;return e},close:function(k){if(!f){return e}k=k||b.Event();k.type="onBeforeClose";j.trigger(k);if(k.isDefaultPrevented()){return e}d.fadeOut(g.closeSpeed,function(){k.type="onClose";j.trigger(k);h.css({zIndex:b.browser.msie?i:null})});f=false;return e},fit:function(){if(d){var k=a();d.css({width:k[0],height:k[1]})}},bind:function(k,l){j.bind(k,l);return e},unbind:function(k){j.unbind(k);return e}});b.each("onBeforeLoad,onLoad,onBeforeClose,onClose".split(","),function(k,l){e[l]=function(m){return e.bind(l,m)}})}b.fn.expose=function(d){var e=this.eq(typeof d=="number"?d:0).data("expose");if(e){return e}if(typeof d=="string"){d={color:d}}var f=b.extend({},b.tools.expose.conf);d=b.extend(f,d);this.each(function(){e=new c(b(this),d);b(this).data("expose",e)});return d.api?e:this}})(jQuery);

/* jquery.colorbox.js */

// ColorBox v1.3.11 - a full featured, light-weight, customizable lightbox based on jQuery 1.3
// Copyright (c) 2010 Jack Moore - jack@colorpowered.com
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
(function ($, 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,
		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,
		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',
	event_loaded = prefix + '_loaded',
	
	// 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,

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

	// jQuery object generator to reduce code size
	function $div(id, css) { 
		id = id ? ' id="' + prefix + id + '"' : '';
		css = css ? ' style="' + css + '"' : '';
		return $('<div' + id + css + '/>');
	}

	// 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, target) {
		url = $.isFunction(url) ? url.call(target) : 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 = settings.href || $(element).attr('href');
		settings.title = settings.title || element.title;
		return settings;
	}

	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, 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 + ' ' + click)
					.one(click, start);
				$box.removeClass(className + "on").addClass(className + "off");
			};
			
			$slideshow.bind(event_closed, function () {
				clearTimeout(timeOut);
			});
			
			if ($box.hasClass(className + "on") || (settings.slideshowAuto && !$box.hasClass(className + "off"))) {
				start();
			} else {
				stop();
			}
		}
	}

	function launch(elem) {
		if (!closing) {
			
			element = elem;
			
			settings = process($.extend({}, $.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();
				
				bookmark = element;
				
				try {
					bookmark.blur(); // Remove the focus from the calling element.
				}catch (e) {}
				
				// +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('scroll.' + event_ie6);
				}
				
				trigger(event_open, settings.onOpen);
				
				$current.add($prev).add($next).add($slideshow).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 + '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(publicMethod.next);
		$prev.click(publicMethod.prev);
		$close.click(publicMethod.close);
		
		// 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 photo,
		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.
		$('#' + prefix + 'Photo').css({cssFloat: 'none', marginLeft: 'auto', marginRight: 'auto'});
		
		// 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) {
			var prev, prevSrc, next, nextSrc, total = $related.length, loop = settings.loop;
			publicMethod.position(s, function () {
				function defilter() {
					if (isIE) {
						//IE adds a filter when ColorBox fades in and out that can cause problems if the loaded content contains transparent pngs.
						$box[0].style.filter = false;
					}
				}
				
				if (!open) {
					return;
				}
				
				if (isIE) {
					//This fadeIn helps the bicubic resampling to kick-in.
					if (photo) {
						$loaded.fadeIn(100);
					}
				}
				
				$loaded.show();
				
				trigger(event_loaded);
				
				$title.show().html(settings.title);
				
				if (total > 1) { // handle grouping
					$current.html(settings.current.replace(/\{current\}/, index + 1).replace(/\{total\}/, total)).show();
					
					$next[(loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
					$prev[(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;
						
						if (isImage(nextSrc, next)) {
							$('<img/>')[0].src = nextSrc;
						}
						
						if (isImage(prevSrc, prev)) {
							$('<img/>')[0].src = prevSrc;
						}
					}
				}
				
				$loadingOverlay.hide();
				
				if (settings.transition === 'fade') {
					$box.fadeTo(speed, 1, function () {
						defilter();
					});
				} else {
					defilter();
				}
				
				$window.bind('resize.' + prefix, function () {
					publicMethod.position(0);
				});
				
				trigger(event_complete, settings.onComplete);
			});
		}
		
		if (settings.transition === 'fade') {
			$box.fadeTo(speed, 0, function () {
				setPosition(0);
			});
		} else {
			setPosition(speed);
		}
	};

	publicMethod.load = function (launched) {
		var href, img, setResize, prep = publicMethod.prep;
		
		active = true;
		element = $related[index];
		
		if (!launched) {
			settings = process($.extend({}, $.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.
			$box.one(event_loaded, function () {
				var $iframe = $("<iframe name='" + new Date().getTime() + "' frameborder=0" + (settings.scrolling ? "" : " scrolling='no'") + (isIE ? " allowtransparency='true'" : '') + " style='width:100%; height:100%; border:0; display:block;'/>");
				$iframe[0].src = settings.href;
				$iframe.appendTo($loaded).one(event_purge, function () {
					$iframe[0].src = 'about:blank';
				});
			});
			
			prep(" ");
		} else if (settings.html) {
			prep(settings.html);
		} else if (isImage(href, element)) {
			img = new Image();
			img.onload = function () {
				var percent;
				img.onload = null;
				img.id = prefix + 'Photo';
				$(img).css({border: 'none', display: 'block', cssFloat: 'left'});
				if (settings.scalePhotos) {
					setResize = function () {
						img.height -= img.height * percent;
						img.width -= img.width * percent;	
					};
					if (settings.mw && img.width > settings.mw) {
						percent = (img.width - settings.mw) / img.width;
						setResize();
					}
					if (settings.mh && img.height > settings.mh) {
						percent = (img.height - settings.mh) / img.height;
						setResize();
					}
				}
				
				if (settings.h) {
					img.style.marginTop = Math.max(settings.h - img.height, 0) / 2 + 'px';
				}
				
				if ($related[1] && (index < $related.length - 1 || settings.loop)) {
					$(img).css({cursor: 'pointer'}).click(publicMethod.next);
				}
				
				if (isIE) {
					img.style.msInterpolationMode = 'bicubic';
				}
				
				setTimeout(function () { // Chrome will sometimes report a 0 by 0 size if there isn't pause in execution
					prep(img);
				}, 1);
			};
			
			setTimeout(function () { // Opera 10.6+ will sometimes load the src before the onload function is set
				img.src = href;
			}, 1);
			
		} else {
			$div().appendTo($loadingBay).load(href, function (data, status, xhr) {
				prep(status === 'error' ? 'Request unsuccessful: ' + xhr.statusText : this);
			});
		}
	};

	// 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('fast', 0);
			
			$box.stop().fadeTo('fast', 0, function () {
				
				trigger(event_purge);
				
				$loaded.remove();
				
				$box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
				
				try {
					bookmark.focus();
				} catch (e) {
					// do nothing
				}
				
				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, this));

/* 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);
/* 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);
	}
}
