/*
 2008-12-08 JFC Added imageAnchorBuilder function for slideshows
 2008-11-16 JFC Fixed "no empty cells at end of month" bug in SSCalendar
 2008-10-24 JFC Added SSCalendar
 2008-06-15 JFC Converted to jQuery
*/
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
};
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
};
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
};
String.prototype.right = function(len) {
	return this.substr(this.length-len);
};
String.prototype.left = function(len) {
	return this.substr(0,len);
};

// Namespace placeholder
//ss = {};

// Initialize things
$(document).ready(
	function() {
		initPup();
		initCalendars();
		initPageToc();
		initQuote();
	}
);

function initPup() {
	// initPup() installs handlers the Pop-Up Pedigree buttons
	$(".pupbutton").click( pup );
};

function pup(e) {
	// pup() handles clicks on Pop-Up Pedigree buttons

	// Get the ID of the data element
	var $button = $(e.target);
	var partsID = $button.attr('id').replace(/pup/i, 'pupd');

	// Get the data and convert it into a table
	var sContent = getPupContent(partsID);

	// Add the new HTML to the pup element,
	// move it relative to button, and show it.
	var pos = $button.offset();
	$("#pup").html(sContent).css(
				{left: pos.left+'px', top: (pos.top+$button.height())+'px'}
			).show();
};

function getPupContent(partsID) {
	// Initialize the arrays
	var msg = "";
	var names = new Array(7);
	var stats = new Array(7);
	var links = new Array(7);
	var i, j;

	for (j=0; j<7; j++) {
		names[j] = "";
		stats[j] = "";
		links[j] = "";
	};

	var sClose = $('#pupclose').text();
	if (sClose=='') sClose = 'Close';

	// Get the data from the hidden DIV
	var sParts = $('#'+partsID).text();
	
	// Fix some potential encoding issues
	sParts = sParts.replace(/\\n/gi, '<br>');
	sParts = sParts.replace(/&lt;/gi, '<');
	sParts = sParts.replace(/&gt;/gi, '>');

	// Parse the sParts into the things we need
	var args = sParts.split("|");

	for (j=0, i=0; i<args.length && j<7;i++, j++) {
		names[j] = args[i++];
		if (names[j] == "") names[j]="&nbsp;";

		stats[j] = args[i++];

		if (args[i] != "") {
			links[j] = '<a href="'+args[i]+'">'+names[j]+'</A>';
		} else {
			links[j] = names[j];
		};
	};

	// Start the content
	var s1='<table><tbody>\n';

	// Build the table from the parts

	// Row 1: 3 cells (0, 1, 3)
	s1 += '<tr><td width="30%" rowspan="4" class="pupsubject">'+links[0]+'<br>'+stats[0]+'</td>';
	s1 += '<td width="30%" rowspan="2" class="pupmale">';
	s1 += links[1]+'<br>'+stats[1]+'</td>';
	s1 += '<td width="40%" class="pupmale">';
	s1 += links[3]+'<br>'+stats[3]+'</td></tr>\n';

	// Row 2: 1 cell (4)
	s1 += '<tr><td width="40%" class="pupfemale">'+links[4]+'<br>'+stats[4]+'</td></tr>\n';

	// Row 3: 2 cells (2, 5)
	s1 += '<tr><td width="30%" rowspan="2" class="pupfemale">'+links[2]+'<br>'+stats[2]+'</td>';
	s1 += '<td width="40%" class="pupmale">';
	s1 += links[5]+'<br>'+stats[5]+'</td></tr>\n';

	// Row 4: 1 cell (6)
	s1 += '<tr><td width="40%" class="pupfemale">'+links[6]+'<br>'+stats[6]+'</td></tr>\n';

	s1 += '<tr><td colspan="3"><input type="button" class="pupbutton" value="'+sClose+'"'+
			' onclick="$(\'#pup\').hide();"></td></tr>\n';

	// End the content
	s1 += '</tbody></table>\n';

	return s1;
};

function initPageToc() {
	// The page "table of contents" creates a list of
	// h2 tags on the page if it finds an element with
	// the id "pagetoc". It only functions if
	// JavaScript is supported, and enabled, and if
	// the user has added HTML similar to the
	// following in one of the static content
	// sections:
	
	// <div id="pagetoc"></div>
	//    or
	// <ul id="pagetoc"></ul>
	
	// 2007-04-06 JFC Now allows pagetoc on UL or OL, or on
	//                container DIV

	var $outerElement = $('#pagetoc');

	if ($outerElement.length>0) {
		var $tocElement = $outerElement.children("ul,ol").filter(":first");

		// Toggling display from none to block speeds
		// up execution, presumably because the browser
		// ignores the new content as it is being
		// added, and only computes locations, size, etc.
		// once at the end. That's just a guess based
		// on observing Firefox. If it actually isn't
		// faster, it seems like it, and that's good
		// enough for me in this case.
		$outerElement.hide();

		if ($tocElement.length==0) {
			// ul or ol is outer element
			$tocElement = $outerElement;
			// If ul or ol has elements, remove the first.
			// That way, user can provide
			//     <ul id="pagetoc"><li></li></ul>
			// to avoid validation errors.
			$tocElement.find(':first-child').remove();
		} else {
			$tocElement = ($outerElement).append("<ul></ul>").children();
		};
		addPageToc($tocElement);
		$outerElement.show();
	};
};

function addPageToc($tocElement) {
	var $content = $('#content');
	$(ss.pageTocElements,$content).each( function(index) {
		var eListElement = document.createElement('li');
		eListElement.className = 'toc'+this.tagName.toLowerCase();

		// Get text of H2 and add to TOC as link

		// Remove all child elements; we want H2 text only
		var sItemText = $(this).clone().children().remove().end().text();
		if (sItemText=='') sItemText = $(this).text();
		var nText = document.createTextNode(sItemText);
		var eLinkElement = document.createElement('a');
		eLinkElement.appendChild(nText);
		eListElement.appendChild(eLinkElement);

		// Set ID of H2 node if it doesn't have one
		if (!this.id) this.id = 't'+index;

		// Set target of the A tag we are adding to ID of H2
		eLinkElement.href = '#' + this.id;
		$tocElement.append(eListElement);
	});
};

function initQuote() {
	// Initializes the "random quote" facility
	
	// <ul class="randomquote"><li> ... </li> etc. </ul>
	//      or
	// <div class="randomquote"><ul><li> ... </li> etc. </ul></div>

	$('ul.randomquote,div.randomquote ul').each( function() {
		pickQuote(this);
	});
	$('ul.randomquote,div.randomquote,div.randomquote ul').show();
};

function pickQuote(eUL) {
	// Hide all but one child (LI) element
	var $listItems = $(eUL).children('li');
	var iIndex = Math.round(Math.random()*($listItems.length-1));
	$listItems.hide();
	$listItems.eq(iIndex).show();
};

function hemlinksc(part1, part2, part3) {
	var loc = '';

	loc = 'm'+"A";loc=loc+"i"+"l"+"to"+":";
	loc = loc.toLowerCase()+part1+"@"+part2;
	if (part3) {
		loc = loc+'?SUBJECT='+part3;
	};
	location.href=loc;
};

function hemlink(part1, part2) {
	hemlinksc(part1, part2, fixTitle(document.title));
};

function hemlinknc(part1, part2) {
	hemlinksc(part1, part2);
};

function fixTitle(title) {
	// Fix issues with ampersands in titles sent to mailto links
	var sTitle = title.replace(/&amp;/gi,'&');
	return sTitle.replace(/&/g,'%26');
}

function tip(on_this, on_event, content) {
	return makeTrue(domTT_activate(on_this, on_event, 'content', content));
};

function tipcap(on_this, on_event, content, caption) {
	return makeTrue(domTT_activate(on_this, on_event, 'content', content, 'caption', caption));
};

/*
	parseUri 1.2.1
	(c) 2007 Steven Levithan <stevenlevithan.com>
	MIT License
*/
function parseUri (str) {
	var o = parseUri.options,
		m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i = 14;

	while (i--) uri[o.key[i]] = m[i] || "";

	uri[o.q.name] = {};
	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
		if ($1) uri[o.q.name][$1] = $2;
	});

	return uri;
};

parseUri.options = {
	strictMode: false,
	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
	q:   {
		name:   "queryKey",
		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
	},
	parser: {
		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
	}
};

// Load framed Second Site pages in proper frame 

function ssFramer(destFrame) {
	var sDestFrame = destFrame;
	$(document).ready( function() {
		var kFrameset = "index.htm";
		var parentUri = parseUri(parent.location.href);
		var windowUri = parseUri(window.location.href);

		if (windowUri.file == '' ||
				windowUri.file.toLowerCase() == kFrameset) {
			// Handle parent page
			// Argument format: ?framename1=uri;anchor&framename2=uri;anchor...
			// Ex: ?ssmain=p1.htm;i32&ssindex=i1.htm;s37
			// Loads: p1.htm#i32 in frame "ssmain"
			// Loads: i1.htm#s37 in frame "ssindex"

			// Process frame arguments
			for (var sArg in windowUri.queryKey) {
				// Get frame URIs from frame name/anchor arguments
				var parts = windowUri.queryKey[sArg].split(';');
				window.frames[sArg].location.href = parts[0]+(parts.length>1 ? '#'+parts[1] : '');
			};

		} else {
			// Handle child page
			if (window.location.href == parent.location.href) {
				// Not in parent frame; reload parent
				// with arguments set to load child
				var sUrl = kFrameset+'?'+sDestFrame+'='+windowUri.file+';'+windowUri.anchor;
				window.location.href=sUrl;
			};
		};
	});
};

var ss = function() {
	var bMapEditor = false;
	var bHaveConsole = false;

	/**
	 * parseColor parses CSS color values. It is based
	 * on RGBColor by Stoyan Stefanov <sstoo@gmail.com>,
	 * rewritten by John Cardinal to improve performance and
	 * make it more compatible with my applications and coding
	 * style.
	 */

	function parseColor(sColor) {
		// Constructor for parseColor object.
		// sColor is optional; if provided,
		// it will be parsed. Otherwise, call the
		// parseColor.parse(sColor) method.

		var self = this;
		this.r = this.g = this.b = 0;
		this.color_names = {
			'aliceblue': 'f0f8ff',
			'antiquewhite': 'faebd7',
			'aqua': '00ffff',
			'aquamarine': '7fffd4',
			'azure': 'f0ffff',
			'beige': 'f5f5dc',
			'bisque': 'ffe4c4',
			'black': '000000',
			'blanchedalmond': 'ffebcd',
			'blue': '0000ff',
			'blueviolet': '8a2be2',
			'brown': 'a52a2a',
			'burlywood': 'deb887',
			'cadetblue': '5f9ea0',
			'chartreuse': '7fff00',
			'chocolate': 'd2691e',
			'coral': 'ff7f50',
			'cornflowerblue': '6495ed',
			'cornsilk': 'fff8dc',
			'crimson': 'dc143c',
			'cyan': '00ffff',
			'darkblue': '00008b',
			'darkcyan': '008b8b',
			'darkgoldenrod': 'b8860b',
			'darkgray': 'a9a9a9',
			'darkgrey': 'a9a9a9',
			'darkgreen': '006400',
			'darkkhaki': 'bdb76b',
			'darkmagenta': '8b008b',
			'darkolivegreen': '556b2f',
			'darkorange': 'ff8c00',
			'darkorchid': '9932cc',
			'darkred': '8b0000',
			'darksalmon': 'e9967a',
			'darkseagreen': '8fbc8b',
			'darkslateblue': '483d8b',
			'darkslategray': '2f4f4f',
			'darkslategrey': '2f4f4f',
			'darkturquoise': '00ced1',
			'darkviolet': '9400d3',
			'deeppink': 'ff1493',
			'deepskyblue': '00bfff',
			'dimgray': '696969',
			'dimgrey': '696969',
			'dodgerblue': '1e90ff',
			'firebrick': 'b22222',
			'floralwhite': 'fffaf0',
			'forestgreen': '228b22',
			'fuchsia': 'ff00ff',
			'gainsboro': 'dcdcdc',
			'ghostwhite': 'f8f8ff',
			'gold': 'ffd700',
			'goldenrod': 'daa520',
			'gray': '808080',
			'grey': '808080',
			'green': '008000',
			'greenyellow': 'adff2f',
			'honeydew': 'f0fff0',
			'hotpink': 'ff69b4',
			'indianred': 'cd5c5c',
			'indigo': '4b0082',
			'ivory': 'fffff0',
			'khaki': 'f0e68c',
			'lavender': 'e6e6fa',
			'lavenderblush': 'fff0f5',
			'lawngreen': '7cfc00',
			'lemonchiffon': 'fffacd',
			'lightblue': 'add8e6',
			'lightcoral': 'f08080',
			'lightcyan': 'e0ffff',
			'lightgoldenrodyellow': 'fafad2',
			'lightgreen': '90ee90',
			'lightgray': 'd3d3d3',
			'lightgrey': 'd3d3d3',
			'lightpink': 'ffb6c1',
			'lightsalmon': 'ffa07a',
			'lightseagreen': '20b2aa',
			'lightskyblue': '87cefa',
			'lightslategray': '778899',
			'lightslategrey': '778899',
			'lightsteelblue': 'b0c4de',
			'lightyellow': 'ffffe0',
			'lime': '00ff00',
			'limegreen': '32cd32',
			'linen': 'faf0e6',
			'magenta': 'ff00ff',
			'maroon': '800000',
			'mediumaquamarine': '66cdaa',
			'mediumblue': '0000cd',
			'mediumorchid': 'ba55d3',
			'mediumpurple': '9370db',
			'mediumseagreen': '3cb371',
			'mediumslateblue': '7b68ee',
			'mediumspringgreen': '00fa9a',
			'mediumturquoise': '48d1cc',
			'mediumvioletred': 'c71585',
			'midnightblue': '191970',
			'mintcream': 'f5fffa',
			'mistyrose': 'ffe4e1',
			'moccasin': 'ffe4b5',
			'navajowhite': 'ffdead',
			'navy': '000080',
			'oldlace': 'fdf5e6',
			'olive': '808000',
			'olivedrab': '6b8e23',
			'orange': 'ffa500',
			'orangered': 'ff4500',
			'orchid': 'da70d6',
			'palegoldenrod': 'eee8aa',
			'palegreen': '98fb98',
			'paleturquoise': 'afeeee',
			'palevioletred': 'db7093',
			'papayawhip': 'ffefd5',
			'peachpuff': 'ffdab9',
			'peru': 'cd853f',
			'pink': 'ffc0cb',
			'plum': 'dda0dd',
			'powderblue': 'b0e0e6',
			'purple': '800080',
			'red': 'ff0000',
			'rosybrown': 'bc8f8f',
			'royalblue': '4169e1',
			'saddlebrown': '8b4513',
			'salmon': 'fa8072',
			'sandybrown': 'f4a460',
			'seagreen': '2e8b57',
			'seashell': 'fff5ee',
			'sienna': 'a0522d',
			'silver': 'c0c0c0',
			'skyblue': '87ceeb',
			'slateblue': '6a5acd',
			'slategray': '708090',
			'slategrey': '708090',
			'snow': 'fffafa',
			'springgreen': '00ff7f',
			'steelblue': '4682b4',
			'tan': 'd2b48c',
			'teal': '008080',
			'thistle': 'd8bfd8',
			'tomato': 'ff6347',
			'turquoise': '40e0d0',
			'violet': 'ee82ee',
			'wheat': 'f5deb3',
			'white': 'ffffff',
			'whitesmoke': 'f5f5f5',
			'yellow': 'ffff00',
			'yellowgreen': '9acd32'
		};

		// Array of functions to parse CSS color strings
		this.parsers = [
			// Handles "ffffff" form
			function(sColor) {
				if (sColor.length==6) {
					self.r = parseInt(sColor.substr(0,2), 16);
					self.g = parseInt(sColor.substr(2,2), 16);
					self.b = parseInt(sColor.substr(4,2), 16);
					return true;
				};
			},
			// Handles "fff" form
			function(sColor) {
				if (sColor.length==3) {
					var c = sColor.charAt(0);
					self.r = parseInt(c+c, 16);
					c = sColor.charAt(1);
					self.g = parseInt(c+c, 16);
					c = sColor.charAt(2);
					self.b = parseInt(c+c, 16);
					return true;
				};
			},
			// Handles "rgb(255,255,255)" form
			function(sColor) {
				var parts = sColor.match(/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/);
				if (parts) {
					self.r = parseInt(parts[1]);
					self.g = parseInt(parts[2]);
					self.b = parseInt(parts[3]);
					return true;
				};
			},
			// Last variation sets values to 0
			function(sColor) {
				self.r = self.g = self.b = 0;
				return false;
			}
		];

		if (sColor) {
			this.parse(sColor);
		};
	};

	parseColor.prototype.toHex = function() {
		var rX = ('0'+this.r.toString(16)).right(2);
		var gX = ('0'+this.g.toString(16)).right(2);
		var bX = ('0'+this.b.toString(16)).right(2);
		return '#' + rX + gX + bX;
	};

	parseColor.prototype.toRGB = function() {
		return 'rgb('+this.r+','+this.g+','+this.b+')';
	};

	parseColor.prototype.parse = function(sColor) {
		var result = false;

		// Remove #s and spaces
		sColor = sColor.toLowerCase().replace(/[# ]/g,'');

		// Check for named color
		if (this.color_names[sColor]) {
			sColor = this.color_names[sColor];
		};

		// Call the parsers until one indicates success
		for (var i = 0; i < this.parsers.length && !result; i++) {
			result = this.parsers[i](sColor);
		};

		if (result) {
			// validate/cleanup values
			this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r);
			this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g);
			this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b);
		};

		return result;
	};

	return {
		enableMapEditor: function(enable) {	bMapEditor=enable; },
		isMapEditor: function() { return (bMapEditor); },

		extend: function(baseClass, subClass) {
			// Copied from Kevin Lindsey
			// http://www.kevlindev.com/tutorials/javascript/inheritance/index.htm
			function inheritance() {};
			inheritance.prototype = baseClass.prototype;

			subClass.prototype = new inheritance();
			subClass.prototype.constructor = subClass;
			subClass.baseConstructor = baseClass;
			subClass.superClass = baseClass.prototype;
		},

		// floating point to decimal degrees, 8 digits after decimal
		fpdd: function(float) { return (float.toFixed(8)) },

		propsToString: function(theObject, prefix, suffix) {
			var sProps = '';
			var sDelim = '';

			for (var prop in theObject) {
				if (typeof(theObject[prop]) != 'function' &&
						typeof(theObject[prop]) != 'object') {
					sProps += '<span title="'+typeof(theObject[prop])+'">';
					sProps +=	(prefix ? prefix : sDelim) + '&nbsp;' + prop + ':' + theObject[prop] + (suffix ? suffix : '')+'</span>';
					sDelim = ', ';
				};
			};
			return sProps;
		},

		parseColor: parseColor,

		imageAnchorBuilder: function(index, slide, width, height) {
			return '<li><a href="#"><img src="' + slide.src + '" width="' + width + '" height="' + height + '"/></a></li>';
		},

		divAnchorBuilder: function(index, slide, width, height) {
			var src = $('img',slide).attr('src');
			return '<li><a href="#"><img src="' + src + '" width="' + width + '" height="' + height + '"/></a></li>';
		},

		getSiblCaption: function(element) {
			return $(element).parent().parent().children('div.egic').html();
		},

		getUseMapFromId: function(sId) {
			if (sId) {
				return ' usemap="#' + sId.replace(/^img/i,'map') + '"';
			} else {
				return '';
			};
		},

		addLightBoxes: function(id, cssClass, tipOpen, tipLink) {
			// Add lightboxes for gallery images and pictures user items
			var sSelector = '#' + id + (cssClass=='egib' ? ' div.egib' : '');
			var sCaptionClass = (cssClass=='egib' ? 'egic' : cssClass+'c');

			$(sSelector).each( function(index) {
				// Change outer div to "position:relative" and add "sslbc" class
				$(this)
					.css({position:'relative', 'paddingTop':'21px'})
					.addClass('sslbc');

				// Add buttons
				if ($('a.sslbPage',this).length) {
					$(this).append('<button class="iconlink" title="' + tipLink + '"/>' +
							'<button class="iconopen" title="' + tipOpen + '"/>');
				} else if ($('a.sslbImage',this).length) {
					$(this).append('<button class="iconopen" title="' + tipOpen + '"/>');
				};

				// Add click handler for iconlink buttons
				$(this).children('button.iconlink').click( function() {
					if (cssClass=='egib') {
						document.location = $(this).siblings().first().children('a.sslbPage').attr('href');
					} else {
						document.location = $(this).siblings('a.sslbPage').attr('href');
					};
				});
			});
			
			// Enable the imageBox for the iconopen buttons
			$('#'+id+' button.iconopen').imageBox({
				rel: (cssClass=='egib' ? id : cssClass),
				getCaption: function(element) {
					return $(element).siblings('div.'+sCaptionClass).html();
				},
				getHref: function(element) {
					var sHref = '';
					if (cssClass=='egib') {
						sHref = $(element).siblings().first().children('a.sslbImage').attr('href');
						if (!sHref) {
							sHref = $(element).siblings().first().children('a.sslbPage').attr('rel');
						};
					} else {
						sHref = $(element).siblings('a.sslbImage').attr('href');
						if (!sHref) {
							sHref = $(element).siblings('a.sslbPage').attr('rel');
						};
					};
					return sHref;
				},
				getUseMap: function(element) {
					var sId = '';
					if (cssClass=='egib') {
						sId = $(element).siblings().first().children('a.sslbImage').attr('id');
						if (!sId) {
							sId = $(element).siblings().first().children('a.sslbPage').attr('id');
						};
					} else {
						sId = $(element).siblings('a.sslbImage').attr('id');
						if (!sId) {
							sId = $(element).siblings('a.sslbPage').attr('id');
						};
					};
					return ss.getUseMapFromId(sId);
				}
			});

			// Enable the imageBox for the thumbnail images
			$('#'+id+' a.sslbImage').imageBox({
				rel: (cssClass=='egib' ? id+'a' : cssClass+'a'),
				getCaption: function(element) {
					if (cssClass=='egib') {
						return $(element).parent().parent().children('div.'+sCaptionClass).html();
					} else {
						return $(element).siblings('div.'+sCaptionClass).html();
					};
				},
				getUseMap: function(element) {
					return ss.getUseMapFromId($(element).attr('id'));
				}
			});
		},

		addExhibitLights: function(cssClass, tipOpen, tipLink) {
			// Add lightboxes for embedded exhibits
			var sSelector = 'div.'+cssClass;
			var sCaptionClass = cssClass+'c';

			$(sSelector).each( function(index) {
				if ($('a.sslbImage',this).length) {
					// Change outer div to "position:relative" and add "sslbc" class
					$(this)
						.css({position:'relative', 'paddingTop':'21px'})
						.addClass('sslbc');

					// Add button
					$(this).append('<button class="iconopen" title="' + tipOpen + '"/>');
				};
			});
			
			// Enable the imageBox for the iconopen buttons
			$(sSelector+' button.iconopen').imageBox({
				rel: 'nofollow',
				getCaption: function(element) {
					return $(element).siblings('div.'+sCaptionClass).html();
				},
				getHref: function(element) {
					return $(element).siblings('a.sslbImage').attr('href');
				},
				getUseMap: function(element) {
					return ss.getUseMapFromId($(element).siblings('a.sslbImage').attr('id'));
				}
			});

			// Enable the imageBox for the thumbnail images
			$(sSelector+' a.sslbImage').imageBox({
				rel: 'nofollow',
				getCaption: function(element) {
					return $(element).siblings('div.'+sCaptionClass).html();
				},
				getUseMap: function(element) {
					return ss.getUseMapFromId($(element).attr('id'));
				}
			});
		},

		pageTocElements: 'h2'
	}
}();

function initCalendars() {
	$("div.calendar").each( function() {
		var id=$(this).attr('id');
		var oCalendar = new SSCalendar(id);
		// Store object off the element so we
		// can access it via element
		$('#'+id).data('obj', oCalendar);
		oCalendar.getData();
	});
};

function SSCalendar(id) {
	this.id = id;
	this.cookieName = id+'|month|year';
	this.maxDays = 32;		// days in longest month, plus one
	this.calendarDate = new Date();

	var sCookie = $.cookie(this.cookieName);
	if (sCookie != null) {
		var sParts = sCookie.split('|');
		this.calendarDate = new Date(sParts[1], sParts[0], 1);
	};
};

SSCalendar.prototype.getData = function() {
	// Save data and make calendar
	this.data = eval('('+$('#caldata'+this.id).html()+')');
	$('#caldata'+this.id).html('');
	this.days = this.data.days;
	this.months = this.data.months;
	this.makeCalendar();
};

SSCalendar.prototype.makeCalendar = function() {
	var iDay;
	this.calendarDate = new Date(this.calendarDate.getFullYear(), this.calendarDate.getMonth(), 1);

	var days = this.getDaysInMonth(this.calendarDate.getMonth());
	var sDays = this.getEventsForMonth(this.calendarDate.getMonth());
	var oCells = this.getCalendarCells(sDays, days, this.calendarDate.getDay());

	$('#'+this.id+' div.caltable').html( this.getHTML(sDays, oCells) );

	this.setHandlers();
};

SSCalendar.prototype.getHTML = function(sDays, oCells) {
	// getHTML creates the HTML to display a month.

	var nWeeks = oCells.length/7;
	var iMonth = this.calendarDate.getMonth();
	var iYear = this.calendarDate.getFullYear();
	var iCell = 0;
	var oCell;
	var sW = '';

	// Heading row with controls, month, year
	sW += '<table class="caltable"><thead>' +
			'<tr class="calmth"><th colspan="7">' +
			'<div style="position:relative; margin: 0 auto; width: 14em;">' +
			'<button class="calprev"></button>' +
			'<button class="calnext"></button>' + this.months[iMonth]+' '+iYear +
			'</div></th></tr>';

	// Heading row with days of week
	sW += '<tr class="caldow">';
	for (iDay=0; iDay<7; iDay++) {
		sW += '<th>'+this.days[iDay]+'</th>';
	};
	sW += '</tr></thead>';

	// Rows with event data
	sW += '<tbody>';
	for (var iWeek=0; iWeek<nWeeks; iWeek++) {
		sW += '<tr>';
		for (var iDay=0; iDay<7; iDay++) {
			oCell = oCells[iCell];
			if (oCell.css != '') {
				sW += '<td class="'+oCell.css+'"';
				if (oCell.colspan>1) sW += ' colspan="'+oCell.colspan+'"';
				sW += '>';
				if (oCell.dayNumber>0) {
					sW += '<div class="caldn';
					if (iMonth==1 && oCell.dayNumber==29) {
						if (!this.isLeapYear(iYear)) sW += ' caldn29';
					};
					sW += '">'+oCell.dayNumber+'</div>';
				};
				if (oCell.daysIndex != -1) sW += sDays[oCell.daysIndex];
				sW += '</td>';
			};
			iCell++;
		};
		sW += '</tr>';
	};
	sW += '</tbody></table>';
	return sW;
};

SSCalendar.prototype.getEventsForMonth = function(nMonth) {
	/* Load event text into sDays array based on day number.
	   Note that months and days are 1-origin in JSON data.
	   Month events (no day) are stored in sDays[0].
	*/
	var sDays = new Array(this.maxDays);
	var iDay;
	var oCalEvt;
	var p, n;

	// Initialize the array
	for (iDay=0; iDay<this.maxDays; iDay++) sDays[iDay]='';

	for (iEvent=0; iEvent<this.data.events.length; iEvent++) {
		oCalEvt = this.data.events[iEvent];
		if (oCalEvt.m==nMonth+1) {
			iDay = oCalEvt.d;
			sDays[iDay] += '<div class="calevt">' +
					'<span class="calppl">'+oCalEvt.p+'</span>' +
					'<span class="calnot">('+oCalEvt.n+')</span>' +
					'</div>';
		};
	};

	// Fix HTML characters
	for (iDay=0; iDay<this.maxDays; iDay++) {
		sDays[iDay]=sDays[iDay].replace(/&gt;/gi, '>');
		sDays[iDay]=sDays[iDay].replace(/&lt;/gi, '<');
		sDays[iDay]=sDays[iDay].replace(/&amp;/gi, '&');
	};
	return sDays;
};

SSCalendar.prototype.getCalendarCells = function(sDays, days, firstDay) {
	/* Create cells for the grid that will represent the month.
	   Cells are used during rendering stage (getHTML()) to
	   control which days are in which cells, colspans, etc.
	*/
	var oCells = new Array;
	var iDay;
	var iCell;
	var extraCells;

	// Adjust February if no 29th day events
	// and not leap year
	if ((days==29) && (sDays[29].length==0)) {
		iYear = this.calendarDate.getFullYear();
		if (!this.isLeapYear(iYear)) days=28;
	};

	if (firstDay>2) {
		// We have at least 3 empty days at
		// front, so put month events there

		// Cell for month events
		oCells.push ( {
			css: (sDays[0].length==0) ? 'calemp':'caloth',
			colspan: (firstDay),
			dayNumber: 0,
			daysIndex: 0 } );

		// Placeholder cells
		for (iCell=1; iCell<firstDay; iCell++) {
			oCells.push ( {
				css: '',
				colspan: 1,
				dayNumber: 0,
				daysIndex: -1 } );
		};

		// Cells for days in month
		for (iDay=1; iDay<=days; iDay++) {
			oCells.push ( {
				css: 'calday',
				colspan: 1,
				dayNumber: iDay,
				daysIndex: iDay } );
		};

		// Empty cells after end of month
		extraCells = 7-(oCells.length%7);
		if (extraCells==7) extraCells=0;
		for (iCell=0; iCell<extraCells; iCell++) {
			oCells.push ( {
				css: "calemp",
				colspan: 1,
				dayNumber: 0,
				daysIndex: -1 } );
		};
	} else {
		// Put month events at end
		
		// Empty cells before start of month
		for (iCell=0; iCell<firstDay; iCell++) {
			oCells.push ( {
				css: "calemp",
				colspan: 1,
				dayNumber: 0,
				daysIndex: -1 } );
		};

		// Cells for days in month
		for (iDay=1; iDay<=days; iDay++) {
			oCells.push ( {
				css: "calday",
				colspan: 1,
				dayNumber: iDay,
				daysIndex: iDay } );
		};

		// Room for other events in last
		// week of month?
		extraCells = 7-(oCells.length%7);
		if (extraCells<=2) {
			for (iCell=0; iCell<extraCells; iCell++) {
				oCells.push ( {
					css: "calemp",
					colspan: 1,
					dayNumber: 0,
					daysIndex: -1 } );
			};
			extraCells=7;
		};

		// Write other cell and extra cells unless
		// it's a whole row and no month events
		if ((extraCells!=7) || (sDays[0].length>0)) {
			// Cell for month events
			oCells.push ( {
				css: (sDays[0].length==0) ? 'calemp':'caloth',
				colspan: extraCells,
				dayNumber: 0,
				daysIndex: 0 } );

			// Placeholder cells
			for (iCell=1; iCell<extraCells; iCell++) {
				oCells.push ( {
					css: '',
					colspan: 1,
					dayNumber: 0,
					daysIndex: -1 } );
			};
		};
	};
	return oCells;
};

SSCalendar.prototype.setHandlers = function() {
	/* setHandlers adds handlers for controls
	   that adjust current month.
	*/
	var oCal = this;

	$('#'+this.id+' button.calprev').click(function() {
		oCal.adjustMonth(-1);
		oCal.makeCalendar();
		return false;
	});

	$('#'+this.id+' button.calnext').click(function() {
		oCal.adjustMonth(1);
		oCal.makeCalendar();
		return false;
	});
};

SSCalendar.prototype.adjustMonth = function(delta) {
	/* adjustMonth is called by control handlers
	   to adjust the month up or down.
	*/
	var iMonth = this.calendarDate.getMonth()+delta;
	var iYear = this.calendarDate.getFullYear();
	$.cookie(this.cookieName, iMonth+'|'+iYear);
	this.calendarDate = new Date(iYear, iMonth, 1);
};

SSCalendar.prototype.getDaysInMonth = function(monthNo) {
	var days=[31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	return days[monthNo];
};

SSCalendar.prototype.isLeapYear = function(yearNo) {
	return (new Date(yearNo, 1, 29).getMonth() == 1);
};;(function($){$.cluetip={version:'1.0.3'};var $cluetip,$cluetipInner,$cluetipOuter,$cluetipTitle,$cluetipArrows,$cluetipWait,$dropShadow,imgCount;$.fn.cluetip=function(js,options){if(typeof js=='object'){options=js;js=null;}
if(js=='destroy'){return this.unbind('.cluetip');}
return this.each(function(index){var link=this,$this=$(this);var opts=$.extend(true,{},$.fn.cluetip.defaults,options||{},$.metadata?$this.metadata():$.meta?$this.data():{});var cluetipContents=false;var cluezIndex=+opts.cluezIndex;$this.data('thisInfo',{title:link.title,zIndex:cluezIndex});var isActive=false,closeOnDelay=0;if(!$('#cluetip').length){$(['<div id="cluetip">','<div id="cluetip-outer">','<h3 id="cluetip-title"></h3>','<div id="cluetip-inner"></div>','</div>','<div id="cluetip-extra"></div>','<div id="cluetip-arrows" class="cluetip-arrows"></div>','</div>'].join(''))
[insertionType](insertionElement).hide();$cluetip=$('#cluetip').css({position:'absolute'});$cluetipOuter=$('#cluetip-outer').css({position:'relative',zIndex:cluezIndex});$cluetipInner=$('#cluetip-inner');$cluetipTitle=$('#cluetip-title');$cluetipArrows=$('#cluetip-arrows');$cluetipWait=$('<div id="cluetip-waitimage"></div>').css({position:'absolute'}).insertBefore($cluetip).hide();}
var dropShadowSteps=(opts.dropShadow)?+opts.dropShadowSteps:0;if(!$dropShadow){$dropShadow=$([]);for(var i=0;i<dropShadowSteps;i++){$dropShadow=$dropShadow.add($('<div></div>').css({zIndex:cluezIndex-1,opacity:.1,top:1+i,left:1+i}));};$dropShadow.css({position:'absolute',backgroundColor:'#000'}).prependTo($cluetip);}
var tipAttribute=$this.attr(opts.attribute),ctClass=opts.cluetipClass;if(!tipAttribute&&!opts.splitTitle&&!js)return true;if(opts.local&&opts.localPrefix){tipAttribute=opts.localPrefix+tipAttribute;}
if(opts.local&&opts.hideLocal){$(tipAttribute+':first').hide();}
var tOffset=parseInt(opts.topOffset,10),lOffset=parseInt(opts.leftOffset,10);var tipHeight,wHeight,defHeight=isNaN(parseInt(opts.height,10))?'auto':(/\D/g).test(opts.height)?opts.height:opts.height+'px';var sTop,linkTop,posY,tipY,mouseY,baseline;var tipInnerWidth=parseInt(opts.width,10)||275,tipWidth=tipInnerWidth+(parseInt($cluetip.css('paddingLeft'),10)||0)+(parseInt($cluetip.css('paddingRight'),10)||0)+dropShadowSteps,linkWidth=this.offsetWidth,linkLeft,posX,tipX,mouseX,winWidth;var tipParts;var tipTitle=(opts.attribute!='title')?$this.attr(opts.titleAttribute):'';if(opts.splitTitle){if(tipTitle==undefined){tipTitle='';}
tipParts=tipTitle.split(opts.splitTitle);tipTitle=tipParts.shift();}
if(opts.escapeTitle){tipTitle=tipTitle.replace(/&/g,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;');}
var localContent;var activate=function(event){if(!opts.onActivate($this)){return false;}
isActive=true;$cluetip.removeClass().css({width:tipInnerWidth});if(tipAttribute==$this.attr('href')){$this.css('cursor',opts.cursor);}
if(opts.hoverClass){$this.addClass(opts.hoverClass);}
linkTop=posY=$this.offset().top;linkLeft=$this.offset().left;mouseX=event.pageX;mouseY=event.pageY;if(link.tagName.toLowerCase()!='area'){sTop=$(document).scrollTop();winWidth=$(window).width();}
if(opts.positionBy=='fixed'){posX=linkWidth+linkLeft+lOffset;$cluetip.css({left:posX});}else{posX=(linkWidth>linkLeft&&linkLeft>tipWidth)||linkLeft+linkWidth+tipWidth+lOffset>winWidth?linkLeft-tipWidth-lOffset:linkWidth+linkLeft+lOffset;if(link.tagName.toLowerCase()=='area'||opts.positionBy=='mouse'||linkWidth+tipWidth>winWidth){if(mouseX+20+tipWidth>winWidth){$cluetip.addClass(' cluetip-'+ctClass);posX=(mouseX-tipWidth-lOffset)>=0?mouseX-tipWidth-lOffset-parseInt($cluetip.css('marginLeft'),10)+parseInt($cluetipInner.css('marginRight'),10):mouseX-(tipWidth/2);}else{posX=mouseX+lOffset;}}
var pY=posX<0?event.pageY+tOffset:event.pageY;$cluetip.css({left:(posX>0&&opts.positionBy!='bottomTop')?posX:(mouseX+(tipWidth/2)>winWidth)?winWidth/2-tipWidth/2:Math.max(mouseX-(tipWidth/2),0),zIndex:$this.data('thisInfo').zIndex});$cluetipArrows.css({zIndex:$this.data('thisInfo').zIndex+1});}
wHeight=$(window).height();if(js){if(typeof js=='function'){js=js(link);}
$cluetipInner.html(js);cluetipShow(pY);}
else if(tipParts){var tpl=tipParts.length;$cluetipInner.html(tipParts[0]);if(tpl>1){for(var i=1;i<tpl;i++){$cluetipInner.append('<div class="split-body">'+tipParts[i]+'</div>');}}
cluetipShow(pY);}
else if(!opts.local&&tipAttribute.indexOf('#')!=0){if(/\.(jpe?g|tiff?|gif|png)$/i.test(tipAttribute)){$cluetipInner.html('<img src="'+tipAttribute+'" alt="'+tipTitle+'" />');cluetipShow(pY);}else if(cluetipContents&&opts.ajaxCache){$cluetipInner.html(cluetipContents);cluetipShow(pY);}else{var optionBeforeSend=opts.ajaxSettings.beforeSend,optionError=opts.ajaxSettings.error,optionSuccess=opts.ajaxSettings.success,optionComplete=opts.ajaxSettings.complete;var ajaxSettings={cache:false,url:tipAttribute,beforeSend:function(xhr){if(optionBeforeSend){optionBeforeSend.call(link,xhr,$cluetip,$cluetipInner);}
$cluetipOuter.children().empty();if(opts.waitImage){$cluetipWait.css({top:mouseY+20,left:mouseX+20,zIndex:$this.data('thisInfo').zIndex-1}).show();}},error:function(xhr,textStatus){if(isActive){if(optionError){optionError.call(link,xhr,textStatus,$cluetip,$cluetipInner);}else{$cluetipInner.html('<i>sorry, the contents could not be loaded</i>');}}},success:function(data,textStatus){cluetipContents=opts.ajaxProcess.call(link,data);if(isActive){if(optionSuccess){optionSuccess.call(link,data,textStatus,$cluetip,$cluetipInner);}
$cluetipInner.html(cluetipContents);}},complete:function(xhr,textStatus){if(optionComplete){optionComplete.call(link,xhr,textStatus,$cluetip,$cluetipInner);}
imgCount=$('#cluetip-inner img').length;if(imgCount&&!$.browser.opera){$('#cluetip-inner img').bind('load error',function(){imgCount--;if(imgCount<1){$cluetipWait.hide();if(isActive)cluetipShow(pY);}});}else{$cluetipWait.hide();if(isActive){cluetipShow(pY);}}}};var ajaxMergedSettings=$.extend(true,{},opts.ajaxSettings,ajaxSettings);$.ajax(ajaxMergedSettings);}}else if(opts.local){var $localContent=$(tipAttribute+(/#\S+$/.test(tipAttribute)?'':':eq('+index+')')).clone(true).show();$cluetipInner.html($localContent);cluetipShow(pY);}};var cluetipShow=function(bpY){$cluetip.addClass('cluetip-'+ctClass);if(opts.truncate){var $truncloaded=$cluetipInner.text().slice(0,opts.truncate)+'...';$cluetipInner.html($truncloaded);}
function doNothing(){};tipTitle?$cluetipTitle.show().html(tipTitle):(opts.showTitle)?$cluetipTitle.show().html('&nbsp;'):$cluetipTitle.hide();if(opts.sticky){var $closeLink=$('<div id="cluetip-close"><a href="#">'+opts.closeText+'</a></div>');(opts.closePosition=='bottom')?$closeLink.appendTo($cluetipInner):(opts.closePosition=='title')?$closeLink.prependTo($cluetipTitle):$closeLink.prependTo($cluetipInner);$closeLink.bind('click.cluetip',function(){cluetipClose();return false;});if(opts.mouseOutClose){if($.fn.hoverIntent&&opts.hoverIntent){$cluetip.hoverIntent({over:doNothing,timeout:opts.hoverIntent.timeout,out:function(){$closeLink.trigger('click.cluetip');}});}else{$cluetip.hover(doNothing,function(){$closeLink.trigger('click.cluetip');});}}else{$cluetip.unbind('mouseout');}}
var direction='';$cluetipOuter.css({zIndex:$this.data('thisInfo').zIndex,overflow:defHeight=='auto'?'visible':'auto',height:defHeight});tipHeight=defHeight=='auto'?Math.max($cluetip.outerHeight(),$cluetip.height()):parseInt(defHeight,10);tipY=posY;baseline=sTop+wHeight;if(opts.positionBy=='fixed'){tipY=posY-opts.dropShadowSteps+tOffset;}else if((posX<mouseX&&Math.max(posX,0)+tipWidth>mouseX)||opts.positionBy=='bottomTop'){if(posY+tipHeight+tOffset>baseline&&mouseY-sTop>tipHeight+tOffset){tipY=mouseY-tipHeight-tOffset;direction='top';}else{tipY=mouseY+tOffset;direction='bottom';}}else if(posY+tipHeight+tOffset>baseline){tipY=(tipHeight>=wHeight)?sTop:baseline-tipHeight-tOffset;}else if($this.css('display')=='block'||link.tagName.toLowerCase()=='area'||opts.positionBy=="mouse"){tipY=bpY-tOffset;}else{tipY=posY-opts.dropShadowSteps;}
if(direction==''){posX<linkLeft?direction='left':direction='right';}
$cluetip.css({top:tipY+'px'}).removeClass().addClass('clue-'+direction+'-'+ctClass).addClass(' cluetip-'+ctClass);if(opts.arrows){var bgY=(posY-tipY-opts.dropShadowSteps);$cluetipArrows.css({top:(/(left|right)/.test(direction)&&posX>=0&&bgY>0)?bgY+'px':/(left|right)/.test(direction)?0:''}).show();}else{$cluetipArrows.hide();}
$dropShadow.hide();$cluetip.hide()[opts.fx.open](opts.fx.open!='show'&&opts.fx.openSpeed);if(opts.dropShadow){$dropShadow.css({height:tipHeight,width:tipInnerWidth,zIndex:$this.data('thisInfo').zIndex-1}).show();}
if($.fn.bgiframe){$cluetip.bgiframe();}
if(opts.delayedClose>0){closeOnDelay=setTimeout(cluetipClose,opts.delayedClose);}
opts.onShow.call(link,$cluetip,$cluetipInner);};var inactivate=function(event){isActive=false;$cluetipWait.hide();if(!opts.sticky||(/click|toggle/).test(opts.activation)){cluetipClose();clearTimeout(closeOnDelay);};if(opts.hoverClass){$this.removeClass(opts.hoverClass);}};var cluetipClose=function(){$cluetipOuter.parent().hide().removeClass();opts.onHide.call(link,$cluetip,$cluetipInner);$this.removeClass('cluetip-clicked');if(tipTitle){$this.attr(opts.titleAttribute,tipTitle);}
$this.css('cursor','');if(opts.arrows)$cluetipArrows.css({top:''});};$(document).bind('hideCluetip',function(e){cluetipClose();});if((/click|toggle/).test(opts.activation)){$this.bind('click.cluetip',function(event){if($cluetip.is(':hidden')||!$this.is('.cluetip-clicked')){activate(event);$('.cluetip-clicked').removeClass('cluetip-clicked');$this.addClass('cluetip-clicked');}else{inactivate(event);}
this.blur();return false;});}else if(opts.activation=='focus'){$this.bind('focus.cluetip',function(event){activate(event);});$this.bind('blur.cluetip',function(event){inactivate(event);});}else{$this.bind('click.cluetip',function(){if($this.attr('href')&&$this.attr('href')==tipAttribute&&!opts.clickThrough){return false;}});var mouseTracks=function(evt){if(opts.tracking==true){var trackX=posX-evt.pageX;var trackY=tipY?tipY-evt.pageY:posY-evt.pageY;$this.bind('mousemove.cluetip',function(evt){$cluetip.css({left:evt.pageX+trackX,top:evt.pageY+trackY});});}};if($.fn.hoverIntent&&opts.hoverIntent){$this.hoverIntent({sensitivity:opts.hoverIntent.sensitivity,interval:opts.hoverIntent.interval,over:function(event){activate(event);mouseTracks(event);},timeout:opts.hoverIntent.timeout,out:function(event){inactivate(event);$this.unbind('mousemove.cluetip');}});}else{$this.bind('mouseenter.cluetip',function(event){activate(event);mouseTracks(event);}).bind('mouseleave.cluetip',function(event){inactivate(event);$this.unbind('mousemove.cluetip');});}
$this.bind('mouseenter.cluetip',function(event){$this.attr('title','');}).bind('mouseleave.cluetip',function(event){$this.attr('title',$this.data('thisInfo').title);});}});};$.fn.cluetip.defaults={width:275,height:'auto',cluezIndex:97,positionBy:'auto',topOffset:15,leftOffset:15,local:false,localPrefix:null,hideLocal:true,attribute:'rel',titleAttribute:'title',splitTitle:'',escapeTitle:false,showTitle:true,cluetipClass:'default',hoverClass:'',waitImage:true,cursor:'help',arrows:false,dropShadow:true,dropShadowSteps:6,sticky:false,mouseOutClose:false,activation:'hover',clickThrough:false,tracking:false,delayedClose:0,closePosition:'top',closeText:'Close',truncate:0,fx:{open:'show',openSpeed:''},hoverIntent:{sensitivity:3,interval:50,timeout:0},onActivate:function(e){return true;},onShow:function(ct,ci){},onHide:function(ct,ci){},ajaxCache:true,ajaxProcess:function(data){data=data.replace(/<(script|style|title)[^<]+<\/(script|style|title)>/gm,'').replace(/<(link|meta)[^>]+>/g,'');return data;},ajaxSettings:{dataType:'html'},debug:false};var insertionType='appendTo',insertionElement='body';$.cluetip.setup=function(options){if(options&&options.insertionType&&(options.insertionType).match(/appendTo|prependTo|insertBefore|insertAfter/)){insertionType=options.insertionType;}
if(options&&options.insertionElement){insertionElement=options.insertionElement;}};})(jQuery);jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){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();}
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{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]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
return cookieValue;}};/*
 * jQuery Cycle Plugin (with Transition Definitions)
 * Examples and documentation at: http://jquery.malsup.com/cycle/
 * Copyright (c) 2007-2010 M. Alsup
 * Version: 2.86 (05-APR-2010)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.2.6 or later
 */
(function($){var ver="2.86";if($.support==undefined){$.support={opacity:!($.browser.msie)};}function debug(s){if($.fn.cycle.debug){log(s);}}function log(){if(window.console&&window.console.log){window.console.log("[cycle] "+Array.prototype.join.call(arguments," "));}}$.fn.cycle=function(options,arg2){var o={s:this.selector,c:this.context};if(this.length===0&&options!="stop"){if(!$.isReady&&o.s){log("DOM not ready, queuing slideshow");$(function(){$(o.s,o.c).cycle(options,arg2);});return this;}log("terminating; zero elements found by selector"+($.isReady?"":" (DOM not ready)"));return this;}return this.each(function(){var opts=handleArguments(this,options,arg2);if(opts===false){return;}opts.updateActivePagerLink=opts.updateActivePagerLink||$.fn.cycle.updateActivePagerLink;if(this.cycleTimeout){clearTimeout(this.cycleTimeout);}this.cycleTimeout=this.cyclePause=0;var $cont=$(this);var $slides=opts.slideExpr?$(opts.slideExpr,this):$cont.children();var els=$slides.get();if(els.length<2){log("terminating; too few slides: "+els.length);return;}var opts2=buildOptions($cont,$slides,els,opts,o);if(opts2===false){return;}var startTime=opts2.continuous?10:getTimeout(opts2.currSlide,opts2.nextSlide,opts2,!opts2.rev);if(startTime){startTime+=(opts2.delay||0);if(startTime<10){startTime=10;}debug("first timeout: "+startTime);this.cycleTimeout=setTimeout(function(){go(els,opts2,0,!opts2.rev);},startTime);}});};function handleArguments(cont,options,arg2){if(cont.cycleStop==undefined){cont.cycleStop=0;}if(options===undefined||options===null){options={};}if(options.constructor==String){switch(options){case"destroy":case"stop":var opts=$(cont).data("cycle.opts");if(!opts){return false;}cont.cycleStop++;if(cont.cycleTimeout){clearTimeout(cont.cycleTimeout);}cont.cycleTimeout=0;$(cont).removeData("cycle.opts");if(options=="destroy"){destroy(opts);}return false;case"toggle":cont.cyclePause=(cont.cyclePause===1)?0:1;checkInstantResume(cont.cyclePause,arg2,cont);return false;case"pause":cont.cyclePause=1;return false;case"resume":cont.cyclePause=0;checkInstantResume(false,arg2,cont);return false;case"prev":case"next":var opts=$(cont).data("cycle.opts");if(!opts){log('options not found, "prev/next" ignored');return false;}$.fn.cycle[options](opts);return false;default:options={fx:options};}return options;}else{if(options.constructor==Number){var num=options;options=$(cont).data("cycle.opts");if(!options){log("options not found, can not advance slide");return false;}if(num<0||num>=options.elements.length){log("invalid slide index: "+num);return false;}options.nextSlide=num;if(cont.cycleTimeout){clearTimeout(cont.cycleTimeout);cont.cycleTimeout=0;}if(typeof arg2=="string"){options.oneTimeFx=arg2;}go(options.elements,options,1,num>=options.currSlide);return false;}}return options;function checkInstantResume(isPaused,arg2,cont){if(!isPaused&&arg2===true){var options=$(cont).data("cycle.opts");if(!options){log("options not found, can not resume");return false;}if(cont.cycleTimeout){clearTimeout(cont.cycleTimeout);cont.cycleTimeout=0;}go(options.elements,options,1,1);}}}function removeFilter(el,opts){if(!$.support.opacity&&opts.cleartype&&el.style.filter){try{el.style.removeAttribute("filter");}catch(smother){}}}function destroy(opts){if(opts.next){$(opts.next).unbind(opts.prevNextEvent);}if(opts.prev){$(opts.prev).unbind(opts.prevNextEvent);}if(opts.pager||opts.pagerAnchorBuilder){$.each(opts.pagerAnchors||[],function(){this.unbind().remove();});}opts.pagerAnchors=null;if(opts.destroy){opts.destroy(opts);}}function buildOptions($cont,$slides,els,options,o){var opts=$.extend({},$.fn.cycle.defaults,options||{},$.metadata?$cont.metadata():$.meta?$cont.data():{});if(opts.autostop){opts.countdown=opts.autostopCount||els.length;}var cont=$cont[0];$cont.data("cycle.opts",opts);opts.$cont=$cont;opts.stopCount=cont.cycleStop;opts.elements=els;opts.before=opts.before?[opts.before]:[];opts.after=opts.after?[opts.after]:[];opts.after.unshift(function(){opts.busy=0;});if(!$.support.opacity&&opts.cleartype){opts.after.push(function(){removeFilter(this,opts);});}if(opts.continuous){opts.after.push(function(){go(els,opts,0,!opts.rev);});}saveOriginalOpts(opts);if(!$.support.opacity&&opts.cleartype&&!opts.cleartypeNoBg){clearTypeFix($slides);}if($cont.css("position")=="static"){$cont.css("position","relative");}if(opts.width){$cont.width(opts.width);}if(opts.height&&opts.height!="auto"){$cont.height(opts.height);}if(opts.startingSlide){opts.startingSlide=parseInt(opts.startingSlide);}if(opts.random){opts.randomMap=[];for(var i=0;i<els.length;i++){opts.randomMap.push(i);}opts.randomMap.sort(function(a,b){return Math.random()-0.5;});opts.randomIndex=1;opts.startingSlide=opts.randomMap[1];}else{if(opts.startingSlide>=els.length){opts.startingSlide=0;}}opts.currSlide=opts.startingSlide||0;var first=opts.startingSlide;$slides.css({position:"absolute",top:0,left:0}).hide().each(function(i){var z=first?i>=first?els.length-(i-first):first-i:els.length-i;$(this).css("z-index",z);});$(els[first]).css("opacity",1).show();removeFilter(els[first],opts);if(opts.fit&&opts.width){$slides.width(opts.width);}if(opts.fit&&opts.height&&opts.height!="auto"){$slides.height(opts.height);}var reshape=opts.containerResize&&!$cont.innerHeight();if(reshape){var maxw=0,maxh=0;for(var j=0;j<els.length;j++){var $e=$(els[j]),e=$e[0],w=$e.outerWidth(),h=$e.outerHeight();if(!w){w=e.offsetWidth||e.width||$e.attr("width");}if(!h){h=e.offsetHeight||e.height||$e.attr("height");}maxw=w>maxw?w:maxw;maxh=h>maxh?h:maxh;}if(maxw>0&&maxh>0){$cont.css({width:maxw+"px",height:maxh+"px"});}}if(opts.pause){$cont.hover(function(){this.cyclePause++;},function(){this.cyclePause--;});}if(supportMultiTransitions(opts)===false){return false;}var requeue=false;options.requeueAttempts=options.requeueAttempts||0;$slides.each(function(){var $el=$(this);this.cycleH=(opts.fit&&opts.height)?opts.height:($el.height()||this.offsetHeight||this.height||$el.attr("height")||0);this.cycleW=(opts.fit&&opts.width)?opts.width:($el.width()||this.offsetWidth||this.width||$el.attr("width")||0);if($el.is("img")){var loadingIE=($.browser.msie&&this.cycleW==28&&this.cycleH==30&&!this.complete);var loadingFF=($.browser.mozilla&&this.cycleW==34&&this.cycleH==19&&!this.complete);var loadingOp=($.browser.opera&&((this.cycleW==42&&this.cycleH==19)||(this.cycleW==37&&this.cycleH==17))&&!this.complete);var loadingOther=(this.cycleH==0&&this.cycleW==0&&!this.complete);if(loadingIE||loadingFF||loadingOp||loadingOther){if(o.s&&opts.requeueOnImageNotLoaded&&++options.requeueAttempts<100){log(options.requeueAttempts," - img slide not loaded, requeuing slideshow: ",this.src,this.cycleW,this.cycleH);setTimeout(function(){$(o.s,o.c).cycle(options);},opts.requeueTimeout);requeue=true;return false;}else{log("could not determine size of image: "+this.src,this.cycleW,this.cycleH);}}}return true;});if(requeue){return false;}opts.cssBefore=opts.cssBefore||{};opts.animIn=opts.animIn||{};opts.animOut=opts.animOut||{};$slides.not(":eq("+first+")").css(opts.cssBefore);if(opts.cssFirst){$($slides[first]).css(opts.cssFirst);}if(opts.timeout){opts.timeout=parseInt(opts.timeout);if(opts.speed.constructor==String){opts.speed=$.fx.speeds[opts.speed]||parseInt(opts.speed);}if(!opts.sync){opts.speed=opts.speed/2;}var buffer=opts.fx=="shuffle"?500:250;while((opts.timeout-opts.speed)<buffer){opts.timeout+=opts.speed;}}if(opts.easing){opts.easeIn=opts.easeOut=opts.easing;}if(!opts.speedIn){opts.speedIn=opts.speed;}if(!opts.speedOut){opts.speedOut=opts.speed;}opts.slideCount=els.length;opts.currSlide=opts.lastSlide=first;if(opts.random){if(++opts.randomIndex==els.length){opts.randomIndex=0;}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{opts.nextSlide=opts.startingSlide>=(els.length-1)?0:opts.startingSlide+1;}if(!opts.multiFx){var init=$.fn.cycle.transitions[opts.fx];if($.isFunction(init)){init($cont,$slides,opts);}else{if(opts.fx!="custom"&&!opts.multiFx){log("unknown transition: "+opts.fx,"; slideshow terminating");return false;}}}var e0=$slides[first];if(opts.before.length){opts.before[0].apply(e0,[e0,e0,opts,true]);}if(opts.after.length>1){opts.after[1].apply(e0,[e0,e0,opts,true]);}if(opts.next){$(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?-1:1);});}if(opts.prev){$(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?1:-1);});}if(opts.pager||opts.pagerAnchorBuilder){buildPager(els,opts);}exposeAddSlide(opts,els);return opts;}function saveOriginalOpts(opts){opts.original={before:[],after:[]};opts.original.cssBefore=$.extend({},opts.cssBefore);opts.original.cssAfter=$.extend({},opts.cssAfter);opts.original.animIn=$.extend({},opts.animIn);opts.original.animOut=$.extend({},opts.animOut);$.each(opts.before,function(){opts.original.before.push(this);});$.each(opts.after,function(){opts.original.after.push(this);});}function supportMultiTransitions(opts){var i,tx,txs=$.fn.cycle.transitions;if(opts.fx.indexOf(",")>0){opts.multiFx=true;opts.fxs=opts.fx.replace(/\s*/g,"").split(",");for(i=0;i<opts.fxs.length;i++){var fx=opts.fxs[i];tx=txs[fx];if(!tx||!txs.hasOwnProperty(fx)||!$.isFunction(tx)){log("discarding unknown transition: ",fx);opts.fxs.splice(i,1);i--;}}if(!opts.fxs.length){log("No valid transitions named; slideshow terminating.");return false;}}else{if(opts.fx=="all"){opts.multiFx=true;opts.fxs=[];for(p in txs){tx=txs[p];if(txs.hasOwnProperty(p)&&$.isFunction(tx)){opts.fxs.push(p);}}}}if(opts.multiFx&&opts.randomizeEffects){var r1=Math.floor(Math.random()*20)+30;for(i=0;i<r1;i++){var r2=Math.floor(Math.random()*opts.fxs.length);opts.fxs.push(opts.fxs.splice(r2,1)[0]);}debug("randomized fx sequence: ",opts.fxs);}return true;}function exposeAddSlide(opts,els){opts.addSlide=function(newSlide,prepend){var $s=$(newSlide),s=$s[0];if(!opts.autostopCount){opts.countdown++;}els[prepend?"unshift":"push"](s);if(opts.els){opts.els[prepend?"unshift":"push"](s);}opts.slideCount=els.length;$s.css("position","absolute");$s[prepend?"prependTo":"appendTo"](opts.$cont);if(prepend){opts.currSlide++;opts.nextSlide++;}if(!$.support.opacity&&opts.cleartype&&!opts.cleartypeNoBg){clearTypeFix($s);}if(opts.fit&&opts.width){$s.width(opts.width);}if(opts.fit&&opts.height&&opts.height!="auto"){$slides.height(opts.height);}s.cycleH=(opts.fit&&opts.height)?opts.height:$s.height();s.cycleW=(opts.fit&&opts.width)?opts.width:$s.width();$s.css(opts.cssBefore);if(opts.pager||opts.pagerAnchorBuilder){$.fn.cycle.createPagerAnchor(els.length-1,s,$(opts.pager),els,opts);}if($.isFunction(opts.onAddSlide)){opts.onAddSlide($s);}else{$s.hide();}};}$.fn.cycle.resetState=function(opts,fx){fx=fx||opts.fx;opts.before=[];opts.after=[];opts.cssBefore=$.extend({},opts.original.cssBefore);opts.cssAfter=$.extend({},opts.original.cssAfter);opts.animIn=$.extend({},opts.original.animIn);opts.animOut=$.extend({},opts.original.animOut);opts.fxFn=null;$.each(opts.original.before,function(){opts.before.push(this);});$.each(opts.original.after,function(){opts.after.push(this);});var init=$.fn.cycle.transitions[fx];if($.isFunction(init)){init(opts.$cont,$(opts.elements),opts);}};function go(els,opts,manual,fwd){if(manual&&opts.busy&&opts.manualTrump){debug("manualTrump in go(), stopping active transition");$(els).stop(true,true);opts.busy=false;}if(opts.busy){debug("transition active, ignoring new tx request");return;}var p=opts.$cont[0],curr=els[opts.currSlide],next=els[opts.nextSlide];if(p.cycleStop!=opts.stopCount||p.cycleTimeout===0&&!manual){return;}if(!manual&&!p.cyclePause&&((opts.autostop&&(--opts.countdown<=0))||(opts.nowrap&&!opts.random&&opts.nextSlide<opts.currSlide))){if(opts.end){opts.end(opts);}return;}var changed=false;if((manual||!p.cyclePause)&&(opts.nextSlide!=opts.currSlide)){changed=true;var fx=opts.fx;curr.cycleH=curr.cycleH||$(curr).height();curr.cycleW=curr.cycleW||$(curr).width();next.cycleH=next.cycleH||$(next).height();next.cycleW=next.cycleW||$(next).width();if(opts.multiFx){if(opts.lastFx==undefined||++opts.lastFx>=opts.fxs.length){opts.lastFx=0;}fx=opts.fxs[opts.lastFx];opts.currFx=fx;}if(opts.oneTimeFx){fx=opts.oneTimeFx;opts.oneTimeFx=null;}$.fn.cycle.resetState(opts,fx);if(opts.before.length){$.each(opts.before,function(i,o){if(p.cycleStop!=opts.stopCount){return;}o.apply(next,[curr,next,opts,fwd]);});}var after=function(){$.each(opts.after,function(i,o){if(p.cycleStop!=opts.stopCount){return;}o.apply(next,[curr,next,opts,fwd]);});};debug("tx firing; currSlide: "+opts.currSlide+"; nextSlide: "+opts.nextSlide);opts.busy=1;if(opts.fxFn){opts.fxFn(curr,next,opts,after,fwd,manual&&opts.fastOnEvent);}else{if($.isFunction($.fn.cycle[opts.fx])){$.fn.cycle[opts.fx](curr,next,opts,after,fwd,manual&&opts.fastOnEvent);}else{$.fn.cycle.custom(curr,next,opts,after,fwd,manual&&opts.fastOnEvent);}}}if(changed||opts.nextSlide==opts.currSlide){opts.lastSlide=opts.currSlide;if(opts.random){opts.currSlide=opts.nextSlide;if(++opts.randomIndex==els.length){opts.randomIndex=0;}opts.nextSlide=opts.randomMap[opts.randomIndex];if(opts.nextSlide==opts.currSlide){opts.nextSlide=(opts.currSlide==opts.slideCount-1)?0:opts.currSlide+1;}}else{var roll=(opts.nextSlide+1)==els.length;opts.nextSlide=roll?0:opts.nextSlide+1;opts.currSlide=roll?els.length-1:opts.nextSlide-1;}}if(changed&&opts.pager){opts.updateActivePagerLink(opts.pager,opts.currSlide,opts.activePagerClass);}var ms=0;if(opts.timeout&&!opts.continuous){ms=getTimeout(curr,next,opts,fwd);}else{if(opts.continuous&&p.cyclePause){ms=10;}}if(ms>0){p.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev);},ms);}}$.fn.cycle.updateActivePagerLink=function(pager,currSlide,clsName){$(pager).each(function(){$(this).children().removeClass(clsName).eq(currSlide).addClass(clsName);});};function getTimeout(curr,next,opts,fwd){if(opts.timeoutFn){var t=opts.timeoutFn(curr,next,opts,fwd);while((t-opts.speed)<250){t+=opts.speed;}debug("calculated timeout: "+t+"; speed: "+opts.speed);if(t!==false){return t;}}return opts.timeout;}$.fn.cycle.next=function(opts){advance(opts,opts.rev?-1:1);};$.fn.cycle.prev=function(opts){advance(opts,opts.rev?1:-1);};function advance(opts,val){var els=opts.elements;var p=opts.$cont[0],timeout=p.cycleTimeout;if(timeout){clearTimeout(timeout);p.cycleTimeout=0;}if(opts.random&&val<0){opts.randomIndex--;if(--opts.randomIndex==-2){opts.randomIndex=els.length-2;}else{if(opts.randomIndex==-1){opts.randomIndex=els.length-1;}}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{if(opts.random){opts.nextSlide=opts.randomMap[opts.randomIndex];}else{opts.nextSlide=opts.currSlide+val;if(opts.nextSlide<0){if(opts.nowrap){return false;}opts.nextSlide=els.length-1;}else{if(opts.nextSlide>=els.length){if(opts.nowrap){return false;}opts.nextSlide=0;}}}}var cb=opts.onPrevNextEvent||opts.prevNextClick;if($.isFunction(cb)){cb(val>0,opts.nextSlide,els[opts.nextSlide]);}go(els,opts,1,val>=0);return false;}function buildPager(els,opts){var $p=$(opts.pager);$.each(els,function(i,o){$.fn.cycle.createPagerAnchor(i,o,$p,els,opts);});opts.updateActivePagerLink(opts.pager,opts.startingSlide,opts.activePagerClass);}$.fn.cycle.createPagerAnchor=function(i,el,$p,els,opts){var a;if($.isFunction(opts.pagerAnchorBuilder)){a=opts.pagerAnchorBuilder(i,el);debug("pagerAnchorBuilder("+i+", el) returned: "+a);}else{a='<a href="#">'+(i+1)+"</a>";}if(!a){return;}var $a=$(a);if($a.parents("body").length===0){var arr=[];if($p.length>1){$p.each(function(){var $clone=$a.clone(true);$(this).append($clone);arr.push($clone[0]);});$a=$(arr);}else{$a.appendTo($p);}}opts.pagerAnchors=opts.pagerAnchors||[];opts.pagerAnchors.push($a);$a.bind(opts.pagerEvent,function(e){e.preventDefault();opts.nextSlide=i;var p=opts.$cont[0],timeout=p.cycleTimeout;if(timeout){clearTimeout(timeout);p.cycleTimeout=0;}var cb=opts.onPagerEvent||opts.pagerClick;if($.isFunction(cb)){cb(opts.nextSlide,els[opts.nextSlide]);}go(els,opts,1,opts.currSlide<i);});if(!/^click/.test(opts.pagerEvent)&&!opts.allowPagerClickBubble){$a.bind("click.cycle",function(){return false;});}if(opts.pauseOnPagerHover){$a.hover(function(){opts.$cont[0].cyclePause++;},function(){opts.$cont[0].cyclePause--;});}};$.fn.cycle.hopsFromLast=function(opts,fwd){var hops,l=opts.lastSlide,c=opts.currSlide;if(fwd){hops=c>l?c-l:opts.slideCount-l;}else{hops=c<l?l-c:l+opts.slideCount-c;}return hops;};function clearTypeFix($slides){debug("applying clearType background-color hack");function hex(s){s=parseInt(s).toString(16);return s.length<2?"0"+s:s;}function getBg(e){for(;e&&e.nodeName.toLowerCase()!="html";e=e.parentNode){var v=$.css(e,"background-color");if(v.indexOf("rgb")>=0){var rgb=v.match(/\d+/g);return"#"+hex(rgb[0])+hex(rgb[1])+hex(rgb[2]);}if(v&&v!="transparent"){return v;}}return"#ffffff";}$slides.each(function(){$(this).css("background-color",getBg(this));});}$.fn.cycle.commonReset=function(curr,next,opts,w,h,rev){$(opts.elements).not(curr).hide();opts.cssBefore.opacity=1;opts.cssBefore.display="block";if(w!==false&&next.cycleW>0){opts.cssBefore.width=next.cycleW;}if(h!==false&&next.cycleH>0){opts.cssBefore.height=next.cycleH;}opts.cssAfter=opts.cssAfter||{};opts.cssAfter.display="none";$(curr).css("zIndex",opts.slideCount+(rev===true?1:0));$(next).css("zIndex",opts.slideCount+(rev===true?0:1));};$.fn.cycle.custom=function(curr,next,opts,cb,fwd,speedOverride){var $l=$(curr),$n=$(next);var speedIn=opts.speedIn,speedOut=opts.speedOut,easeIn=opts.easeIn,easeOut=opts.easeOut;$n.css(opts.cssBefore);if(speedOverride){if(typeof speedOverride=="number"){speedIn=speedOut=speedOverride;}else{speedIn=speedOut=1;}easeIn=easeOut=null;}var fn=function(){$n.animate(opts.animIn,speedIn,easeIn,cb);};$l.animate(opts.animOut,speedOut,easeOut,function(){if(opts.cssAfter){$l.css(opts.cssAfter);}if(!opts.sync){fn();}});if(opts.sync){fn();}};$.fn.cycle.transitions={fade:function($cont,$slides,opts){$slides.not(":eq("+opts.currSlide+")").css("opacity",0);opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.cssBefore.opacity=0;});opts.animIn={opacity:1};opts.animOut={opacity:0};opts.cssBefore={top:0,left:0};}};$.fn.cycle.ver=function(){return ver;};$.fn.cycle.defaults={fx:"fade",timeout:4000,timeoutFn:null,continuous:0,speed:1000,speedIn:null,speedOut:null,next:null,prev:null,onPrevNextEvent:null,prevNextEvent:"click.cycle",pager:null,onPagerEvent:null,pagerEvent:"click.cycle",allowPagerClickBubble:false,pagerAnchorBuilder:null,before:null,after:null,end:null,easing:null,easeIn:null,easeOut:null,shuffle:null,animIn:null,animOut:null,cssBefore:null,cssAfter:null,fxFn:null,height:"auto",startingSlide:0,sync:1,random:0,fit:0,containerResize:1,pause:0,pauseOnPagerHover:0,autostop:0,autostopCount:0,delay:0,slideExpr:null,cleartype:!$.support.opacity,cleartypeNoBg:false,nowrap:0,fastOnEvent:0,randomizeEffects:1,rev:0,manualTrump:true,requeueOnImageNotLoaded:true,requeueTimeout:250,activePagerClass:"activeSlide",updateActivePagerLink:null};})(jQuery);
/*
 * jQuery Cycle Plugin Transition Definitions
 * This script is a plugin for the jQuery Cycle Plugin
 * Examples and documentation at: http://malsup.com/jquery/cycle/
 * Copyright (c) 2007-2008 M. Alsup
 * Version:	 2.72
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
(function($){$.fn.cycle.transitions.none=function($cont,$slides,opts){opts.fxFn=function(curr,next,opts,after){$(next).show();$(curr).hide();after();};};$.fn.cycle.transitions.scrollUp=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var h=$cont.height();opts.cssBefore={top:h,left:0};opts.cssFirst={top:0};opts.animIn={top:0};opts.animOut={top:-h};};$.fn.cycle.transitions.scrollDown=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var h=$cont.height();opts.cssFirst={top:0};opts.cssBefore={top:-h,left:0};opts.animIn={top:0};opts.animOut={top:h};};$.fn.cycle.transitions.scrollLeft=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var w=$cont.width();opts.cssFirst={left:0};opts.cssBefore={left:w,top:0};opts.animIn={left:0};opts.animOut={left:0-w};};$.fn.cycle.transitions.scrollRight=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var w=$cont.width();opts.cssFirst={left:0};opts.cssBefore={left:-w,top:0};opts.animIn={left:0};opts.animOut={left:w};};$.fn.cycle.transitions.scrollHorz=function($cont,$slides,opts){$cont.css("overflow","hidden").width();opts.before.push(function(curr,next,opts,fwd){$.fn.cycle.commonReset(curr,next,opts);opts.cssBefore.left=fwd?(next.cycleW-1):(1-next.cycleW);opts.animOut.left=fwd?-curr.cycleW:curr.cycleW;});opts.cssFirst={left:0};opts.cssBefore={top:0};opts.animIn={left:0};opts.animOut={top:0};};$.fn.cycle.transitions.scrollVert=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push(function(curr,next,opts,fwd){$.fn.cycle.commonReset(curr,next,opts);opts.cssBefore.top=fwd?(1-next.cycleH):(next.cycleH-1);opts.animOut.top=fwd?curr.cycleH:-curr.cycleH;});opts.cssFirst={top:0};opts.cssBefore={left:0};opts.animIn={top:0};opts.animOut={left:0};};$.fn.cycle.transitions.slideX=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$(opts.elements).not(curr).hide();$.fn.cycle.commonReset(curr,next,opts,false,true);opts.animIn.width=next.cycleW;});opts.cssBefore={left:0,top:0,width:0};opts.animIn={width:"show"};opts.animOut={width:0};};$.fn.cycle.transitions.slideY=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$(opts.elements).not(curr).hide();$.fn.cycle.commonReset(curr,next,opts,true,false);opts.animIn.height=next.cycleH;});opts.cssBefore={left:0,top:0,height:0};opts.animIn={height:"show"};opts.animOut={height:0};};$.fn.cycle.transitions.shuffle=function($cont,$slides,opts){var i,w=$cont.css("overflow","visible").width();$slides.css({left:0,top:0});opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,true,true);});if(!opts.speedAdjusted){opts.speed=opts.speed/2;opts.speedAdjusted=true;}opts.random=0;opts.shuffle=opts.shuffle||{left:-w,top:15};opts.els=[];for(i=0;i<$slides.length;i++){opts.els.push($slides[i]);}for(i=0;i<opts.currSlide;i++){opts.els.push(opts.els.shift());}opts.fxFn=function(curr,next,opts,cb,fwd){var $el=fwd?$(curr):$(next);$(next).css(opts.cssBefore);var count=opts.slideCount;$el.animate(opts.shuffle,opts.speedIn,opts.easeIn,function(){var hops=$.fn.cycle.hopsFromLast(opts,fwd);for(var k=0;k<hops;k++){fwd?opts.els.push(opts.els.shift()):opts.els.unshift(opts.els.pop());}if(fwd){for(var i=0,len=opts.els.length;i<len;i++){$(opts.els[i]).css("z-index",len-i+count);}}else{var z=$(curr).css("z-index");$el.css("z-index",parseInt(z)+1+count);}$el.animate({left:0,top:0},opts.speedOut,opts.easeOut,function(){$(fwd?this:curr).hide();if(cb){cb();}});});};opts.cssBefore={display:"block",opacity:1,top:0,left:0};};$.fn.cycle.transitions.turnUp=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false);opts.cssBefore.top=next.cycleH;opts.animIn.height=next.cycleH;});opts.cssFirst={top:0};opts.cssBefore={left:0,height:0};opts.animIn={top:0};opts.animOut={height:0};};$.fn.cycle.transitions.turnDown=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false);opts.animIn.height=next.cycleH;opts.animOut.top=curr.cycleH;});opts.cssFirst={top:0};opts.cssBefore={left:0,top:0,height:0};opts.animOut={height:0};};$.fn.cycle.transitions.turnLeft=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true);opts.cssBefore.left=next.cycleW;opts.animIn.width=next.cycleW;});opts.cssBefore={top:0,width:0};opts.animIn={left:0};opts.animOut={width:0};};$.fn.cycle.transitions.turnRight=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true);opts.animIn.width=next.cycleW;opts.animOut.left=curr.cycleW;});opts.cssBefore={top:0,left:0,width:0};opts.animIn={left:0};opts.animOut={width:0};};$.fn.cycle.transitions.zoom=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,false,true);opts.cssBefore.top=next.cycleH/2;opts.cssBefore.left=next.cycleW/2;opts.animIn={top:0,left:0,width:next.cycleW,height:next.cycleH};opts.animOut={width:0,height:0,top:curr.cycleH/2,left:curr.cycleW/2};});opts.cssFirst={top:0,left:0};opts.cssBefore={width:0,height:0};};$.fn.cycle.transitions.fadeZoom=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,false);opts.cssBefore.left=next.cycleW/2;opts.cssBefore.top=next.cycleH/2;opts.animIn={top:0,left:0,width:next.cycleW,height:next.cycleH};});opts.cssBefore={width:0,height:0};opts.animOut={opacity:0};};$.fn.cycle.transitions.blindX=function($cont,$slides,opts){var w=$cont.css("overflow","hidden").width();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.animIn.width=next.cycleW;opts.animOut.left=curr.cycleW;});opts.cssBefore={left:w,top:0};opts.animIn={left:0};opts.animOut={left:w};};$.fn.cycle.transitions.blindY=function($cont,$slides,opts){var h=$cont.css("overflow","hidden").height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.animIn.height=next.cycleH;opts.animOut.top=curr.cycleH;});opts.cssBefore={top:h,left:0};opts.animIn={top:0};opts.animOut={top:h};};$.fn.cycle.transitions.blindZ=function($cont,$slides,opts){var h=$cont.css("overflow","hidden").height();var w=$cont.width();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.animIn.height=next.cycleH;opts.animOut.top=curr.cycleH;});opts.cssBefore={top:h,left:w};opts.animIn={top:0,left:0};opts.animOut={top:h,left:w};};$.fn.cycle.transitions.growX=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true);opts.cssBefore.left=this.cycleW/2;opts.animIn={left:0,width:this.cycleW};opts.animOut={left:0};});opts.cssBefore={width:0,top:0};};$.fn.cycle.transitions.growY=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false);opts.cssBefore.top=this.cycleH/2;opts.animIn={top:0,height:this.cycleH};opts.animOut={top:0};});opts.cssBefore={height:0,left:0};};$.fn.cycle.transitions.curtainX=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true,true);opts.cssBefore.left=next.cycleW/2;opts.animIn={left:0,width:this.cycleW};opts.animOut={left:curr.cycleW/2,width:0};});opts.cssBefore={top:0,width:0};};$.fn.cycle.transitions.curtainY=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false,true);opts.cssBefore.top=next.cycleH/2;opts.animIn={top:0,height:next.cycleH};opts.animOut={top:curr.cycleH/2,height:0};});opts.cssBefore={left:0,height:0};};$.fn.cycle.transitions.cover=function($cont,$slides,opts){var d=opts.direction||"left";var w=$cont.css("overflow","hidden").width();var h=$cont.height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);if(d=="right"){opts.cssBefore.left=-w;}else{if(d=="up"){opts.cssBefore.top=h;}else{if(d=="down"){opts.cssBefore.top=-h;}else{opts.cssBefore.left=w;}}}});opts.animIn={left:0,top:0};opts.animOut={opacity:1};opts.cssBefore={top:0,left:0};};$.fn.cycle.transitions.uncover=function($cont,$slides,opts){var d=opts.direction||"left";var w=$cont.css("overflow","hidden").width();var h=$cont.height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,true,true);if(d=="right"){opts.animOut.left=w;}else{if(d=="up"){opts.animOut.top=-h;}else{if(d=="down"){opts.animOut.top=h;}else{opts.animOut.left=-w;}}}});opts.animIn={left:0,top:0};opts.animOut={opacity:1};opts.cssBefore={top:0,left:0};};$.fn.cycle.transitions.toss=function($cont,$slides,opts){var w=$cont.css("overflow","visible").width();var h=$cont.height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,true,true);if(!opts.animOut.left&&!opts.animOut.top){opts.animOut={left:w*2,top:-h/2,opacity:0};}else{opts.animOut.opacity=0;}});opts.cssBefore={left:0,top:0};opts.animIn={left:0};};$.fn.cycle.transitions.wipe=function($cont,$slides,opts){var w=$cont.css("overflow","hidden").width();var h=$cont.height();opts.cssBefore=opts.cssBefore||{};var clip;if(opts.clip){if(/l2r/.test(opts.clip)){clip="rect(0px 0px "+h+"px 0px)";}else{if(/r2l/.test(opts.clip)){clip="rect(0px "+w+"px "+h+"px "+w+"px)";}else{if(/t2b/.test(opts.clip)){clip="rect(0px "+w+"px 0px 0px)";}else{if(/b2t/.test(opts.clip)){clip="rect("+h+"px "+w+"px "+h+"px 0px)";}else{if(/zoom/.test(opts.clip)){var top=parseInt(h/2);var left=parseInt(w/2);clip="rect("+top+"px "+left+"px "+top+"px "+left+"px)";}}}}}}opts.cssBefore.clip=opts.cssBefore.clip||clip||"rect(0px 0px 0px 0px)";var d=opts.cssBefore.clip.match(/(\d+)/g);var t=parseInt(d[0]),r=parseInt(d[1]),b=parseInt(d[2]),l=parseInt(d[3]);opts.before.push(function(curr,next,opts){if(curr==next){return;}var $curr=$(curr),$next=$(next);$.fn.cycle.commonReset(curr,next,opts,true,true,false);opts.cssAfter.display="block";var step=1,count=parseInt((opts.speedIn/13))-1;(function f(){var tt=t?t-parseInt(step*(t/count)):0;var ll=l?l-parseInt(step*(l/count)):0;var bb=b<h?b+parseInt(step*((h-b)/count||1)):h;var rr=r<w?r+parseInt(step*((w-r)/count||1)):w;$next.css({clip:"rect("+tt+"px "+rr+"px "+bb+"px "+ll+"px)"});(step++<=count)?setTimeout(f,13):$curr.css("display","none");})();});opts.cssBefore={display:"block",opacity:1,top:0,left:0};opts.animIn={left:0};opts.animOut={left:0};};})(jQuery);/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @return    The object (aka "this") that called hoverIntent, and the event object
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

