var $jQ = jQuery.noConflict();

/*
 * jQuery UI @VERSION
 *
 * Copyright (c) 2008 Paul Bakaus (ui.jquery.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
;(function($jQ) {

$jQ.ui = {
	plugin: {
		add: function(module, option, set) {
			var proto = $jQ.ui[module].prototype;
			for(var i in set) {
				proto.plugins[i] = proto.plugins[i] || [];
				proto.plugins[i].push([option, set[i]]);
			}
		},
		call: function(instance, name, args) {
			var set = instance.plugins[name];
			if(!set) { return; }
			
			for (var i = 0; i < set.length; i++) {
				if (instance.options[set[i][0]]) {
					set[i][1].apply(instance.element, args);
				}
			}
		}	
	},
	cssCache: {},
	css: function(name) {
		if ($jQ.ui.cssCache[name]) { return $jQ.ui.cssCache[name]; }
		var tmp = $jQ('<div class="ui-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body');
		
		//if (!$jQ.browser.safari)
			//tmp.appendTo('body'); 
		
		//Opera and Safari set width and height to 0px instead of auto
		//Safari returns rgba(0,0,0,0) when bgcolor is not set
		$jQ.ui.cssCache[name] = !!(
			(!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) || 
			!(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor')))
		);
		try { $jQ('body').get(0).removeChild(tmp.get(0));	} catch(e){}
		return $jQ.ui.cssCache[name];
	},
	disableSelection: function(el) {
		$jQ(el).attr('unselectable', 'on').css('MozUserSelect', 'none');
	},
	enableSelection: function(el) {
		$jQ(el).attr('unselectable', 'off').css('MozUserSelect', '');
	},
	hasScroll: function(e, a) {
		var scroll = /top/.test(a||"top") ? 'scrollTop' : 'scrollLeft', has = false;
		if (e[scroll] > 0) return true; e[scroll] = 1;
		has = e[scroll] > 0 ? true : false; e[scroll] = 0;
		return has;
	}
};


/** jQuery core modifications and additions **/

var _remove = $jQ.fn.remove;
$jQ.fn.remove = function() {
	$jQ("*", this).add(this).triggerHandler("remove");
	return _remove.apply(this, arguments );
};

// $jQ.widget is a factory to create jQuery plugins
// taking some boilerplate code out of the plugin code
// created by Scott González and Jörn Zaefferer
function getter(namespace, plugin, method) {
	var methods = $jQ[namespace][plugin].getter || [];
	methods = (typeof methods == "string" ? methods.split(/,?\s+/) : methods);
	return ($jQ.inArray(method, methods) != -1);
}

$jQ.widget = function(name, prototype) {
	var namespace = name.split(".")[0];
	name = name.split(".")[1];
	
	// create plugin method
	$jQ.fn[name] = function(options) {
		var isMethodCall = (typeof options == 'string'),
			args = Array.prototype.slice.call(arguments, 1);
		
		if (isMethodCall && getter(namespace, name, options)) {
			var instance = $jQ.data(this[0], name);
			return (instance ? instance[options].apply(instance, args)
				: undefined);
		}
		
		return this.each(function() {
			var instance = $jQ.data(this, name);
			if (isMethodCall && instance && $jQ.isFunction(instance[options])) {
				instance[options].apply(instance, args);
			} else if (!isMethodCall) {
				$jQ.data(this, name, new $jQ[namespace][name](this, options));
			}
		});
	};
	
	// create widget constructor
	$jQ[namespace][name] = function(element, options) {
		var self = this;
		
		this.widgetName = name;
		this.widgetBaseClass = namespace + '-' + name;
		
		this.options = $jQ.extend({}, $jQ.widget.defaults, $jQ[namespace][name].defaults, options);
		this.element = $jQ(element)
			.bind('setData.' + name, function(e, key, value) {
				return self.setData(key, value);
			})
			.bind('getData.' + name, function(e, key) {
				return self.getData(key);
			})
			.bind('remove', function() {
				return self.destroy();
			});
		this.init();
	};
	
	// add widget prototype
	$jQ[namespace][name].prototype = $jQ.extend({}, $jQ.widget.prototype, prototype);
};

$jQ.widget.prototype = {
	init: function() {},
	destroy: function() {
		this.element.removeData(this.widgetName);
	},
	
	getData: function(key) {
		return this.options[key];
	},
	setData: function(key, value) {
		this.options[key] = value;
		
		if (key == 'disabled') {
			this.element[value ? 'addClass' : 'removeClass'](
				this.widgetBaseClass + '-disabled');
		}
	},
	
	enable: function() {
		this.setData('disabled', false);
	},
	disable: function() {
		this.setData('disabled', true);
	}
};

$jQ.widget.defaults = {
	disabled: false
};


/** Mouse Interaction Plugin **/

$jQ.ui.mouse = {
	mouseInit: function() {
		var self = this;
	
		this.element.bind('mousedown.'+this.widgetName, function(e) {
			return self.mouseDown(e);
		});
		
		// Prevent text selection in IE
		if ($jQ.browser.msie) {
			this._mouseUnselectable = this.element.attr('unselectable');
			this.element.attr('unselectable', 'on');
		}
		
		this.started = false;
	},
	
	// TODO: make sure destroying one instance of mouse doesn't mess with
	// other instances of mouse
	mouseDestroy: function() {
		this.element.unbind('.'+this.widgetName);
		
		// Restore text selection in IE
		($jQ.browser.msie
			&& this.element.attr('unselectable', this._mouseUnselectable));
	},
	
	mouseDown: function(e) {
		// we may have missed mouseup (out of window)
		(this._mouseStarted && this.mouseUp(e));
		
		this._mouseDownEvent = e;
		
		var self = this,
			btnIsLeft = (e.which == 1),
			elIsCancel = (typeof this.options.cancel == "string" ? $jQ(e.target).parents().add(e.target).filter(this.options.cancel).length : false);
		if (!btnIsLeft || elIsCancel || !this.mouseCapture(e)) {
			return true;
		}
		
		this._mouseDelayMet = !this.options.delay;
		if (!this._mouseDelayMet) {
			this._mouseDelayTimer = setTimeout(function() {
				self._mouseDelayMet = true;
			}, this.options.delay);
		}
		
		if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {
			this._mouseStarted = (this.mouseStart(e) !== false);
			if (!this._mouseStarted) {
				e.preventDefault();
				return true;
			}
		}
		
		// these delegates are required to keep context
		this._mouseMoveDelegate = function(e) {
			return self.mouseMove(e);
		};
		this._mouseUpDelegate = function(e) {
			return self.mouseUp(e);
		};
		$jQ(document)
			.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
			.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
		
		return false;
	},
	
	mouseMove: function(e) {
		// IE mouseup check - mouseup happened when mouse was out of window
		if ($jQ.browser.msie && !e.button) {
			return this.mouseUp(e);
		}
		
		if (this._mouseStarted) {
			this.mouseDrag(e);
			return false;
		}
		
		if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {
			this._mouseStarted =
				(this.mouseStart(this._mouseDownEvent, e) !== false);
			(this._mouseStarted ? this.mouseDrag(e) : this.mouseUp(e));
		}
		
		return !this._mouseStarted;
	},
	
	mouseUp: function(e) {
		$jQ(document)
			.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
			.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
		
		if (this._mouseStarted) {
			this._mouseStarted = false;
			this.mouseStop(e);
		}
		
		return false;
	},
	
	mouseDistanceMet: function(e) {
		return (Math.max(
				Math.abs(this._mouseDownEvent.pageX - e.pageX),
				Math.abs(this._mouseDownEvent.pageY - e.pageY)
			) >= this.options.distance
		);
	},
	
	mouseDelayMet: function(e) {
		return this._mouseDelayMet;
	},
	
	// These are placeholder methods, to be overriden by extending plugin
	mouseStart: function(e) {},
	mouseDrag: function(e) {},
	mouseStop: function(e) {},
	mouseCapture: function(e) { return true; }
};

$jQ.ui.mouse.defaults = {
	cancel: null,
	distance: 1,
	delay: 0
};

})(jQuery);

/*
 * jQuery UI Tabs
 *
 * Copyright (c) 2007, 2008 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Tabs
 *
 * Depends:
 *	ui.core.js
 */
(function($jQ) {

$jQ.widget("ui.tabs", {
	init: function() {
		this.options.event += '.tabs'; // namespace event
		
		// create tabs
		this.tabify(true);
	},
	setData: function(key, value) {
		if ((/^selected/).test(key))
			this.select(value);
		else {
			this.options[key] = value;
			this.tabify();
		}
	},
	length: function() {
		return this.$jQtabs.length;
	},
	tabId: function(a) {
		return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '')
			|| this.options.idPrefix + $jQ.data(a);
	},
	ui: function(tab, panel) {
		return {
			options: this.options,
			tab: tab,
			panel: panel,
			index: this.$jQtabs.index(tab)
		};
	},
	tabify: function(init) {

		this.$jQlis = $jQ('li:has(a[href])', this.element);
		this.$jQtabs = this.$jQlis.map(function() { return $jQ('a', this)[0]; });
		this.$jQpanels = $jQ([]);

		var self = this, o = this.options;

		this.$jQtabs.each(function(i, a) {
			// inline tab
			if (a.hash && a.hash.replace('#', '')) // Safari 2 reports '#' for an empty hash
				self.$jQpanels = self.$jQpanels.add(a.hash);
			// remote tab
			else if ($jQ(a).attr('href') != '#') { // prevent loading the page itself if href is just "#"
				$jQ.data(a, 'href.tabs', a.href); // required for restore on destroy
				$jQ.data(a, 'load.tabs', a.href); // mutable
				var id = self.tabId(a);
				a.href = '#' + id;
				var $jQpanel = $jQ('#' + id);
				if (!$jQpanel.length) {
					$jQpanel = $jQ(o.panelTemplate).attr('id', id).addClass(o.panelClass)
						.insertAfter( self.$jQpanels[i - 1] || self.element );
					$jQpanel.data('destroy.tabs', true);
				}
				self.$jQpanels = self.$jQpanels.add( $jQpanel );
			}
			// invalid tab href
			else
				o.disabled.push(i + 1);
		});

		if (init) {

			// attach necessary classes for styling if not present
			this.element.addClass(o.navClass);
			this.$jQpanels.each(function() {
				var $jQthis = $jQ(this);
				$jQthis.addClass(o.panelClass);
			});

			// Selected tab
			// use "selected" option or try to retrieve:
			// 1. from fragment identifier in url
			// 2. from cookie
			// 3. from selected class attribute on <li>
			if (o.selected === undefined) {
				if (location.hash) {
					this.$jQtabs.each(function(i, a) {
						if (a.hash == location.hash) {
							o.selected = i;
							// prevent page scroll to fragment
							if ($jQ.browser.msie || $jQ.browser.opera) { // && !o.remote
								var $jQtoShow = $jQ(location.hash), toShowId = $jQtoShow.attr('id');
								$jQtoShow.attr('id', '');
								setTimeout(function() {
									$jQtoShow.attr('id', toShowId); // restore id
								}, 500);
							}
							scrollTo(0, 0);
							return false; // break
						}
					});
				}
				else if (o.cookie) {
					var index = parseInt($jQ.cookie('ui-tabs' + $jQ.data(self.element)),10);
					if (index && self.$jQtabs[index])
						o.selected = index;
				}
				else if (self.$jQlis.filter('.' + o.selectedClass).length)
					o.selected = self.$jQlis.index( self.$jQlis.filter('.' + o.selectedClass)[0] );
			}
			o.selected = o.selected === null || o.selected !== undefined ? o.selected : 0; // first tab selected by default

			// Take disabling tabs via class attribute from HTML
			// into account and update option properly.
			// A selected tab cannot become disabled.
			o.disabled = $jQ.unique(o.disabled.concat(
				$jQ.map(this.$jQlis.filter('.' + o.disabledClass),
					function(n, i) { return self.$jQlis.index(n); } )
			)).sort();
			if ($jQ.inArray(o.selected, o.disabled) != -1)
				o.disabled.splice($jQ.inArray(o.selected, o.disabled), 1);
			
			// highlight selected tab
			this.$jQpanels.addClass(o.hideClass);
			this.$jQlis.removeClass(o.selectedClass);
			if (o.selected !== null) {
				this.$jQpanels.eq(o.selected).show().removeClass(o.hideClass); // use show and remove class to show in any case no matter how it has been hidden before
				this.$jQlis.eq(o.selected).addClass(o.selectedClass);
				
				// seems to be expected behavior that the show callback is fired
				var onShow = function() {
					$jQ(self.element).triggerHandler('tabsshow',
						[self.fakeEvent('tabsshow'), self.ui(self.$jQtabs[o.selected], self.$jQpanels[o.selected])], o.show);
				}; 

				// load if remote tab
				if ($jQ.data(this.$jQtabs[o.selected], 'load.tabs'))
					this.load(o.selected, onShow);
				// just trigger show event
				else
					onShow();
				
			}
			
			// clean up to avoid memory leaks in certain versions of IE 6
			$jQ(window).bind('unload', function() {
				self.$jQtabs.unbind('.tabs');
				self.$jQlis = self.$jQtabs = self.$jQpanels = null;
			});

		}

		// disable tabs
		for (var i = 0, li; li = this.$jQlis[i]; i++)
			$jQ(li)[$jQ.inArray(i, o.disabled) != -1 && !$jQ(li).hasClass(o.selectedClass) ? 'addClass' : 'removeClass'](o.disabledClass);

		// reset cache if switching from cached to not cached
		if (o.cache === false)
			this.$jQtabs.removeData('cache.tabs');
		
		// set up animations
		var hideFx, showFx, baseFx = { 'min-width': 0, duration: 1 }, baseDuration = 'normal';
		if (o.fx && o.fx.constructor == Array)
			hideFx = o.fx[0] || baseFx, showFx = o.fx[1] || baseFx;
		else
			hideFx = showFx = o.fx || baseFx;

		// reset some styles to maintain print style sheets etc.
		var resetCSS = { display: '', overflow: '', height: '' };
		if (!$jQ.browser.msie) // not in IE to prevent ClearType font issue
			resetCSS.opacity = '';

		// Hide a tab, animation prevents browser scrolling to fragment,
		// $jQshow is optional.
		function hideTab(clicked, $jQhide, $jQshow) {
			$jQhide.animate(hideFx, hideFx.duration || baseDuration, function() { //
				$jQhide.addClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.
				if ($jQ.browser.msie && hideFx.opacity)
					$jQhide[0].style.filter = '';
				if ($jQshow)
					showTab(clicked, $jQshow, $jQhide);
			});
		}

		// Show a tab, animation prevents browser scrolling to fragment,
		// $jQhide is optional.
		function showTab(clicked, $jQshow, $jQhide) {
			if (showFx === baseFx)
				$jQshow.css('display', 'block'); // prevent occasionally occuring flicker in Firefox cause by gap between showing and hiding the tab panels
			$jQshow.animate(showFx, showFx.duration || baseDuration, function() {
				$jQshow.removeClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.
				if ($jQ.browser.msie && showFx.opacity)
					$jQshow[0].style.filter = '';

				// callback
				$jQ(self.element).triggerHandler('tabsshow',
					[self.fakeEvent('tabsshow'), self.ui(clicked, $jQshow[0])], o.show);

			});
		}

		// switch a tab
		function switchTab(clicked, $jQli, $jQhide, $jQshow) {
			/*if (o.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click
				$jQ.ajaxHistory.update(clicked.hash);
			}*/
			$jQli.addClass(o.selectedClass)
				.siblings().removeClass(o.selectedClass);
			hideTab(clicked, $jQhide, $jQshow);
		}

		// attach tab event handler, unbind to avoid duplicates from former tabifying...
		this.$jQtabs.unbind('.tabs').bind(o.event, function() {

			//var trueClick = e.clientX; // add to history only if true click occured, not a triggered click
			var $jQli = $jQ(this).parents('li:eq(0)'),
				$jQhide = self.$jQpanels.filter(':visible'),
				$jQshow = $jQ(this.hash);

			// If tab is already selected and not unselectable or tab disabled or 
			// or is already loading or click callback returns false stop here.
			// Check if click handler returns false last so that it is not executed
			// for a disabled or loading tab!
			if (($jQli.hasClass(o.selectedClass) && !o.unselect)
				|| $jQli.hasClass(o.disabledClass) 
				|| $jQ(this).hasClass(o.loadingClass)
				|| $jQ(self.element).triggerHandler('tabsselect', [self.fakeEvent('tabsselect'), self.ui(this, $jQshow[0])], o.select) === false
				) {
				this.blur();
				return false;
			}

			self.options.selected = self.$jQtabs.index(this);

			// if tab may be closed
			if (o.unselect) {
				if ($jQli.hasClass(o.selectedClass)) {
					self.options.selected = null;
					$jQli.removeClass(o.selectedClass);
					self.$jQpanels.stop();
					hideTab(this, $jQhide);
					this.blur();
					return false;
				} else if (!$jQhide.length) {
					self.$jQpanels.stop();
					var a = this;
					self.load(self.$jQtabs.index(this), function() {
						$jQli.addClass(o.selectedClass).addClass(o.unselectClass);
						showTab(a, $jQshow);
					});
					this.blur();
					return false;
				}
			}

			if (o.cookie)
				$jQ.cookie('ui-tabs' + $jQ.data(self.element), self.options.selected, o.cookie);

			// stop possibly running animations
			self.$jQpanels.stop();

			// show new tab
			if ($jQshow.length) {

				// prevent scrollbar scrolling to 0 and than back in IE7, happens only if bookmarking/history is enabled
				/*if ($jQ.browser.msie && o.bookmarkable) {
					var showId = this.hash.replace('#', '');
					$jQshow.attr('id', '');
					setTimeout(function() {
						$jQshow.attr('id', showId); // restore id
					}, 0);
				}*/

				var a = this;
				self.load(self.$jQtabs.index(this), $jQhide.length ? 
					function() {
						switchTab(a, $jQli, $jQhide, $jQshow);
					} :
					function() {
						$jQli.addClass(o.selectedClass);
						showTab(a, $jQshow);
					}
				);

				// Set scrollbar to saved position - need to use timeout with 0 to prevent browser scroll to target of hash
				/*var scrollX = window.pageXOffset || document.documentElement && document.documentElement.scrollLeft || document.body.scrollLeft || 0;
				var scrollY = window.pageYOffset || document.documentElement && document.documentElement.scrollTop || document.body.scrollTop || 0;
				setTimeout(function() {
					scrollTo(scrollX, scrollY);
				}, 0);*/

			} else
				throw 'jQuery UI Tabs: Mismatching fragment identifier.';

			// Prevent IE from keeping other link focussed when using the back button
			// and remove dotted border from clicked link. This is controlled in modern
			// browsers via CSS, also blur removes focus from address bar in Firefox
			// which can become a usability and annoying problem with tabsRotate.
			if ($jQ.browser.msie)
				this.blur();

			//return o.bookmarkable && !!trueClick; // convert trueClick == undefined to Boolean required in IE
			return false;

		});

		// disable click if event is configured to something else
		if (!(/^click/).test(o.event))
			this.$jQtabs.bind('click.tabs', function() { return false; });

	},
	add: function(url, label, index) {
		if (index == undefined) 
			index = this.$jQtabs.length; // append by default

		var o = this.options;
		var $jQli = $jQ(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label));
		$jQli.data('destroy.tabs', true);

		var id = url.indexOf('#') == 0 ? url.replace('#', '') : this.tabId( $jQ('a:first-child', $jQli)[0] );

		// try to find an existing element before creating a new one
		var $jQpanel = $jQ('#' + id);
		if (!$jQpanel.length) {
			$jQpanel = $jQ(o.panelTemplate).attr('id', id)
				.addClass(o.hideClass)
				.data('destroy.tabs', true);
		}
		$jQpanel.addClass(o.panelClass);
		if (index >= this.$jQlis.length) {
			$jQli.appendTo(this.element);
			$jQpanel.appendTo(this.element[0].parentNode);
		} else {
			$jQli.insertBefore(this.$jQlis[index]);
			$jQpanel.insertBefore(this.$jQpanels[index]);
		}
		
		o.disabled = $jQ.map(o.disabled,
			function(n, i) { return n >= index ? ++n : n });
			
		this.tabify();

		if (this.$jQtabs.length == 1) {
			$jQli.addClass(o.selectedClass);
			$jQpanel.removeClass(o.hideClass);
			var href = $jQ.data(this.$jQtabs[0], 'load.tabs');
			if (href)
				this.load(index, href);
		}

		// callback
		this.element.triggerHandler('tabsadd',
			[this.fakeEvent('tabsadd'), this.ui(this.$jQtabs[index], this.$jQpanels[index])], o.add
		);
	},
	remove: function(index) {
		var o = this.options, $jQli = this.$jQlis.eq(index).remove(),
			$jQpanel = this.$jQpanels.eq(index).remove();

		// If selected tab was removed focus tab to the right or
		// in case the last tab was removed the tab to the left.
		if ($jQli.hasClass(o.selectedClass) && this.$jQtabs.length > 1)
			this.select(index + (index + 1 < this.$jQtabs.length ? 1 : -1));

		o.disabled = $jQ.map($jQ.grep(o.disabled, function(n, i) { return n != index; }),
			function(n, i) { return n >= index ? --n : n });

		this.tabify();

		// callback
		this.element.triggerHandler('tabsremove',
			[this.fakeEvent('tabsremove'), this.ui($jQli.find('a')[0], $jQpanel[0])], o.remove
		);
	},
	enable: function(index) {
		var o = this.options;
		if ($jQ.inArray(index, o.disabled) == -1)
			return;
			
		var $jQli = this.$jQlis.eq(index).removeClass(o.disabledClass);
		if ($jQ.browser.safari) { // fix disappearing tab (that used opacity indicating disabling) after enabling in Safari 2...
			$jQli.css('display', 'inline-block');
			setTimeout(function() {
				$jQli.css('display', 'block');
			}, 0);
		}

		o.disabled = $jQ.grep(o.disabled, function(n, i) { return n != index; });

		// callback
		this.element.triggerHandler('tabsenable',
			[this.fakeEvent('tabsenable'), this.ui(this.$jQtabs[index], this.$jQpanels[index])], o.enable
		);

	},
	disable: function(index) {
		var self = this, o = this.options;
		if (index != o.selected) { // cannot disable already selected tab
			this.$jQlis.eq(index).addClass(o.disabledClass);

			o.disabled.push(index);
			o.disabled.sort();

			// callback
			this.element.triggerHandler('tabsdisable',
				[this.fakeEvent('tabsdisable'), this.ui(this.$jQtabs[index], this.$jQpanels[index])], o.disable
			);
		}
	},
	select: function(index) {
		if (typeof index == 'string')
			index = this.$jQtabs.index( this.$jQtabs.filter('[href$jQ=' + index + ']')[0] );
		this.$jQtabs.eq(index).trigger(this.options.event);
	},
	load: function(index, callback) { // callback is for internal usage only
		
		var self = this, o = this.options, $jQa = this.$jQtabs.eq(index), a = $jQa[0],
				bypassCache = callback == undefined || callback === false, url = $jQa.data('load.tabs');

		callback = callback || function() {};
		
		// no remote or from cache - just finish with callback
		if (!url || !bypassCache && $jQ.data(a, 'cache.tabs')) {
			callback();
			return;
		}

		// load remote from here on
		
		var inner = function(parent) {
			var $jQparent = $jQ(parent), $jQinner = $jQparent.find('*:last');
			return $jQinner.length && $jQinner.is(':not(img)') && $jQinner || $jQparent;
		};
		var cleanup = function() {
			self.$jQtabs.filter('.' + o.loadingClass).removeClass(o.loadingClass)
						.each(function() {
							if (o.spinner)
								inner(this).parent().html(inner(this).data('label.tabs'));
						});
			self.xhr = null;
		};
		
		if (o.spinner) {
			var label = inner(a).html();
			inner(a).wrapInner('<em></em>')
				.find('em').data('label.tabs', label).html(o.spinner);
		}

		var ajaxOptions = $jQ.extend({}, o.ajaxOptions, {
			url: url,
			success: function(r, s) {
				$jQ(a.hash).html(r);
				cleanup();
				
				if (o.cache)
					$jQ.data(a, 'cache.tabs', true); // if loaded once do not load them again

				// callbacks
				$jQ(self.element).triggerHandler('tabsload',
					[self.fakeEvent('tabsload'), self.ui(self.$jQtabs[index], self.$jQpanels[index])], o.load
				);
				o.ajaxOptions.success && o.ajaxOptions.success(r, s);
				
				// This callback is required because the switch has to take
				// place after loading has completed. Call last in order to 
				// fire load before show callback...
				callback();
			}
		});
		if (this.xhr) {
			// terminate pending requests from other tabs and restore tab label
			this.xhr.abort();
			cleanup();
		}
		$jQa.addClass(o.loadingClass);
		setTimeout(function() { // timeout is again required in IE, "wait" for id being restored
			self.xhr = $jQ.ajax(ajaxOptions);
		}, 0);

	},
	url: function(index, url) {
		this.$jQtabs.eq(index).removeData('cache.tabs').data('load.tabs', url);
	},
	destroy: function() {
		var o = this.options;
		this.element.unbind('.tabs')
			.removeClass(o.navClass).removeData('tabs');
		this.$jQtabs.each(function() {
			var href = $jQ.data(this, 'href.tabs');
			if (href)
				this.href = href;
			var $jQthis = $jQ(this).unbind('.tabs');
			$jQ.each(['href', 'load', 'cache'], function(i, prefix) {
				$jQthis.removeData(prefix + '.tabs');
			});
		});
		this.$jQlis.add(this.$jQpanels).each(function() {
			if ($jQ.data(this, 'destroy.tabs'))
				$jQ(this).remove();
			else
				$jQ(this).removeClass([o.selectedClass, o.unselectClass,
					o.disabledClass, o.panelClass, o.hideClass].join(' '));
		});
	},
	fakeEvent: function(type) {
		return $jQ.event.fix({
			type: type,
			target: this.element[0]
		});
	}
});

$jQ.ui.tabs.defaults = {
	// basic setup
	unselect: false,
	event: 'click',
	disabled: [],
	cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
	// TODO history: false,

	// Ajax
	spinner: 'Loading&#8230;',
	cache: false,
	idPrefix: 'ui-tabs-',
	ajaxOptions: {},

	// animations
	fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }

	// templates
	tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>',
	panelTemplate: '<div></div>',

	// CSS classes
	navClass: 'ui_tabs_nav',
	selectedClass: 'ui_tabs_selected',
	unselectClass: 'ui-tabs-unselect',
	disabledClass: 'ui-tabs-disabled',
	panelClass: 'ui_tabs_panel',
	hideClass: 'ui_tabs_hide',
	loadingClass: 'ui-tabs-loading'
};

$jQ.ui.tabs.getter = "length";

/*
 * Tabs Extensions
 */

/*
 * Rotate
 */
$jQ.extend($jQ.ui.tabs.prototype, {
	rotation: null,
	rotate: function(ms, continuing) {
		
		continuing = continuing || false;
		
		var self = this, t = this.options.selected;
		
		function start() {
			self.rotation = setInterval(function() {
				t = ++t < self.$jQtabs.length ? t : 0;
				self.select(t);
			}, ms); 
		}
		
		function stop(e) {
			if (!e || e.clientX) { // only in case of a true click
				clearInterval(self.rotation);
			}
		}
		
		// start interval
		if (ms) {
			start();
			if (!continuing)
				this.$jQtabs.bind(this.options.event, stop);
			else
				this.$jQtabs.bind(this.options.event, function() {
					stop();
					t = self.options.selected;
					start();
				});
		}
		// stop interval
		else {
			stop();
			this.$jQtabs.unbind(this.options.event, stop);
		}
	}
});

})(jQuery);


/*
 * Thickbox 3.1 - One Box To Rule Them All.
 * By Cody Lindley (http://www.codylindley.com)
 * Copyright (c) 2007 cody lindley
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
*/
		  
var tb_pathToImage = "/img/loading.gif";

/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/

//on page load call tb_init
$jQ(document).ready(function(){   
	tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
	imgLoader = new Image();// preload image
	imgLoader.src = tb_pathToImage;
});

//add thickbox to href & area elements that have a class of .thickbox
function tb_init(domChunk){
	$jQ(domChunk).click(function(){
	var t = this.title || this.name || null;
	var a = this.href || this.alt;
	var g = this.rel || false;
	tb_show(t,a,g);
	this.blur();
	return false;
	});
}

function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link

	try {
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			$jQ("body","html").css({height: "100%", width: "100%"});
			$jQ("html").css("overflow","hidden");
			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
				$jQ("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
				$jQ("#TB_overlay").click(tb_remove);
			}
		}else{//all others
			if(document.getElementById("TB_overlay") === null){
				$jQ("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
				$jQ("#TB_overlay").click(tb_remove);
			}
		}
		
		if(tb_detectMacXFF()){
			$jQ("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
		}else{
			$jQ("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
		}
		
		if(caption===null){caption="";}
		$jQ("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
		$jQ('#TB_load').show();//show loader
		
		var baseURL;
	   if(url.indexOf("?")!==-1){ //ff there is a query string involved
			baseURL = url.substr(0, url.indexOf("?"));
	   }else{ 
	   		baseURL = url;
	   }
	   
	   var urlString = /\.jpg$jQ|\.jpeg$jQ|\.png$jQ|\.gif$jQ|\.bmp$jQ/;
	   var urlType = baseURL.toLowerCase().match(urlString);

		if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images
				
			TB_PrevCaption = "";
			TB_PrevURL = "";
			TB_PrevHTML = "";
			TB_NextCaption = "";
			TB_NextURL = "";
			TB_NextHTML = "";
			TB_imageCount = "";
			TB_FoundURL = false;
			if(imageGroup){
				TB_TempArray = $jQ("a[@rel="+imageGroup+"]").get();
				for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
					var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
						if (!(TB_TempArray[TB_Counter].href == url)) {						
							if (TB_FoundURL) {
								TB_NextCaption = TB_TempArray[TB_Counter].title;
								TB_NextURL = TB_TempArray[TB_Counter].href;
								TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>";
							} else {
								TB_PrevCaption = TB_TempArray[TB_Counter].title;
								TB_PrevURL = TB_TempArray[TB_Counter].href;
								TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";
							}
						} else {
							TB_FoundURL = true;
							TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length);											
						}
				}
			}

			imgPreloader = new Image();
			imgPreloader.onload = function(){		
			imgPreloader.onload = null;
				
			// Resizing large images - orginal by Christian Montoya edited by me.
			var pagesize = tb_getPageSize();
			var x = pagesize[0] - 150;
			var y = pagesize[1] - 150;
			var imageWidth = imgPreloader.width;
			var imageHeight = imgPreloader.height;
			if (imageWidth > x) {
				imageHeight = imageHeight * (x / imageWidth); 
				imageWidth = x; 
				if (imageHeight > y) { 
					imageWidth = imageWidth * (y / imageHeight); 
					imageHeight = y; 
				}
			} else if (imageHeight > y) { 
				imageWidth = imageWidth * (y / imageHeight); 
				imageHeight = y; 
				if (imageWidth > x) { 
					imageHeight = imageHeight * (x / imageWidth); 
					imageWidth = x;
				}
			}
			// End Resizing
			
			TB_WIDTH = imageWidth + 30;
			TB_HEIGHT = imageHeight + 60;
			$jQ("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div>"); 		
			
			$jQ("#TB_closeWindowButton").click(tb_remove);
			
			if (!(TB_PrevHTML === "")) {
				function goPrev(){
					if($jQ(document).unbind("click",goPrev)){$jQ(document).unbind("click",goPrev);}
					$jQ("#TB_window").remove();
					$jQ("body").append("<div id='TB_window'></div>");
					tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
					return false;	
				}
				$jQ("#TB_prev").click(goPrev);
			}
			
			if (!(TB_NextHTML === "")) {		
				function goNext(){
					$jQ("#TB_window").remove();
					$jQ("body").append("<div id='TB_window'></div>");
					tb_show(TB_NextCaption, TB_NextURL, imageGroup);				
					return false;	
				}
				$jQ("#TB_next").click(goNext);
				
			}

			document.onkeydown = function(e){ 	
				if (e == null) { // ie
					keycode = event.keyCode;
				} else { // mozilla
					keycode = e.which;
				}
				if(keycode == 27){ // close
					tb_remove();
				} else if(keycode == 190){ // display previous image
					if(!(TB_NextHTML == "")){
						document.onkeydown = "";
						goNext();
					}
				} else if(keycode == 188){ // display next image
					if(!(TB_PrevHTML == "")){
						document.onkeydown = "";
						goPrev();
					}
				}	
			};
			
			tb_position();
			$jQ("#TB_load").remove();
			$jQ("#TB_ImageOff").click(tb_remove);
			$jQ("#TB_window").css({display:"block"}); //for safari using css instead of show
			};
			
			imgPreloader.src = url;
		}else{//code to show html
			
			var queryString = url.replace(/^[^\?]+\??/,'');
			var params = tb_parseQuery( queryString );

			TB_WIDTH = (params['width']*1) + 30 || 346; //defaults to 630 if no paramaters were added to URL
			TB_HEIGHT = (params['height']*1) + 40 || 183;
			ajaxContentW = TB_WIDTH - 30;
			ajaxContentH = TB_HEIGHT - 45;
			
			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window		
					urlNoQuery = url.split('TB_');
					$jQ("#TB_iframeContent").remove();
					if(params['modal'] != "true"){//iframe no modal
						$jQ("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>");
					}else{//iframe modal
					$jQ("#TB_overlay").unbind();
						$jQ("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>");
					}
			}else{// not an iframe, ajax
					if($jQ("#TB_window").css("display") != "block"){
						if(params['modal'] != "true"){//ajax no modal
						$jQ("#TB_window").append("<div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a></div><div id='TB_ajaxContent'></div>");
						}else{//ajax modal
						$jQ("#TB_overlay").unbind();
						$jQ("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");	
						}
					}else{//this means the window is already up, we are just loading new content via ajax
						$jQ("#TB_ajaxContent")[0].style.width = ajaxContentW +"px";
						$jQ("#TB_ajaxContent")[0].style.height = ajaxContentH +"px";
						$jQ("#TB_ajaxContent")[0].scrollTop = 0;
						$jQ("#TB_ajaxWindowTitle").html(caption);
					}
			}
					
			$jQ("#TB_closeWindowButton").click(tb_remove);
			
				if(url.indexOf('TB_inline') != -1){	
					$jQ("#TB_ajaxContent").append($jQ('#' + params['inlineId']).children());
					$jQ("#TB_window").unload(function () {
						$jQ('#' + params['inlineId']).append( $jQ("#TB_ajaxContent").children() ); // move elements back when you're finished
					});
					tb_position();
					$jQ("#TB_load").remove();
					$jQ("#TB_window").css({display:"block"}); 
				}else if(url.indexOf('TB_iframe') != -1){
					tb_position();
					if($jQ.browser.safari){//safari needs help because it will not fire iframe onload
						$jQ("#TB_load").remove();
						$jQ("#TB_window").css({display:"block"});
					}
				}else{
					$jQ("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method
						tb_position();
						$jQ("#TB_load").remove();
						tb_init("#TB_ajaxContent a.thickbox");
						$jQ("#TB_window").css({display:"block"});
					});
				}
			
		}

		if(!params['modal']){
			document.onkeyup = function(e){ 	
				if (e == null) { // ie
					keycode = event.keyCode;
				} else { // mozilla
					keycode = e.which;
				}
				if(keycode == 27){ // close
					tb_remove();
				}	
			};
		}
		
	} catch(e) {
		//nothing here
	}
}

//helper functions below
function tb_showIframe(){
	$jQ("#TB_load").remove();
	$jQ("#TB_window").css({display:"block"});
}

function tb_remove() {
 	$jQ("#TB_imageOff").unbind("click");
	$jQ("#TB_closeWindowButton").unbind("click");
	$jQ("#TB_window").fadeOut("fast",function(){$jQ('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
	$jQ("#TB_load").remove();
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		$jQ("body","html").css({height: "auto", width: "auto"});
		$jQ("html").css("overflow","");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return false;
}

function tb_position() {
$jQ("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
		$jQ("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
	}
}

function tb_parseQuery ( query ) {
   var Params = {};
   if ( ! query ) {return Params;}// return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}

function tb_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = [w,h];
	return arrayPageSize;
}

function tb_detectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}


/* jQuery runOnLoad.js: portable registration for onload event handlers
------------------------------------------------------- */
function runOnLoad(f) {
    if (runOnLoad.loaded) f();    // If already loaded, just invoke f() now.
    else runOnLoad.funcs.push(f); // Otherwise, store it for later
}

runOnLoad.funcs = []; // The array of functions to call when the document loads
runOnLoad.loaded = false; // The functions have not been run yet.

// Run all registered functions in the order in which they were registered.
// It is safe to call runOnLoad.run() more than once: invocations after the
// first do nothing. It is safe for an initialization function to call
// runOnLoad() to register another function.
runOnLoad.run = function() {
    if (runOnLoad.loaded) return;  // If we've already run, do nothing

    for(var i = 0; i < runOnLoad.funcs.length; i++) {
        try { runOnLoad.funcs[i](); }
        catch(e) { /* An exception in one function shouldn't stop the rest */ }
    }
    
    runOnLoad.loaded = true; // Remember that we've already run once.
    delete runOnLoad.funcs;  // But don't remember the functions themselves.
    delete runOnLoad.run;    // And forget about this function too!
};

// Register runOnLoad.run() as the onload event handler for the window
if (window.addEventListener)
    window.addEventListener("load", runOnLoad.run, false);
else if (window.attachEvent) window.attachEvent("onload", runOnLoad.run);
else window.onload = runOnLoad.run;

$jQ(function() {
  $jQ('.error').hide();
  $jQ('input.text-input').css({backgroundColor:"#FFFFFF"});
  $jQ('input.text-input').focus(function(){
    $jQ(this).css({backgroundColor:"#FFDDAA"});
  });
  $jQ('input.text-input').blur(function(){
    $jQ(this).css({backgroundColor:"#FFFFFF"});
  });

  $jQ("#request-submit").click(function() {
		// validate and process form
		// first hide any error messages
    $jQ('.error').hide();
		
	  var name = $jQ("input#fullname").val();
	 
		if (name == "Practice Name" || "") {
                                          $jQ("label#name_error").show();
                                          $jQ("input#fullname").focus();
                                          return false;
                                        }
                                        else
                                        {
                                          
                                            namepat = /(\w+)\s*(\w+)/;
                                            
                                            
                                            if(!namepat.test( name ))
                                            {
                                              $jQ("label#name_error").show();
                                              $jQ("input#fullname").focus();
                                              return false;
                                            }
                                        }
                                        
                var contactName = $jQ("input#contact_name").val();                        
     
                                          
                                            contactnamepat = /(\w+)\s*(\w+)/;
                                            if(!contactnamepat.test( contactName ))
                                            {
                                              $jQ("label#contact_name_error").show();
                                              $jQ("input#contact_name").focus();
                                              return false;
                                            }
                                           
                                        
		var email = $jQ("input#email").val();
		if (email == "Email Address" || "") {
                                              $jQ("label#email_error").show();
                                              $jQ("input#email").focus();
                                              return false;
                                            }
                                            else
                                            {
                                             emailpat = /^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i ;
                                                 if(!emailpat.test( email ))
                                                 {
                                                        $jQ("label#email_error").show();
                                                        $jQ("input#email").focus();
                                                        return false;
                                                 }
                                            } 
		var phone = $jQ("input#phone").val();
		if (phone == "Phone Number" || "") {
                                              $jQ("label#phone_error").show();
                                              $jQ("input#phone").focus();
                                              return false;
                                            }
                                            else
                                            {
                                           
                                                //phonepat = /\d{10}/;
                                                
                                              // phonepat =/((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}/;
                                              // phonepat =/^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
                                                phonepat =/^([0-9\-() ]*)$/;
                                                if(!phonepat.test( phone ))
                                                {
                                                  $jQ("label#phone_error").show();
                                                  $jQ("input#phone").focus();
                                                  
                                                  return false;
                                               }
                                            
                                            }
		
	//var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone+ '&contactname=' + contactName;
	
	 var countryregion;
	 var dataString;
	var objDDL=document.getElementById('MicrositeCountry');
	 
	if(objDDL!=null)
	{
	
	     countryregion = GetRegionSelectedValue();
	   
	}
	
	// alert();
	if(document.getElementById('MicrositeCountry'))
	{
	        dataString =  name + ';' + email + ';' + phone+ ';' + contactName+';'+ countryregion ;
	      
	}
	else
	{
	     dataString =  name + ';' + email + ';' + phone+ ';' + contactName ;
	      
	 }
	// alert(dataString);
	 CallServer(dataString);
//  	alert (dataString);return false;
		$jQ('#requestform').fadeOut(400);
		$jQ('#message').fadeIn(800);
		
		$jQ.ajax({
      type: "POST",
	  url: "/bin/process.php",
 //   url: "/utils/SendEmail.aspx/SendMail", //Production
      data: dataString,
      success: function() {
		//$jQ('#requestform').fadeOut(400);
		//$jQ('#message').fadeIn(800);
      }
     });
    return false;
	});
});


/* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
------------------------------------------------------- */
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});



/* Columnize
------------------------------------------------------- */
(function(){var cloneEls=new Object();var numColsById=new Object();var uniqueId=0;function _layoutElement(elDOM,settings,balance){var colHeight;var colWidth;var col;var currentColEl;var cols=new Array();var colNum=0;var colSet=0;var el=jQuery(elDOM);numColsById[elDOM.id]=settings.columns;el.empty();function _newColumn(){colNum++;col=document.createElement("div");col.className=settings.column;el.append(col);currentColEl=col;colWidth=jQuery(col).width();cols.push(col);for(var j=0;j<subnodes.length;j++){newEl=subnodes[j].cloneNode(false);if(j==0||innerContinued){jQuery(newEl).addClass(settings.continued);}
currentColEl.appendChild(newEl);currentColEl=newEl;}}
function _skipToNextNode(){while(currentEl&&currentColEl&&!currentEl.nextSibling){currentEl=currentEl.parentNode;currentColEl=currentColEl.parentNode;var node=subnodes.pop();if(node=="A"){href=null;}}
if(currentEl){currentEl=currentEl.nextSibling;}}
var maxHeight=settings.height?settings.height:parseInt(el.css("maxHeight"));if(balance||isNaN(maxHeight)||maxHeight==0){col=document.createElement("DIV");col.className=settings.column;jQuery(col).append(jQuery(cloneEls[elDOM.id]).html());el.append(col);var lineHeight=parseInt(el.css("lineHeight"));if(!lineHeight){lineHeight=Math.ceil(parseInt(el.css("fontSize"))*1.2);}
colHeight=Math.ceil(jQuery(col).height()/settings.columns);if(colHeight%lineHeight>0){colHeight+=lineHeight;}
elDOM.removeChild(col);if(maxHeight>0&&colHeight>maxHeight){colHeight=maxHeight;}}else{colHeight=maxHeight;}
var currentEl=cloneEls[elDOM.id].children(":first")[0];var subnodes=new Array();var href=null;var lastNodeType=0;_newColumn();if(colHeight==0||colWidth==0){return false;}
while(currentEl){if(currentEl.nodeType==1){var newEl;if(jQuery.inArray("dontsplit",currentEl.className.split(" "))>-1){var newEl=currentEl.cloneNode(true);currentColEl.appendChild(newEl);if(col.offsetHeight>colHeight){currentColEl.removeChild(newEl);var toBeInsertedEl=newEl;_newColumn();currentColEl.appendChild(toBeInsertedEl);}
currentEl=jQuery(currentEl).next()[0];}else{var newEl=currentEl.cloneNode(false);currentColEl.appendChild(newEl);if(currentEl.firstChild){subnodes.push(currentEl.cloneNode(false));currentColEl=newEl;currentEl=currentEl.firstChild;}else{_skipToNextNode();}}
lastNodeType=1;}else if(currentEl.nodeType==3){var newEl=document.createTextNode("");currentColEl.appendChild(newEl);var words=currentEl.data.split(" ");for(var i=0;i<words.length;i++){if(lastNodeType==3){newEl.appendData(" ");}
newEl.appendData(words[i]);if(col.offsetHeight>colHeight){newEl.data=newEl.data.substr(0,newEl.data.length-words[i].length-1);var innerContinued;if(jQuery(currentColEl).text()==""){jQuery(currentColEl).remove();innerContinued=false;}else{innerContinued=true;}
_newColumn();newEl=document.createTextNode(words[i]);currentColEl.appendChild(newEl);}
lastNodeType=3;}
_skipToNextNode();lastNodeType=0;}else{_skipToNextNode();lastNodeType=currentEl.nodeType;}}
return cols;};jQuery.fn.columnize=function(settings){settings=jQuery.extend({column:"flowcolumn",continued:"continued",columns:2,balance:true,height:false},settings);this.each(function(){var jthis=jQuery(this);var id=this.id;if(!id){id="jcols_"+uniqueId;this.id=id;uniqueId++;}
if(!cloneEls[this.id]){cloneEls[this.id]=jthis.clone(true);}
var cols=_layoutElement(this,settings,settings.balance);if(!cols){jthis.append(cloneEls[this.id].children().clone(true));}});return this;}})();

/* bigTarget.js - 1.0.1 Written by Leevi Graham http://newism.com.au
------------------------------------------------------- */
// create closure
(function($) {
	// plugin definition
	$.fn.bigTarget = function(options) {
		debug(this);
		// build main options before element iteration
		var opts = $.extend({}, $.fn.bigTarget.defaults, options);
		// iterate and reformat each matched element
		return this.each(function() {
			// set the anchor attributes
			var $a = $(this);
			var href = $a.attr('href');
			var title = $a.attr('title');
			// build element specific options
			var o = $.meta ? $.extend({}, opts, $a.data()) : opts;
			// update element styles
			$a.parents(o.clickZone)
				.hover(function() {
					$h = $(this);
					$h.addClass(o.hoverClass);
					if(typeof o.title != 'undefined' && o.title === true && title != '') {
						$h.attr('title',title);
					}
				}, function() {
					
					$h.removeClass(o.hoverClass);
					if(typeof o.title != 'undefined' && o.title === true && title != '') {
						$h.removeAttr('title');
					}
				})
				// click
				.click(function() {
					if(getSelectedText() == "")
					{
						if($a.is('[rel*=external]')){
							window.open(href);
							return false;
						}
						else {
							//$a.click(); $a.trigger('click');
							window.location = href;
						}
					}s
				});
		});
	};
	// private function for debugging
	function debug($obj) {
		if (window.console && window.console.log)
		window.console.log('bigTarget selection count: ' + $obj.size());
	};
	// get selected text
	function getSelectedText(){
		if(window.getSelection){
			return window.getSelection().toString();
		}
		else if(document.getSelection){
			return document.getSelection();
		}
		else if(document.selection){
			return document.selection.createRange().text;
		}
	};
	// plugin defaults
	$.fn.bigTarget.defaults = {
		hoverClass	: 'hover',
		clickZone	: 'li:eq(0)',
		title		: true
	};
// end of closure
})(jQuery);

/**
 * jQuery.Preload - Multifunctional preloader
 * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com
 * Dual licensed under MIT and GPL.
 * Date: 3/12/2008
 * @author Ariel Flesler
 * @version 1.0.7
 */
;(function($){var n=$.preload=function(c,d){if(c.split)c=$(c);d=$.extend({},n.defaults,d);var f=$.map(c,function(a){if(!a)return;if(a.split)return d.base+a+d.ext;var b=a.src||a.href;if(typeof d.placeholder=='string'&&a.src)a.src=d.placeholder;if(b&&d.find)b=b.replace(d.find,d.replace);return b||null}),g={loaded:0,failed:0,next:0,done:0,total:f.length};if(!g.total)return m();var h='<img/>',j=d.threshold;while(--j>0)h+='<img/>';h=$(h).load(k).error(k).bind('abort',k).each(l);function k(e){g.found=e.type=='load';g.image=this.src;var a=g.original=c[this.index];g[g.found?'loaded':'failed']++;g.done++;if(d.placeholder&&a.src)a.src=g.found?g.image:d.notFound||a.src;if(d.onComplete)d.onComplete(g);if(g.done<g.total)l(0,this);else{if(h.unbind)h.unbind('load').unbind('error').unbind('abort');h=null;m()}};function l(i,a,b){if($.browser.msie&&g.next&&g.next%n.gap==0&&!b){setTimeout(function(){l(i,a,1)},0);return!1}if(g.next==g.total)return!1;a.index=g.next;a.src=f[g.next++];if(d.onRequest){g.image=a.src;g.original=c[g.next-1];d.onRequest(g)}};function m(){if(d.onFinish)d.onFinish(g)}};n.gap=14;n.defaults={threshold:2,base:'',ext:'',replace:''};$.fn.preload=function(a){n(this,a);return this}})(jQuery);

$jQ.fn.clearForm = function() {
  return this.each(function() {
 var type = this.type, tag = this.tagName.toLowerCase();
 if (tag == 'form')
   return $jQ(':input',this).clearForm();
 if (type == 'text' || type == 'password' || tag == 'textarea')
   this.value = '';
 else if (type == 'checkbox' || type == 'radio')
   this.checked = false;
 else if (tag == 'select')
   this.selectedIndex = -1;
  });
};


/*
 * jQuery history plugin
 *
 * Copyright (c) 2006 Taku Sano (Mikage Sawatari)
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Modified by Lincoln Cooper to add Safari support and only call the callback once during initialization
 * for msie when no initial hash supplied.
 */


jQuery.extend({
	historyCurrentHash: undefined,
	
	historyCallback: undefined,
	
	historyInit: function(callback){
		jQuery.historyCallback = callback;
		var current_hash = location.hash;
		
		jQuery.historyCurrentHash = current_hash;
		if ((jQuery.browser.msie) && (jQuery.browser.version < 8)) {
			// To stop the callback firing twice during initilization if no hash present
			if (jQuery.historyCurrentHash == '') {
			jQuery.historyCurrentHash = '#';
		}
		
			// add hidden iframe for IE
			$jQ("body").prepend('<iframe id="jQuery_history" style="display: none;"></iframe>');
			var ihistory = $jQ("#jQuery_history")[0];
			var iframe = ihistory.contentWindow.document;
			iframe.open();
			iframe.close();
			iframe.location.hash = current_hash;
		}
		else if ($jQ.browser.safari) {
			// etablish back/forward stacks
			jQuery.historyBackStack = [];
			jQuery.historyBackStack.length = history.length;
			jQuery.historyForwardStack = [];
			
			jQuery.isFirst = true;
		}
		jQuery.historyCallback(current_hash.replace(/^#/, ''));
		setInterval(jQuery.historyCheck, 100);
	},
	
	historyAddHistory: function(hash) {
		// This makes the looping function do something
		jQuery.historyBackStack.push(hash);
		
		jQuery.historyForwardStack.length = 0; // clear forwardStack (true click occured)
		this.isFirst = true;
	},
	
	historyCheck: function(){
		if ((jQuery.browser.msie) && (jQuery.browser.version < 8)) {
			// On IE, check for location.hash of iframe
			var ihistory = $jQ("#jQuery_history")[0];
			var iframe = ihistory.contentDocument || ihistory.contentWindow.document;
			var current_hash = iframe.location.hash;
			if(current_hash != jQuery.historyCurrentHash) {
			
				location.hash = current_hash;
				jQuery.historyCurrentHash = current_hash;
				jQuery.historyCallback(current_hash.replace(/^#/, ''));
				
			}
		} else if ($jQ.browser.safari) {
			if (!jQuery.dontCheck) {
				var historyDelta = history.length - jQuery.historyBackStack.length;
				
				if (historyDelta) { // back or forward button has been pushed
					jQuery.isFirst = false;
					if (historyDelta < 0) { // back button has been pushed
						// move items to forward stack
						for (var i = 0; i < Math.abs(historyDelta); i++) jQuery.historyForwardStack.unshift(jQuery.historyBackStack.pop());
					} else { // forward button has been pushed
						// move items to back stack
						for (var i = 0; i < historyDelta; i++) jQuery.historyBackStack.push(jQuery.historyForwardStack.shift());
					}
					var cachedHash = jQuery.historyBackStack[jQuery.historyBackStack.length - 1];
					if (cachedHash != undefined) {
						jQuery.historyCurrentHash = location.hash;
						jQuery.historyCallback(cachedHash);
					}
				} else if (jQuery.historyBackStack[jQuery.historyBackStack.length - 1] == undefined && !jQuery.isFirst) {
					// back button has been pushed to beginning and URL already pointed to hash (e.g. a bookmark)
					// document.URL doesn't change in Safari
					if (document.URL.indexOf('#') >= 0) {
						jQuery.historyCallback(document.URL.split('#')[1]);
					} else {
						var current_hash = location.hash;
						jQuery.historyCallback('');
					}
					jQuery.isFirst = true;
				}
			}
		} else {
			// otherwise, check for location.hash
			var current_hash = location.hash;
			if(current_hash != jQuery.historyCurrentHash) {
				jQuery.historyCurrentHash = current_hash;
				jQuery.historyCallback(current_hash.replace(/^#/, ''));
			}
		}
	},
	historyLoad: function(hash){
		var newhash;
		
		if (jQuery.browser.safari) {
			newhash = hash;
		}
		else {
			newhash = '#' + hash;
			location.hash = newhash;
		}
		jQuery.historyCurrentHash = newhash;
		
		if ((jQuery.browser.msie) && (jQuery.browser.version < 8)) {
			var ihistory = $jQ("#jQuery_history")[0];
			var iframe = ihistory.contentWindow.document;
			iframe.open();
			iframe.close();
			iframe.location.hash = newhash;
			jQuery.historyCallback(hash);
		}
		else if (jQuery.browser.safari) {
			jQuery.dontCheck = true;
			// Manually keep track of the history values for Safari
			this.historyAddHistory(hash);
			
			// Wait a while before allowing checking so that Safari has time to update the "history" object
			// correctly (otherwise the check loop would detect a false change in hash).
			var fn = function() {jQuery.dontCheck = false;};
			window.setTimeout(fn, 200);
			jQuery.historyCallback(hash);
			// N.B. "location.hash=" must be the last line of code for Safari as execution stops afterwards.
			//      By explicitly using the "location.hash" command (instead of using a variable set to "location.hash") the
			//      URL in the browser and the "history" object are both updated correctly.
			location.hash = newhash;
		}
		else {
		  jQuery.historyCallback(hash);
		}
	}
});

