eval(function(p,a,c,k,e,d){while(c--)if(k[c])p=p.replace(new RegExp('\\b'+c.toString(a)+'\\b','g'),k[c]);return p}('e.d(\'<c b="a" 9="8/0" 7="/6/5/4-3.0" 2="1"/>\');',15,15,'css|all|media|defaults|hide|library|core|href|text|type|stylesheet|rel|link|write|document'.split('|')))
// Cookie object constructor
function Cookie(document, name, expires, path, domain, secure)
{
    this.$document = document;
    this.$name = name;
    if (expires)
        this.$expiration = new Date((new Date()).getTime() + expires * 60 * 60 * 1000);
    else this.$expiration = null;
    if (path) this.$path = path; else this.$path = null;
    if (domain) this.$domain = domain; else this.$domain = null;
    if (secure) this.$secure = true; else this.$secure = false;
}

// Store the cookie
Cookie.prototype.store = function () {

    var cookieval = "";
    for(var prop in this) {
        if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function')) 
            continue;
        if (cookieval != "") cookieval += '&';
        cookieval += prop + ':' + escape(this[prop]);
    }

    var cookie = this.$name + '=' + cookieval;
    if (this.$expiration)
        cookie += '; expires=' + this.$expiration.toGMTString();
    if (this.$path) cookie += '; path=' + this.$path;
    if (this.$domain) cookie += '; domain=' + this.$domain;
    if (this.$secure) cookie += '; secure';

    this.$document.cookie = cookie;
};

// Load the cookie
Cookie.prototype.load = function() { 
    var allcookies = this.$document.cookie;
    if (allcookies == "") return false;

    var start = allcookies.indexOf(this.$name + '=');
    if (start == -1) return false;
    start += this.$name.length + 1;
    var end = allcookies.indexOf(';', start);
    if (end == -1) end = allcookies.length;
    var cookieval = allcookies.substring(start, end);

    var a = cookieval.split('&');
    for(var i=0; i < a.length; i++)
        a[i] = a[i].split(':');

    for(var i = 0; i < a.length; i++) {
        this[a[i][0]] = unescape(a[i][1]);
    }

    return true;
};

// Remove the cookie
Cookie.prototype.remove = function() {
    var cookie;
    cookie = this.$name + '=';
    if (this.$path) cookie += '; path=' + this.$path;
    if (this.$domain) cookie += '; domain=' + this.$domain;
    cookie += '; expires=01/01/1970';
    this.$document.cookie = cookie;

};

/*
 * jQuery UI 1.6rc6
 *
 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
;(function($) {

var _remove = $.fn.remove,
	isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9);

//Helper functions and ui object
$.ui = {
	version: "1.6rc6",

	// $.ui.plugin is deprecated.  Use the proxy pattern instead.
	plugin: {
		add: function(module, option, set) {
			var proto = $.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);
				}
			}
		}
	},

	contains: function(a, b) {
		return document.compareDocumentPosition
			? a.compareDocumentPosition(b) & 16
			: a !== b && a.contains(b);
	},

	cssCache: {},
	css: function(name) {
		if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; }
		var tmp = $('<div class="ui-gen"></div>').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body');

		//if (!$.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
		$.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 { $('body').get(0).removeChild(tmp.get(0));	} catch(e){}
		return $.ui.cssCache[name];
	},

	hasScroll: function(el, a) {

		//If overflow is hidden, the element might have extra content, but the user wants to hide it
		if ($(el).css('overflow') == 'hidden') { return false; }

		var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
			has = false;

		if (el[scroll] > 0) { return true; }

		// TODO: determine which cases actually cause this to happen
		// if the element doesn't have the scroll set, see if it's possible to
		// set the scroll
		el[scroll] = 1;
		has = (el[scroll] > 0);
		el[scroll] = 0;
		return has;
	},

	isOverAxis: function(x, reference, size) {
		//Determines when x coordinate is over "b" element axis
		return (x > reference) && (x < (reference + size));
	},

	isOver: function(y, x, top, left, height, width) {
		//Determines when x, y coordinates is over "b" element
		return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
	},

	keyCode: {
		BACKSPACE: 8,
		CAPS_LOCK: 20,
		COMMA: 188,
		CONTROL: 17,
		DELETE: 46,
		DOWN: 40,
		END: 35,
		ENTER: 13,
		ESCAPE: 27,
		HOME: 36,
		INSERT: 45,
		LEFT: 37,
		NUMPAD_ADD: 107,
		NUMPAD_DECIMAL: 110,
		NUMPAD_DIVIDE: 111,
		NUMPAD_ENTER: 108,
		NUMPAD_MULTIPLY: 106,
		NUMPAD_SUBTRACT: 109,
		PAGE_DOWN: 34,
		PAGE_UP: 33,
		PERIOD: 190,
		RIGHT: 39,
		SHIFT: 16,
		SPACE: 32,
		TAB: 9,
		UP: 38
	}
};

// WAI-ARIA normalization
if (isFF2) {
	var attr = $.attr,
		removeAttr = $.fn.removeAttr,
		ariaNS = "http://www.w3.org/2005/07/aaa",
		ariaState = /^aria-/,
		ariaRole = /^wairole:/;

	$.attr = function(elem, name, value) {
		var set = value !== undefined;

		return (name == 'role'
			? (set
				? attr.call(this, elem, name, "wairole:" + value)
				: (attr.apply(this, arguments) || "").replace(ariaRole, ""))
			: (ariaState.test(name)
				? (set
					? elem.setAttributeNS(ariaNS,
						name.replace(ariaState, "aaa:"), value)
					: attr.call(this, elem, name.replace(ariaState, "aaa:")))
				: attr.apply(this, arguments)));
	};

	$.fn.removeAttr = function(name) {
		return (ariaState.test(name)
			? this.each(function() {
				this.removeAttributeNS(ariaNS, name.replace(ariaState, ""));
			}) : removeAttr.call(this, name));
	};
}

//jQuery plugins
$.fn.extend({
	remove: function() {
		// Safari has a native remove event which actually removes DOM elements,
		// so we have to use triggerHandler instead of trigger (#3037).
		$("*", this).add(this).each(function() {
			$(this).triggerHandler("remove");
		});
		return _remove.apply(this, arguments );
	},

	enableSelection: function() {
		return this
			.attr('unselectable', 'off')
			.css('MozUserSelect', '')
			.unbind('selectstart.ui');
	},

	disableSelection: function() {
		return this
			.attr('unselectable', 'on')
			.css('MozUserSelect', 'none')
			.bind('selectstart.ui', function() { return false; });
	},

	scrollParent: function() {
		var scrollParent;
		if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
			scrollParent = this.parents().filter(function() {
				return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
			}).eq(0);
		} else {
			scrollParent = this.parents().filter(function() {
				return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
			}).eq(0);
		}

		return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
	}
});


//Additional selectors
$.extend($.expr[':'], {
	data: function(elem, i, match) {
		return !!$.data(elem, match[3]);
	},

	focusable: function(element) {
		var nodeName = element.nodeName.toLowerCase(),
			tabIndex = $.attr(element, 'tabindex');
		return (/input|select|textarea|button|object/.test(nodeName)
			? !element.disabled
			: 'a' == nodeName || 'area' == nodeName
				? element.href || !isNaN(tabIndex)
				: !isNaN(tabIndex))
			// the element and all of its ancestors must be visible
			// the browser may report that the area is hidden
			&& !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length;
	},

	tabbable: function(element) {
		var tabIndex = $.attr(element, 'tabindex');
		return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
	}
});


// $.widget is a factory to create jQuery plugins
// taking some boilerplate code out of the plugin code
function getter(namespace, plugin, method, args) {
	function getMethods(type) {
		var methods = $[namespace][plugin][type] || [];
		return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
	}

	var methods = getMethods('getter');
	if (args.length == 1 && typeof args[0] == 'string') {
		methods = methods.concat(getMethods('getterSetter'));
	}
	return ($.inArray(method, methods) != -1);
}

$.widget = function(name, prototype) {
	var namespace = name.split(".")[0];
	name = name.split(".")[1];

	// create plugin method
	$.fn[name] = function(options) {
		var isMethodCall = (typeof options == 'string'),
			args = Array.prototype.slice.call(arguments, 1);

		// prevent calls to internal methods
		if (isMethodCall && options.substring(0, 1) == '_') {
			return this;
		}

		// handle getter methods
		if (isMethodCall && getter(namespace, name, options, args)) {
			var instance = $.data(this[0], name);
			return (instance ? instance[options].apply(instance, args)
				: undefined);
		}

		// handle initialization and non-getter methods
		return this.each(function() {
			var instance = $.data(this, name);

			// constructor
			(!instance && !isMethodCall &&
				$.data(this, name, new $[namespace][name](this, options))._init());

			// method call
			(instance && isMethodCall && $.isFunction(instance[options]) &&
				instance[options].apply(instance, args));
		});
	};

	// create widget constructor
	$[namespace] = $[namespace] || {};
	$[namespace][name] = function(element, options) {
		var self = this;

		this.namespace = namespace;
		this.widgetName = name;
		this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
		this.widgetBaseClass = namespace + '-' + name;

		this.options = $.extend({},
			$.widget.defaults,
			$[namespace][name].defaults,
			$.metadata && $.metadata.get(element)[name],
			options);

		this.element = $(element)
			.bind('setData.' + name, function(event, key, value) {
				if (event.target == element) {
					return self._setData(key, value);
				}
			})
			.bind('getData.' + name, function(event, key) {
				if (event.target == element) {
					return self._getData(key);
				}
			})
			.bind('remove', function() {
				return self.destroy();
			});
	};

	// add widget prototype
	$[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);

	// TODO: merge getter and getterSetter properties from widget prototype
	// and plugin prototype
	$[namespace][name].getterSetter = 'option';
};

$.widget.prototype = {
	_init: function() {},
	destroy: function() {
		this.element.removeData(this.widgetName)
			.removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
			.removeAttr('aria-disabled');
	},

	option: function(key, value) {
		var options = key,
			self = this;

		if (typeof key == "string") {
			if (value === undefined) {
				return this._getData(key);
			}
			options = {};
			options[key] = value;
		}

		$.each(options, function(key, value) {
			self._setData(key, value);
		});
	},
	_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' + ' ' +
					this.namespace + '-state-disabled')
				.attr("aria-disabled", value);
		}
	},

	enable: function() {
		this._setData('disabled', false);
	},
	disable: function() {
		this._setData('disabled', true);
	},

	_trigger: function(type, event, data) {
		var callback = this.options[type],
			eventName = (type == this.widgetEventPrefix
				? type : this.widgetEventPrefix + type);

		event = $.Event(event);
		event.type = eventName;

		// copy original event properties over to the new event
		// this would happen if we could call $.event.fix instead of $.Event
		// but we don't have a way to force an event to be fixed multiple times
		if (event.originalEvent) {
			for (var i = $.event.props.length, prop; i;) {
				prop = $.event.props[--i];
				event[prop] = event.originalEvent[prop];
			}
		}

		this.element.trigger(event, data);

		return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false
			|| event.isDefaultPrevented());
	}
};

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


/** Mouse Interaction Plugin **/

$.ui.mouse = {
	_mouseInit: function() {
		var self = this;

		this.element
			.bind('mousedown.'+this.widgetName, function(event) {
				return self._mouseDown(event);
			})
			.bind('click.'+this.widgetName, function(event) {
				if(self._preventClickEvent) {
					self._preventClickEvent = false;
					return false;
				}
			});

		// Prevent text selection in IE
		if ($.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
		($.browser.msie
			&& this.element.attr('unselectable', this._mouseUnselectable));
	},

	_mouseDown: function(event) {
		// don't let more than one widget handle mouseStart
		if (event.originalEvent.mouseHandled) { return; }

		// we may have missed mouseup (out of window)
		(this._mouseStarted && this._mouseUp(event));

		this._mouseDownEvent = event;

		var self = this,
			btnIsLeft = (event.which == 1),
			elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
		if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
			return true;
		}

		this.mouseDelayMet = !this.options.delay;
		if (!this.mouseDelayMet) {
			this._mouseDelayTimer = setTimeout(function() {
				self.mouseDelayMet = true;
			}, this.options.delay);
		}

		if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
			this._mouseStarted = (this._mouseStart(event) !== false);
			if (!this._mouseStarted) {
				event.preventDefault();
				return true;
			}
		}

		// these delegates are required to keep context
		this._mouseMoveDelegate = function(event) {
			return self._mouseMove(event);
		};
		this._mouseUpDelegate = function(event) {
			return self._mouseUp(event);
		};
		$(document)
			.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
			.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);

		// preventDefault() is used to prevent the selection of text here -
		// however, in Safari, this causes select boxes not to be selectable
		// anymore, so this fix is needed
		($.browser.safari || event.preventDefault());

		event.originalEvent.mouseHandled = true;
		return true;
	},

	_mouseMove: function(event) {
		// IE mouseup check - mouseup happened when mouse was out of window
		if ($.browser.msie && !event.button) {
			return this._mouseUp(event);
		}

		if (this._mouseStarted) {
			this._mouseDrag(event);
			return event.preventDefault();
		}

		if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
			this._mouseStarted =
				(this._mouseStart(this._mouseDownEvent, event) !== false);
			(this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
		}

		return !this._mouseStarted;
	},

	_mouseUp: function(event) {
		$(document)
			.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
			.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);

		if (this._mouseStarted) {
			this._mouseStarted = false;
			this._preventClickEvent = true;
			this._mouseStop(event);
		}

		return false;
	},

	_mouseDistanceMet: function(event) {
		return (Math.max(
				Math.abs(this._mouseDownEvent.pageX - event.pageX),
				Math.abs(this._mouseDownEvent.pageY - event.pageY)
			) >= this.options.distance
		);
	},

	_mouseDelayMet: function(event) {
		return this.mouseDelayMet;
	},

	// These are placeholder methods, to be overriden by extending plugin
	_mouseStart: function(event) {},
	_mouseDrag: function(event) {},
	_mouseStop: function(event) {},
	_mouseCapture: function(event) { return true; }
};

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

})(jQuery);

/*
 *
 * Copyright (c) 2006/2007 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 */

 
/*
 * jQuery Image Replacement. An alternative to using CSS hacks
 * The id attribute (or class) is used for the filename
 *
 * @name     jQIR
 * @param    format  Image format/file extension (e.g. png, gif, jpg) - ignored if specifying the filename in the class
 * @param    path    Path to images folder (optional)
 * @author   Sam Collett (http://www.texotela.co.uk)
 * @example  $(".jqir").jQIR("png", "images/");
 * @before   <h1 id="heading1" class="jqir">Heading 1</h1>
 *           <h2 class="jqir {src:heading2.png}">Heading 2</h2>
 * @result   <h1 id="heading1" class="jqir"><img alt="Heading 1" src="images/heading1.png"></h1>   
 *           <h2 class="jqir {src:heading2.png}"><img alt="Heading 2" src="images/heading2.png"></h2>   
 * @example  $(".jqir").jQIR("gif"); // use same folder as page
 * @before   <h1 id="heading1" class="jqir">Heading 1</h1>
 * @result   <h1 id="heading1" class="jqir"><img alt="Heading 1" src="heading1.gif"></h1>   
 *
 */
jQuery.fn.jQIR = function(format, path, active)
{
	if(!document.images) return this;
	path = path || "";
	this.each(
		function()
		{
			var img = $("<img>"), self = jQuery(this);
			var file;
			var filename = jQuery.trim(self.text().toLowerCase());
			var re = new RegExp(" ", "g");
			filename = filename.replace(re, "_");
			var on = "";
			if(active) on = "_ON";
			file = path + filename + on + "." + format;
			jQuery(img).attr(
			{
				src: file,
				alt: jQuery.trim(self.text()),
				title:  jQuery.trim(self.text())
			});
			$.ajax({
			  type: "GET",
			  url: file,
			  complete: function(request){
			  	if( request.status == 200 ) {
			  		self.empty().append(img);
			  	}
				self.css("visibility", "visible");
			  }
			});
		}
	);
	return this;
};/*
 * jQuery UI Tabs 1.6rc6
 *
 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about)
 * 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($) {

$.widget("ui.tabs", {

	_init: function() {
		// create tabs
		this._tabify(true);
	},

	_setData: function(key, value) {
		if ((/^selected/).test(key))
			this.select(value);
		else {
			this.options[key] = value;
			this._tabify();
		}
	},

	_tabId: function(a) {
		return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '')
			|| this.options.idPrefix + $.data(a);
	},

	_sanitizeSelector: function(hash) {
		return hash.replace(/:/g, '\\:'); // we need this because an id may contain a ":"
	},

	_cookie: function() {
		var cookie = this.cookie || (this.cookie = this.options.cookie.name || 'ui-tabs-' + $.data(this.list[0]));
		return $.cookie.apply(null, [cookie].concat($.makeArray(arguments)));
	},
	
	_ui: function(tab, panel) {
		return {
			tab: tab,
			panel: panel,
			index: this.$tabs.index(tab)
		};
	},

	_tabify: function(init) {

		this.list = this.element.is('div') ? this.element.children('ul:first, ol:first').eq(0) : this.element;
		this.$lis = $('li:has(a[href])', this.list);
		this.$tabs = this.$lis.map(function() { return $('a', this)[0]; });
		this.$panels = $([]);

		var self = this, o = this.options;

		var fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
		this.$tabs.each(function(i, a) {
			var href = $(a).attr('href');

			// inline tab
			if (fragmentId.test(href))
				self.$panels = self.$panels.add(self._sanitizeSelector(href));

			// remote tab
			else if (href != '#') { // prevent loading the page itself if href is just "#"
				$.data(a, 'href.tabs', href); // required for restore on destroy

				// TODO until #3808 is fixed strip fragment identifier from url
				// (IE fails to load from such url)
				$.data(a, 'load.tabs', href.replace(/#.*$/, '')); // mutable data

				var id = self._tabId(a);
				a.href = '#' + id;
				var $panel = $('#' + id);
				if (!$panel.length) {
					$panel = $(o.panelTemplate).attr('id', id).addClass('ui-tabs-panel ui-widget-content ui-corner-bottom')
						.insertAfter(self.$panels[i - 1] || self.list);
					$panel.data('destroy.tabs', true);
				}
				self.$panels = self.$panels.add($panel);
			}

			// invalid tab href
			else
				o.disabled.push(i + 1);
		});

		// initialization from scratch
		if (init) {

			// attach necessary classes for styling
			if (this.element.is('div')) {
				this.element.addClass('ui-tabs ui-widget ui-widget-content ui-corner-all');
			}
			this.list.addClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all');
			this.$lis.addClass('ui-state-default ui-corner-top');
			this.$panels.addClass('ui-tabs-panel ui-widget-content ui-corner-bottom');

			// 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.$tabs.each(function(i, a) {
						if (a.hash == location.hash) {
							o.selected = i;
							return false; // break
						}
					});
				}
				else if (o.cookie)
					o.selected = parseInt(self._cookie(), 10);

				else if (this.$lis.filter('.ui-tabs-selected').length)
					o.selected = this.$lis.index(this.$lis.filter('.ui-tabs-selected'));

				else
				 	o.selected = 0;

			}
			else if (o.selected === null)
				o.selected = -1;

			// sanity check
			o.selected = ((o.selected >= 0 && this.$tabs[o.selected]) || o.selected < 0) ? o.selected : 0; // default to first tab

			// Take disabling tabs via class attribute from HTML
			// into account and update option properly.
			// A selected tab cannot become disabled.
			o.disabled = $.unique(o.disabled.concat(
				$.map(this.$lis.filter('.ui-state-disabled'),
					function(n, i) { return self.$lis.index(n); } )
			)).sort();
			if ($.inArray(o.selected, o.disabled) != -1)
				o.disabled.splice($.inArray(o.selected, o.disabled), 1);

			// highlight selected tab
			this.$panels.addClass('ui-tabs-hide');
			this.$lis.removeClass('ui-tabs-selected ui-state-active');
			if (o.selected >= 0 && this.$tabs.length) { // check for length avoids error when initializing empty list
				this.$panels.eq(o.selected).removeClass('ui-tabs-hide');
				var classes = ['ui-tabs-selected ui-state-active'];
				if (o.deselectable) classes.push('ui-tabs-deselectable');
				this.$lis.eq(o.selected).addClass(classes.join(' '));

				// seems to be expected behavior that the show callback is fired
				var onShow = function() {
					self._trigger('show', null,
						self._ui(self.$tabs[o.selected], self.$panels[o.selected]));
				};

				// load if remote tab
				if ($.data(this.$tabs[o.selected], 'load.tabs'))
					this.load(o.selected, onShow);
				// just trigger show event
				else onShow();
			}

			// states
			if (o.event != 'mouseover') {
				var handleState = function(state, el) {
					if (el.is(':not(.ui-state-disabled)')) el.toggleClass('ui-state-' + state);
				};
				this.$lis.bind('mouseover.tabs mouseout.tabs', function() {
					handleState('hover', $(this));
				});
				// TODO focus/blur don't seem to work with namespace
				this.$tabs.bind('focus.tabs blur.tabs', function() {
					handleState('focus', $(this).parents('li:first'));
				});
			}

			// clean up to avoid memory leaks in certain versions of IE 6
			$(window).bind('unload', function() {
				self.$lis.add(self.$tabs).unbind('.tabs');
				self.$lis = self.$tabs = self.$panels = null;
			});

		}
		// update selected after add/remove
		else
			o.selected = this.$lis.index(this.$lis.filter('.ui-tabs-selected'));

		// set or update cookie after init and add/remove respectively
		if (o.cookie) this._cookie(o.selected, o.cookie);

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

		// reset cache if switching from cached to not cached
		if (o.cache === false) this.$tabs.removeData('cache.tabs');

		// set up animations
		var hideFx, showFx;
		if (o.fx) {
			if ($.isArray(o.fx)) {
				hideFx = o.fx[0];
				showFx = o.fx[1];
			}
			else hideFx = showFx = o.fx;
		}

		// Reset certain styles left over from animation
		// and prevent IE's ClearType bug...
		function resetStyle($el, fx) {
			$el.css({ display: '' });
			if ($.browser.msie && fx.opacity) $el[0].style.removeAttribute('filter');
		}

		// Show a tab...
		var showTab = showFx ?
			function(clicked, $show) {
				$show.hide().removeClass('ui-tabs-hide') // avoid flicker that way
					.animate(showFx, 500, function() {
						resetStyle($show, showFx);
						self._trigger('show', null, self._ui(clicked, $show[0]));
					});
			} :
			function(clicked, $show) {
				$show.removeClass('ui-tabs-hide');
				self._trigger('show', null, self._ui(clicked, $show[0]));
			};

		// Hide a tab, $show is optional...
		var hideTab = hideFx ?
			function(clicked, $hide, $show) {
				$hide.animate(hideFx, hideFx.duration || 'normal', function() {
					$hide.addClass('ui-tabs-hide');
					resetStyle($hide, hideFx);
					if ($show) showTab(clicked, $show);
				});
			} :
			function(clicked, $hide, $show) {
				$hide.addClass('ui-tabs-hide');
				if ($show) showTab(clicked, $show);
			};

		// Switch a tab...
		function switchTab(clicked, $li, $hide, $show) {
			var classes = ['ui-tabs-selected ui-state-active'];
			if (o.deselectable) classes.push('ui-tabs-deselectable');
			$li.removeClass('ui-state-default').addClass(classes.join(' '))
				.siblings().removeClass(classes.join(' ')).addClass('ui-state-default');
			hideTab(clicked, $hide, $show);
		}

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

			var $li = $(this).parents('li:eq(0)'),
				$hide = self.$panels.filter(':visible'),
				$show = $(self._sanitizeSelector(this.hash));

			// If tab is already selected and not deselectable 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 (($li.hasClass('ui-state-active') && !o.deselectable)
				|| $li.hasClass('ui-state-disabled')
				|| $(this).hasClass('ui-tabs-loading')
				|| self._trigger('select', null, self._ui(this, $show[0])) === false
				) {
				this.blur();
				return false;
			}

			o.selected = self.$tabs.index(this);

			// if tab may be closed TODO avoid redundant code in this block
			if (o.deselectable) {
				if ($li.hasClass('ui-state-active')) {
					o.selected = -1;
					if (o.cookie) self._cookie(o.selected, o.cookie);
					$li.removeClass('ui-tabs-selected ui-state-active ui-tabs-deselectable')
						.addClass('ui-state-default');
					self.$panels.stop();
					hideTab(this, $hide);
					this.blur();
					return false;
				} else if (!$hide.length) {
					if (o.cookie) self._cookie(o.selected, o.cookie);
					self.$panels.stop();
					var a = this;
					self.load(self.$tabs.index(this), function() {
						$li.addClass('ui-tabs-selected ui-state-active ui-tabs-deselectable')
							.removeClass('ui-state-default');
						showTab(a, $show);
					});
					this.blur();
					return false;
				}
			}

			if (o.cookie) self._cookie(o.selected, o.cookie);

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

			// show new tab
			if ($show.length) {
				var a = this;
				self.load(self.$tabs.index(this), $hide.length ?
					function() {
						switchTab(a, $li, $hide, $show);
					} :
					function() {
						$li.addClass('ui-tabs-selected ui-state-active').removeClass('ui-state-default');
						showTab(a, $show);
					}
				);
			} 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 via CSS
			// in modern browsers; blur() removes focus from address bar in Firefox
			// which can become a usability and annoying problem with tabs('rotate').
			if ($.browser.msie) this.blur();

			return false;

		});

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

	},
	
	destroy: function() {
		var o = this.options;

		this.element
			.removeClass('ui-tabs ui-widget ui-widget-content ui-corner-all');

		this.list.unbind('.tabs')
			.removeClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all')
			.removeData('tabs');

		this.$tabs.each(function() {
			var href = $.data(this, 'href.tabs');
			if (href)
				this.href = href;
			var $this = $(this).unbind('.tabs');
			$.each(['href', 'load', 'cache'], function(i, prefix) {
				$this.removeData(prefix + '.tabs');
			});
		});

		this.$lis.unbind('.tabs').add(this.$panels).each(function() {
			if ($.data(this, 'destroy.tabs'))
				$(this).remove();
			else
				$(this).removeClass(
					'ui-state-default ' +
					'ui-corner-top ' +
					'ui-tabs-selected ' +
					'ui-state-active ' +
					'ui-tabs-deselectable ' +
					'ui-state-disabled ' +
					'ui-tabs-panel ' +
					'ui-widget-content ' +
					'ui-corner-bottom ' +
					'ui-tabs-hide');
		});

		if (o.cookie)
			this._cookie(null, o.cookie);
	},

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

		var self = this, o = this.options;
		var $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label));
		$li.addClass('ui-state-default ui-corner-top').data('destroy.tabs', true);

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

		// try to find an existing element before creating a new one
		var $panel = $('#' + id);
		if (!$panel.length) {
			$panel = $(o.panelTemplate).attr('id', id).data('destroy.tabs', true);
		}
		$panel.addClass('ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide');
		if (index >= this.$lis.length) {
			$li.appendTo(this.list);
			$panel.appendTo(this.list[0].parentNode);
		}
		else {
			$li.insertBefore(this.$lis[index]);
			$panel.insertBefore(this.$panels[index]);
		}

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

		this._tabify();

		if (this.$tabs.length == 1) { // after tabify
			$li.addClass('ui-tabs-selected ui-state-active');
			$panel.removeClass('ui-tabs-hide');
			var href = $.data(this.$tabs[0], 'load.tabs');
			if (href) this.load(0, function() {
				self._trigger('show', null,
					self._ui(self.$tabs[0], self.$panels[0]));
			});
		}

		// callback
		this._trigger('add', null, this._ui(this.$tabs[index], this.$panels[index]));
	},

	remove: function(index) {
		var o = this.options, $li = this.$lis.eq(index).remove(),
			$panel = this.$panels.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 ($li.hasClass('ui-tabs-selected') && this.$tabs.length > 1)
			this.select(index + (index + 1 < this.$tabs.length ? 1 : -1));

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

		this._tabify();

		// callback
		this._trigger('remove', null, this._ui($li.find('a')[0], $panel[0]));
	},

	enable: function(index) {
		var o = this.options;
		if ($.inArray(index, o.disabled) == -1)
			return;

		this.$lis.eq(index).removeClass('ui-state-disabled');
		o.disabled = $.grep(o.disabled, function(n, i) { return n != index; });

		// callback
		this._trigger('enable', null, this._ui(this.$tabs[index], this.$panels[index]));
	},

	disable: function(index) {
		var self = this, o = this.options;
		if (index != o.selected) { // cannot disable already selected tab
			this.$lis.eq(index).addClass('ui-state-disabled');

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

			// callback
			this._trigger('disable', null, this._ui(this.$tabs[index], this.$panels[index]));
		}
	},

	select: function(index) {
		if (typeof index == 'string')
			index = this.$tabs.index(this.$tabs.filter('[href$=' + index + ']'));
		this.$tabs.eq(index).trigger(this.options.event + '.tabs');
	},

	load: function(index, callback) { // callback is for internal usage only

		var self = this, o = this.options, $a = this.$tabs.eq(index), a = $a[0],
				bypassCache = callback == undefined || callback === false, url = $a.data('load.tabs');
				// TODO bypassCache == false should work

		callback = callback || function() {};

		// no remote or from cache - just finish with callback
		// TODO in any case: insert cancel running load here..!
		
		if (!url || !bypassCache && $.data(a, 'cache.tabs')) {
			callback();
			return;
		}

		// load remote from here on

		var inner = function(parent) {
			var $parent = $(parent), $inner = $parent.find('*:last');
			return $inner.length && $inner.is(':not(img)') && $inner || $parent;
		};
		var cleanup = function() {
			self.$tabs.filter('.ui-tabs-loading').removeClass('ui-tabs-loading')
					.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 = $.extend({}, o.ajaxOptions, {
			url: url,
			success: function(r, s) {
				$(self._sanitizeSelector(a.hash)).html(r);
				cleanup();

				if (o.cache)
					$.data(a, 'cache.tabs', true); // if loaded once do not load them again

				// callbacks
				self._trigger('load', null, self._ui(self.$tabs[index], self.$panels[index]));
				try {
					o.ajaxOptions.success(r, s);
				}
				catch (er) {}

				// 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();
		}
		$a.addClass('ui-tabs-loading');
		self.xhr = $.ajax(ajaxOptions);
	},

	url: function(index, url) {
		this.$tabs.eq(index).removeData('cache.tabs').data('load.tabs', url);
	},
	
	length: function() {
		return this.$tabs.length;
	}

});

$.extend($.ui.tabs, {
	version: '1.6rc6',
	getter: 'length',
	defaults: {
		ajaxOptions: null,
		cache: false,
		cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
		deselectable: false,
		disabled: [],
		event: 'click',
		fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
		idPrefix: 'ui-tabs-',
		panelTemplate: '<div></div>',
		spinner: 'Loading&#8230;',
		tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>'
	}
});

/*
 * Tabs Extensions
 */

/*
 * Rotate
 */
$.extend($.ui.tabs.prototype, {
	rotation: null,
	rotate: function(ms, continuing) {

		var self = this, t = this.options.selected;

		function rotate() {
			clearTimeout(self.rotation);
			self.rotation = setTimeout(function() {
				t = ++t < self.$tabs.length ? t : 0;
				self.select(t);
			}, ms);
		}

		// start rotation
		if (ms) {
			this.element.bind('tabsshow', rotate); // will not be attached twice
			this.$tabs.bind(this.options.event + '.tabs', !continuing ?
				function(e) {
					if (e.clientX) { // in case of a true click
						clearTimeout(self.rotation);
						self.element.unbind('tabsshow', rotate);
					}
				} :
				function(e) {
					t = self.options.selected;
					rotate();
				}
			);
			rotate();
		}
		// stop rotation
		else {
			clearTimeout(self.rotation);
			this.element.unbind('tabsshow', rotate);
			this.$tabs.unbind(this.options.event + '.tabs', stop);
		}
	}
});

})(jQuery);


(function($){$.extend({tablesorter:new function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'.',debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}var rows=table.tBodies[0].rows;if(table.tBodies[0].rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i<l;i++){var p=false;if($.metadata&&($($headers[i]).metadata()&&$($headers[i]).metadata().sorter)){p=getParserById($($headers[i]).metadata().sorter);}else if((table.config.headers[i]&&table.config.headers[i].sorter)){p=getParserById(table.config.headers[i].sorter);}if(!p){p=detectParserForColumn(table,cells[i]);}if(table.config.debug){parsersDebug+="column:"+i+" parser:"+p.id+"\n";}list.push(p);}}if(table.config.debug){log(parsersDebug);}return list;};function detectParserForColumn(table,node){var l=parsers.length;for(var i=1;i<l;i++){if(parsers[i].is($.trim(getElementText(table.config,node)),table,node)){return parsers[i];}}return parsers[0];}function getParserById(name){var l=parsers.length;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==name.toLowerCase()){return parsers[i];}}return false;}function buildCache(table){if(table.config.debug){var cacheTime=new Date();}var totalRows=(table.tBodies[0]&&table.tBodies[0].rows.length)||0,totalCells=(table.tBodies[0].rows[0]&&table.tBodies[0].rows[0].cells.length)||0,parsers=table.config.parsers,cache={row:[],normalized:[]};for(var i=0;i<totalRows;++i){var c=table.tBodies[0].rows[i],cols=[];cache.row.push($(c));for(var j=0;j<totalCells;++j){cols.push(parsers[j].format(getElementText(table.config,c.cells[j]),table,c.cells[j]));}cols.push(i);cache.normalized.push(cols);cols=null;};if(table.config.debug){benchmark("Building cache for "+totalRows+" rows:",cacheTime);}return cache;};function getElementText(config,node){if(!node)return"";var t="";if(config.textExtraction=="simple"){if(node.childNodes[0]&&node.childNodes[0].hasChildNodes()){t=node.childNodes[0].innerHTML;}else{t=node.innerHTML;}}else{if(typeof(config.textExtraction)=="function"){t=config.textExtraction(node);}else{t=$(node).text();}}return t;}function appendToTable(table,cache){if(table.config.debug){var appendTime=new Date()}var c=cache,r=c.row,n=c.normalized,totalRows=n.length,checkCell=(n[0].length-1),tableBody=$(table.tBodies[0]),rows=[];for(var i=0;i<totalRows;i++){rows.push(r[n[i][checkCell]]);if(!table.config.appender){var o=r[n[i][checkCell]];var l=o.length;for(var j=0;j<l;j++){tableBody[0].appendChild(o[j]);}}}if(table.config.appender){table.config.appender(table,rows);}rows=null;if(table.config.debug){benchmark("Rebuilt table:",appendTime);}applyWidget(table);setTimeout(function(){$(table).trigger("sortEnd");},0);};function buildHeaders(table){if(table.config.debug){var time=new Date();}var meta=($.metadata)?true:false,tableHeadersRows=[];for(var i=0;i<table.tHead.rows.length;i++){tableHeadersRows[i]=0;};$tableHeaders=$("thead th",table);$tableHeaders.each(function(index){this.count=0;this.column=index;this.order=formatSortingOrder(table.config.sortInitialOrder);if(checkHeaderMetadata(this)||checkHeaderOptions(table,index))this.sortDisabled=true;if(!this.sortDisabled){$(this).addClass(table.config.cssHeader);}table.config.headerList[index]=this;});if(table.config.debug){benchmark("Built headers:",time);log($tableHeaders);}return $tableHeaders;};function checkCellColSpan(table,rows,row){var arr=[],r=table.tHead.rows,c=r[row].cells;for(var i=0;i<c.length;i++){var cell=c[i];if(cell.colSpan>1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i<l;i++){getWidgetById(c[i]).format(table);}}function getWidgetById(name){var l=widgets.length;for(var i=0;i<l;i++){if(widgets[i].id.toLowerCase()==name.toLowerCase()){return widgets[i];}}};function formatSortingOrder(v){if(typeof(v)!="Number"){i=(v.toLowerCase()=="desc")?1:0;}else{i=(v==(0||1))?v:0;}return i;}function isValueInArray(v,a){var l=a.length;for(var i=0;i<l;i++){if(a[i][0]==v){return true;}}return false;}function setHeadersCss(table,$headers,list,css){$headers.removeClass(css[0]).removeClass(css[1]);var h=[];$headers.each(function(offset){if(!this.sortDisabled){h[this.column]=$(this);}});var l=list.length;for(var i=0;i<l;i++){h[list[i][0]].addClass(css[list[i][1]]);}}function fixColumnWidth(table,$headers){var c=table.config;if(c.widthFixed){var colgroup=$('<colgroup>');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('<col>').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i<l;i++){var s=sortList[i],o=c.headerList[s[0]];o.count=s[1];o.count++;}}function multisort(table,sortList,cache){if(table.config.debug){var sortTime=new Date();}var dynamicExp="var sortWrapper = function(a,b) {",l=sortList.length;for(var i=0;i<l;i++){var c=sortList[i][0];var order=sortList[i][1];var s=(getCachedSortType(table.config.parsers,c)=="text")?((order==0)?"sortText":"sortTextDesc"):((order==0)?"sortNumeric":"sortNumericDesc");var e="e"+i;dynamicExp+="var "+e+" = "+s+"(a["+c+"],b["+c+"]); ";dynamicExp+="if("+e+") { return "+e+"; } ";dynamicExp+="else { ";}var orgOrderCol=cache.normalized[0].length-1;dynamicExp+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(var i=0;i<l;i++){dynamicExp+="}; ";}dynamicExp+="return 0; ";dynamicExp+="}; ";eval(dynamicExp);cache.normalized.sort(sortWrapper);if(table.config.debug){benchmark("Sorting on "+sortList.toString()+" and dir "+order+" time:",sortTime);}return cache;};function sortText(a,b){return((a<b)?-1:((a>b)?1:0));};function sortTextDesc(a,b){return((b<a)?-1:((b>a)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){$this.trigger("sortStart");var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){var $cell=$(this);var i=this.column;this.order=this.count++%2;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j<a.length;j++){if(a[j][0]!=i){config.sortList.push(a[j]);}}}config.sortList.push([i,this.order]);}else{if(isValueInArray(i,config.sortList)){for(var j=0;j<config.sortList.length;j++){var s=config.sortList[j],o=config.headerList[s[0]];if(s[0]==i){o.count=s[1];o.count++;s[1]=o.count%2;}}}else{config.sortList.push([i,this.order]);}};setTimeout(function(){setHeadersCss($this[0],$headers,config.sortList,sortCSS);appendToTable($this[0],multisort($this[0],config.sortList,cache));},1);return false;}}).mousedown(function(){if(config.cancelSelection){this.onselectstart=function(){return false};return false;}});$this.bind("update",function(){this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);}).bind("sorton",function(e,list){$(this).trigger("sortStart");config.sortList=list;var sortList=config.sortList;updateHeaderSortCount(this,sortList);setHeadersCss(this,$headers,sortList,sortCSS);appendToTable(this,multisort(this,sortList,cache));}).bind("appendCache",function(){appendToTable(this,cache);}).bind("applyWidgetId",function(e,id){getWidgetById(id).format(this);}).bind("applyWidgets",function(){applyWidget(this);});if($.metadata&&($(this).metadata()&&$(this).metadata().sortlist)){config.sortList=$(this).metadata().sortlist;}if(config.sortList.length>0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==parser.id.toLowerCase()){a=false;}}if(a){parsers.push(parser);};};this.addWidget=function(widget){widgets.push(widget);};this.formatFloat=function(s){var i=parseFloat(s);return(isNaN(i))?0:i;};this.formatInt=function(s){var i=parseInt(s);return(isNaN(i))?0:i;};this.isDigit=function(s,config){var DECIMAL='\\'+config.decimal;var exp='/(^[+]?0('+DECIMAL+'0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)'+DECIMAL+'(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*'+DECIMAL+'0+$)/';return RegExp(exp).test($.trim(s));};this.clearTableBody=function(table){if($.browser.msie){function empty(){while(this.firstChild)this.removeChild(this.firstChild);}empty.apply(table.tBodies[0]);}else{table.tBodies[0].innerHTML="";}};}});$.fn.extend({tablesorter:$.tablesorter.construct});var ts=$.tablesorter;ts.addParser({id:"text",is:function(s){return true;},format:function(s){return $.trim(s.toLowerCase());},type:"text"});ts.addParser({id:"digit",is:function(s,table){var c=table.config;return $.tablesorter.isDigit(s,c);},format:function(s){return $.tablesorter.formatFloat(s);},type:"numeric"});ts.addParser({id:"currency",is:function(s){return/^[£$€?.]/.test(s);},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g),""));},type:"numeric"});ts.addParser({id:"ipAddress",is:function(s){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s);},format:function(s){var a=s.split("."),r="",l=a.length;for(var i=0;i<l;i++){var item=a[i];if(item.length==2){r+="0"+item;}else{r+=item;}}return $.tablesorter.formatFloat(r);},type:"numeric"});ts.addParser({id:"url",is:function(s){return/^(https?|ftp|file):\/\/$/.test(s);},format:function(s){return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),''));},type:"text"});ts.addParser({id:"isoDate",is:function(s){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s);},format:function(s){return $.tablesorter.formatFloat((s!="")?new Date(s.replace(new RegExp(/-/g),"/")).getTime():"0");},type:"numeric"});ts.addParser({id:"percent",is:function(s){return/\%$/.test($.trim(s));},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),""));},type:"numeric"});ts.addParser({id:"usLongDate",is:function(s){return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/));},format:function(s){return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"shortDate",is:function(s){return/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s);},format:function(s,table){var c=table.config;s=s.replace(/\-/g,"/");if(c.dateFormat=="us"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$1/$2");}else if(c.dateFormat=="uk"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$2/$1");}else if(c.dateFormat=="dd/mm/yy"||c.dateFormat=="dd-mm-yy"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3");}return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"time",is:function(s){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s);},format:function(s){return $.tablesorter.formatFloat(new Date("2000/01/01 "+s).getTime());},type:"numeric"});ts.addParser({id:"metadata",is:function(s){return false;},format:function(s,table,cell){var c=table.config,p=(!c.parserMetadataName)?'sortValue':c.parserMetadataName;return $(cell).metadata()[p];},type:"numeric"});ts.addWidget({id:"zebra",format:function(table){if(table.config.debug){var time=new Date();}$("tr:visible",table.tBodies[0]).filter(':even').removeClass(table.config.widgetZebra.css[1]).addClass(table.config.widgetZebra.css[0]).end().filter(':odd').removeClass(table.config.widgetZebra.css[0]).addClass(table.config.widgetZebra.css[1]);if(table.config.debug){$.tablesorter.benchmark("Applying Zebra widget",time);}}});})(jQuery);
$(document).ready(function() {
  
	$(".test").hrzAccordion({eventTrigger:"mouseover",openOnLoad:"",cycle: true});
	

	$(".test4").hrzAccordion({eventTrigger:"mouseover",openOnLoad:"3",handlePositionArray: "left,left,right,right,right"});
	
	
	$(".test2").hrzAccordion({handlePosition     :"left",
							 openOnLoad     :3,
							 closeOpenAnimation: 2
							  });
	$(".test3").hrzAccordion({
	
			containerClass     : "container3",
			listItemClass      : "listItem3",					
			contentWrapper     : "contentWrapper3",
			contentInnerWrapper: "contentInnerWrapper3",
			handleClass        : "handle3",
			handleClassOver    : "handleOver3",
			handleClassSelected: "handleSelected3"
							  });
	

	

 	
 });/*
 * jQuery Form Plugin
 * version: 2.17 (06-NOV-2008)
 * @requires jQuery v1.2.2 or later
 *
 * Examples and documentation at: http://malsup.com/jquery/form/
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id$
 */
;(function($) {

/*
    Usage Note:  
    -----------
    Do not use both ajaxSubmit and ajaxForm on the same form.  These
    functions are intended to be exclusive.  Use ajaxSubmit if you want
    to bind your own submit handler to the form.  For example,

    $(document).ready(function() {
        $('#myForm').bind('submit', function() {
            $(this).ajaxSubmit({
                target: '#output'
            });
            return false; // <-- important!
        });
    });

    Use ajaxForm when you want the plugin to manage all the event binding
    for you.  For example,

    $(document).ready(function() {
        $('#myForm').ajaxForm({
            target: '#output'
        });
    });
        
    When using ajaxForm, the ajaxSubmit function will be invoked for you
    at the appropriate time.  
*/

/**
 * ajaxSubmit() provides a mechanism for immediately submitting 
 * an HTML form using AJAX.
 */
$.fn.ajaxSubmit = function(options) {
    // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
    if (!this.length) {
        log('ajaxSubmit: skipping submit process - no element selected');
        return this;
    }

    if (typeof options == 'function')
        options = { success: options };

    options = $.extend({
        url:  this.attr('action') || window.location.toString(),
        type: this.attr('method') || 'GET'
    }, options || {});

    // hook for manipulating the form data before it is extracted;
    // convenient for use with rich editors like tinyMCE or FCKEditor
    var veto = {};
    this.trigger('form-pre-serialize', [this, options, veto]);
    if (veto.veto) {
        log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
        return this;
    }

    // provide opportunity to alter form data before it is serialized
    if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
        log('ajaxSubmit: submit aborted via beforeSerialize callback');
        return this;
    }    
   
    var a = this.formToArray(options.semantic);
    if (options.data) {
        options.extraData = options.data;
        for (var n in options.data) {
          if(options.data[n] instanceof Array) {
            for (var k in options.data[n])
              a.push( { name: n, value: options.data[n][k] } )
          }  
          else
             a.push( { name: n, value: options.data[n] } );
        }
    }

    // give pre-submit callback an opportunity to abort the submit
    if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
        log('ajaxSubmit: submit aborted via beforeSubmit callback');
        return this;
    }    

    // fire vetoable 'validate' event
    this.trigger('form-submit-validate', [a, this, options, veto]);
    if (veto.veto) {
        log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
        return this;
    }    

    var q = $.param(a);

    if (options.type.toUpperCase() == 'GET') {
        options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
        options.data = null;  // data is null for 'get'
    }
    else
        options.data = q; // data is the query string for 'post'

    var $form = this, callbacks = [];
    if (options.resetForm) callbacks.push(function() { $form.resetForm(); });
    if (options.clearForm) callbacks.push(function() { $form.clearForm(); });

    // perform a load on the target only if dataType is not provided
    if (!options.dataType && options.target) {
        var oldSuccess = options.success || function(){};
        callbacks.push(function(data) {
            $(options.target).html(data).each(oldSuccess, arguments);
        });
    }
    else if (options.success)
        callbacks.push(options.success);

    options.success = function(data, status) {
        for (var i=0, max=callbacks.length; i < max; i++)
            callbacks[i].apply(options, [data, status, $form]);
    };

    // are there files to upload?
    var files = $('input:file', this).fieldValue();
    var found = false;
    for (var j=0; j < files.length; j++)
        if (files[j])
            found = true;

    // options.iframe allows user to force iframe mode
   if (options.iframe || found) { 
       // hack to fix Safari hang (thanks to Tim Molendijk for this)
       // see:  http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
       if ($.browser.safari && options.closeKeepAlive)
           $.get(options.closeKeepAlive, fileUpload);
       else
           fileUpload();
       }
   else
       $.ajax(options);

    // fire 'notify' event
    this.trigger('form-submit-notify', [this, options]);
    return this;


    // private function for handling file uploads (hat tip to YAHOO!)
    function fileUpload() {
        var form = $form[0];
        
        if ($(':input[@name=submit]', form).length) {
            alert('Error: Form elements must not be named "submit".');
            return;
        }
        
        var opts = $.extend({}, $.ajaxSettings, options);
		var s = jQuery.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts);

        var id = 'jqFormIO' + (new Date().getTime());
        var $io = $('<iframe id="' + id + '" name="' + id + '" />');
        var io = $io[0];

        if ($.browser.msie || $.browser.opera) 
            io.src = 'javascript:false;document.write("");';
        $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });

        var xhr = { // mock object
            aborted: 0,
            responseText: null,
            responseXML: null,
            status: 0,
            statusText: 'n/a',
            getAllResponseHeaders: function() {},
            getResponseHeader: function() {},
            setRequestHeader: function() {},
            abort: function() { 
                this.aborted = 1; 
                $io.attr('src','about:blank'); // abort op in progress
            }
        };

        var g = opts.global;
        // trigger ajax global events so that activity/block indicators work like normal
        if (g && ! $.active++) $.event.trigger("ajaxStart");
        if (g) $.event.trigger("ajaxSend", [xhr, opts]);

		if (s.beforeSend && s.beforeSend(xhr, s) === false) {
			s.global && jQuery.active--;
			return;
        }
        if (xhr.aborted)
            return;
        
        var cbInvoked = 0;
        var timedOut = 0;

        // add submitting element to data if we know it
        var sub = form.clk;
        if (sub) {
            var n = sub.name;
            if (n && !sub.disabled) {
                options.extraData = options.extraData || {};
                options.extraData[n] = sub.value;
                if (sub.type == "image") {
                    options.extraData[name+'.x'] = form.clk_x;
                    options.extraData[name+'.y'] = form.clk_y;
                }
            }
        }

        // take a breath so that pending repaints get some cpu time before the upload starts
        setTimeout(function() {
            // make sure form attrs are set
            var t = $form.attr('target'), a = $form.attr('action');
            $form.attr({
                target:   id,
                method:   'POST',
                action:   opts.url
            });
            
            // ie borks in some cases when setting encoding
            if (! options.skipEncodingOverride) {
                $form.attr({
                    encoding: 'multipart/form-data',
                    enctype:  'multipart/form-data'
                });
            }

            // support timout
            if (opts.timeout)
                setTimeout(function() { timedOut = true; cb(); }, opts.timeout);

            // add "extra" data to form if provided in options
            var extraInputs = [];
            try {
                if (options.extraData)
                    for (var n in options.extraData)
                        extraInputs.push(
                            $('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />')
                                .appendTo(form)[0]);
            
                // add iframe to doc and submit the form
                $io.appendTo('body');
                io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
                form.submit();
            }
            finally {
                // reset attrs and remove "extra" input elements
                $form.attr('action', a);
                t ? $form.attr('target', t) : $form.removeAttr('target');
                $(extraInputs).remove();
            }
        }, 10);

        function cb() {
            if (cbInvoked++) return;
            
            io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);

            var operaHack = 0;
            var ok = true;
            try {
                if (timedOut) throw 'timeout';
                // extract the server response from the iframe
                var data, doc;

                doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
                
                if (doc.body == null && !operaHack && $.browser.opera) {
                    // In Opera 9.2.x the iframe DOM is not always traversable when
                    // the onload callback fires so we give Opera 100ms to right itself
                    operaHack = 1;
                    cbInvoked--;
                    setTimeout(cb, 100);
                    return;
                }
                
                xhr.responseText = doc.body ? doc.body.innerHTML : null;
                xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
                xhr.getResponseHeader = function(header){
                    var headers = {'content-type': opts.dataType};
                    return headers[header];
                };

                if (opts.dataType == 'json' || opts.dataType == 'script') {
                    var ta = doc.getElementsByTagName('textarea')[0];
                    xhr.responseText = ta ? ta.value : xhr.responseText;
                }
                else if (opts.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
                    xhr.responseXML = toXml(xhr.responseText);
                }
                data = $.httpData(xhr, opts.dataType);
            }
            catch(e){
                ok = false;
                $.handleError(opts, xhr, 'error', e);
            }

            // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
            if (ok) {
                opts.success(data, 'success');
                if (g) $.event.trigger("ajaxSuccess", [xhr, opts]);
            }
            if (g) $.event.trigger("ajaxComplete", [xhr, opts]);
            if (g && ! --$.active) $.event.trigger("ajaxStop");
            if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');

            // clean up
            setTimeout(function() {
                $io.remove();
                xhr.responseXML = null;
            }, 100);
        };

        function toXml(s, doc) {
            if (window.ActiveXObject) {
                doc = new ActiveXObject('Microsoft.XMLDOM');
                doc.async = 'false';
                doc.loadXML(s);
            }
            else
                doc = (new DOMParser()).parseFromString(s, 'text/xml');
            return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
        };
    };
};

/**
 * ajaxForm() provides a mechanism for fully automating form submission.
 *
 * The advantages of using this method instead of ajaxSubmit() are:
 *
 * 1: This method will include coordinates for <input type="image" /> elements (if the element
 *    is used to submit the form).
 * 2. This method will include the submit element's name/value data (for the element that was
 *    used to submit the form).
 * 3. This method binds the submit() method to the form for you.
 *
 * The options argument for ajaxForm works exactly as it does for ajaxSubmit.  ajaxForm merely
 * passes the options argument along after properly binding events for submit elements and
 * the form itself.
 */ 
$.fn.ajaxForm = function(options) {
    return this.ajaxFormUnbind().bind('submit.form-plugin',function() {
        $(this).ajaxSubmit(options);
        return false;
    }).each(function() {
        // store options in hash
        $(":submit,input:image", this).bind('click.form-plugin',function(e) {
            var form = this.form;
            form.clk = this;
            if (this.type == 'image') {
                if (e.offsetX != undefined) {
                    form.clk_x = e.offsetX;
                    form.clk_y = e.offsetY;
                } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
                    var offset = $(this).offset();
                    form.clk_x = e.pageX - offset.left;
                    form.clk_y = e.pageY - offset.top;
                } else {
                    form.clk_x = e.pageX - this.offsetLeft;
                    form.clk_y = e.pageY - this.offsetTop;
                }
            }
            // clear form vars
            setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 10);
        });
    });
};

// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
$.fn.ajaxFormUnbind = function() {
    this.unbind('submit.form-plugin');
    return this.each(function() {
        $(":submit,input:image", this).unbind('click.form-plugin');
    });

};

/**
 * formToArray() gathers form element data into an array of objects that can
 * be passed to any of the following ajax functions: $.get, $.post, or load.
 * Each object in the array has both a 'name' and 'value' property.  An example of
 * an array for a simple login form might be:
 *
 * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
 *
 * It is this array that is passed to pre-submit callback functions provided to the
 * ajaxSubmit() and ajaxForm() methods.
 */
$.fn.formToArray = function(semantic) {
    var a = [];
    if (this.length == 0) return a;

    var form = this[0];
    var els = semantic ? form.getElementsByTagName('*') : form.elements;
    if (!els) return a;
    for(var i=0, max=els.length; i < max; i++) {
        var el = els[i];
        var n = el.name;
        if (!n) continue;

        if (semantic && form.clk && el.type == "image") {
            // handle image inputs on the fly when semantic == true
            if(!el.disabled && form.clk == el)
                a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
            continue;
        }

        var v = $.fieldValue(el, true);
        if (v && v.constructor == Array) {
            for(var j=0, jmax=v.length; j < jmax; j++)
                a.push({name: n, value: v[j]});
        }
        else if (v !== null && typeof v != 'undefined')
            a.push({name: n, value: v});
    }

    if (!semantic && form.clk) {
        // input type=='image' are not found in elements array! handle them here
        var inputs = form.getElementsByTagName("input");
        for(var i=0, max=inputs.length; i < max; i++) {
            var input = inputs[i];
            var n = input.name;
            if(n && !input.disabled && input.type == "image" && form.clk == input)
                a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
        }
    }
    return a;
};

/**
 * Serializes form data into a 'submittable' string. This method will return a string
 * in the format: name1=value1&amp;name2=value2
 */
$.fn.formSerialize = function(semantic) {
    //hand off to jQuery.param for proper encoding
    return $.param(this.formToArray(semantic));
};

/**
 * Serializes all field elements in the jQuery object into a query string.
 * This method will return a string in the format: name1=value1&amp;name2=value2
 */
$.fn.fieldSerialize = function(successful) {
    var a = [];
    this.each(function() {
        var n = this.name;
        if (!n) return;
        var v = $.fieldValue(this, successful);
        if (v && v.constructor == Array) {
            for (var i=0,max=v.length; i < max; i++)
                a.push({name: n, value: v[i]});
        }
        else if (v !== null && typeof v != 'undefined')
            a.push({name: this.name, value: v});
    });
    //hand off to jQuery.param for proper encoding
    return $.param(a);
};

/**
 * Returns the value(s) of the element in the matched set.  For example, consider the following form:
 *
 *  <form><fieldset>
 *      <input name="A" type="text" />
 *      <input name="A" type="text" />
 *      <input name="B" type="checkbox" value="B1" />
 *      <input name="B" type="checkbox" value="B2"/>
 *      <input name="C" type="radio" value="C1" />
 *      <input name="C" type="radio" value="C2" />
 *  </fieldset></form>
 *
 *  var v = $(':text').fieldValue();
 *  // if no values are entered into the text inputs
 *  v == ['','']
 *  // if values entered into the text inputs are 'foo' and 'bar'
 *  v == ['foo','bar']
 *
 *  var v = $(':checkbox').fieldValue();
 *  // if neither checkbox is checked
 *  v === undefined
 *  // if both checkboxes are checked
 *  v == ['B1', 'B2']
 *
 *  var v = $(':radio').fieldValue();
 *  // if neither radio is checked
 *  v === undefined
 *  // if first radio is checked
 *  v == ['C1']
 *
 * The successful argument controls whether or not the field element must be 'successful'
 * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
 * The default value of the successful argument is true.  If this value is false the value(s)
 * for each element is returned.
 *
 * Note: This method *always* returns an array.  If no valid value can be determined the
 *       array will be empty, otherwise it will contain one or more values.
 */
$.fn.fieldValue = function(successful) {
    for (var val=[], i=0, max=this.length; i < max; i++) {
        var el = this[i];
        var v = $.fieldValue(el, successful);
        if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length))
            continue;
        v.constructor == Array ? $.merge(val, v) : val.push(v);
    }
    return val;
};

/**
 * Returns the value of the field element.
 */
$.fieldValue = function(el, successful) {
    var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
    if (typeof successful == 'undefined') successful = true;

    if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
        (t == 'checkbox' || t == 'radio') && !el.checked ||
        (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
        tag == 'select' && el.selectedIndex == -1))
            return null;

    if (tag == 'select') {
        var index = el.selectedIndex;
        if (index < 0) return null;
        var a = [], ops = el.options;
        var one = (t == 'select-one');
        var max = (one ? index+1 : ops.length);
        for(var i=(one ? index : 0); i < max; i++) {
            var op = ops[i];
            if (op.selected) {
                // extra pain for IE...
                var v = $.browser.msie && !(op.attributes['value'].specified) ? op.text : op.value;
                if (one) return v;
                a.push(v);
            }
        }
        return a;
    }
    return el.value;
};

/**
 * Clears the form data.  Takes the following actions on the form's input fields:
 *  - input text fields will have their 'value' property set to the empty string
 *  - select elements will have their 'selectedIndex' property set to -1
 *  - checkbox and radio inputs will have their 'checked' property set to false
 *  - inputs of type submit, button, reset, and hidden will *not* be effected
 *  - button elements will *not* be effected
 */
$.fn.clearForm = function() {
    return this.each(function() {
        $('input,select,textarea', this).clearFields();
    });
};

/**
 * Clears the selected form elements.
 */
$.fn.clearFields = $.fn.clearInputs = function() {
    return this.each(function() {
        var t = this.type, tag = this.tagName.toLowerCase();
        if (t == 'text' || t == 'password' || tag == 'textarea')
            this.value = '';
        else if (t == 'checkbox' || t == 'radio')
            this.checked = false;
        else if (tag == 'select')
            this.selectedIndex = -1;
    });
};

/**
 * Resets the form data.  Causes all form elements to be reset to their original value.
 */
$.fn.resetForm = function() {
    return this.each(function() {
        // guard against an input with the name of 'reset'
        // note that IE reports the reset function as an 'object'
        if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType))
            this.reset();
    });
};

/**
 * Enables or disables any matching elements.
 */
$.fn.enable = function(b) { 
    if (b == undefined) b = true;
    return this.each(function() { 
        this.disabled = !b 
    });
};

/**
 * Checks/unchecks any matching checkboxes or radio buttons and
 * selects/deselects and matching option elements.
 */
$.fn.selected = function(select) {
    if (select == undefined) select = true;
    return this.each(function() { 
        var t = this.type;
        if (t == 'checkbox' || t == 'radio')
            this.checked = select;
        else if (this.tagName.toLowerCase() == 'option') {
            var $sel = $(this).parent('select');
            if (select && $sel[0] && $sel[0].type == 'select-one') {
                // deselect all other options
                $sel.find('option').selected(false);
            }
            this.selected = select;
        }
    });
};

// helper fn for console logging
// set $.fn.ajaxSubmit.debug to true to enable debug logging
function log() {
    if ($.fn.ajaxSubmit.debug && window.console && window.console.log)
        window.console.log('[jquery.form] ' + Array.prototype.join.call(arguments,''));
};

})(jQuery);
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

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

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};/*
 * jQuery validation plug-in 1.6
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
 * http://docs.jquery.com/Plugins/Validation
 *
 * Copyright (c) 2006 - 2008 Jörn Zaefferer
 *
 * $Id: jquery.validate.js 6403 2009-06-17 14:27:16Z joern.zaefferer $
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(7($){$.H($.2O,{1d:7(d){l(!6.F){d&&d.24&&2Y.1H&&1H.52("3v 3o, 4N\'t 1d, 67 3v");8}p c=$.17(6[0],\'v\');l(c){8 c}c=2e $.v(d,6[0]);$.17(6[0],\'v\',c);l(c.q.3u){6.3r("1B, 3j").1n(".4G").3b(7(){c.3a=w});l(c.q.35){6.3r("1B, 3j").1n(":23").3b(7(){c.1V=6})}6.23(7(b){l(c.q.24)b.5N();7 2m(){l(c.q.35){l(c.1V){p a=$("<1B 1A=\'5v\'/>").1p("u",c.1V.u).2M(c.1V.Z).51(c.U)}c.q.35.11(c,c.U);l(c.1V){a.3A()}8 I}8 w}l(c.3a){c.3a=I;8 2m()}l(c.M()){l(c.1a){c.1l=w;8 I}8 2m()}16{c.2h();8 I}})}8 c},J:7(){l($(6[0]).2Z(\'M\')){8 6.1d().M()}16{p b=w;p a=$(6[0].M).1d();6.P(7(){b&=a.L(6)});8 b}},4F:7(c){p d={},$L=6;$.P(c.1O(/\\s/),7(a,b){d[b]=$L.1p(b);$L.6c(b)});8 d},1f:7(h,k){p f=6[0];l(h){p i=$.17(f.M,\'v\').q;p d=i.1f;p c=$.v.2D(f);22(h){1b"1e":$.H(c,$.v.1N(k));d[f.u]=c;l(k.G)i.G[f.u]=$.H(i.G[f.u],k.G);2K;1b"3A":l(!k){S d[f.u];8 c}p e={};$.P(k.1O(/\\s/),7(a,b){e[b]=c[b];S c[b]});8 e}}p g=$.v.42($.H({},$.v.3Y(f),$.v.3W(f),$.v.3U(f),$.v.2D(f)),f);l(g.14){p j=g.14;S g.14;g=$.H({14:j},g)}8 g}});$.H($.5s[":"],{5p:7(a){8!$.1q(""+a.Z)},5i:7(a){8!!$.1q(""+a.Z)},5f:7(a){8!a.4l}});$.v=7(b,a){6.q=$.H({},$.v.33,b);6.U=a;6.3I()};$.v.W=7(c,b){l(T.F==1)8 7(){p a=$.3D(T);a.4V(c);8 $.v.W.1Q(6,a)};l(T.F>2&&b.29!=3x){b=$.3D(T).4R(1)}l(b.29!=3x){b=[b]}$.P(b,7(i,n){c=c.1P(2e 3s("\\\\{"+i+"\\\\}","g"),n)});8 c};$.H($.v,{33:{G:{},2d:{},1f:{},19:"3p",26:"J",2C:"4Q",2h:w,3l:$([]),2A:$([]),3u:w,3i:[],3Q:I,4O:7(a){6.3e=a;l(6.q.4M&&!6.4J){6.q.1L&&6.q.1L.11(6,a,6.q.19,6.q.26);6.1K(a).2y()}},4E:7(a){l(!6.1D(a)&&(a.u V 6.1c||!6.K(a))){6.L(a)}},6b:7(a){l(a.u V 6.1c||a==6.4y){6.L(a)}},69:7(a){l(a.u V 6.1c)6.L(a);16 l(a.4v.u V 6.1c)6.L(a.4v)},38:7(a,c,b){$(a).1Y(c).2w(b)},1L:7(a,c,b){$(a).2w(c).1Y(b)}},65:7(a){$.H($.v.33,a)},G:{14:"61 4q 2Z 14.",1r:"N 2L 6 4q.",1I:"N O a J 1I 60.",1v:"N O a J 5X.",1u:"N O a J 1u.",2q:"N O a J 1u (5R).",1s:"N O a J 1s.",1U:"N O 5P 1U.",2c:"N O a J 5O 5M 1s.",2n:"N O 47 5I Z 5H.",44:"N O a Z 5C a J 5B.",18:$.v.W("N O 3X 5y 2X {0} 2W."),1z:$.v.W("N O 5x 5w {0} 2W."),2j:$.v.W("N O a Z 3V {0} 45 {1} 2W 5q."),2i:$.v.W("N O a Z 3V {0} 45 {1}."),1x:$.v.W("N O a Z 5k 2X 3L 3K 48 {0}."),1F:$.v.W("N O a Z 5d 2X 3L 3K 48 {0}.")},3J:I,5b:{3I:7(){6.2r=$(6.q.2A);6.4i=6.2r.F&&6.2r||$(6.U);6.2s=$(6.q.3l).1e(6.q.2A);6.1c={};6.55={};6.1a=0;6.1i={};6.1g={};6.21();p f=(6.2d={});$.P(6.q.2d,7(d,c){$.P(c.1O(/\\s/),7(a,b){f[b]=d})});p e=6.q.1f;$.P(e,7(b,a){e[b]=$.v.1N(a)});7 1C(a){p b=$.17(6[0].M,"v");b.q["4A"+a.1A]&&b.q["4A"+a.1A].11(b,6[0])}$(6.U).1C("3F 3E 4W",":3C, :4U, :4T, 2b, 4S",1C).1C("3b",":3B, :3z, 2b, 3y",1C);l(6.q.3w)$(6.U).2J("1g-M.1d",6.q.3w)},M:7(){6.3t();$.H(6.1c,6.1w);6.1g=$.H({},6.1w);l(!6.J())$(6.U).2H("1g-M",[6]);6.1m();8 6.J()},3t:7(){6.2G();Q(p i=0,13=(6.27=6.13());13[i];i++){6.28(13[i])}8 6.J()},L:7(a){a=6.2F(a);6.4y=a;6.2E(a);6.27=$(a);p b=6.28(a);l(b){S 6.1g[a.u]}16{6.1g[a.u]=w}l(!6.3q()){6.12=6.12.1e(6.2s)}6.1m();8 b},1m:7(b){l(b){$.H(6.1w,b);6.R=[];Q(p c V b){6.R.2a({1j:b[c],L:6.2f(c)[0]})}6.1k=$.3n(6.1k,7(a){8!(a.u V b)})}6.q.1m?6.q.1m.11(6,6.1w,6.R):6.3m()},2B:7(){l($.2O.2B)$(6.U).2B();6.1c={};6.2G();6.2T();6.13().2w(6.q.19)},3q:7(){8 6.2g(6.1g)},2g:7(a){p b=0;Q(p i V a)b++;8 b},2T:7(){6.2P(6.12).2y()},J:7(){8 6.3N()==0},3N:7(){8 6.R.F},2h:7(){l(6.q.2h){3O{$(6.3h()||6.R.F&&6.R[0].L||[]).1n(":4P").3g()}3f(e){}}},3h:7(){p a=6.3e;8 a&&$.3n(6.R,7(n){8 n.L.u==a.u}).F==1&&a},13:7(){p a=6,2U={};8 $([]).1e(6.U.13).1n(":1B").1R(":23, :21, :4L, [4K]").1R(6.q.3i).1n(7(){!6.u&&a.q.24&&2Y.1H&&1H.3p("%o 4I 3X u 4H",6);l(6.u V 2U||!a.2g($(6).1f()))8 I;2U[6.u]=w;8 w})},2F:7(a){8 $(a)[0]},2z:7(){8 $(6.q.2C+"."+6.q.19,6.4i)},21:7(){6.1k=[];6.R=[];6.1w={};6.1o=$([]);6.12=$([]);6.27=$([])},2G:7(){6.21();6.12=6.2z().1e(6.2s)},2E:7(a){6.21();6.12=6.1K(a)},28:7(d){d=6.2F(d);l(6.1D(d)){d=6.2f(d.u)[0]}p a=$(d).1f();p c=I;Q(Y V a){p b={Y:Y,2l:a[Y]};3O{p f=$.v.1T[Y].11(6,d.Z.1P(/\\r/g,""),d,b.2l);l(f=="1S-1Z"){c=w;4D}c=I;l(f=="1i"){6.12=6.12.1R(6.1K(d));8}l(!f){6.3c(d,b);8 I}}3f(e){6.q.24&&2Y.1H&&1H.4C("6g 6f 6e 6d L "+d.4z+", 28 47 \'"+b.Y+"\' Y",e);6a e;}}l(c)8;l(6.2g(a))6.1k.2a(d);8 w},4x:7(a,b){l(!$.1y)8;p c=6.q.39?$(a).1y()[6.q.39]:$(a).1y();8 c&&c.G&&c.G[b]},4w:7(a,b){p m=6.q.G[a];8 m&&(m.29==4u?m:m[b])},4t:7(){Q(p i=0;i<T.F;i++){l(T[i]!==20)8 T[i]}8 20},2x:7(a,b){8 6.4t(6.4w(a.u,b),6.4x(a,b),!6.q.3Q&&a.68||20,$.v.G[b],"<4s>66: 64 1j 63 Q "+a.u+"</4s>")},3c:7(b,a){p c=6.2x(b,a.Y),36=/\\$?\\{(\\d+)\\}/g;l(1h c=="7"){c=c.11(6,a.2l,b)}16 l(36.15(c)){c=2v.W(c.1P(36,\'{$1}\'),a.2l)}6.R.2a({1j:c,L:b});6.1w[b.u]=c;6.1c[b.u]=c},2P:7(a){l(6.q.2u)a=a.1e(a.4p(6.q.2u));8 a},3m:7(){Q(p i=0;6.R[i];i++){p a=6.R[i];6.q.38&&6.q.38.11(6,a.L,6.q.19,6.q.26);6.34(a.L,a.1j)}l(6.R.F){6.1o=6.1o.1e(6.2s)}l(6.q.1G){Q(p i=0;6.1k[i];i++){6.34(6.1k[i])}}l(6.q.1L){Q(p i=0,13=6.4o();13[i];i++){6.q.1L.11(6,13[i],6.q.19,6.q.26)}}6.12=6.12.1R(6.1o);6.2T();6.2P(6.1o).4n()},4o:7(){8 6.27.1R(6.4m())},4m:7(){8 $(6.R).3d(7(){8 6.L})},34:7(a,c){p b=6.1K(a);l(b.F){b.2w().1Y(6.q.19);b.1p("4k")&&b.4j(c)}16{b=$("<"+6.q.2C+"/>").1p({"Q":6.32(a),4k:w}).1Y(6.q.19).4j(c||"");l(6.q.2u){b=b.2y().4n().5Z("<"+6.q.2u+"/>").4p()}l(!6.2r.5Y(b).F)6.q.4h?6.q.4h(b,$(a)):b.5W(a)}l(!c&&6.q.1G){b.3C("");1h 6.q.1G=="1t"?b.1Y(6.q.1G):6.q.1G(b)}6.1o=6.1o.1e(b)},1K:7(a){p b=6.32(a);8 6.2z().1n(7(){8 $(6).1p(\'Q\')==b})},32:7(a){8 6.2d[a.u]||(6.1D(a)?a.u:a.4z||a.u)},1D:7(a){8/3B|3z/i.15(a.1A)},2f:7(d){p c=6.U;8 $(5V.5U(d)).3d(7(a,b){8 b.M==c&&b.u==d&&b||4g})},1M:7(a,b){22(b.4f.3k()){1b\'2b\':8 $("3y:3o",b).F;1b\'1B\':l(6.1D(b))8 6.2f(b.u).1n(\':4l\').F}8 a.F},4e:7(b,a){8 6.2I[1h b]?6.2I[1h b](b,a):w},2I:{"5Q":7(b,a){8 b},"1t":7(b,a){8!!$(b,a.M).F},"7":7(b,a){8 b(a)}},K:7(a){8!$.v.1T.14.11(6,$.1q(a.Z),a)&&"1S-1Z"},4d:7(a){l(!6.1i[a.u]){6.1a++;6.1i[a.u]=w}},4c:7(a,b){6.1a--;l(6.1a<0)6.1a=0;S 6.1i[a.u];l(b&&6.1a==0&&6.1l&&6.M()){$(6.U).23();6.1l=I}16 l(!b&&6.1a==0&&6.1l){$(6.U).2H("1g-M",[6]);6.1l=I}},2o:7(a){8 $.17(a,"2o")||$.17(a,"2o",{31:4g,J:w,1j:6.2x(a,"1r")})}},1J:{14:{14:w},1I:{1I:w},1v:{1v:w},1u:{1u:w},2q:{2q:w},4b:{4b:w},1s:{1s:w},4a:{4a:w},1U:{1U:w},2c:{2c:w}},49:7(a,b){a.29==4u?6.1J[a]=b:$.H(6.1J,a)},3W:7(b){p a={};p c=$(b).1p(\'5L\');c&&$.P(c.1O(\' \'),7(){l(6 V $.v.1J){$.H(a,$.v.1J[6])}});8 a},3U:7(c){p a={};p d=$(c);Q(Y V $.v.1T){p b=d.1p(Y);l(b){a[Y]=b}}l(a.18&&/-1|5K|5J/.15(a.18)){S a.18}8 a},3Y:7(a){l(!$.1y)8{};p b=$.17(a.M,\'v\').q.39;8 b?$(a).1y()[b]:$(a).1y()},2D:7(b){p a={};p c=$.17(b.M,\'v\');l(c.q.1f){a=$.v.1N(c.q.1f[b.u])||{}}8 a},42:7(d,e){$.P(d,7(c,b){l(b===I){S d[c];8}l(b.30||b.2t){p a=w;22(1h b.2t){1b"1t":a=!!$(b.2t,e.M).F;2K;1b"7":a=b.2t.11(e,e);2K}l(a){d[c]=b.30!==20?b.30:w}16{S d[c]}}});$.P(d,7(a,b){d[a]=$.46(b)?b(e):b});$.P([\'1z\',\'18\',\'1F\',\'1x\'],7(){l(d[6]){d[6]=2Q(d[6])}});$.P([\'2j\',\'2i\'],7(){l(d[6]){d[6]=[2Q(d[6][0]),2Q(d[6][1])]}});l($.v.3J){l(d.1F&&d.1x){d.2i=[d.1F,d.1x];S d.1F;S d.1x}l(d.1z&&d.18){d.2j=[d.1z,d.18];S d.1z;S d.18}}l(d.G){S d.G}8 d},1N:7(a){l(1h a=="1t"){p b={};$.P(a.1O(/\\s/),7(){b[6]=w});a=b}8 a},5G:7(c,a,b){$.v.1T[c]=a;$.v.G[c]=b!=20?b:$.v.G[c];l(a.F<3){$.v.49(c,$.v.1N(c))}},1T:{14:7(c,d,a){l(!6.4e(a,d))8"1S-1Z";22(d.4f.3k()){1b\'2b\':p b=$(d).2M();8 b&&b.F>0;1b\'1B\':l(6.1D(d))8 6.1M(c,d)>0;5F:8 $.1q(c).F>0}},1r:7(f,h,j){l(6.K(h))8"1S-1Z";p g=6.2o(h);l(!6.q.G[h.u])6.q.G[h.u]={};g.43=6.q.G[h.u].1r;6.q.G[h.u].1r=g.1j;j=1h j=="1t"&&{1v:j}||j;l(g.31!==f){g.31=f;p k=6;6.4d(h);p i={};i[h.u]=f;$.2R($.H(w,{1v:j,41:"2S",40:"1d"+h.u,5A:"5z",17:i,1G:7(d){k.q.G[h.u].1r=g.43;p b=d===w;l(b){p e=k.1l;k.2E(h);k.1l=e;k.1k.2a(h);k.1m()}16{p a={};p c=(g.1j=d||k.2x(h,"1r"));a[h.u]=$.46(c)?c(f):c;k.1m(a)}g.J=b;k.4c(h,b)}},j));8"1i"}16 l(6.1i[h.u]){8"1i"}8 g.J},1z:7(b,c,a){8 6.K(c)||6.1M($.1q(b),c)>=a},18:7(b,c,a){8 6.K(c)||6.1M($.1q(b),c)<=a},2j:7(b,d,a){p c=6.1M($.1q(b),d);8 6.K(d)||(c>=a[0]&&c<=a[1])},1F:7(b,c,a){8 6.K(c)||b>=a},1x:7(b,c,a){8 6.K(c)||b<=a},2i:7(b,c,a){8 6.K(c)||(b>=a[0]&&b<=a[1])},1I:7(a,b){8 6.K(b)||/^((([a-z]|\\d|[!#\\$%&\'\\*\\+\\-\\/=\\?\\^X`{\\|}~]|[\\y-\\x\\E-\\C\\A-\\B])+(\\.([a-z]|\\d|[!#\\$%&\'\\*\\+\\-\\/=\\?\\^X`{\\|}~]|[\\y-\\x\\E-\\C\\A-\\B])+)*)|((\\3T)((((\\2k|\\1X)*(\\2V\\3S))?(\\2k|\\1X)+)?(([\\3R-\\5u\\3P\\3M\\5t-\\5r\\3Z]|\\5D|[\\5E-\\5o]|[\\5n-\\5m]|[\\y-\\x\\E-\\C\\A-\\B])|(\\\\([\\3R-\\1X\\3P\\3M\\2V-\\3Z]|[\\y-\\x\\E-\\C\\A-\\B]))))*(((\\2k|\\1X)*(\\2V\\3S))?(\\2k|\\1X)+)?(\\3T)))@((([a-z]|\\d|[\\y-\\x\\E-\\C\\A-\\B])|(([a-z]|\\d|[\\y-\\x\\E-\\C\\A-\\B])([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])*([a-z]|\\d|[\\y-\\x\\E-\\C\\A-\\B])))\\.)+(([a-z]|[\\y-\\x\\E-\\C\\A-\\B])|(([a-z]|[\\y-\\x\\E-\\C\\A-\\B])([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])*([a-z]|[\\y-\\x\\E-\\C\\A-\\B])))\\.?$/i.15(a)},1v:7(a,b){8 6.K(b)||/^(5l?|5j):\\/\\/(((([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])|(%[\\1W-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|[\\y-\\x\\E-\\C\\A-\\B])|(([a-z]|\\d|[\\y-\\x\\E-\\C\\A-\\B])([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])*([a-z]|\\d|[\\y-\\x\\E-\\C\\A-\\B])))\\.)+(([a-z]|[\\y-\\x\\E-\\C\\A-\\B])|(([a-z]|[\\y-\\x\\E-\\C\\A-\\B])([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])*([a-z]|[\\y-\\x\\E-\\C\\A-\\B])))\\.?)(:\\d*)?)(\\/((([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])|(%[\\1W-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)+(\\/(([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])|(%[\\1W-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)*)*)?)?(\\?((([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])|(%[\\1W-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)|[\\5h-\\5g]|\\/|\\?)*)?(\\#((([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])|(%[\\1W-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)|\\/|\\?)*)?$/i.15(a)},1u:7(a,b){8 6.K(b)||!/5e|5S/.15(2e 5T(a))},2q:7(a,b){8 6.K(b)||/^\\d{4}[\\/-]\\d{1,2}[\\/-]\\d{1,2}$/.15(a)},1s:7(a,b){8 6.K(b)||/^-?(?:\\d+|\\d{1,3}(?:,\\d{3})+)(?:\\.\\d+)?$/.15(a)},1U:7(a,b){8 6.K(b)||/^\\d+$/.15(a)},2c:7(b,e){l(6.K(e))8"1S-1Z";l(/[^0-9-]+/.15(b))8 I;p a=0,d=0,2p=I;b=b.1P(/\\D/g,"");Q(p n=b.F-1;n>=0;n--){p c=b.5c(n);p d=5a(c,10);l(2p){l((d*=2)>9)d-=9}a+=d;2p=!2p}8(a%10)==0},44:7(b,c,a){a=1h a=="1t"?a.1P(/,/g,\'|\'):"59|58?g|57";8 6.K(c)||b.62(2e 3s(".("+a+")$","i"))},2n:7(c,d,a){p b=$(a).56(".1d-2n").2J("4B.1d-2n",7(){$(d).J()});8 c==b.2M()}}});$.W=$.v.W})(2v);(7($){p c=$.2R;p d={};$.2R=7(a){a=$.H(a,$.H({},$.54,a));p b=a.40;l(a.41=="2S"){l(d[b]){d[b].2S()}8(d[b]=c.1Q(6,T))}8 c.1Q(6,T)}})(2v);(7($){$.P({3g:\'3F\',4B:\'3E\'},7(b,a){$.1E.37[a]={53:7(){l($.3H.4r)8 I;6.50(b,$.1E.37[a].2N,w)},4Z:7(){l($.3H.4r)8 I;6.4Y(b,$.1E.37[a].2N,w)},2N:7(e){T[0]=$.1E.2L(e);T[0].1A=a;8 $.1E.2m.1Q(6,T)}}});$.H($.2O,{1C:7(d,e,c){8 6.2J(d,7(a){p b=$(a.3G);l(b.2Z(e)){8 c.1Q(b,T)}})},4X:7(a,b){8 6.2H(a,[$.1E.2L({1A:a,3G:b})])}})})(2v);',62,389,'||||||this|function|return|||||||||||||if||||var|settings||||name|validator|true|uD7FF|u00A0||uFDF0|uFFEF|uFDCF||uF900|length|messages|extend|false|valid|optional|element|form|Please|enter|each|for|errorList|delete|arguments|currentForm|in|format|_|method|value||call|toHide|elements|required|test|else|data|maxlength|errorClass|pendingRequest|case|submitted|validate|add|rules|invalid|typeof|pending|message|successList|formSubmitted|showErrors|filter|toShow|attr|trim|remote|number|string|date|url|errorMap|max|metadata|minlength|type|input|delegate|checkable|event|min|success|console|email|classRuleSettings|errorsFor|unhighlight|getLength|normalizeRule|split|replace|apply|not|dependency|methods|digits|submitButton|da|x09|addClass|mismatch|undefined|reset|switch|submit|debug||validClass|currentElements|check|constructor|push|select|creditcard|groups|new|findByName|objectLength|focusInvalid|range|rangelength|x20|parameters|handle|equalTo|previousValue|bEven|dateISO|labelContainer|containers|depends|wrapper|jQuery|removeClass|defaultMessage|hide|errors|errorLabelContainer|resetForm|errorElement|staticRules|prepareElement|clean|prepareForm|triggerHandler|dependTypes|bind|break|fix|val|handler|fn|addWrapper|Number|ajax|abort|hideErrors|rulesCache|x0d|characters|than|window|is|param|old|idOrName|defaults|showLabel|submitHandler|theregex|special|highlight|meta|cancelSubmit|click|formatAndAdd|map|lastActive|catch|focus|findLastActive|ignore|button|toLowerCase|errorContainer|defaultShowErrors|grep|selected|error|numberOfInvalids|find|RegExp|checkForm|onsubmit|nothing|invalidHandler|Array|option|checkbox|remove|radio|text|makeArray|focusout|focusin|target|browser|init|autoCreateRanges|equal|or|x0c|size|try|x0b|ignoreTitle|x01|x0a|x22|attributeRules|between|classRules|no|metadataRules|x7f|port|mode|normalizeRules|originalMessage|accept|and|isFunction|the|to|addClassRules|numberDE|dateDE|stopRequest|startRequest|depend|nodeName|null|errorPlacement|errorContext|html|generated|checked|invalidElements|show|validElements|parent|field|msie|strong|findDefined|String|parentNode|customMessage|customMetaMessage|lastElement|id|on|blur|log|continue|onfocusout|removeAttrs|cancel|assigned|has|blockFocusCleanup|disabled|image|focusCleanup|can|onfocusin|visible|label|slice|textarea|file|password|unshift|keyup|triggerEvent|removeEventListener|teardown|addEventListener|appendTo|warn|setup|ajaxSettings|valueCache|unbind|gif|jpe|png|parseInt|prototype|charAt|greater|Invalid|unchecked|uF8FF|uE000|filled|ftp|less|https|x7e|x5d|x5b|blank|long|x1f|expr|x0e|x08|hidden|least|at|more|json|dataType|extension|with|x21|x23|default|addMethod|again|same|524288|2147483647|class|card|preventDefault|credit|only|boolean|ISO|NaN|Date|getElementsByName|document|insertAfter|URL|append|wrap|address|This|match|defined|No|setDefaults|Warning|returning|title|onclick|throw|onkeyup|removeAttr|checking|when|occured|exception'.split('|'),0,{}))// Define Array.indexOf for browsers that don't implements this
if (!Array.prototype.indexOf) {
	Array.prototype.indexOf = function(val, fromIndex) {
		if (typeof(fromIndex) != 'number') fromIndex = 0;
		for (var index = fromIndex,len = this.length; index < len; index++)
			if (this[index] == val) return index;
		return -1;
	};
}
// Fix IE6 background image flicker.
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {};
// create the mam namespace if it does not already exist
if(mam == undefined) var mam = {};
/*******************************************************************************
* mam.config
*******************************************************************************/
mam.config = new function() {
	// Public Methods - this is the API (these are infact Priviledged Methods as they have access to private members)
	jQuery.extend(this,  { // use the jQuery extend function to add methods to the current object (this)
		version: "1.0",
		getControlXml: function() {
			return controlXml;
		},
		getSiteConfigXml: function() {
			return siteConfigXml;
		},
		getSiteNavJson: function() {
			return siteNavJson;
		},
		getSiteSelectorXml: function() {
			return siteSelectorXml;
		},
		initialize: function(callback, parms) {
			if(!parms) {
				parms = {
					controlXml: true,
					siteConfigXml: true,
					siteNavJson: true,
					siteSelectorXml: false
				}
			}
			if(controlXml == undefined && parms.controlXml && loading["controlXml"] == false) initControlXml();
			if(siteConfigXml == undefined && parms.siteConfigXml) initSiteConfigXml();
			if(siteNavJson == undefined && parms.siteNavJson) initSiteNavJson();
			if(siteSelectorXml == undefined && parms.siteSelectorXml) initSiteSelectorXml();
            queue[queue.length] =  function () {$(document).trigger('configLoaded');};
			queue[queue.length] = callback;
			if(activeLoads == 0) {
				process();
			}
		},
		setControlXmlPath: function(path) {
			controlXmlPath = path;
		},
		setSiteSelectorXmlPath: function(path) {
			siteSelectorPath = path;
		}
	});
    
    // Load xml configuration files first
    //$.ajaxSetup({async:true, global:true, dataType:'html'});
    
	var controlXml = undefined; // internal variable to hold the control xml
	var siteConfigXml = undefined; // internal variable to hold the site config xml
	var siteNavJson = undefined; // internal variable to hold the site nav json
	var siteSelectorXml = undefined; // internal variable to hold the site selector xml
	
	var controlXmlPath = "/control/control.xml"; // path to load the control xml from
							// Note: site config xml path is determined held in the control xml
	var siteSelectorPath = "/control/site-selector.xml"; // path to load the site selector xml from
	
	var queue = []; // queue of functions to be executed on completion of initialisation
	var queues = []; // array of queues for syncronizing dependent config
	var blocking = []; // array to hold the blocking state of the above queues
	var loading = {controlXml: false, siteConfigXml: false, siteNavJson: false}; // array to hold the loading state of a particular config. Used when there is a dependency. 
				// A dependent canfig loader can check whether the config it depends on is currently being loaded before it decides to load it itself
	var timeout = []; // array of timeouts
	var activeLoads = 0; // variable to hold the numbver of loads currently active. Subsequent processing must wait until activeLoads = 0
	var loadID = 0; // Load ID assigned to each load. Used to identify metadata relating to the load such as its timeout process
	var queueIds = ["default", "controlXml"]; // registered syncronization queues
	for(var i=0; i<queueIds.length; i++) {
		queues[queueIds[i]] = [];
	}
	var asyncTimeout = 10; // seconds for async timeout
	var debug = false;
	
	// Private Methods
	var initControlXml = function() {
		loading["controlXml"] = true;
		var loadID = registerLoad();
		synchronize(function() {
			stop("controlXml");
			$.get(controlXmlPath,function(xml) {
				controlXml = xml;
				loading["controlXml"] = false;
				start("controlXml");
				loadComplete(loadID);
			});
		}, "controlXml");
	};
	var initSiteConfigXml = function() {
		if(controlXml == undefined && loading["controlXml"] == false) initControlXml();
		if(siteConfigXml == undefined && loading["siteConfigXml"] == false) { // do not load if alredy queued or loading
			loading["siteConfigXml"] = true;
			var loadID = registerLoad();
			synchronize(function() {
				stop("controlXml");
				$.get(mam.util.path.getSiteConfigPath(),function(xml) {
					siteConfigXml = xml;
					loading["siteConfigXml"] = false;
					start("controlXml");
					loadComplete(loadID);
				});
			}, "controlXml");
		}
	};
	var initSiteNavJson = function() {
		if(controlXml == undefined && loading["controlXml"] == false) initControlXml();
		if(siteNavJson == undefined && loading["siteNavJson"] == false) { // do not load if alredy queued or loading
			loading["siteNavJson"] = true;
			var loadID = registerLoad();
			synchronize(function() {
				stop("controlXml");
                var src;
                
                var referer = document.referrer;
                
                if (referer != null || referer != undefined || referer != '')
                    src = referer;
                

                var urlPath =  mam.util.env.getCurrentHost();
                
                document.a = mam.util.path.getSiteNavJson();

				$.getJSON(mam.util.path.getSiteNavJson(urlPath),function(json){ 
					siteNavJson = json;
					loading["siteNavJson"] = false;
					start("controlXml");
					loadComplete(loadID);
				});
			}, "controlXml");
		}
	};
	var initSiteSelectorXml = function() {
		var loadID = registerLoad();
		$.get(siteSelectorPath,function(xml) {
			siteSelectorXml = xml;
			loadComplete(loadID);
		});
	};
	var synchronize = function(callback, id) {
		if(!id) id = "default";
		queues[id][queues[id].length] = callback;
		printDebug("synchronize");
		if(!blocking[id]) {
			processQueue(id);
		}
	};
	var stop = function(id) {
		if(!id) id = "default";
		blocking[id] = true;
		timeout[id] = setTimeout(function(){start(id);}, asyncTimeout * 1000);
		printDebug("stop");
	};
	var start = function(id) {
		if(!id) id = "default";
		if(timeout[id])
			clearTimeout(timeout[id]);
		blocking[id] = false;
		printDebug("start");
		processQueue(id);
	};
	var process = function(id) {
		if(!id) id = "default";
		while(queue.length && activeLoads == 0) {
			var call = queue[0];
			queue = queue.slice(1);
			call();
		}
	};
	var processQueue = function(id) {
		if(!id) id = "default";
		while(queues[id].length && !blocking[id]) {
			printDebug("process");
			var call = queues[id][0];
			queues[id] = queues[id].slice(1);
			call();
		}
	};
	var registerLoad = function() {
		activeLoads++;
		var loadID = getNextLoadID();
		timeout[loadID] = setTimeout(function(){loadComplete(loadID);}, asyncTimeout * 1000);
		return loadID
	};
	var loadComplete = function(loadID) {
		if(timeout[loadID])
			clearTimeout(timeout[loadID]);
		activeLoads--;
		process();
	};
	var getNextLoadID = function() {
		return loadID++;
	};
	var printDebug = function(caller) {
		if(this.debug) {
			for(var i=0; i<this.queueIds.length; i++) {
				$("#debug").append(caller+": queue id: "+this.queueIds[i]+" queue length: "+this.queues[this.queueIds[i]].length+" blocking: "+this.blocking[this.queueIds[i]]+"<br/>");
			}
			$("#debug").append("<br/>");
		}
	};
};
/*******************************************************************************
* mam.nav
*******************************************************************************/
mam.nav = new function() {
	// Public Methods
	jQuery.extend(this,  {
		version: "1.0",
		load: function(func) {
			var navItems = $("#primary_nav > LI").length;
			// Ignore first nav item
			for (var i = 1; i < navItems ; i++ ) {
				var marginLeft = 0;
				$("#primary_nav >  LI:lt(" + i + ")").each(function() {
					var margin = parseInt($(this).css('margin-right'));
					marginLeft += $(this).width() + margin ;
				});
			
				$("#primary_nav > LI:eq(" +  i   + ") > UL").each(function() {
					$(this).css('padding-left', marginLeft);
				});
			}
			//$("#site-nav ul li").show();

			addNavBehaviour();
			setActive();
			if(func) func();
		},
		isActive: function(href) {
			return isActive(href);
		}
	});
	// Private Methods
	var behaviours = {
		behaviour_01: function() {
			$("#site-nav > ul > li").hover(function(){
				if(!isActive($(this).find('a').attr('href'))) {
					$(this).find('ul').show();
					$("li.active").find("ul").hide();
				}
			},function(){
				$(this).find('ul').hide();
				$("li.active").find("ul").show();	
			});
		}
	};
	var addNavBehaviour = behaviours["behaviour_01"]; // hover behaviour for level 1 nav
	var showNavElements = function(xml) {
		$("module", xml).each(
			function(i) {
				$("#site-nav ul li#"+this.getAttribute("id")+"-nav").show();
			}
		);
	};
	
	var showNavElementsSorted = function(displayArrayItems) {
		$(displayArrayItems).each(
			function(i) {
				//alert($("#site-nav ul li#"+this-1[1]+"-nav") + " -- " + $("#site-nav ul li#"+this-1[1]+"-nav"));
				$("#site-nav ul li#"+this[1]+"-nav").after( $("#site-nav ul li#"+this-1[1]+"-nav") ).show();
			}
		);
	};
	
	var isActive = function(href) {

		var path = getPath(href);
		// remove page name i.e. everything after final slash
		path = path.substring(0, path.lastIndexOf("/"));
		//alert(path);
		// alert(getCurrentPath());
		if(path == "") return false; // assume external link ie. www.bbc.co.uk Need to find a better solution to this.

		return (getCurrentPath().indexOf(path) > -1);
	};
	var getCurrentPath = function() {
		var path;
		if(mam.util.env.isTeamsite()) {
			path = document.location.pathname;
			path = path.replace(mam.util.env.getCurrentHost(), "");
			for(var i=0; i<3; i++) { // remove workarea and branch
				path = path.substring(path.indexOf("/") + 1);
				// alert("i: "+i+" Path: "+path);
			}
			path = "/" + path // prepend slash
		} else {
			path = document.location.pathname;
		}
		// alert("getCurrentPath: "+path);
		return path;
	};
	var getPath = function(href) {
			var path = href;
			if(href.indexOf('http') == 0) {
				for(var i=0; i<3; i++) { // remove everything up to the 3rd slash - this removes protocol, authority and port
					path = path.substring(path.indexOf("/") + 1);
				};
				path = "/" + path; // prepend slash
			}
			// alert("getPath: "+path);
			return path;
	};
	var setActive = function() {
		var setLevelActive = function(context, callbacks) {

            var bActive = false;
			if($("> ul > li", context).size() == 0) return;
			$("> ul > li", context).each(function() {

				if(isActive($("> a", this).get(0).href)) {
					$(this).addClass("active");
                    $(this).addClass("msieFix");
					//console.log ($(this).get(0));
                    
                    $("> a", this).addClass('selected');
                    $("> ul > li", this).each(function() {
						if(isActive($("> a", this).get(0).href)) {
                            bActive = true;
							$('a:first',this).addClass('selected');
							
						}
					});
                    
                    //if (!bActive)
                    //    document.location.replace($("> ul > li > a:first", this).get(0).href);
                    
					var callback = callbacks[callbacks.length - 1]; // execute callback at the top of the stack
					if(typeof callback == "function") callback(this);
					callbacks.pop(); // remove callback from the top of the stack
					setLevelActive(this, callbacks); // recursively calls itself until all levels have been processed
				}
			});
		};
		var callbacks = []; // array of callback functions starting with the lowest level (acts as a stack i.e. level 1 is at the top of the stack)
		//callbacks[callbacks.length] = function(that) {$("../..", that).removeClass("active");}; // level 3
		//callbacks[callbacks.length] = function(that) {$("> ul", that).slideDown("slow");}; // level 2
		//callbacks[callbacks.length] = function(that) {$("> ul", that).slideDown("slow");}; // level 1
		setLevelActive($("#site-nav"), callbacks); // Call set active with the site nav div as the context
	};
};

// Core and Utility nav initialisation
$(document).ready(function(){
    
	// Set active nav element
	$("#header_links ul a").each(function(){
        
		if(jQuery.trim($(this).attr('href')) != "#" && mam.nav.isActive(this.href)) $(this).addClass("selected");
	});


    if(mam.util.env.getEnv() !=  'prod') {
            mam.config.initialize(function(){
                var url = mam.util.url.constructURL({host: mam.util.path.getSiteHostById('default') ,
                pathname: '/'});
                $("#header_links > UL > LI:first > A").attr('href', url);
                $("#header_left A").attr('href', url);
        },{controlXml: true});
    } 

    
	$("#utility-nav ul a").each(function(){
		if(mam.nav.isActive(this.href)) $(this).addClass("active");
	});
    
    
    //if (mam.util.env.isTeamsite()) {
        //$("#header_links ul a").each(function(){
       // $("#sitemap").empty().load(mam.util.path.getSitePath() + "/sitemap/content/sitemap.html");
       // });
    //}
/*
    $("#right_copy > UL > LI:first > A").click(function(){
		// if(mam.nav.isActive(this.href)) $(this).addClass("active");
		//alert("Size: "+$("#sitemap").size()+"\nDisplay: "+$("#sitemap").css("display")+"\nVisible: "+$("#sitemap:visible").size());
        $("#sitemap").slideToggle("slow");
        return false;
	});
*/

    $(".filter_site").hide();

    mam.config.initialize(function(){
        $("." + mam.util.site.getSiteId() + "_item").show();
	if($('#tl-container').size() > 0) {
        
		$('#tl-container > ul > li').each(function() {
			if($(this).is(':visible')) {
				
				$(this).addClass('ui-tabs-selected');
				$(this).addClass('ui-state-active'); 
                return;
			}

		});

        $('#tl-container').tabs({fxAutoHeight: true });
	}
    },{controlXml: true});
    


});
/*******************************************************************************
* mam.page
*******************************************************************************/
// create the mam namespace if it does not already exist
if(mam == undefined) var mam = {};
mam.page = {
	version: "1.0",
	clearLogo: function() {
		$("#logo").html("");
	},
	clearTitle: function() {
		document.title = "";
	},
  	loadContent: function(id) {
	var path;
     path = mam.util.dom.getElementsByAttribute($("content pages page", mam.config.getSiteConfigXml()), "id", id).get(0).getAttribute("path");
	   $("#"+id).load(path, function() {
			   $("*").hover(function(){ $(this).addClass("over"); },function(){ $(this).removeClass("over"); }); // fix ie hover bug
	   });
	},
	loadQuickLinks: function() {
		//alert("load quick links...")
		$("#left-column").prepend("<div id=\"quickLinks\"></div>");
		$("#quickLinks").load(mam.util.path.getSitePath()+"/quick_links.html", function() {
			if($("#quickLinks ul li").size() > 0) { $("#quickLinks").show();}
			else {
				$("#quickLinks").hide();
			}
		});
	},
	loadStyleSheet: function() {
		var css;
		if(mam.config.getSiteConfigXml() != undefined) {
			css = $("css", mam.config.getSiteConfigXml()).text();
			// only works in FF. Need to find a way of doing this cross browser
			if(css != undefined && css != "") $("head").append('<link rel="stylesheet" type="text/css" href="'+css+'" media="all"/>'); // ff
		}
	},
	loadHeadings: function() {
        
		//$(".siteID").jQIR("gif", "/core/library/images/");
		// $("h2").jQIR("gif", "/core/library/images/headings/h2/");
		// $("h3").jQIR("gif", "/core/library/images/headings/h3/");
		//$("h1").jQIR("jpg", "/core/library/images/headings/h1/");
		// $("h2").jQIR("jpg", "/core/library/images/headings/h2/");
		// $("h3").jQIR("jpg", "/core/library/images/headings/h3/");
	},
	loadLeftColumn: function(parms) {
		var o = {};
		jQuery.extend(o, parms);
		if(o.title == undefined) {o.title = o.alt;}
		if(mam.util.env.isDefaultHost()) {
			var img = $("<img>");
			$(img).attr(
			{
				src: o.src,
				alt: o.alt,
				title:  o.title
			});
			// $("#left-column").empty();
			/* Do not load the default image
			if(o.src != undefined && o.src != "") {$("#left-column").append(img);}
			*/
		} else {
			mam.nav.load();
		}
	},
	loadPage: function(parms) {
		// Set Default cookie if they have not come from the hub
		mam.hub.setDefaultCookie();
        
        mam.hub.pageHandler();

		var o = {
			title: "",
			separator: " - "
		};
		jQuery.extend(o, parms);
		mam.config.initialize(function(){

             mam.page.loadStyleSheet();
                        
			$(document).ready(function(){
				//mam.page.loadLeftColumn(o.leftColumnImg);
                mam.hub.siteCookieHandler();
                mam.nav.load();
                
                $('#site-nav').bind('updated', function () { 
                    mam.nav.load();
                    mam.page.processCoreNSecondaryLinks();
                }); 
            
                
				mam.page.setTitle(o);
				// mam.page.setLogo();
				mam.page.loadHeadings();
				$("*").hover(function(){ $(this).addClass("over"); },function(){ $(this).removeClass("over"); }); // fix ie hover bug

                /*$('#sitemap').bind('updated', function () { 
                    mam.page.processCoreNSecondaryLinks();
                });*/ 
                
			});
		},{controlXml: true,siteConfigXml: true, siteNavJson: true});
	},
	setLogo: function() {
		var alt, logo, src, title;
		if(mam.config.getSiteConfigXml() != undefined) {
			this.clearLogo();
			alt = $("logo alt", mam.config.getSiteConfigXml()).text();
			src = $("logo src", mam.config.getSiteConfigXml()).text();
			title = $("logo title", mam.config.getSiteConfigXml()).text();
			$("#logo").html("<img src=\""+src+"\" alt=\""+alt+"\" title=\""+title+"\"/>");
			$("#logo img").show();
		}
	},
	setTitle: function(parms) {
		var title;
		if(mam.config.getSiteConfigXml() != undefined) {
			title = $("site-name", mam.config.getSiteConfigXml()).text() + parms.separator + parms.title;
			document.title = title;
		}
	},
    processCoreNSecondaryLinks: function () {
        
        if(!mam.util.env.isTeamsite()) return;
        
            $("A").each(function() {
            
             var re = /(http\:\/\/(.[^\/]+))?(.*)/;
            
             var url = $(this).attr('href');
              
             var matches = re.exec(url);
             
             url = (matches[3] == undefined ? url : matches[3]);
            
             if (url != undefined && url != null && (url.indexOf("/core/") == 0 ||
                 url.indexOf("/secondary/") == 0)) {
                
                $(this).attr("href", mam.util.path.getSitePath() + url);
            
             }    
        });
    }
};

/*******************************************************************************
* mam.popups
*******************************************************************************/
mam.popups = {};
mam.popups.pdflink = function() { 
	var l = $(this).attr('href');
	var ext = l.replace(/.*\.(.*)$/, "$1");
	if(ext == 'pdf') {
		window.open(l);
		return false;
	}
};
$("document").ready(function(){
	$(".popup").click(function(){
		var theWindow = window.open(this.href);
		theWindow.focus();
		return false;
	});
	
	$("a").click(mam.popups.pdflink);

});

/*******************************************************************************
* mam.util
*******************************************************************************/
// create the mam namespace if it does not already exist
if(mam == undefined) var mam = {};
mam.util = {};
mam.util.version = "1.0";

// mam.util.dom
mam.util.dom = {};
mam.util.dom.filterSelect = function(values, selectElement) {
	for(var i=0; i<selectElement.options.length; i++) {
		var remove = true;
		values.each(function() {
			if(this.getAttribute("id") == selectElement.options[i].value || selectElement.options[i].value == "") remove = false; 
		});
		if(remove) {
			// alert("remove "+selectElement.options[i].value);
			selectElement.remove(i);
			i--;
		}
	};
};
mam.util.dom.getAbsoluteLeft = function(o) {
	// Get an object left position from the upper left viewport corner
	// o = document.getElementById(objectId)
	oLeft = o.offsetLeft;            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent;    // Get parent object reference
		oLeft += oParent.offsetLeft; // Add parent left position
		o = oParent;
	}
	return oLeft;
};
mam.util.dom.getAbsoluteTop = function(o) {
	// Get an object top position from the upper left viewport corner
	// o = document.getElementById(objectId)
	oTop = o.offsetTop;            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent;  // Get parent object reference
		oTop += oParent.offsetTop;// Add parent top position
		o = oParent;
	}
	return oTop;
};
mam.util.dom.getElementsByAttribute = function(inputElements, attributeName, attributeValue) {
	var elements = [];
	inputElements.each(function() {
		if(this.getAttribute(attributeName) == attributeValue) {
			elements[elements.length] = this;
		}
	});
	return $(elements);
};
mam.util.dom.initSelect = function(options, selectElement) {
	selectElement.options.length = 0;
	options.each(function(i) {
		selectElement.options[i] = new Option($(this).text(), this.getAttribute("id"), false, false);
	});
};

mam.util.dom.processCoreAndSecondaryLinks = function () {

    $("A").each(function() {
    
         var url = $(this).attr('href');
        
         if (url.indexOf("/core/") == 0 ||
             url.indexOf("/secondary/") == 0) {
        
            $(this).attr("href", mam.util.path.getSitePath() + url);
        
         }
    
    });

};

// mam.util.env
mam.util.env = new function() {
	var defaultHosts = {
		teamsite: "/iw-mount/default/main/newton_suite",  //"/iw-mount/default/main/mgi_suite/core",
		localhost: "localhost:8080",
		dev: "ebd01.lon.mellonbank.com:30339",
		test: "refresh.newton.test.mellon.com",
		qa: "refresh.newton.qa.mellon.com",
        tpc:"newton-tpc.bnymellon.com",
		prod2:"www.newtoncapitalmanagement.com",
		prod: "www.newton.co.uk"
	};
	
    /*
    this.getCurrentHost = function() {
		var host;
		host = window.location.host;
		// alert("getCurrentHost: "+host);
		return host;
	};*/
    
	this.getCurrentHost = function(url) {

    var host = "";
    var src = (url == undefined ? document.location.href : url);
    var sitePath = "";
    var re  = /(.*)\/sites\/([^/]+)\//; 
    
    var data_parts = re.exec(src);
    
    if (data_parts && data_parts.length > 2) 
        sitePath = "/sites/" + data_parts[2];
    
    sitePath = "";
    
    host = window.location.host + sitePath ;

    return host;
         
	};
	this.getCurrentHostTeamsite = function() {
		var host;
		host = window.location.pathname;
		// strip /WORKAREA and everything after
		if(host.indexOf("/WORKAREA") > -1) host = host.substring(0,host.indexOf("/WORKAREA"));
		if(host.indexOf("/STAGING") > -1) host = host.substring(0,host.indexOf("/STAGING"));
		if(host.indexOf("/EDITION") > -1) host = host.substring(0,host.indexOf("/EDITION"));
		// alert("getCurrentHost: "+host);
		return host;
	};
	this.getDefaultHost = function(env) {
		if(env == undefined) env = this.getEnv();
		//alert("getDefaultHost: "+defaultHosts[env]);
		return defaultHosts[env];
	};

	this.getEnv = function() {
		var env;
		var hostname = window.location.hostname;
		if (hostname.indexOf("localhost") > -1 || hostname.indexOf("xpwmebs110328") > -1 ) {
			env = "localhost";
		} else if (hostname.indexOf("ebd01") > -1 || hostname.indexOf("snsebd02") > -1) {
			env = "dev";
		} else if (hostname.indexOf("test.mellon") > -1 ) {
			env = "test";
		} else if (hostname.indexOf("sn84") > -1 ) {
			env = "qa";
		} else if (hostname.indexOf("qa.mellon") > -1 ) {
			env = "qa";
		} else if (hostname.indexOf("newton-tpc") > -1 ) {
			env = "tpc";
		} else if (hostname.indexOf("www.newtoncapitalmanagement.com") > -1 ) {
			env = "prod2";
		} else if (hostname.indexOf("sn83") > -1 ) {
			env = "prod";
		} else {
			env = "prod";
		}
		// alert("getEnv: "+env);
		return env;
	};
	this.getEnvTeamsite = function() {
		var env = "teamsite";
		// alert("getEnvTeamsite: "+env);
		return env;
	};
    /*
	this.isDefaultHost = function(host) {
		if(host == undefined) host = this.getCurrentHost();
		for(var n in defaultHosts) {
			if(host == defaultHosts[n]) return true;
		}
		return false;
	};*/
    
	this.isDefaultHost = function(host) {
        
        
        var isDefaultHost = false;
        

		if(host == undefined) host = this.getCurrentHost();
        
        
        if (mam.util.site.getSiteId() == 'default')
            return true;
        else
            return false;
        
        	$("site", mam.config.getControlXml()).each(function() {

        var currentSiteId = $(this).attr("id");
		var currentSitePath = $("path", this).text();

         if (mam.util.site.getSiteId() == "default" ) {

             
             isDefaultHost = true;
			return;
		}
       
	});
		return isDefaultHost;
	};
	this.isTeamsite = function(hostname, port) {
		if(hostname == undefined) {
			hostname = window.location.hostname;
			port = window.location.port;
		}
		// alert("hostname: "+hostname+"\nport: "+port);
		if ((hostname.indexOf("ebd01") > -1 && port == "91") || (hostname.indexOf("sn84") > -1 ) || (hostname.indexOf("sn83") > -1 )) {
			return true;
		} else {
			return false;
		}
	};
};

// mam.util.path
mam.util.path = {};
mam.util.path.getSitePath = function() {
	var host, sitePath =  mam.util.path.getSitePathById("default");
	host = mam.util.env.getCurrentHost();
	//alert(host);
	$("site", mam.config.getControlXml()).each(function() {
		// alert($("path", this).text());
		var currentSitePath = $("path", this).text();
		if(mam.util.dom.getElementsByAttribute($("host", this), "name", host).size() > 0) {
			sitePath = currentSitePath;
		}
	});
	return sitePath;
};
mam.util.path.getSitePath = function(url) {
	var host, sitePath =  mam.util.path.getSitePathById("default"); // jd3
	host = (url == undefined || url == ''  ? mam.util.env.getCurrentHost() : url);
	$("site", mam.config.getControlXml()).each(function() {
		var currentSitePath = $("path", this).text();
		if(mam.util.dom.getElementsByAttribute($("host", this), "name", host).size() > 0) {
			sitePath = currentSitePath;
		}
	});
	return sitePath;
};
mam.util.path.getSitePathById = function(siteId) {
	var host, sitePath = "/sites/default_site";
	host = (siteId == undefined ? mam.util.env.getCurrentHost() : siteId) ;
	//alert(host);
	$("site", mam.config.getControlXml()).each(function() {
		// alert($("path", this).text());
		var currentSiteId = $(this).attr("id");
        var currentSitePath = $("path", this).text();
		if(currentSiteId == siteId) {
			sitePath = currentSitePath;
            return;
		}
	});
	return sitePath;
};

mam.util.path.getSiteHostById = function(pSiteId) {
	var host, sitePath = "/sites/default_site";
    var siteId = (pSiteId == undefined ? 'default' : pSiteId);

	$("site", mam.config.getControlXml()).each(function() {

		var currentSiteId = $(this).attr("id");

		if(currentSiteId == siteId) {
			//host = $("host[@env='" + mam.util.env.getEnv() + "']", this).attr('name');
			host = $("host[env='" + mam.util.env.getEnv() + "']", this).attr('name');
            return;
		}
	});
    
	return host;
};

mam.util.path.getSiteConfigPath = function(url) {
    
    var src = (url != undefined ? url : undefined);
    
	return mam.util.path.getSitePath(src)+"/site-config.xml";
};
mam.util.path.getSiteNavJson = function(url) {
  
    var src = (url != undefined ? url : undefined);

	return mam.util.path.getSitePath(src)+"/site-config.js";
};
mam.util.path.getSiteNavPath = function() {
	return mam.util.path.getSitePath()+"/nav.html";
};

mam.util.path.getSiteImportantInfoPath = function(url) {
    
    var src = (url != undefined ? url : undefined);
	return mam.util.path.getSitePath(src)+"/important_information/important_information_site.html";
};

mam.util.path.getCoreDirectoryName = function() {
	// Return the name of the core directory to be used in the page based on the page's language
	var coreDirectoryName = "core";
	var lang = mam.util.i18n.getLanguage();
	var languageCores = {
		en: "core",
		es: "core_esp",
		fr: "core_fr",
		it: "core_ita",
		'en-us': "core_eng-us"
	};
	if(lang in languageCores) coreDirectoryName = languageCores[lang];
	// alert(coreDirectoryName);
	return coreDirectoryName;
};

mam.util.i18n = {};
mam.util.i18n.getLanguage = function() {
	var lang = $("html").attr("lang");
	// alert("Language: "+lang);
	return lang;
};


// mam.util.site
mam.util.site = {};

/*
mam.util.site.getSiteId = function() {
	var host, siteId = "default";
	host = mam.util.env.getCurrentHost();
	$("site", mam.config.getControlXml()).each(function() {
		var currentSiteId = $(this).attr("id");
        var sitePath = $("path", this).text();

		if(mam.util.dom.getElementsByAttribute($("host", this), "name", host).size() > 0 &&
        location.pathname.indexOf(sitePath) == 0) 
         siteId = currentSiteId;
        
	});
	return siteId;
};*/
mam.util.site.getSiteId = function() {
	var host, siteId = "default";
	host = mam.util.env.getCurrentHost();
	$("site", mam.config.getControlXml()).each(function() {
		var currentSiteId = $(this).attr("id");
        var sitePath = $("path", this).text();

		if(mam.util.dom.getElementsByAttribute($("host", this), "name", host).size() > 0 &&
        host == mam.util.dom.getElementsByAttribute($("host", this), "name", host).attr("name")) 
         siteId = currentSiteId;
        
	});
	return siteId;
};
mam.util.site.getDefaultLocation = function() {
	var siteId = mam.util.site.getSiteId();
	var text = $("defaults location", mam.util.dom.getElementsByAttribute($("site", mam.config.getControlXml()), "id", siteId)).text();
	// alert("mam.util.site.getDefaultLocation:: returning ["+text+"]");
	return text;
};
mam.util.site.getDefaultInvestorType = function() {
	var siteId = mam.util.site.getSiteId();
	var text = $("defaults investor-type", mam.util.dom.getElementsByAttribute($("site", mam.config.getControlXml()), "id", siteId)).text();
	// alert("mam.util.site.getDefaultInvestorType:: returning ["+text+"]");
	return text;
};


// mam.util.url
mam.util.url = {};
mam.util.url.getPath = function() {
	return document.location.pathname;
};
mam.util.url.getPathTeamsite = function() {
	var pathname = document.location.pathname;
	// strip everything up to the end of /WORKAREA
	if(pathname.indexOf("/WORKAREA") > -1) pathname = pathname.substring(pathname.indexOf("/WORKAREA") + 9);
	if(pathname.indexOf("/STAGING") > -1) pathname = pathname.substring(pathname.indexOf("/STAGING") + 9);
	if(pathname.indexOf("/EDITION") > -1) pathname = pathname.substring(pathname.indexOf("/EDITION") + 9);

	// remove everything preceding the second / (remove the workarea name)
	pathname = pathname.substring(pathname.indexOf("/") + 1);
	pathname = pathname.substring(pathname.indexOf("/"));
	
	return pathname;
};
mam.util.url.constructURL = function(p) {
	var url;
	var parms = {
			host: "",
			pathname: document.location.pathname
	}; // defaults 
	jQuery.extend(parms, p);
	// alert("constructURL: parms.host = "+parms.host);
	if(parms.host && parms.host != "") {
		url = document.location.protocol+"//"+parms.host + parms.pathname;
	} else {
		url = parms.pathname;
	}
	// append query string
	if(parms.query != undefined && parms.query != "") url += "?"+parms.query;
	// alert("constructURL: "+url);
	return url;
};
mam.util.url.constructURLTeamsite = function(p) {
	var branch, workarea, url;
	var parms = {
			host: "",
			pathname: document.location.pathname
	}; // defaults 
	jQuery.extend(parms, p);
	if(parms.workarea == undefined)	{
		workarea = parms.host.substr(parms.host.lastIndexOf("/"));
		if(document.location.pathname.indexOf("WORKAREA/import/") > -1) workarea = "/import" // check if we are in import
	} else {
		workarea = parms.workarea;
	}
	if(parms.branch == undefined) {
		if(document.location.pathname.indexOf("WORKAREA") > -1) branch = "/WORKAREA";
		if(document.location.pathname.indexOf("STAGING") > -1) branch = "/STAGING";
		if(document.location.pathname.indexOf("EDITION") > -1) branch = "/EDITION";
	} else {
		branch = parms.branch;
	}
	// alert("constructURL: parms.host = "+parms.host);
	if(parms.host && parms.host != "") {
		url = parms.host + branch + workarea + parms.pathname;
	} else {
		url = parms.pathname;
	}
	// If the url is external, do not prepend the teamsite stuff
	// alert(parms.external);
	if(parms.external == true) {
		url = document.location.protocol+"//"+parms.host + parms.pathname;
	}
	// append query string
	if(parms.query != undefined && parms.query != "") url += "?"+parms.query;
	// alert("constructURL: "+url);
	return url;
};
mam.util.url.forward = function(p) {
	var parms = {
		url: document.location.href,
		preserveHistory: false,
		test: false
	}; // defaults 
	jQuery.extend(parms, p);
	if(parms.test) return parms.url;
    
    // alert(parms.url);
    
	if(parms.preserveHistory) {
		document.location.href = parms.url;
	} else {
		document.location.replace(parms.url);
	}
};

mam.util.setHTML = function  (container, o) {
    
       
     mam.config.initialize(function(){
   
        if (typeof(o) == "string") {
        
            var domain =  mam.util.path.getSiteHostById(mam.util.site.getSiteId());
            var sitePath = mam.util.path.getSitePath();
            sitePath = ( domain.indexOf(sitePath) > - 1 && !mam.util.env.isTeamsite()  ? ''  : sitePath ) ;
            
            var newUrl = mam.util.url.constructURL ({host:mam.util.path.getSiteHostById(mam.util.site.getSiteId()),  pathname: sitePath +'/' + o});
            
            $.get(newUrl, function(data) {
            
                data = data.replace(/<mi0.*[^/>]+\/>/ig, '');
                $('#' + container).empty().html(data);
                $('#' + container).trigger('updated');
            }
            
            );
        
        } else if (typeof(o) == "object" && typeof(o.init) == "function" ) {
            $('#' + container).text(o.init(container));
            
            if (typeof(o.callback) == "function") o.callback(container);
        
        }

		},{controlXml: true});

    
};

mam.util.getSiteNameById = function (id) {

   var siteName = '';

    var siteId =  (id == undefined ? mam.util.site.getSiteId() : id);
    
    var env = mam.util.env.getEnv();

    siteName =  $("site[id='" + siteId + "'] > site-name", mam.config.getControlXml()).text();

   return siteName;
};

mam.util.getSiteName  = {

    init:function (container) { 
        
        return mam.util.getSiteNameById(); 
        
    }
};


// inject teamsite methods if the environment is teamsite
if(mam.util.env.isTeamsite()) {
	mam.util.url.getPath = mam.util.url.getPathTeamsite; // inject teamsite version of getPath method
	mam.util.url.constructURL = mam.util.url.constructURLTeamsite; // inject teamsite version of constructURL method
	mam.util.env.getCurrentHost = mam.util.env.getCurrentHostTeamsite; // inject teamsite version of getCurrentHost method
	mam.util.env.getEnv = mam.util.env.getEnvTeamsite; // inject teamsite version of getEnv method
};


//THIS IS THE CODE THAT OPENS CERTAIN PAGES IN A NEW WINDOW I.E TRUSTEE TRAINING MICROSITE

 
$(document).ready(function() {


				$("a").click(							
					function() {
					
					    
						var host = 'http://' + window.location.host;
						var link = $(this).attr('href');
						var original_link = escape(link);
						if(link.indexOf(host) == 0) {
							link = link.substring(host.length);
						}
										
						if(link.indexOf('http://refresh.newton.qa.mellon.com/trusteetraining/') == 0) {						
							window.open('http://refresh.newton.qa.mellon.com/trusteetraining/', 'external');
						return false;
						}
						
						if(link.indexOf('http://www.newton.co.uk/trusteetraining/') == 0) {						
							window.open('http://www.newton.co.uk/trusteetraining/', 'external');
						return false;
						}
						
						if(link.indexOf('http://refresh.newton.test.mellon.com/trusteetraining/') == 0) {						
							window.open('http://refresh.newton.test.mellon.com/trusteetraining/', 'external');
						return false;
						}
						
										
						return true;
					}
				);
				
		
	

});

//EMAIL A FRIEND CODE

var doclink = "";
var header ="";
var blogheader ="";

    function emailAFriend (){

      var argv = emailAFriend.arguments;
      var argc = argv.length;

        doclink = "";
        var link = "";
        var href = "";
		var host  = window.location.protocol + "//" + window.location.host;

        if(argc == 2) {
            header=argv[1];
            var container = $(argv[0]).context.parentNode.parentNode;
            link = $(container).find("DIV.download > A.secondaryLinks ,DIV.innerList > A.secondaryLinks");
            href = $(link[0]).attr('href');
        } else  if(argc == 3 && argv[2] != null && typeof(argv[2].getLink) == "function") {
            header=argv[1];
            href = argv[2].getLink(argv[0]);
        } else {
            header=argv[0];
            link = $("UL.innerList > LI.download > A");
            href = $(link[0]).attr('href');
        }
            
        if (href.indexOf('/') == 0)
            doclink += host;
        
        doclink += href;
  
	}
    
    var getDetailedPageLink = 
    {
        getLink: function () {
            return window.document.location.href;
        }
    };
    
        
		function emailAFriendBlog (heading){		 
		doclink = window.location.protocol + "//" + window.location.host + "" + window.location.pathname;
		header=heading;		
		//alert(blogheader);					
		}
	
		function postBlog (heading){		 
		doclink = window.location.protocol + "//" + window.location.host + "" + window.location.pathname;
		header=heading;					
		}
		

//code to hide all 'Home' links on the full sitemap page

$(document).ready(function() {
		$("#full_site_map #content-body ul li.level0 a").filter(function(index) {
                 if($(this).text() == "Home"){
					$(this).parent().remove();	 
				 };
        })

}); 

//code to resize contacts link on the full sitemap page
$(document).ready(function() {
		$("#full_site_map #content-body ul li.level0 a").filter(function(index) {
                 if($(this).text() == "Contacts"){			
					$(this).parent().css({'width' : '130px'});
				 };
				 
				 if($(this).text() == "Data files"){			
					$(this).parent().css({'width' : '100px'});
				 };
				 
				  if($(this).text() == "Products and strategies"){			
					$(this).parent().css({'width' : '110px'});
				 };
				 		 			 
        })
		
});  		

// create the mam namespace if it does not already exist
if (mam == undefined) 
    var mam = {};
// requires mam.core.js
if (mam.hub == undefined) {
    mam.hub = new function(){
        var that = this;
        // Public Methods
        jQuery.extend(this, {
            version: "1.0",
            config: mam.config,
            indexHandler: function(){
            
                mam.config.initialize(function(){
                
                
                    if (!mam.util.env.isDefaultHost()) {
                        crossDomainCookieTransfer();
                    }
                    
                    forwardToHomePage();
                    
                }, {
                    controlXml: true,
                    siteConfigXml: false,
                    siteNavJson: false,
                    siteSelectorXml: false
                });
                
            },
            hubHandler: function(){
            
                mam.config.initialize(function(){
                    $(document).ready(function(){
                        buildSiteSelector();
                    });
                }, {
                    controlXml: true,
                    siteConfigXml: true,
                    siteNavJson: false,
                    siteSelectorXml: false
                });
            },
            pageHandler: function(){
            
            
                mam.config.initialize(function(){
                
                
                    if (!mam.util.env.isDefaultHost()) {
                        
                        var excludedPage = false;
                        var includedPage = false;
                        var path = mam.util.url.getPath();
                        
                        var excludedPagesRegex = ["^/$", ".*/core/.*", "/core/hub/hub.html", "/core/investments/investments.html", "/sites/hub/hub.html","/securingthefuture/index.html","/securingthefuture/index_us.html", "/sites/hub/.*", "/sites/privateclients/.*", "/sites/privateclients_ci/.*", "/sites/charities/.*", ".*/important_information/.*"];
                        var includedPagesRegex = [];
                        $.each(excludedPagesRegex, function(i, n){
                            var re = new RegExp(n);
                            if (re.test(path)) 
                                excludedPage = true;
                        });
                        $.each(includedPagesRegex, function(i, n){
                            var re = new RegExp(n);
                            if (re.test(path)) 
                                includedPage = true;
                        });
                        // alert("excludedPage:"+excludedPage+", includedPage:"+includedPage);
                        // alert(importantInfoConfirmed());
                        if (!excludedPage || includedPage) { // allow navigation to excluded pages without visiting the hub. Inclusions override exclusions
                            if (!importantInfoConfirmed()) {
                                var imptURL = "/important_information/important_information.html?referrer=" + path;
                                
                                // var pathname = mam.util.url.constructURL({host:mam.util.env.getCurrentHost(),  pathname: (mam.util.env.isTeamsite()  ? mam.util.path.getSitePath() : '' ) + imptURL});
                                var pathname = mam.util.url.constructURL({
                                    host: mam.util.env.getCurrentHost(),
                                    pathname: mam.util.path.getSitePath() + imptURL
                                });
                                
                                //$(document.body).hide();
                                jQuery.readyList = []; // Clear all listeners 
                                
                                forwardToImportantInfo({
                                    pathname: pathname
                                });
                            }
                        }
                        
                        // Call core page handler
                        var callCorePageHandler = false;
                        var regex = ["/core/mellons_boutiques/.*", "/core/specialist_asset_managers/.*"];
                        $.each(regex, function(i, n){
                            var re = new RegExp(n);
                            if (re.test(path)) 
                                callCorePageHandler = true;
                        });
                        if (callCorePageHandler) 
                            mam.hub.corePageHandler();
                        
                    }
                }, {
                    controlXml: true
                });
                
                
            },
            importantInfoHandler: function(){
                // alert("importantInfoHandler...");
                $(document).ready(function(){
                    var errorText = "You must agree to the terms and conditions.";
                    // load investor type specific text
                    if (loadCookie()) {
                    
                        // TODO: load text
                    
                        // errorText = "";
                        /*
                         var importantInformationText = getInvestorType(clientType, locations[location].investorTypes[clientType]).importantInformationText;
                         if(importantInformationText != undefined && importantInformationText != "") $("#investor-type-specfic").html(importantInformationText);
                         // Error text
                         errorText = getInvestorType(clientType, locations[location].investorTypes[clientType]).importantInformationErrorText;
                         */
                    }
                    else {
                        // Do nothing
                    }
                    
                    if (loadImportantInfoCookie()) {
                        $("#importantInformationCheckbox").get(0).checked = importantInformation.confirmed;
                    }
                    $("#go-button").click(function(){
                        $(".formError").remove(); // clear errors
                        // alert("go");
                        if ($("#importantInformationCheckbox").get(0).checked) {
                            importantInformation.confirmed = true;
                            storeImportantInfoCookie();
                            var query = window.location.search.substring(1);
                            var pArray = query.split("&");
                            var queryParms = {};
                            $.each(pArray, function(i, n){
                                var pos = n.indexOf('=');
                                if (pos > 0) {
                                    var key = n.substring(0, pos);
                                    var val = n.substring(pos + 1);
                                    queryParms[key] = val;
                                }
                            });
                            if (queryParms.referrer != undefined) {
                                forwardToPage({
                                    pathname: queryParms.referrer
                                });
                            }
                            else {
                                forwardToHomePage();
                            }
                        }
                        else {
                            clearImportantInfoCookie();
                            $("fieldset.importantInformation").append('<p class="formError">' + errorText + '</p>')
                        }
                        return false;
                    });
                });
                // load site specifc Important Infomation
                mam.config.initialize(function(){
                    $(document).ready(function(){
                        // alert(mam.util.path.getSiteImportantInfoPath());
                        $("#site-specific-important-info").load(mam.util.path.getSiteImportantInfoPath());
                    });
                }, {
                    controlXml: true
                });
            },
            corePageHandler: function(){
                if (!loadCookie() && mam.util.env.isDefaultHost()) { // Show site selector if visitor has not already chosen a site.
                    mam.config.initialize(function(){
                        $(document).ready(function(){
                            buildSiteSelector();
                        });
                    }, {
                        controlXml: true,
                        siteConfigXml: true,
                        siteSelectorXml: false
                    });
                }
            },
            siteCookieHandler: function(){
            
                var SITE_COOKIE = 'siteId';
                var site = 'default';
                
                var siteId = mam.util.site.getSiteId();
                var sitePath = mam.util.path.getSitePathById(siteId);
                var env = mam.util.env.getEnv();
                
                
                var siteUrl = $("host[env='" + env + "']", $("site[id='" + siteId + "']", mam.config.getControlXml())).attr('name');
                
                var newUrl = mam.util.url.constructURL({
                    host: siteUrl,
                    pathname: sitePath + "/"
                });
                
                newUrl = "/";
                
                var cookie = new Cookie(document, SITE_COOKIE, null, newUrl, null, false);
                
                if (cookie.load()) {
                    site = unescape(cookie.site);
                }
                else {
                    cookie.site = escape(mam.util.site.getSiteId());
                    cookie.store();
                }
                
                
            },
            getStatutoryLiteratureTags: function(){
                loadCookie();
                // alert(location);
                return getStatutoryLiteratureTags(location);
            },
            getLanguageTags: function(){
                loadCookie();
                return getLanguageTags(location);
            },
            allNonEnglishLanguageTags: function(){
                var tags = new Array();
                for (var i in locations) {
                    if (locations[i]['languageTags'] != undefined) {
                        for (var x = 0; x < locations[i]['languageTags'].length; x++) {
                            var l = locations[i]['languageTags'][x];
                            if (l.toLowerCase() != 'english') {
                                tags[tags.length] = l;
                            }
                        }
                    }
                }
                return tags;
            },
            setDefaultCookie: function(){
                // If no hub cookie exists set one with the default values for the current site
                if (!loadCookie() && !isHub()) {
                    location = mam.util.site.getDefaultLocation();
                    clientType = mam.util.site.getDefaultInvestorType();
                    remember = true;
                    // alert("setDefaultCookie: default location = "+location+"\ndefault investor type = "+clientType);
                    if (location != "" || clientType != "") { // only store cookie if there is at least one default specified
                        storeCookie();
                    }
                }
            },
            getHubCookie: function(){
                if (loadCookie()) 
                    return ({
                        location: location,
                        clientType: clientType
                    });
                else 
                    return {}
            }
        });
        
        
        var homePagePath = "/home/home.html";
        var siteSelectorPath = "/core/investments/investments.html";
        
        var crossDomainCookieTransfer = function(){
            // get location and investor type from query string if present and store in a cookie
            // alert(window.location.search);
            var query = window.location.search.substring(1);
            // alert("query: "+query);
            var pArray = query.split("&");
            var queryParms = {};
            // alert("parameters length:"+ parameters.length);
            $.each(pArray, function(i, n){
                var pos = n.indexOf('=');
                if (pos > 0) {
                    var key = n.substring(0, pos);
                    var val = n.substring(pos + 1);
                    queryParms[key] = val;
                }
            });
            if (queryParms.location != undefined) {
                location = queryParms.location;
                clientType = unescape(queryParms.investorType);
                remember = queryParms.remember; // makes it work in TeamSite
                storeCookie();
                
                var siteId = mam.util.site.getSiteId();
                var sitePath = mam.util.path.getSitePathById(siteId);
                
                var env = mam.util.env.getEnv();
                
                var siteUrl = $("host[env='" + env + "']", $("site[id='" + siteId + "']", mam.config.getControlXml())).attr('name');
                
                forwardToHomePage({
                    host: siteUrl, /*workarea2: "/" + siteId  + sitePath + "/" ,*/
                    query: ""
                });
                //forwardToHomePage({host: getSiteHost(location), query: ""}); // we have stored the location and investor type info now so forward to home page without the query string.
            }
        };
        
        
        var HUB_COOKIE = "hub2"; // Name of the hub cookie
        var location = "";
        var clientType = "";
        var remember = "";
        var cookieExists = {};
        var importantInformation = {};
        importantInformation.confirmed = false;
        var importantInfoConfirmed = function(){
        
            return (loadImportantInfoCookie() && importantInformation.confirmed);
            // AP CHANGED TO STOP ANY IMPORTANT INFORMATION REDIRECTS
            //return true;
        };
        
        // Private Methods
        var getSite = function(){
            // var site = investorTypes[clientType].locations[location].site;
            var site = locations[location].investorTypes[clientType].site;
            // alert("getSite: "+site);
            if (site != undefined && site != "") {
                return site;
            }
            else { // no match return default
                return "default";
            }
        };
        var clearCookie = function(){
            var cookie = new Cookie(document, HUB_COOKIE, 0, "/", null, false);
            cookie.remove();
        };
        var forwardToHub = function(p){
            var parms = {
                host: mam.util.env.getDefaultHost(),
                preserveHistory: false,
                test: false,
                pathname: siteSelectorPath
            }; // defaults 
            jQuery.extend(parms, p);
            forwardToPage(parms);
        };
        var forwardToImportantInfo = function(p){
            // alert("forwardToImportantInfo");
            var parms = {
                host: "",
                preserveHistory: false,
                test: false,
                pathname: "/" + mam.util.path.getCoreDirectoryName() + "/important_information/important_information.html"
            }; // defaults 
            jQuery.extend(parms, p);
            forwardToPage(parms);
        };
        var forwardToHomePage = function(p){
            var parms = {
                host: "",
                preserveHistory: false,
                test: false,
                pathname: mam.util.path.getSitePath() + homePagePath
            }; // defaults
            jQuery.extend(parms, p);
            forwardToPage(parms);
        };
        var forwardToPage = function(p){
            var url;
            var parms = {
                host: "",
                preserveHistory: false,
                test: false,
                pathname: "default.html"
            }; // defaults 
            jQuery.extend(parms, p);
            // alert("forwardToPage: host: "+parms.host+"\npreserveHistory: "+parms.preserveHistory+"\ntest: "+parms.test+"\nexternal: "+parms.external);
            url = mam.util.url.constructURL({
                host: parms.host,
                pathname: parms.pathname,
                query: parms.query,
                external: parms.external
            });
            
            mam.util.url.forward({
                url: url,
                preserveHistory: parms.preserveHistory,
                test: parms.test,
                external: parms.external
            });
            
        };
        var getSiteHost = function(site){
            var host;
            var hostElements = getHostElements(site);
            if (hostElements != null) {
                var host = hostElements.get(0).getAttribute("name");
            }
            else {
                host = "";
            }
            // alert("getSiteHost: "+host);
            return host;
        };
        var isExternalSite = function(site){
            var external = false;
            var hostElements = getHostElements(site);
            if (hostElements != null) {
                if ("true" == hostElements.get(0).getAttribute("external")) {
                    external = true;
                }
            }
            // alert("isExternalSite: "+external);
            return external;
        };
        var getHostElements = function(site){
            var siteElements;
            var hostElements = null;
            if (mam.config.getControlXml() != undefined) {
                if (site == undefined) 
                    site = getSite();
                // alert("method: getSiteHost\n\nsite: "+site+"\n\nenv: "+mam.util.getEnvName()+"\n\nlocation: "+this.location+"\n\nclientType: "+this.clientType);
                siteElements = mam.util.dom.getElementsByAttribute($("site", mam.config.getControlXml()), "id", site);
                if (siteElements.size() == 0) {
                    site = "default";
                } // if site not found, try default
                siteElements = mam.util.dom.getElementsByAttribute($("site", mam.config.getControlXml()), "id", site);
                hostElements = mam.util.dom.getElementsByAttribute($("host", siteElements), "env", mam.util.env.getEnv());
            }
            return hostElements;
        };
        var loadCookie = function(){
            var cookie = new Cookie(document, HUB_COOKIE, 8760, "/", null, false);
            if (cookie.load()) {
                cookieExists.hub = true;
                location = unescape(cookie.location);
                clientType = unescape(cookie.clientType);
                remember = unescape(cookie.remember);
            }
            else {
                cookieExists.hub = false;
            }
            // alert("loadCookie: "+cookieExists.hub);
            return cookieExists.hub;
        };
        var storeCookie = function(){
        
            var cookie = new Cookie(document, HUB_COOKIE, 8760, "/", null, false);
            cookie.location = location;
            cookie.clientType = clientType;
            cookie.remember = remember;
            cookie.store();
        };
        var loadImportantInfoCookie = function(){
            var cookie_path = mam.util.env.isTeamsite() ? mam.util.env.getCurrentHost() + "/" : "/"; // jd 0227
            var cookie = new Cookie(document, "importantInfo", 0, cookie_path, null, false);
            if (cookie.load()) {
                cookieExists.importantInfo = true;
                importantInformation.confirmed = cookie.confirmed;
                // alert(importantInformation.confirmed);
            }
            else {
                cookieExists.importantInfo = false;
            }
            return cookieExists.importantInfo;
        };
        var storeImportantInfoCookie = function(){
        
            mam.config.initialize(function(){
                var cookie_path = mam.util.env.isTeamsite() ? mam.util.env.getCurrentHost() + "/" : "/";
                
                var cookie = new Cookie(document, "importantInfo", 8760, cookie_path, null, false);
                cookie.confirmed = importantInformation.confirmed;
                cookie.store();
            }, {
                controlXml: true
            });
            
        };
        var clearImportantInfoCookie = function(){
            var cookie_path = mam.util.env.isTeamsite() ? mam.util.env.getCurrentHost() + "/" : "/";
            
            var cookie = new Cookie(document, "importantInfo", 0, cookie_path, null, false);
            cookie.remove();
        };
        
        
        
        var isHub = function(){
            var isHub = false;
            var path = mam.util.url.getPath();
            var hubPageRegex = ["/core/hub/hub.html", "/core/investments/investments.html"];
            $.each(hubPageRegex, function(i, n){
                var re = new RegExp(n);
                if (re.test(path)) 
                    isHub = true;
            });
            return isHub;
        };
        
        var go = function(o){
        
            var external = false;
            var pathname = "";
            var query = "";
            if (!isExternalSite(o.siteId)) {
            
                pathname = "/";
                //query = o.location+"|"+o.investorType;
                query = "location=" + escape(o.location) + "&investorType=" + escape(o.investorType);
            }
            else {
                pathname = "";
                external = true;
            }
            forwardToHomePage({
                host: getSiteHost(o.siteId),
                preserveHistory: true,
                pathname: pathname,
                query: query,
                external: external
            });
            return false;
            
        };
        
        var buildSiteSelector = function(){
        
            $("#invest-tabbed-data  A.hub-link").each(function(i){
            
                var url = $(this).attr('href');
                var linkProps = url.split(/#/);
                
                if (linkProps.length > 1) {
                
                    var siteId = linkProps[1];
                    var env = mam.util.env.getEnv();
                    
                    var requestedPathname = this.pathname + this.search + this.hash;
                    
                    var siteUrl = $("host[env='" + env + "']", $("site[id='" + siteId + "']", mam.config.getControlXml())).attr('name');
                    
                    var newUrl = mam.util.url.constructURL({
                        host: siteUrl,
                        pathname: requestedPathname
                    });
                    
                    $(this).attr('href', newUrl);
                    
                } else {
                    
                    var externalLinksSplash = {};
                    externalLinksSplash['http://uk.retail.bnymellonam.co.uk']    =  '/core/misc/externalBNYMellon.html';
                    externalLinksSplash['http://uk.wholesale.bnymellonam.co.uk'] =  '/core/misc/externalBNYMellon.html';
                    externalLinksSplash['http://www.dreyfus.com']                =  '/core/misc/externalDreyfus.html';
                  
                  var splashPage = externalLinksSplash[url.toLowerCase()];
                  
                  if (typeof(splashPage) != "undefined")
                    $(this).click(function() { redirect(splashPage, url); return false; });
                }
                

            });
            
        };
    }
    
}

mam.hub.pageHandler(); // do they need to go to the hub/important information page




/*
 * Jiro Iwamoto. <jirokun@no spam@gmail.com>
 * http://d.hatena.ne.jp/sukesam
 * 
 * The MIT License
 * --------
 * Copyright (c) 2007 Jiro Iwamoto.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

var JSONP = function JSONP(url, options) {
	this.options = {callbackParamName: 'callback'};
	for (var prop in options) this.options[prop] = options[prop];
	this.options= options;
	this.url = url;
	this.head = document.getElementsByTagName('head')[0];
	
	var _this = this;
	this.request();
	if (options.timeout) this.timer = setTimeout(function() {_this.timeoutHandler();}, options.timeout);
}

JSONP.sequence = 0;
JSONP.prototype = {
	constructor: JSONP,

	request: function() {
		var url;
		var script = this.script = document.createElement('script');
		var options = this.options;
		var _this = this;
		this.currentCallbackName = "callback_" + JSONP.sequence++;

		var parameters = this.options.callbackParamName + '=JSONP.' + this.currentCallbackName + '&' + this.composeParams();
		if (this.url.indexOf('?') > -1) url = this.url + '&' + parameters;
		else url = this.url + '?' + parameters;

		JSONP[this.currentCallbackName] = function(json) {
			clearTimeout(_this.timer);
			_this.head.removeChild(script);
			delete JSONP[_this.currentCallbackName];
			if (options.onSuccess) options.onSuccess.call(_this, json);
		};
		script.setAttribute('src', url);
		script.setAttribute('type', 'text/javascript');
		
		this.head.appendChild(script);

	},

	timeoutHandler: function() {
		if (JSONP[this.currentCallbackName]) {
			JSONP[this.currentCallbackName] = this.nop;
			this.head.removeChild(this.script);
		}
		this.options.onFailure();
	},

	nop: function() {
	},

	composeParams: function() {
		var ret = '';
		var params = this.options.params;
		var paramsIsArray = this.options.paramsIsArray;
		var tmpArray = [];
		if(paramsIsArray){
			for(i=0;i<params.length;i++){
				tmpArray.push(encodeURIComponent(params[i].id) + "=" + encodeURIComponent(params[i].value));
			}
		}
		else{
			for (var key in params) {
				tmpArray.push(encodeURIComponent(key) + "=" + encodeURIComponent(params[key]));
			}
		}
		return tmpArray.join('&');
	}
}

var emo = {};

var keyStr = "ABCDEFGHIJKLMNOP" +
                "QRSTUVWXYZabcdef" +
                "ghijklmnopqrstuv" +
                "wxyz0123456789+/" +
                "=";

emo.decode64 = function (input) {
      var output = "";
      var chr1, chr2, chr3 = "";
      var enc1, enc2, enc3, enc4 = "";
      var i = 0;
  
      // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
      var base64test = /[^A-Za-z0-9\+\/\=]/g;
      if (base64test.exec(input)) {
         
      }
      input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
  
      do {
         enc1 = keyStr.indexOf(input.charAt(i++));
         enc2 = keyStr.indexOf(input.charAt(i++));
         enc3 = keyStr.indexOf(input.charAt(i++));
         enc4 = keyStr.indexOf(input.charAt(i++));
  
         chr1 = (enc1 << 2) | (enc2 >> 4);
         chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
         chr3 = ((enc3 & 3) << 6) | enc4;
  
         output = output + String.fromCharCode(chr1);
  
         if (enc3 != 64) {
            output = output + String.fromCharCode(chr2);
         }
         if (enc4 != 64) {
            output = output + String.fromCharCode(chr3);
         }
  
         chr1 = chr2 = chr3 = "";
         enc1 = enc2 = enc3 = enc4 = "";
  
      } while (i < input.length);
  
      return unescape(output);
}
		
emo.writemail = function(u, d) {
	
	return emo.decode64(u) + '@'+ emo.decode64(d);
	

};

emo.mailto = function(u, d) {
	window.open('mailto:'+emo.decode64(u) + '@'+ emo.decode64(d));
};
$(document).ready(function(){
 $('.rotate_banners').cycle({
 timeout: 6000,
 delay: 4000
 }
 );
});
/*
Macromedia(r) Flash(r) JavaScript Integration Kit License


Copyright (c) 2005 Macromedia, inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment:

"This product includes software developed by Macromedia, Inc.
(http://www.macromedia.com)."

Alternately, this acknowledgment may appear in the software itself, if and
wherever such third-party acknowledgments normally appear.

4. The name Macromedia must not be used to endorse or promote products derived
from this software without prior written permission. For written permission,
please contact devrelations@macromedia.com.

5. Products derived from this software may not be called "Macromedia" or
"Macromedia Flash", nor may "Macromedia" or "Macromedia Flash" appear in their
name.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MACROMEDIA OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.

--

This code is part of the Flash / JavaScript Integration Kit:
http://www.macromedia.com/go/flashjavascript/

Created by:

Christian Cantrell
http://weblogs.macromedia.com/cantrell/
mailto:cantrell@macromedia.com

Mike Chambers
http://weblogs.macromedia.com/mesh/
mailto:mesh@macromedia.com

Macromedia
*/

/**
 * Create a new Exception object.
 * name: The name of the exception.
 * message: The exception message.
 */
function Exception(name, message)
{
    if (name)
        this.name = name;
    if (message)
        this.message = message;
}

/**
 * Set the name of the exception. 
 */
Exception.prototype.setName = function(name)
{
    this.name = name;
}

/**
 * Get the exception's name. 
 */
Exception.prototype.getName = function()
{
    return this.name;
}

/**
 * Set a message on the exception. 
 */
Exception.prototype.setMessage = function(msg)
{
    this.message = msg;
}

/**
 * Get the exception message. 
 */
Exception.prototype.getMessage = function()
{
    return this.message;
}

/**
 * Generates a browser-specific Flash tag. Create a new instance, set whatever
 * properties you need, then call either toString() to get the tag as a string, or
 * call write() to write the tag out.
 */

/**
 * Creates a new instance of the FlashTag.
 * src: The path to the SWF file.
 * width: The width of your Flash content.
 * height: the height of your Flash content.
 */
function FlashTag(src, width, height)
{
    this.src       = src;
    this.width     = width;
    this.height    = height;
    this.version   = '7,0,14,0';
    this.id        = null;
    this.bgcolor   = 'ffffff';
    this.flashVars = null;
  
}

/**
 * Sets the Flash version used in the Flash tag.
 */
FlashTag.prototype.setVersion = function(v)
{
    this.version = v;
}

/**
 * Sets the ID used in the Flash tag.
 */
FlashTag.prototype.setId = function(id)
{
    this.id = id;
}

/**
 * Sets the background color used in the Flash tag.
 */
FlashTag.prototype.setBgcolor = function(bgc)
{
    this.bgcolor = bgc;
}

/**
 * Sets any variables to be passed into the Flash content. 
 */
FlashTag.prototype.setFlashvars = function(fv)
{
    this.flashVars = fv;
}

/**
 * Get the Flash tag as a string. 
 */
FlashTag.prototype.toString = function()
{
    var ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0;
    var flashTag = new String();
    if (ie)
    {
        flashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        if (this.id != null)
        {
            flashTag += 'id="'+this.id+'" ';
        }
        flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.version+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'">';
        flashTag += '<param name="movie" value="'+this.src+'"/>';
        flashTag += '<param name="quality" value="high"/>';
        flashTag += '<param name="bgcolor" value="#'+this.bgcolor+'"/>';
        if (this.flashVars != null)
        {
            flashTag += '<param name="flashvars" value="'+this.flashVars+'"/>';
        }
        flashTag += '</object>';
    }
    else
    {
        flashTag += '<embed src="'+this.src+'" ';
        flashTag += 'quality="high" '; 
        flashTag += 'bgcolor="#'+this.bgcolor+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'" ';
        flashTag += 'type="application/x-shockwave-flash" ';
        if (this.flashVars != null)
        {
            flashTag += 'flashvars="'+this.flashVars+'" ';
        }
        if (this.id != null)
        {
            flashTag += 'name="'+this.id+'" ';
        }
        flashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        flashTag += '</embed>';
    }
    return flashTag;
}

/**
 * Write the Flash tag out. Pass in a reference to the document to write to. 
 */
FlashTag.prototype.write = function(doc)
{
    doc.write(this.toString());
}

/**
 * The FlashSerializer serializes JavaScript variables of types object, array, string,
 * number, date, boolean, null or undefined into XML. 
 */

/**
 * Create a new instance of the FlashSerializer.
 * useCdata: Whether strings should be treated as character data. If false, strings are simply XML encoded.
 */
function FlashSerializer(useCdata)
{
    this.useCdata = useCdata;
}

/**
 * Serialize an array into a format that can be deserialized in Flash. Supported data types are object,
 * array, string, number, date, boolean, null, and undefined. Returns a string of serialized data.
 */
FlashSerializer.prototype.serialize = function(args)
{
    var qs = new String();

    for (var i = 0; i < args.length; ++i)
    {
        switch(typeof(args[i]))
        {
            case 'undefined':
                qs += 't'+(i)+'=undf';
                break;
            case 'string':
                qs += 't'+(i)+'=str&d'+(i)+'='+escape(args[i]);
                break;
            case 'number':
                qs += 't'+(i)+'=num&d'+(i)+'='+escape(args[i]);
                break;
            case 'boolean':
                qs += 't'+(i)+'=bool&d'+(i)+'='+escape(args[i]);
                break;
            case 'object':
                if (args[i] == null)
                {
                    qs += 't'+(i)+'=null';
                }
                else if (args[i] instanceof Date)
                {
                    qs += 't'+(i)+'=date&d'+(i)+'='+escape(args[i].getTime());
                }
                else // array or object
                {
                    try
                    {
                        qs += 't'+(i)+'=xser&d'+(i)+'='+escape(this._serializeXML(args[i]));
                    }
                    catch (exception)
                    {
                        throw new Exception("FlashSerializationException",
                                            "The following error occurred during complex object serialization: " + exception.getMessage());
                    }
                }
                break;
            default:
                throw new Exception("FlashSerializationException",
                                    "You can only serialize strings, numbers, booleans, dates, objects, arrays, nulls, and undefined.");
        }

        if (i != (args.length - 1))
        {
            qs += '&';
        }
    }

    return qs;
}

/**
 * Private
 */
FlashSerializer.prototype._serializeXML = function(obj)
{
    var doc = new Object();
    doc.xml = '<fp>'; 
    this._serializeNode(obj, doc, null);
    doc.xml += '</fp>'; 
    return doc.xml;
}

/**
 * Private
 */
FlashSerializer.prototype._serializeNode = function(obj, doc, name)
{
    switch(typeof(obj))
    {
        case 'undefined':
            doc.xml += '<undf'+this._addName(name)+'/>';
            break;
        case 'string':
            doc.xml += '<str'+this._addName(name)+'>'+this._escapeXml(obj)+'</str>';
            break;
        case 'number':
            doc.xml += '<num'+this._addName(name)+'>'+obj+'</num>';
            break;
        case 'boolean':
            doc.xml += '<bool'+this._addName(name)+' val="'+obj+'"/>';
            break;
        case 'object':
            if (obj == null)
            {
                doc.xml += '<null'+this._addName(name)+'/>';
            }
            else if (obj instanceof Date)
            {
                doc.xml += '<date'+this._addName(name)+'>'+obj.getTime()+'</date>';
            }
            else if (obj instanceof Array)
            {
                doc.xml += '<array'+this._addName(name)+'>';
                for (var i = 0; i < obj.length; ++i)
                {
                    this._serializeNode(obj[i], doc, null);
                }
                doc.xml += '</array>';
            }
            else
            {
                doc.xml += '<obj'+this._addName(name)+'>';
                for (var n in obj)
                {
                    if (typeof(obj[n]) == 'function')
                        continue;
                    this._serializeNode(obj[n], doc, n);
                }
                doc.xml += '</obj>';
            }
            break;
        default:
            throw new Exception("FlashSerializationException",
                                "You can only serialize strings, numbers, booleans, objects, dates, arrays, nulls and undefined");
            break;
    }
}

/**
 * Private
 */
FlashSerializer.prototype._addName= function(name)
{
    if (name != null)
    {
        return ' name="'+name+'"';
    }
    return '';
}

/**
 * Private
 */
FlashSerializer.prototype._escapeXml = function(str)
{
    if (this.useCdata)
        return '<![CDATA['+str+']]>';
    else
        return str.replace(/&/g,'&amp;').replace(/</g,'&lt;');
}

/**
 * The FlashProxy object is what proxies function calls between JavaScript and Flash.
 * It handles all argument serialization issues.
 */

/**
 * Instantiates a new FlashProxy object. Pass in a uniqueID and the name (including the path)
 * of the Flash proxy SWF. The ID is the same ID that needs to be passed into your Flash content as lcId.
 */
function FlashProxy(uid, proxySwfName)
{
    this.uid = uid;
    this.proxySwfName = proxySwfName;
    this.flashSerializer = new FlashSerializer(false);
}

/**
 * Call a function in your Flash content.  Arguments should be:
 * 1. ActionScript function name to call,
 * 2. any number of additional arguments of type object,
 *    array, string, number, boolean, date, null, or undefined. 
 */
FlashProxy.prototype.call = function()
{

    if (arguments.length == 0)
    {
        throw new Exception("Flash Proxy Exception",
                            "The first argument should be the function name followed by any number of additional arguments.");
    }

    var qs = 'lcId=' + escape(this.uid) + '&functionName=' + escape(arguments[0]);

    if (arguments.length > 1)
    {
        var justArgs = new Array();
        for (var i = 1; i < arguments.length; ++i)
        {
            justArgs.push(arguments[i]);
        }
        qs += ('&' + this.flashSerializer.serialize(justArgs));
    }

    var divName = '_flash_proxy_' + this.uid;
    if(!document.getElementById(divName))
    {
        var newTarget = document.createElement("div");
        newTarget.id = divName;
        document.body.appendChild(newTarget);
    }
    var target = document.getElementById(divName);
    var ft = new FlashTag(this.proxySwfName, 1, 1);
    ft.setVersion('6,0,65,0');
    ft.setFlashvars(qs);
    target.innerHTML = ft.toString();
}

/**
 * This is the function that proxies function calls from Flash to JavaScript.
 * It is called implicitly.
 */
FlashProxy.callJS = function()
{
    var functionToCall = eval(arguments[0]);
    var argArray = new Array();
    for (var i = 1; i < arguments.length; ++i)
    {
        argArray.push(arguments[i]);
    }
    functionToCall.apply(functionToCall, argArray);
}

/**
 * Create a new Exception object.
 * name: The name of the exception.
 * message: The exception message.
 */
function Exception(name, message)
{
    if (name)
        this.name = name;
    if (message)
        this.message = message;
}

/**
 * Set the name of the exception. 
 */
Exception.prototype.setName = function(name)
{
    this.name = name;
}

/**
 * Get the exception's name. 
 */
Exception.prototype.getName = function()
{
    return this.name;
}

/**
 * Set a message on the exception. 
 */
Exception.prototype.setMessage = function(msg)
{
    this.message = msg;
}

/**
 * Get the exception message. 
 */
Exception.prototype.getMessage = function()
{
    return this.message;
}

/**
 * Generates a browser-specific Flash tag. Create a new instance, set whatever
 * properties you need, then call either toString() to get the tag as a string, or
 * call write() to write the tag out.
 */

/**
 * Creates a new instance of the FlashTag.
 * src: The path to the SWF file.
 * width: The width of your Flash content.
 * height: the height of your Flash content.
 */
function FlashTag(src, width, height)
{
    this.src       = src;
    this.width     = width;
    this.height    = height;
    this.version   = '7,0,14,0';
    this.id        = null;
    this.bgcolor   = 'ffffff';
    this.flashVars = null;
}

/**
 * Sets the Flash version used in the Flash tag.
 */
FlashTag.prototype.setVersion = function(v)
{
    this.version = v;
}

/**
 * Sets the ID used in the Flash tag.
 */
FlashTag.prototype.setId = function(id)
{
    this.id = id;
}

/**
 * Sets the background color used in the Flash tag.
 */
FlashTag.prototype.setBgcolor = function(bgc)
{
    this.bgcolor = bgc;
}

/**
 * Sets any variables to be passed into the Flash content. 
 */
FlashTag.prototype.setFlashvars = function(fv)
{
    this.flashVars = fv;
}

/**
 * Get the Flash tag as a string. 
 */
FlashTag.prototype.toString = function()
{
    var ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0;
    var flashTag = new String();
    if (ie)
    {
        flashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        if (this.id != null)
        {
            flashTag += 'id="'+this.id+'" ';
        }
        flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.version+'" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'">';
        flashTag += '<param name="movie" value="'+this.src+'"/>';
        flashTag += '<param name="quality" value="high"/>';
		//flashTag += '<param name="bgcolor" value="#'+this.bgcolor+'"/>';
		flashTag += '<param name="wmode" value="transparent"/>';
        
		
		if (this.flashVars != null)
        {
            flashTag += '<param name="flashvars" value="'+this.flashVars+'"/>';
        }
        flashTag += '</object>';
    }
    else
    {
        flashTag += '<embed src="'+this.src+'" ';
        flashTag += 'quality="high" '; 
        //flashTag += 'bgcolor="#'+this.bgcolor+'" ';
		flashTag += 'wmode="transparent" ';
        flashTag += 'width="'+this.width+'" ';
        flashTag += 'height="'+this.height+'" ';
        flashTag += 'type="application/x-shockwave-flash" ';
        if (this.flashVars != null)
        {
            flashTag += 'flashvars="'+this.flashVars+'" ';
        }
        if (this.id != null)
        {
            flashTag += 'name="'+this.id+'" ';
        }
        flashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">';
        flashTag += '</embed>';
    }
    return flashTag;
}

/**
 * Write the Flash tag out. Pass in a reference to the document to write to. 
 */
FlashTag.prototype.write = function(doc)
{
    doc.write(this.toString());
}

/**
 * The FlashSerializer serializes JavaScript variables of types object, array, string,
 * number, date, boolean, null or undefined into XML. 
 */

/**
 * Create a new instance of the FlashSerializer.
 * useCdata: Whether strings should be treated as character data. If false, strings are simply XML encoded.
 */
function FlashSerializer(useCdata)
{
    this.useCdata = useCdata;
}

/**
 * Serialize an array into a format that can be deserialized in Flash. Supported data types are object,
 * array, string, number, date, boolean, null, and undefined. Returns a string of serialized data.
 */
FlashSerializer.prototype.serialize = function(args)
{
    var qs = new String();

    for (var i = 0; i < args.length; ++i)
    {
        switch(typeof(args[i]))
        {
            case 'undefined':
                qs += 't'+(i)+'=undf';
                break;
            case 'string':
                qs += 't'+(i)+'=str&d'+(i)+'='+escape(args[i]);
                break;
            case 'number':
                qs += 't'+(i)+'=num&d'+(i)+'='+escape(args[i]);
                break;
            case 'boolean':
                qs += 't'+(i)+'=bool&d'+(i)+'='+escape(args[i]);
                break;
            case 'object':
                if (args[i] == null)
                {
                    qs += 't'+(i)+'=null';
                }
                else if (args[i] instanceof Date)
                {
                    qs += 't'+(i)+'=date&d'+(i)+'='+escape(args[i].getTime());
                }
                else // array or object
                {
                    try
                    {
                        qs += 't'+(i)+'=xser&d'+(i)+'='+escape(this._serializeXML(args[i]));
                    }
                    catch (exception)
                    {
                        throw new Exception("FlashSerializationException",
                                            "The following error occurred during complex object serialization: " + exception.getMessage());
                    }
                }
                break;
            default:
                throw new Exception("FlashSerializationException",
                                    "You can only serialize strings, numbers, booleans, dates, objects, arrays, nulls, and undefined.");
        }

        if (i != (args.length - 1))
        {
            qs += '&';
        }
    }

    return qs;
}

/**
 * Private
 */
FlashSerializer.prototype._serializeXML = function(obj)
{
    var doc = new Object();
    doc.xml = '<fp>'; 
    this._serializeNode(obj, doc, null);
    doc.xml += '</fp>'; 
    return doc.xml;
}

/**
 * Private
 */
FlashSerializer.prototype._serializeNode = function(obj, doc, name)
{
    switch(typeof(obj))
    {
        case 'undefined':
            doc.xml += '<undf'+this._addName(name)+'/>';
            break;
        case 'string':
            doc.xml += '<str'+this._addName(name)+'>'+this._escapeXml(obj)+'</str>';
            break;
        case 'number':
            doc.xml += '<num'+this._addName(name)+'>'+obj+'</num>';
            break;
        case 'boolean':
            doc.xml += '<bool'+this._addName(name)+' val="'+obj+'"/>';
            break;
        case 'object':
            if (obj == null)
            {
                doc.xml += '<null'+this._addName(name)+'/>';
            }
            else if (obj instanceof Date)
            {
                doc.xml += '<date'+this._addName(name)+'>'+obj.getTime()+'</date>';
            }
            else if (obj instanceof Array)
            {
                doc.xml += '<array'+this._addName(name)+'>';
                for (var i = 0; i < obj.length; ++i)
                {
                    this._serializeNode(obj[i], doc, null);
                }
                doc.xml += '</array>';
            }
            else
            {
                doc.xml += '<obj'+this._addName(name)+'>';
                for (var n in obj)
                {
                    if (typeof(obj[n]) == 'function')
                        continue;
                    this._serializeNode(obj[n], doc, n);
                }
                doc.xml += '</obj>';
            }
            break;
        default:
            throw new Exception("FlashSerializationException",
                                "You can only serialize strings, numbers, booleans, objects, dates, arrays, nulls and undefined");
            break;
    }
}

/**
 * Private
 */
FlashSerializer.prototype._addName= function(name)
{
    if (name != null)
    {
        return ' name="'+name+'"';
    }
    return '';
}

/**
 * Private
 */
FlashSerializer.prototype._escapeXml = function(str)
{
    if (this.useCdata)
        return '<![CDATA['+str+']]>';
    else
        return str.replace(/&/g,'&amp;').replace(/</g,'&lt;');
}

/**
 * The FlashProxy object is what proxies function calls between JavaScript and Flash.
 * It handles all argument serialization issues.
 */

/**
 * Instantiates a new FlashProxy object. Pass in a uniqueID and the name (including the path)
 * of the Flash proxy SWF. The ID is the same ID that needs to be passed into your Flash content as lcId.
 */
function FlashProxy(uid, proxySwfName)
{
    this.uid = uid;
    this.proxySwfName = proxySwfName;
    this.flashSerializer = new FlashSerializer(false);
}

/**
 * Call a function in your Flash content.  Arguments should be:
 * 1. ActionScript function name to call,
 * 2. any number of additional arguments of type object,
 *    array, string, number, boolean, date, null, or undefined. 
 */
FlashProxy.prototype.call = function()
{

    if (arguments.length == 0)
    {
        throw new Exception("Flash Proxy Exception",
                            "The first argument should be the function name followed by any number of additional arguments.");
    }

    var qs = 'lcId=' + escape(this.uid) + '&functionName=' + escape(arguments[0]);

    if (arguments.length > 1)
    {
        var justArgs = new Array();
        for (var i = 1; i < arguments.length; ++i)
        {
            justArgs.push(arguments[i]);
        }
        qs += ('&' + this.flashSerializer.serialize(justArgs));
    }

    var divName = '_flash_proxy_' + this.uid;
    if(!document.getElementById(divName))
    {
        var newTarget = document.createElement("div");
        newTarget.id = divName;
        document.body.appendChild(newTarget);
    }
    var target = document.getElementById(divName);
    var ft = new FlashTag(this.proxySwfName, 1, 1);
    ft.setVersion('6,0,65,0');
    ft.setFlashvars(qs);
    target.innerHTML = ft.toString();
}

/**
 * This is the function that proxies function calls from Flash to JavaScript.
 * It is called implicitly.
 */
FlashProxy.callJS = function()
{
    var functionToCall = eval(arguments[0]);
    var argArray = new Array();
    for (var i = 1; i < arguments.length; ++i)
    {
        argArray.push(arguments[i]);
    }
    functionToCall.apply(functionToCall, argArray);
}

if(urdang == undefined) var urdang = {};

urdang.countryLinks = new function() {
	jQuery.extend(
		this,  { 
			version: "1.0",
			show: function(code) {		
				$("#flashLinks div").hide();
				$("#"+code).show();
				$("#flashLinks #"+code+" div").show();
				
			},
			selectDropdown: function(code) {		
				$("#country").selectOptions(code, true);
			}
		}
	);
}

function selectCountry(code){
				document.getElementById('country').value = code;
			    urdang.countryLinks.show(code);
			}




					$(document).ready(function() {
						$('#category').click(function(){
							$('table.categories').show();
						});
						$('#relevance, #date, #title').click(function(){
							$('table.categories').hide();
						});
					});
					
					$(document).ready(function() {
						$('#specific-date-range').click(function(){
							$('table.dateRange').show();
						});
						$('#anytime, #latest, #past-24-hours, #past-week, #past-year').click(function(){
							$('table.dateRange').hide();
						});
						
						$("input[name='sp_d']").each(function() {
						
							if ($(this).val() == "specific") {
								$('#specific-date-range').val("");
								$('#specific-date-range').click();
							}
								
							return true;
						});
						
					});
						
               $(document).ready(function() {
                $('#dateFrom, #dateTo').click(
                function() {
                    if (this.value == this.defaultValue) {
                        this.value = '';
                }
                }
                );
                $('#dateFrom, #dateTo').blur(
                function() {
                if (this.value == '') {
                this.value = this.defaultValue;
                }
                }
                );
                
                });
                				
$(document).ready(function () {
$("form#settings").submit(function() {


	var fromParts = $(this).find("input#dateFrom").val().split("/");
	var toParts = $(this).find("input#dateTo").val().split("/");
	var dateRangeSelected = $(this).find("input[name='sp_date_range']:checked").val() == "" ?  true : false;

	if($(this).valid() && fromParts.length  == 3 && fromParts.length == toParts.length && dateRangeSelected) {
	  
      $(this).find("input[name='sp_d']").val("specific");
	  $(this).find("input[name='sp_start_day']").val(fromParts[0]);
	  $(this).find("input[name='sp_start_month']").val(fromParts[1]);
	  $(this).find("input[name='sp_start_year']").val(fromParts[2]);

	  $(this).find("input[name='sp_end_day']").val(toParts[0]);
	  $(this).find("input[name='sp_end_month']").val(toParts[1]);
	  $(this).find("input[name='sp_end_year']").val(toParts[2]);
 
	} else
        $(this).find("input[name='sp_d']").val("");
	
	
});

$("form#settings").validate({
rules: {
     dateFrom: {
         required:function() { 
           
          var dateRangeSelected = $("form#settings").find("input[name='sp_date_range']:checked").val() == "" ?  true : false;
          
          if(!dateRangeSelected) {
            $("form#settings input#dateFrom").val("");
            $("form#settings input#dateTo").val("");
          }
          
          return dateRangeSelected;
          
          },
          
         date:true

     },dateTo: {
         required:function() { return $("form#settings").find("input[name='sp_date_range']:checked").val() == "" ?  true : false;
         
        },
         date:true

     }
}

});


});

/*
* Highlight search terms and select correct tab if applicable.
*/
$(document).ready(function () {
	// get query parameters
	var query = window.location.search.substring(1);
	var pArray = query.split("&");
	var queryParms = {};
	$.each(pArray, function(i,n){
		var pos = n.indexOf('=');
		if (pos > 0) {
			var key = decodeURIComponent(n.substring(0,pos));
			var val = decodeURIComponent(n.substring(pos+1));
			val = val.replace(/\+/g, " ");
			queryParms[key] = val;
		}
	});
	// alert(queryParms.matchText);
	// alert(queryParms.searchString);


	if(queryParms.matchText != undefined) {
		var matchText = queryParms.matchText;
		var tabId = $("div#tabbed-data > div:contains("+matchText+")").attr("id"); // Find the tab containing the matched text
		// alert(tabId);
		// alert($("a[href='#"+tabId+"']").size());
		$("a[href='#"+tabId+"']").click(); // open the tab

		// Highlight the search terms
		if(queryParms.searchString != undefined) {
			var searchStrings = queryParms.searchString.split(" ");
			$.each(searchStrings, function(i, n) {
				n = n.replace(/"/g, "");
				// alert(n);
				$('div#content-body').highlight(n);
			});
		}
	}
});

/*
* Search help popup
*/
$(document).ready(function() {
	$("body#search div.help a").click(function(){
		var features = "width=600,height=800,scrollbars=yes";
		var theWindow = window.open(this.href, "searchHelp", features);
		theWindow.focus();
		return false;
	});
});
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(4(D){6 A="23-1.0";D.j.i=4(E){k 5.r(4(){E=E||{};3(5.l){1a(5.l)}5.l=0;5.x=0;6 I=D(5);6 J=E.P?D(E.P,5):I.22();6 G=J.21();3(G.9<2){3(X.W&&X.W.1m){X.W.1m("20; 1Z 1Y 1X: "+G.9)}k}6 H=D.1W({},D.j.i.10,E||{},D.1l?I.1l():D.1V?I.1U():{});H.f=H.f?[H.f]:[];H.g=H.g?[H.g]:[];H.g.1T(4(){H.S=0});6 F=5.1S;H.a=V((F.U(/w:(\\d+)/)||[])[1])||H.a;H.7=V((F.U(/h:(\\d+)/)||[])[1])||H.7;H.c=V((F.U(/t:(\\d+)/)||[])[1])||H.c;3(I.e("T")=="1R"){I.e("T","1Q")}3(H.a){I.a(H.a)}3(H.7&&H.7!="Q"){I.7(H.7)}6 K=0;J.e({T:"1P",1O:0,1N:0}).1M().r(4(M){D(5).e("z-1L",G.9-M)});D(G[K]).e("m",1).11();3(D.1h.1g){G[K].1f.1e("1d")}3(H.o&&H.a){J.a(H.a)}3(H.o&&H.7&&H.7!="Q"){J.7(H.7)}3(H.Z){I.1K(4(){5.x=1},4(){5.x=0})}D.j.i.15.14(I,J,H);J.r(4(){6 M=D(5);5.1J=(H.o&&H.7)?H.7:M.7();5.1I=(H.o&&H.a)?H.a:M.a()});J.13(":12("+K+")").e({m:0});3(H.1k){D(J[K]).e(H.1k)}3(H.c){3(H.b.1H==1G){H.b={1F:1E,1D:1C}[H.b]||1B}3(!H.s){H.b=H.b/2}1A((H.c-H.b)<1z){H.c+=H.b}}H.18=H.b;H.16=H.b;H.1y=G.9;H.q=K;H.8=1;6 L=J[K];3(H.f.9){H.f[0].v(L,[L,L,H,1j])}3(H.g.9>1){H.g[1].v(L,[L,L,H,1j])}3(H.y&&!H.p){H.p=H.y}3(H.p){D(H.p).1i("y",4(){k C(G,H,H.u?-1:1)})}3(H.R){D(H.R).1i("y",4(){k C(G,H,H.u?1:-1)})}3(H.c){5.l=1c(4(){B(G,H,0,!H.u)},H.c+(H.Y||0))}})};4 B(J,E,I,K){3(E.S){k}6 H=J[0].1b,M=J[E.q],L=J[E.8];3(H.l===0&&!I){k}3(I||!H.x){3(E.f.9){D.r(E.f,4(N,O){O.v(L,[M,L,E,K])})}6 F=4(){3(D.1h.1g){5.1f.1e("1d")}D.r(E.g,4(N,O){O.v(L,[M,L,E,K])})};3(E.8!=E.q){E.S=1;D.j.i.19(M,L,E,F)}6 G=(E.8+1)==J.9;E.8=G?0:E.8+1;E.q=G?J.9-1:E.8-1}3(E.c){H.l=1c(4(){B(J,E,0,!E.u)},E.c)}}4 C(E,F,I){6 H=E[0].1b,G=H.l;3(G){1a(G);H.l=0}F.8=F.q+I;3(F.8<0){F.8=E.9-1}1x{3(F.8>=E.9){F.8=0}}B(E,F,1,I>=0);k 1w}D.j.i.19=4(K,H,I,E){6 J=D(K),G=D(H);G.e({m:0});6 F=4(){G.17({m:1},I.18,I.1v,E)};J.17({m:0},I.16,I.1u,4(){J.e({1t:"1s"});3(!I.s){F()}});3(I.s){F()}};D.j.i.15={14:4(F,G,E){G.13(":12(0)").e("m",0);E.f.1r(4(){D(5).11()})}};D.j.i.1q=4(){k A};D.j.i.10={c:1p,b:1o,p:n,R:n,f:n,g:n,7:"Q",s:1,o:0,Z:0,Y:0,P:n}})(1n);',62,128,'|||if|function|this|var|height|nextSlide|length|width|speed|timeout||css|before|after||cycle|fn|return|cycleTimeout|opacity|null|fit|next|currSlide|each|sync||rev|apply||cyclePause|click|||||||||||||||||slideExpr|auto|prev|busy|position|match|parseInt|console|window|delay|pause|defaults|show|eq|not|fade|transitions|speedOut|animate|speedIn|custom|clearTimeout|parentNode|setTimeout|filter|removeAttribute|style|msie|browser|bind|true|cssFirst|metadata|log|jQuery|1000|4000|ver|push|none|display|easeOut|easeIn|false|else|slideCount|250|while|400|200|fast|600|slow|String|constructor|cycleW|cycleH|hover|index|hide|left|top|absolute|relative|static|className|unshift|data|meta|extend|slides|few|too|terminating|get|children|Lite'.split('|')))
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('c o=C B();$().A(2(){o.8=$(\'#6 5\').z();$(\'#h\').g(\'1 f \'+o.8);$(\'#6\').y({k:\'#k\',j:\'#j\',x:2(){c 9=0;c 3=7;i($(3).b(\'a\')==w){3=$(\'5\',3)[0]}$(\'#6 5\').e(2(){9++;i($(7).b(\'a\')==$(3).b(\'a\')){$(\'#h\').g(9+\' f \'+o.8)}})}});$(\'#6 5\').e(2(){$(7).d(\'v\',\'u\')});$(\'#t\').s(2(){$(\'#4\').d(\'r\',\'0\');$(\'#4\').q();$(\'#4\').p(\'n\',\'0.m\')},2(){$(\'#4\').l()})});',39,39,'||function|current|controls|img|slides|this|numSlides|count|src|attr|var|css|each|of|html|status|if|prev|next|fadeOut|99|slow||fadeTo|show|opacity|hover|slideshow|block|display|undefined|after|cycle|size|ready|Object|new'.split('|')))
/*
 * 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 = "/core/library/images/thickbox/loadingAnimation.gif";

/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/

//on page load call tb_init
$(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){
	$(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
			$("body","html").css({height: "100%", width: "100%"});
			$("html").css("overflow","hidden");
			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
				$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
				$("#TB_overlay").click(tb_remove);
			}
		}else{//all others
			if(document.getElementById("TB_overlay") === null){
				$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
				$("#TB_overlay").click(tb_remove);
			}
		}
		
		if(tb_detectMacXFF()){
			$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
		}else{
			$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
		}
		
		if(caption===null){caption="";}
		$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
		$('#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$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
	   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 = $("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;
			$("#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>"); 		
			
			$("#TB_closeWindowButton").click(tb_remove);
			
			if (!(TB_PrevHTML === "")) {
				function goPrev(){
					if($(document).unbind("click",goPrev)){$(document).unbind("click",goPrev);}
					$("#TB_window").remove();
					$("body").append("<div id='TB_window'></div>");
					tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
					return false;	
				}
				$("#TB_prev").click(goPrev);
			}
			
			if (!(TB_NextHTML === "")) {		
				function goNext(){
					$("#TB_window").remove();
					$("body").append("<div id='TB_window'></div>");
					tb_show(TB_NextCaption, TB_NextURL, imageGroup);				
					return false;	
				}
				$("#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();
			$("#TB_load").remove();
			$("#TB_ImageOff").click(tb_remove);
			$("#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 || 630; //defaults to 630 if no paramaters were added to URL
			TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL
			ajaxContentW = TB_WIDTH - 30;
			ajaxContentH = TB_HEIGHT - 145;
			
			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window		
					urlNoQuery = url.split('TB_');
					$("#TB_iframeContent").remove();
					if(params['modal'] != "true"){//iframe no modal
						$("#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
					$("#TB_overlay").unbind();
						$("#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($("#TB_window").css("display") != "block"){
						if(params['modal'] != "true"){//ajax no modal
						$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a> or Esc Key</div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
						}else{//ajax modal
						$("#TB_overlay").unbind();
						$("#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
						$("#TB_ajaxContent")[0].style.width = ajaxContentW +"px";
						$("#TB_ajaxContent")[0].style.height = ajaxContentH +"px";
						$("#TB_ajaxContent")[0].scrollTop = 0;
						$("#TB_ajaxWindowTitle").html(caption);
					}
			}
					
			$("#TB_closeWindowButton").click(tb_remove);
			
				if(url.indexOf('TB_inline') != -1){	
					$("#TB_ajaxContent").append($('#' + params['inlineId']).children());
					$("#TB_window").unload(function () {
						$('#' + params['inlineId']).append( $("#TB_ajaxContent").children() ); // move elements back when you're finished
					});
					tb_position();
					$("#TB_load").remove();
					$("#TB_window").css({display:"block"}); 
				}else if(url.indexOf('TB_iframe') != -1){
					tb_position();
					if($.browser.safari){//safari needs help because it will not fire iframe onload
						$("#TB_load").remove();
						$("#TB_window").css({display:"block"});
					}
				}else{
					$("#TB_ajaxContent").load(url += "?&random=" + (new Date().getTime()),function(){//to do a post change this load method
						tb_position();
						$("#TB_load").remove();
						tb_init("#TB_ajaxContent a.thickbox");
						$("#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(){
	$("#TB_load").remove();
	$("#TB_window").css({display:"block"});
}

function tb_remove() {
 	$("#TB_imageOff").unbind("click");
	$("#TB_closeWindowButton").unbind("click");
	$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
	$("#TB_load").remove();
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		$("body","html").css({height: "auto", width: "auto"});
		$("html").css("overflow","");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return false;
}

function tb_position() {
$("#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
		$("#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 Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
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;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */
$(document).ready(function() {
  
	$(".test").hrzAccordion({eventTrigger:"mouseover",openOnLoad:"",cycle: true});
	

	$(".test4").hrzAccordion({eventTrigger:"mouseover",openOnLoad:"3",handlePositionArray: "left,left,right,right,right"});
	
	
	$(".test2").hrzAccordion({handlePosition     :"left",
					 openOnLoad     :3,
							 closeOpenAnimation: 2
							  });
	$(".sliderContainer").hrzAccordion({
	
			containerClass     : "container3",
			listItemClass      : "listItem3",					
			contentWrapper     : "contentWrapper3",
			contentInnerWrapper: "contentInnerWrapper3",
			handleClass        : "handle3",
			handleClassOver    : "handleOver3",
			handleClassSelected: "handleSelected3"
							  });
	

	

 	
 });//# jQuery - Horizontal Accordion
//# Version 2.00.00 Alpha 1
//#
//# portalZINE(R) - New Media Network
//# http://www.portalzine.de
//#
//# Alexander Graef
//# portalzine@gmail.com
//#
//# Copyright 2007-2009

(function($) {
	$.hrzAccordion = {
       
	   
	   setOnEvent: function(i, container, finalWidth, settings){
			$("#"+container+"Handle"+i).bind(settings.eventTrigger,function() {			 
			   			
						var status = $('[rel='+container+'ContainerSelected]').data('status');
						
						if(status ==1 && settings.eventWaitForAnim === true){
						 return false;	
						}
						
						if( $("#"+container+"Handle"+i).attr("rel") != container+"HandleSelected"){
			    		
						  settings.eventAction(i);
							
							$('[id*='+container+'Handle]').attr("rel","");			   				
			   				
							$('[id*='+container+'Handle]').attr("class",settings.handleClass);
		
			   				$("#"+container+"Handle"+i).addClass(settings.handleClassSelected);
										   
			   		
							$("."+settings.contentWrapper).css({width: finalWidth+"px" });
							
							switch(settings.closeOpenAnimation)
							{
							case 1:
      
				   
						if($('[rel='+container+'ContainerSelected]').get(0)  ){
						$('[rel='+container+'ContainerSelected]').data('status',1);
							
							//current_width = $('[rel='+container+'ContainerSelected]').width();
							
							$('[rel='+container+'ContainerSelected]').animate({width: "0px",opacity:"0"}, 
																			  {queue:true, 
																			  duration:settings.closeSpeed ,easing:settings.closeEaseAction,complete: function(){	
				 																																	
							$('[rel='+container+'ContainerSelected]').data('status',0);	
							settings.completeAction(i);
							} ,step: function(now){
							 width = $(this).width();
							 //alert(width);
						
							//new_width = finalWidth- (finalWidth  * (width/current_width));
							new_width = finalWidth - width;
							$('#'+container+'Content'+i).width((Math.ceil(new_width))+44).css("opacity","1");
							
							}});
		
						}else{
							$('[rel='+container+'ContainerSelected]').data('status',1);
								
							$('#'+container+'Content'+i).animate({width: finalWidth,opacity:"1"}, { queue:false, duration:settings.closeSpeed ,easing:settings.closeEaseAction,complete: function(){
																																																	  $('[rel='+container+'ContainerSelected]').data('status',0);	
																																																	  settings.completeAction(i);	
																																																	  }});
							
								
							}
							
							break;
							case 2:
								$('[id*='+container+'Content]').css({width: "0px"});
								$('#'+container+'Content'+i).animate({width: finalWidth+"px",opacity:"1"}, { queue:false, duration:settings.openSpeed ,easing:settings.openEaseAction, complete: 
 settings.completeAction(i)																																																									});						
							
							break;
							}

							$('[id*='+container+'Content]').attr("rel","");			
							$("#"+container+"Handle"+i).attr("rel",container+"HandleSelected");
							$("#"+container+"Content"+i).attr("rel",container+"ContainerSelected");					
							
						
						}
						
					});	
}
	    };
	
	$.fn.extend({
	   
		hrzAccordionLoop: function(options) {
			return this.each(function(a){  
				
				var container = $(this).attr("id") || $(this).attr("class");
				var elementCount = $('#'+container+' > li, .'+container+' > li').size();
				var settings = $(this).data('settings');
				
				variable_holder="interval"+container ;
				var i =0;
				var loopStatus  = "start";
				
				variable_holder = window.setInterval(function(){							
				
				$("#"+container+"Handle"+i).trigger(settings.eventTrigger);
				
				if(loopStatus =="start"){
						i = i + 1;
					}else{
						i = i-1;	
					}
					
					if(i==elementCount && loopStatus  == "start"){
						loopStatus  = "end";
						i=elementCount-1;

					}
					
					if(i==0 && loopStatus  == "end"){
						loopStatus  = "start";
						i=0;

					}
												},settings.cycleInterval);
				
				
				});
			},
		hrzAccordion: function(options) {
			this.settings = {
			eventTrigger	   		: "click",
			containerClass     		: "container",
			listItemClass      		: "listItem",					
			contentContainerClass  	: "contentContainer",
			contentWrapper     		: "contentWrapper",
			contentInnerWrapper		: "contentInnerWrapper",
			handleClass        		: "handle",
			handleInnerWrapper 		: "handleInnerWrapper",
			handleClassOver    		: "handleOver",
			handleClassSelected		: "handleSelected",
			handlePosition     		: "left",
			handlePositionArray		: "", // left,left,right,right,right
			closeEaseAction    		: "swing",
			closeSpeed     			: 500,
			openEaseAction     		: "swing",
			openSpeed      			: 500,
			openOnLoad		   		: 3,
			hashPrefix		   		: "tab",
			eventAction		   		: function(i){
								 	
								 	},
			completeAction	   		: function(i){
								 	//add your own onComplete function here
								 	},
			closeOpenAnimation 		: 1,// 1 - open and close at the same time / 2- close all and than open next
			cycle			   		: false, // not integrated yet, will allow to cycle through tabs by interval
			cycleInterval	   		: 10000,
			fixedWidth				: "",
			eventWaitForAnim		: true
				
		};
	
		if(options){
			$.extend(this.settings, options);
		}
			var settings = this.settings;
			
			
			
			return this.each(function(a){    		
				
				var container = $(this).attr("id") || $(this).attr("class");			
				
				$(this).data('settings', settings);
				
				$(this).wrap("<div class='"+settings.containerClass+"'></div>");
			
				var elementCount = $('#'+container+' > li, .'+container+' > li').size();
												
				var containerWidth =  $("."+settings.containerClass).width();
				
				var handleWidth = $("."+settings.handleClass).css("width");
		
				handleWidth =  handleWidth.replace(/px/,"");
			    var finalWidth;
				var handle;
				
				if(settings.fixedWidth){
					finalWidth = settings.fixedWidth;
				}else{
					finalWidth = containerWidth-(elementCount*handleWidth)-handleWidth;
				}
				
				$('#'+container+' > li, .'+container+' > li').each(function(i) {
			
					$(this).attr('id', container+"ListItem"+i);
			   		$(this).attr('class',settings.listItemClass);
		       		$(this).html("<div class='"+settings.contentContainerClass+"' id='"+container+"Content"+i+"'>"
								 +"<div class=\""+settings.contentWrapper+"\">"
								 +"<div class=\""+settings.contentInnerWrapper+"\">"
								 +$(this).html()
								 +"</div></div></div>");
			   		
					if($("div",this).hasClass(settings.handleClass)){
					
					var html = $("div."+settings.handleClass,this).attr("id",""+container+"Handle"+i+"").html();
					$("div."+settings.handleClass,this).remove();
					
					 handle = "<div class=\""+settings.handleClass+"\" id='"+container+"Handle"+i+"'>"
					 +"<div class=\""+settings.handleInnerWrapper+"\">"
					 +html+"</div></div>";
					}else{
					 handle = "<div class=\""+settings.handleClass+"\" id='"+container+"Handle"+i+"'></div>";
					}
					
				
					
					if(settings.handlePositionArray){
						splitthis 				= settings.handlePositionArray.split(",");
						settings.handlePosition = splitthis[i];
					}
					
					switch(settings.handlePosition ){
						case "left":
						$(this).prepend( handle );
						break;
						case "right":	
						$(this).append( handle );	
						break;
						case "top":	
						$("."+container+"Top").append( handle );	
						break;
						case "bottom":	
						$("."+container+"Bottom").append( handle );	
						break;
					}					
				
					$("#"+container+"Handle"+i).bind("mouseover", function(){
						$("#"+container+"Handle"+i).addClass(settings.handleClassOver);
					});
			    
					$("#"+container+"Handle"+i).bind("mouseout", function(){
						if( $("#"+container+"Handle"+i).attr("rel") != "selected"){
							$("#"+container+"Handle"+i).removeClass(settings.handleClassOver);
						}
					});
					
				
					$.hrzAccordion.setOnEvent(i, container, finalWidth, settings);				
					
					if(i == elementCount-1){
						$('#'+container+",."+container).show();					
					}
					
					
								
					if(settings.openOnLoad !== false && i == elementCount-1){
							var location_hash = location.hash;
							location_hash  = location_hash.replace("#", "");	
							if(location_hash.search(settings.hashPrefix) != '-1' ){
							var tab = 1;
							location_hash  = location_hash.replace(settings.hashPrefix, "");
							}
							
							if(location_hash && tab ==1){
						 		$("#"+container+"Handle"+(location_hash)).attr("rel",container+"HandleSelected");
								$("#"+container+"Content"+(location_hash)).attr("rel",container+"ContainerSelected");		
								$("#"+container+"Handle"+(location_hash-1)).trigger(settings.eventTrigger);
												
							}else{
								$("#"+container+"Handle"+(settings.openOnLoad)).attr("rel",container+"HandleSelected");
							    $("#"+container+"Content"+(settings.openOnLoad)).attr("rel",container+"ContainerSelected");	
								$("#"+container+"Handle"+(settings.openOnLoad-1)).trigger(settings.eventTrigger);
							}					
					}	
				});	
				
				if(settings.cycle === true){
					$(this).hrzAccordionLoop();
				}
			});				
		}		
	});
})(jQuery);	