/*
* Droppy 0.1.2
* (c) 2008 Jason Frame (jason@onehackoranother.com)
*/
$.fn.droppy = function(options) {

	options = $.extend({speed: 250}, options || {});

	this.each(function() {

		var root = this, zIndex = 1000;

		function getSubnav(ele) {
			if (ele.nodeName.toLowerCase() == 'li') {
				var subnav = $('> ul', ele);
				return subnav.length ? subnav[0] : null;
			} else {
				return ele;
			}
		}

		function getActuator(ele) {
			if (ele.nodeName.toLowerCase() == 'ul') {
				return $(ele).parents('li')[0];
			} else {
				return ele;
			}
		}

		function hide() {
			var subnav = getSubnav(this);
			if (!subnav) return;
			$.data(subnav, 'cancelHide', false);
			setTimeout(function() {
				if (!$.data(subnav, 'cancelHide')) {
					$(subnav).slideUp(options.speed);
				}
			}, 10);
		}

		function show() {
			var subnav = getSubnav(this);
			if (!subnav) return;
			$.data(subnav, 'cancelHide', true);
			$(subnav).css({zIndex: zIndex++}).slideDown(options.speed);
			if (this.nodeName.toLowerCase() == 'ul') {
				var li = getActuator(this);
				$(li).addClass('hover');
				$('> a', li).addClass('hover');
			}
		}

		$('ul, li', this).hover(show, hide);
		$('li', this).hover(
		function() { $(this).addClass('hover'); $('> a', this).addClass('hover'); },
		function() { $(this).removeClass('hover'); $('> a', this).removeClass('hover'); }
		);

	});

};

/*
* jQuery Media Plugin for converting elements into rich media content.
*
* Examples and documentation at: http://malsup.com/jquery/media/
* Copyright (c) 2007-2008 M. Alsup
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* @author: M. Alsup
* @version: 0.84 (12/01/2008)
* @requires jQuery v1.1.2 or later
* $Id: jquery.media.js 2460 2007-07-23 02:53:15Z malsup $
*
* Supported Media Players:
*    - Flash
*    - Quicktime
*    - Real Player
*    - Silverlight
*    - Windows Media Player
*    - iframe
*
* Supported Media Formats:
*   Any types supported by the above players, such as:
*     Video: asf, avi, flv, mov, mpg, mpeg, mp4, qt, smil, swf, wmv, 3g2, 3gp
*     Audio: aif, aac, au, gsm, mid, midi, mov, mp3, m4a, snd, rm, wav, wma
*     Other: bmp, html, pdf, psd, qif, qtif, qti, tif, tiff, xaml
*
* Thanks to Mark Hicken and Brent Pedersen for helping me debug this on the Mac!
* Thanks to Dan Rossi for numerous bug reports and code bits!
*/
;(function($) {

	/**
	* Chainable method for converting elements into rich media.
	*
	* @param options
	* @param callback fn invoked for each matched element before conversion
	* @param callback fn invoked for each matched element after conversion
	*/
	$.fn.media = function(options, f1, f2) {
		return this.each(function() {
			if (typeof options == 'function') {
				f2 = f1;
				f1 = options;
				options = {};
			}
			var o = getSettings(this, options);
			// pre-conversion callback, passes original element and fully populated options
			if (typeof f1 == 'function') f1(this, o);

			var r = getTypesRegExp();
			var m = r.exec(o.src) || [''];
			o.type ? m[0] = o.type : m.shift();
			for (var i=0; i < m.length; i++) {
				fn = m[i].toLowerCase();
				if (isDigit(fn[0])) fn = 'fn' + fn; // fns can't begin with numbers
				if (!$.fn.media[fn])
				continue;  // unrecognized media type
				// normalize autoplay settings
				var player = $.fn.media[fn+'_player'];
				if (!o.params) o.params = {};
				if (player) {
					var num = player.autoplayAttr == 'autostart';
					o.params[player.autoplayAttr || 'autoplay'] = num ? (o.autoplay ? 1 : 0) : o.autoplay ? true : false;
				}
				var $div = $.fn.media[fn](this, o);

				$div.css('backgroundColor', o.bgColor).width(o.width);
				// post-conversion callback, passes original element, new div element and fully populated options
				if (typeof f2 == 'function') f2(this, $div[0], o, player.name);
				break;
			}
		});
	};

	/**
	* Non-chainable method for adding or changing file format / player mapping
	* @name mapFormat
	* @param String format File format extension (ie: mov, wav, mp3)
	* @param String player Player name to use for the format (one of: flash, quicktime, realplayer, winmedia, silverlight or iframe
	*/
	$.fn.media.mapFormat = function(format, player) {
		if (!format || !player || !$.fn.media.defaults.players[player]) return; // invalid
		format = format.toLowerCase();
		if (isDigit(format[0])) format = 'fn' + format;
		$.fn.media[format] = $.fn.media[player];
		$.fn.media[format+'_player'] = $.fn.media.defaults.players[player];
	};

	// global defautls; override as needed
	$.fn.media.defaults = {
		width:         400,
		height:        400,
		autoplay:      0,         // normalized cross-player setting
		bgColor:       '#ffffff', // background color
		params:        { wmode: 'transparent'},  // added to object element as param elements; added to embed element as attrs
		attrs:         {},        // added to object and embed elements as attrs
		flvKeyName:    'file',    // key used for object src param (thanks to Andrea Ercolino)
		flashvars:     {},        // added to flash content as flashvars param/attr
		flashVersion:  '7',       // required flash version
		expressInstaller: null,   // src for express installer

		// default flash video and mp3 player (@see: http://jeroenwijering.com/?item=Flash_Media_Player)
		flvPlayer:     'mediaplayer.swf',
		mp3Player:     'mediaplayer.swf',

		// @see http://msdn2.microsoft.com/en-us/library/bb412401.aspx
		silverlight: {
			inplaceInstallPrompt: 'true', // display in-place install prompt?
			isWindowless:         'true', // windowless mode (false for wrapping markup)
			framerate:            '24',   // maximum framerate
			version:              '0.9',  // Silverlight version
			onError:              null,   // onError callback
			onLoad:               null,   // onLoad callback
			initParams:           null,   // object init params
			userContext:          null    // callback arg passed to the load callback
		}
	};

	// Media Players; think twice before overriding
	$.fn.media.defaults.players = {
		flash: {
			name:         'flash',
			types:        'flv,mp3,swf',
			oAttrs:   {
				classid:  'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
				type:     'application/x-oleobject',
				codebase: 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + $.fn.media.defaults.flashVersion
			},
			eAttrs: {
				type:         'application/x-shockwave-flash',
				pluginspage:  'http://www.adobe.com/go/getflashplayer'
			}
		},
		quicktime: {
			name:         'quicktime',
			types:        'aif,aiff,aac,au,bmp,gsm,mov,mid,midi,mpg,mpeg,mp4,m4a,psd,qt,qtif,qif,qti,snd,tif,tiff,wav,3g2,3gp',
			oAttrs:   {
				classid:  'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
				codebase: 'http://www.apple.com/qtactivex/qtplugin.cab'
			},
			eAttrs: {
				pluginspage:  'http://www.apple.com/quicktime/download/'
			}
		},
		realplayer: {
			name:         'real',
			types:        'ra,ram,rm,rpm,rv,smi,smil',
			autoplayAttr: 'autostart',
			oAttrs:   {
				classid:  'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'
			},
			eAttrs: {
				type:         'audio/x-pn-realaudio-plugin',
				pluginspage:  'http://www.real.com/player/'
			}
		},
		winmedia: {
			name:         'winmedia',
			types:        'asf,avi,wma,wmv',
			autoplayAttr: 'autostart',
			oUrl:         'url',
			oAttrs:   {
				classid:  'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6',
				type:     'application/x-oleobject'
			},
			eAttrs: {
				type:         $.browser.mozilla && isFirefoxWMPPluginInstalled() ? 'application/x-ms-wmp' : 'application/x-mplayer2',
				pluginspage:  'http://www.microsoft.com/Windows/MediaPlayer/'
			}
		},
		// special cases
		iframe: {
			name:  'iframe',
			types: 'html,pdf'
		},
		silverlight: {
			name:  'silverlight',
			types: 'xaml'
		}
	};

	//
	//  everything below here is private
	//


	// detection script for FF WMP plugin (http://www.therossman.org/experiments/wmp_play.html)
	// (hat tip to Mark Ross for this script)
	function isFirefoxWMPPluginInstalled() {
		var plugs = navigator.plugins;
		for (i = 0; i < plugs.length; i++) {
			var plugin = plugs[i];
			if (plugin['filename'] == 'np-mswmp.dll')
			return true;
		}
		return false;
	}

	var counter = 1;

	for (var player in $.fn.media.defaults.players) {
		var types = $.fn.media.defaults.players[player].types;
		$.each(types.split(','), function(i,o) {
			if (isDigit(o[0])) o = 'fn' + o;
			$.fn.media[o] = $.fn.media[player] = getGenerator(player);
			$.fn.media[o+'_player'] = $.fn.media.defaults.players[player];
		});
	};

	function getTypesRegExp() {
		var types = '';
		for (var player in $.fn.media.defaults.players) {
			if (types.length) types += ',';
			types += $.fn.media.defaults.players[player].types;
		};
		return new RegExp('\\.(' + types.replace(/,/g,'|') + ')$\\b');
	};

	function getGenerator(player) {
		return function(el, options) {
			return generate(el, options, player);
		};
	};

	function isDigit(c) {
		return '0123456789'.indexOf(c) > -1;
	};

	// flatten all possible options: global defaults, meta, option obj
	function getSettings(el, options) {
		options = options || {};
		var $el = $(el);
		var cls = el.className || '';
		// support metadata plugin (v1.0 and v2.0)
		var meta = $.metadata ? $el.metadata() : $.meta ? $el.data() : {};
		meta = meta || {};
		var w = meta.width  || parseInt(((cls.match(/w:(\d+)/)||[])[1]||0));
		var h = meta.height || parseInt(((cls.match(/h:(\d+)/)||[])[1]||0));

		if (w) meta.width  = w;
		if (h) meta.height = h;
		if (cls) meta.cls = cls;

		var a = $.fn.media.defaults;
		var b = options;
		var c = meta;

		var p = { params: { bgColor: options.bgColor || $.fn.media.defaults.bgColor } };
		var opts = $.extend({}, a, b, c);
		$.each(['attrs','params','flashvars','silverlight'], function(i,o) {
			opts[o] = $.extend({}, p[o] || {}, a[o] || {}, b[o] || {}, c[o] || {});
		});

		if (typeof opts.caption == 'undefined') opts.caption = $el.text();

		// make sure we have a source!
		opts.src = opts.src || $el.attr('href') || $el.attr('src') || 'unknown';
		return opts;
	};

	//
	//  Flash Player
	//

	// generate flash using SWFObject library if possible
	$.fn.media.swf = function(el, opts) {
		if (!window.SWFObject && !window.swfobject) {
			// roll our own
			if (opts.flashvars) {
				var a = [];
				for (var f in opts.flashvars)
				a.push(f + '=' + opts.flashvars[f]);
				if (!opts.params) opts.params = {};
				opts.params.flashvars = a.join('&');
			}
			return generate(el, opts, 'flash');
		}

		var id = el.id ? (' id="'+el.id+'"') : '';
		var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
		var $div = $('<div' + id + cls + '>');

		// swfobject v2+
		if (window.swfobject) {
			$(el).after($div).appendTo($div);
			if (!el.id) el.id = 'movie_player_' + counter++;

			// replace el with swfobject content
			swfobject.embedSWF(opts.src, el.id, opts.width, opts.height, opts.flashVersion,
			opts.expressInstaller, opts.flashvars, opts.params, opts.attrs);
		}
		// swfobject < v2
		else {
			$(el).after($div).remove();
			var so = new SWFObject(opts.src, 'movie_player_' + counter++, opts.width, opts.height, opts.flashVersion, opts.bgColor);
			if (opts.expressInstaller) so.useExpressInstall(opts.expressInstaller);

			for (var p in opts.params)
			if (p != 'bgColor') so.addParam(p, opts.params[p]);
			for (var f in opts.flashvars)
			so.addVariable(f, opts.flashvars[f]);
			so.write($div[0]);
		}

		if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
		return $div;
	};

	// map flv and mp3 files to the swf player by default
	$.fn.media.flv = $.fn.media.mp3 = function(el, opts) {
		var src = opts.src;
		var player = /\.mp3\b/i.test(src) ? $.fn.media.defaults.mp3Player : $.fn.media.defaults.flvPlayer;
		var key = opts.flvKeyName;
		src = encodeURIComponent(src);
		opts.src = player;
		opts.src = opts.src + '?'+key+'=' + (src);
		var srcObj = {};
		srcObj[key] = src;
		opts.flashvars = $.extend({}, srcObj, opts.flashvars );
		return $.fn.media.swf(el, opts);
	};

	//
	//  Silverlight
	//
	$.fn.media.xaml = function(el, opts) {
		if (!window.Sys || !window.Sys.Silverlight) {
			if ($.fn.media.xaml.warning) return;
			$.fn.media.xaml.warning = 1;
			alert('You must include the Silverlight.js script.');
			return;
		}

		var props = {
			width: opts.width,
			height: opts.height,
			background: opts.bgColor,
			inplaceInstallPrompt: opts.silverlight.inplaceInstallPrompt,
			isWindowless: opts.silverlight.isWindowless,
			framerate: opts.silverlight.framerate,
			version: opts.silverlight.version
		};
		var events = {
			onError: opts.silverlight.onError,
			onLoad: opts.silverlight.onLoad
		};

		var id1 = el.id ? (' id="'+el.id+'"') : '';
		var id2 = opts.id || 'AG' + counter++;
		// convert element to div
		var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
		var $div = $('<div' + id1 + cls + '>');
		$(el).after($div).remove();

		Sys.Silverlight.createObjectEx({
			source: opts.src,
			initParams: opts.silverlight.initParams,
			userContext: opts.silverlight.userContext,
			id: id2,
			parentElement: $div[0],
			properties: props,
			events: events
		});

		if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
		return $div;
	};

	//
	// generate object/embed markup
	//
	function generate(el, opts, player) {
		var $el = $(el);
		var o = $.fn.media.defaults.players[player];

		if (player == 'iframe') {
			var o = $('<iframe' + ' width="' + opts.width + '" height="' + opts.height + '" >');
			o.attr('src', opts.src);
			o.css('backgroundColor', o.bgColor);
		}
		else if ($.browser.msie) {
			var a = ['<object width="' + opts.width + '" height="' + opts.height + '" '];
			for (var key in opts.attrs)
			a.push(key + '="'+opts.attrs[key]+'" ');
			for (var key in o.oAttrs || {}) {
				var v = o.oAttrs[key];
				if (key == 'codebase' && window.location.protocol == 'https')
				v = v.replace('http','https');
				a.push(key + '="'+v+'" ');
			}
			a.push('></ob'+'ject'+'>');
			var p = ['<param name="' + (o.oUrl || 'src') +'" value="' + opts.src + '">'];
			for (var key in opts.params)
			p.push('<param name="'+ key +'" value="' + opts.params[key] + '">');
			var o = document.createElement(a.join(''));
			for (var i=0; i < p.length; i++)
			o.appendChild(document.createElement(p[i]));
		}
		else {
			var a = ['<embed width="' + opts.width + '" height="' + opts.height + '" style="display:block"'];
			if (opts.src) a.push(' src="' + opts.src + '" ');
			for (var key in opts.attrs)
			a.push(key + '="'+opts.attrs[key]+'" ');
			for (var key in o.eAttrs || {})
			a.push(key + '="'+o.eAttrs[key]+'" ');
			for (var key in opts.params)
			if (key != 'wmode') // FF3/Quicktime borks on wmode
			a.push(key + '="'+opts.params[key]+'" ');
			a.push('></em'+'bed'+'>');
		}
		// convert element to div
		var id = el.id ? (' id="'+el.id+'"') : '';
		var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
		var $div = $('<div' + id + cls + '>');
		$el.after($div).remove();
		($.browser.msie || player == 'iframe') ? $div.append(o) : $div.html(a.join(''));
		if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
		return $div;
	};


})(jQuery);

/**
* jQuery lightBox plugin
* This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
* and adapted to me for use like a plugin from jQuery.
* @name jquery-lightbox-0.5.js
* @author Leandro Vieira Pinho - http://leandrovieira.com
* @version 0.5
* @date April 11, 2008
* @category jQuery plugin
* @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
* @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
* @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
*/

// Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias
(function($) {
	/**
	* $ is an alias to jQuery object
	*
	*/
	$.fn.lightBox = function(settings) {
		// Settings to configure the jQuery lightBox plugin how you like
		settings = jQuery.extend({
			// Configuration related to overlay
			overlayBgColor: 		'#000000',		// (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
			overlayOpacity:			0.8,		// (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
			// Configuration related to navigation
			fixedNavigation:		false,		// (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
			// Configuration related to images
			imageLoading:			'/images/core/lightbox/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
			imageBtnPrev:			'/images/core/lightbox/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
			imageBtnNext:			'/images/core/lightbox/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
			imageBtnClose:		'/images/core/lightbox/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
			imageBlank:				'/images/core/lightbox/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
			// Configuration related to container image box
			containerBorderSize:	10,			// (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
			containerResizeSpeed:	400,		// (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
			// Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
			txtImage:				'Image',	// (string) Specify text "Image"
			txtOf:					'of',		// (string) Specify text "of"
			// Configuration related to keyboard navigation
			keyToClose:				'c',		// (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
			keyToPrev:				'p',		// (string) (p = previous) Letter to show the previous image
			keyToNext:				'n',		// (string) (n = next) Letter to show the next image.
			// Donīt alter these variables in any way
			imageArray:				[],
			activeImage:			0
		},settings);
		// Caching the jQuery object with all elements matched
		var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
		/**
		* Initializing the plugin calling the start function
		*
		* @return boolean false
		*/
		function _initialize() {
			_start(this,jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked
			return false; // Avoid the browser following the link
		}
		/**
		* Start the jQuery lightBox plugin
		*
		* @param object objClicked The object (link) whick the user have clicked
		* @param object jQueryMatchedObj The jQuery object with all elements matched
		*/
		function _start(objClicked,jQueryMatchedObj) {
			// Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'hidden' });
			// Call the function to create the markup structure; style some elements; assign events in some elements.
			_set_interface();
			// Unset total images in imageArray
			settings.imageArray.length = 0;
			// Unset image active information
			settings.activeImage = 0;
			// We have an image set? Or just an image? Letīs see it.
			if ( jQueryMatchedObj.length == 1 ) {
				settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));
			} else {
				// Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references
				for ( var i = 0; i < jQueryMatchedObj.length; i++ ) {
					settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));
				}
			}
			while ( settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href') ) {
				settings.activeImage++;
			}
			// Call the function that prepares image exibition
			_set_image_to_view();
		}
		/**
		* Create the jQuery lightBox plugin interface
		*
		* The HTML markup will be like that:
		<div id="jquery-overlay"></div>
		<div id="jquery-lightbox">
		<div id="lightbox-container-image-box">
		<div id="lightbox-container-image">
		<img src="../fotos/XX.jpg" id="lightbox-image">
		<div id="lightbox-nav">
		<a href="#" id="lightbox-nav-btnPrev"></a>
		<a href="#" id="lightbox-nav-btnNext"></a>
		</div>
		<div id="lightbox-loading">
		<a href="#" id="lightbox-loading-link">
		<img src="../images/lightbox-ico-loading.gif">
		</a>
		</div>
		</div>
		</div>
		<div id="lightbox-container-image-data-box">
		<div id="lightbox-container-image-data">
		<div id="lightbox-image-details">
		<span id="lightbox-image-details-caption"></span>
		<span id="lightbox-image-details-currentNumber"></span>
		</div>
		<div id="lightbox-secNav">
		<a href="#" id="lightbox-secNav-btnClose">
		<img src="../images/lightbox-btn-close.gif">
		</a>
		</div>
		</div>
		</div>
		</div>
		*
		*/
		function _set_interface() {
			// Apply the HTML markup into body tag
			$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="' + settings.imageBtnClose + '"></a></div></div></div></div>');
			// Get page sizes
			var arrPageSizes = ___getPageSize();
			// Style overlay and show it
			$('#jquery-overlay').css({
				backgroundColor:	settings.overlayBgColor,
				opacity:			settings.overlayOpacity,
				width:				arrPageSizes[0],
				height:				arrPageSizes[1]
			}).fadeIn();
			// Get page scroll
			var arrPageScroll = ___getPageScroll();
			// Calculate top and left offset for the jquery-lightbox div object and show it
			$('#jquery-lightbox').css({
				top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
				left:	arrPageScroll[0]
			}).show();
			// Assigning click events in elements to close overlay
			$('#jquery-overlay,#jquery-lightbox').click(function() {
				_finish();
			});
			// Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
			$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
				_finish();
				return false;
			});
			// If window was resized, calculate the new overlay dimensions
			$(window).resize(function() {
				// Get page sizes
				var arrPageSizes = ___getPageSize();
				// Style overlay and show it
				$('#jquery-overlay').css({
					width:		arrPageSizes[0],
					height:		arrPageSizes[1]
				});
				// Get page scroll
				var arrPageScroll = ___getPageScroll();
				// Calculate top and left offset for the jquery-lightbox div object and show it
				$('#jquery-lightbox').css({
					top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
					left:	arrPageScroll[0]
				});
			});
		}
		/**
		* Prepares image exibition; doing a imageīs preloader to calculate itīs size
		*
		*/
		function _set_image_to_view() { // show the loading
			// Show the loading
			$('#lightbox-loading').show();
			if ( settings.fixedNavigation ) {
				$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
			} else {
				// Hide some elements
				$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
			}
			// Image preload process
			var objImagePreloader = new Image();
			objImagePreloader.onload = function() {
				$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);
				// Perfomance an effect in the image container resizing it
				_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
				//	clear onLoad, IE behaves irratically with animated gifs otherwise
				objImagePreloader.onload=function(){};
			};
			objImagePreloader.src = settings.imageArray[settings.activeImage][0];
		};
		/**
		* Perfomance an effect in the image container resizing it
		*
		* @param integer intImageWidth The imageīs width that will be showed
		* @param integer intImageHeight The imageīs height that will be showed
		*/
		function _resize_container_image_box(intImageWidth,intImageHeight) {
			// Get current width and height
			var intCurrentWidth = $('#lightbox-container-image-box').width();
			var intCurrentHeight = $('#lightbox-container-image-box').height();
			// Get the width and height of the selected image plus the padding
			var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the imageīs width and the left and right padding value
			var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the imageīs height and the left and right padding value
			// Diferences
			var intDiffW = intCurrentWidth - intWidth;
			var intDiffH = intCurrentHeight - intHeight;
			// Perfomance the effect
			$('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight },settings.containerResizeSpeed,function() { _show_image(); });
			if ( ( intDiffW == 0 ) && ( intDiffH == 0 ) ) {
				if ( $.browser.msie ) {
					___pause(250);
				} else {
					___pause(100);
				}
			}
			$('#lightbox-container-image-data-box').css({ width: intImageWidth });
			$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });
		};
		/**
		* Show the prepared image
		*
		*/
		function _show_image() {
			$('#lightbox-loading').hide();
			$('#lightbox-image').fadeIn(function() {
				_show_image_data();
				_set_navigation();
			});
			_preload_neighbor_images();
		};
		/**
		* Show the image information
		*
		*/
		function _show_image_data() {
			$('#lightbox-container-image-data-box').slideDown('fast');
			$('#lightbox-image-details-caption').hide();
			if ( settings.imageArray[settings.activeImage][1] ) {
				$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
			}
			// If we have a image set, display 'Image X of X'
			if ( settings.imageArray.length > 1 ) {
				$('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + ( settings.activeImage + 1 ) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();
			}
		}
		/**
		* Display the button navigations
		*
		*/
		function _set_navigation() {
			$('#lightbox-nav').show();

			// Instead to define this configuration in CSS file, we define here. And itīs need to IE. Just.
			$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });

			// Show the prev button, if not the first image in set
			if ( settings.activeImage != 0 ) {
				if ( settings.fixedNavigation ) {
					$('#lightbox-nav-btnPrev').css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' })
					.unbind()
					.bind('click',function() {
						settings.activeImage = settings.activeImage - 1;
						_set_image_to_view();
						return false;
					});
				} else {
					// Show the images button for Next buttons
					$('#lightbox-nav-btnPrev').unbind().hover(function() {
						$(this).css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' });
					},function() {
						$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
					}).show().bind('click',function() {
						settings.activeImage = settings.activeImage - 1;
						_set_image_to_view();
						return false;
					});
				}
			}

			// Show the next button, if not the last image in set
			if ( settings.activeImage != ( settings.imageArray.length -1 ) ) {
				if ( settings.fixedNavigation ) {
					$('#lightbox-nav-btnNext').css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' })
					.unbind()
					.bind('click',function() {
						settings.activeImage = settings.activeImage + 1;
						_set_image_to_view();
						return false;
					});
				} else {
					// Show the images button for Next buttons
					$('#lightbox-nav-btnNext').unbind().hover(function() {
						$(this).css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' });
					},function() {
						$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
					}).show().bind('click',function() {
						settings.activeImage = settings.activeImage + 1;
						_set_image_to_view();
						return false;
					});
				}
			}
			// Enable keyboard navigation
			_enable_keyboard_navigation();
		}
		/**
		* Enable a support to keyboard navigation
		*
		*/
		function _enable_keyboard_navigation() {
			$(document).keydown(function(objEvent) {
				_keyboard_action(objEvent);
			});
		}
		/**
		* Disable the support to keyboard navigation
		*
		*/
		function _disable_keyboard_navigation() {
			$(document).unbind();
		}
		/**
		* Perform the keyboard actions
		*
		*/
		function _keyboard_action(objEvent) {
			// To ie
			if ( objEvent == null ) {
				keycode = event.keyCode;
				escapeKey = 27;
				// To Mozilla
			} else {
				keycode = objEvent.keyCode;
				escapeKey = objEvent.DOM_VK_ESCAPE;
			}
			// Get the key in lower case form
			key = String.fromCharCode(keycode).toLowerCase();
			// Verify the keys to close the ligthBox
			if ( ( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey ) ) {
				_finish();
			}
			// Verify the key to show the previous image
			if ( ( key == settings.keyToPrev ) || ( keycode == 37 ) ) {
				// If weīre not showing the first image, call the previous
				if ( settings.activeImage != 0 ) {
					settings.activeImage = settings.activeImage - 1;
					_set_image_to_view();
					_disable_keyboard_navigation();
				}
			}
			// Verify the key to show the next image
			if ( ( key == settings.keyToNext ) || ( keycode == 39 ) ) {
				// If weīre not showing the last image, call the next
				if ( settings.activeImage != ( settings.imageArray.length - 1 ) ) {
					settings.activeImage = settings.activeImage + 1;
					_set_image_to_view();
					_disable_keyboard_navigation();
				}
			}
		}
		/**
		* Preload prev and next images being showed
		*
		*/
		function _preload_neighbor_images() {
			if ( (settings.imageArray.length -1) > settings.activeImage ) {
				objNext = new Image();
				objNext.src = settings.imageArray[settings.activeImage + 1][0];
			}
			if ( settings.activeImage > 0 ) {
				objPrev = new Image();
				objPrev.src = settings.imageArray[settings.activeImage -1][0];
			}
		}
		/**
		* Remove jQuery lightBox plugin HTML markup
		*
		*/
		function _finish() {
			$('#jquery-lightbox').remove();
			$('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
			// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'visible' });
		}
		/**
		/ THIRD FUNCTION
		* getPageSize() by quirksmode.com
		*
		* @return Array Return an array with page width, height and window width, height
		*/
		function ___getPageSize() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth;
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else {
				pageHeight = yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){
				pageWidth = xScroll;
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
		};
		/**
		/ THIRD FUNCTION
		* getPageScroll() by quirksmode.com
		*
		* @return Array Return an array with x,y page scroll values.
		*/
		function ___getPageScroll() {
			var xScroll, yScroll;
			if (self.pageYOffset) {
				yScroll = self.pageYOffset;
				xScroll = self.pageXOffset;
			} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
				yScroll = document.documentElement.scrollTop;
				xScroll = document.documentElement.scrollLeft;
			} else if (document.body) {// all other Explorers
				yScroll = document.body.scrollTop;
				xScroll = document.body.scrollLeft;
			}
			arrayPageScroll = new Array(xScroll,yScroll);
			return arrayPageScroll;
		};
		/**
		* Stop the code execution from a escified time in milisecond
		*
		*/
		function ___pause(ms) {
			var date = new Date();
			curDate = null;
			do { var curDate = new Date(); }
			while ( curDate - date < ms);
		};
		// Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
		return this.unbind('click').click(_initialize);
	};
})(jQuery); // Call and execute the function immediately passing the jQuery object

//** Animated Collapsible DIV v2.0- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com.
//** May 24th, 08'- Script rewritten and updated to 2.0.
//** June 4th, 08'- Version 2.01: Bug fix to work with jquery 1.2.6 (which changed the way attr() behaves).
var animatedcollapse={
	divholders: {}, //structure: {div.id, div.attrs, div.$divref}
	divgroups: {}, //structure: {groupname.count, groupname.lastactivedivid}
	lastactiveingroup: {}, //structure: {lastactivediv.id}
	show:function(divids){ //public method
		if (typeof divids=="object"){
			for (var i=0; i<divids.length; i++)
			this.showhide(divids[i], "show")
		}
		else
		this.showhide(divids, "show")
	},
	hide:function(divids){ //public method
		if (typeof divids=="object"){
			for (var i=0; i<divids.length; i++)
			this.showhide(divids[i], "hide")
		}
		else
		this.showhide(divids, "hide")
	},
	toggle:function(divid){ //public method
		this.showhide(divid, "toggle")
	},
	addDiv:function(divid, attrstring){ //public function
		this.divholders[divid]=({id: divid, $divref: null, attrs: attrstring})
		this.divholders[divid].getAttr=function(name){ //assign getAttr() function to each divholder object
			var attr=new RegExp(name+"=([^,]+)", "i") //get name/value config pair (ie: width=400px,)
			return (attr.test(this.attrs) && parseInt(RegExp.$1)!=0)? RegExp.$1 : null //return value portion (string), or 0 (false) if none found
		}
	},
	showhide:function(divid, action){
		var $divref=this.divholders[divid].$divref //reference collapsible DIV
		if (this.divholders[divid] && $divref.length==1){ //if DIV exists
			var targetgroup=this.divgroups[$divref.attr('groupname')] //find out which group DIV belongs to (if any)
			if ($divref.attr('groupname') && targetgroup.count>1 && (action=="show" || action=="toggle" && $divref.css('display')=='none')){ //If current DIV belongs to a group
				if (targetgroup.lastactivedivid && targetgroup.lastactivedivid!=divid) //if last active DIV is set
				this.slideengine(targetgroup.lastactivedivid, 'hide') //hide last active DIV within group first
				this.slideengine(divid, 'show')
				targetgroup.lastactivedivid=divid //remember last active DIV
			}
			else{
				this.slideengine(divid, action)
			}
		}
	},
	slideengine:function(divid, action){
		var $divref=this.divholders[divid].$divref
		if (this.divholders[divid] && $divref.length==1){ //if this DIV exists
			var animateSetting={height: action}
			if ($divref.attr('fade'))
			animateSetting.opacity=action
			$divref.animate(animateSetting, $divref.attr('speed')? parseInt($divref.attr('speed')) : 500)
			return false
		}
	},
	generatemap:function(){
		var map={}
		for (var i=0; i<arguments.length; i++){
			if (arguments[i][1]!=null){
				map[arguments[i][0]]=arguments[i][1]
			}
		}
		return map
	},
	init:function(){
		var ac=this
		jQuery(document).ready(function($){
			var persistopenids=ac.getCookie('acopendivids') //Get list of div ids that should be expanded due to persistence ('div1,div2,etc')
			var groupswithpersist=ac.getCookie('acgroupswithpersist') //Get list of group names that have 1 or more divs with "persist" attribute defined
			if (persistopenids!=null) //if cookie isn't null (is null if first time page loads, and cookie hasnt been set yet)
			persistopenids=(persistopenids=='nada')? [] : persistopenids.split(',') //if no divs are persisted, set to empty array, else, array of div ids
			groupswithpersist=(groupswithpersist==null || groupswithpersist=='nada')? [] : groupswithpersist.split(',') //Get list of groups with divs that are persisted
			jQuery.each(ac.divholders, function(){ //loop through each collapsible DIV object
				this.$divref=$('#'+this.id)
				if ((this.getAttr('persist') || jQuery.inArray(this.getAttr('group'), groupswithpersist)!=-1) && persistopenids!=null){
					var cssdisplay=(jQuery.inArray(this.id, persistopenids)!=-1)? 'block' : 'none'
				}
				else{
					var cssdisplay=this.getAttr('hide')? 'none' : null
				}
				this.$divref.css(ac.generatemap(['height', this.getAttr('height')], ['display', cssdisplay]))
				this.$divref.attr(ac.generatemap(['groupname', this.getAttr('group')], ['fade', this.getAttr('fade')], ['speed', this.getAttr('speed')]))
				if (this.getAttr('group')){ //if this DIV has the "group" attr defined
					var targetgroup=ac.divgroups[this.getAttr('group')] || (ac.divgroups[this.getAttr('group')]={}) //Get settings for this group, or if it no settings exist yet, create blank object to store them in
					targetgroup.count=(targetgroup.count||0)+1 //count # of DIVs within this group
					if (!targetgroup.lastactivedivid && this.$divref.css('display')!='none' || cssdisplay=="block") //if this DIV was open by default or should be open due to persistence
					targetgroup.lastactivedivid=this.id //remember this DIV as the last "active" DIV (this DIV will be expanded)
					this.$divref.css({display:'none'}) //hide any DIV that's part of said group for now
				}
			}) //end divholders.each
			jQuery.each(ac.divgroups, function(){ //loop through each group
				if (this.lastactivedivid)
				ac.divholders[this.lastactivedivid].$divref.show() //and show last "active" DIV within each group (one that should be expanded)
			})
			var $allcontrols=$('*[rel]').filter('[@rel^="collapse-"], [@rel^="expand-"], [@rel^="toggle-"]') //get all elements on page with rel="collapse-", "expand-" and "toggle-"
			var controlidentifiers=/(collapse-)|(expand-)|(toggle-)/
			$allcontrols.each(function(){
				$(this).click(function(){
					var relattr=this.getAttribute('rel')
					var divid=relattr.replace(controlidentifiers, '')
					var doaction=(relattr.indexOf("collapse-")!=-1)? "hide" : (relattr.indexOf("expand-")!=-1)? "show" : "toggle"
					return ac.showhide(divid, doaction)
				}) //end control.click
			})// end control.each
			$(window).bind('unload', function(){
				ac.uninit()
			})
		}) //end doc.ready()
	},
	uninit:function(){
		var opendivids='', groupswithpersist=''
		jQuery.each(this.divholders, function(){
			if (this.$divref.css('display')!='none'){
				opendivids+=this.id+',' //store ids of DIVs that are expanded when page unloads: 'div1,div2,etc'
			}
			if (this.getAttr('group') && this.getAttr('persist'))
			groupswithpersist+=this.getAttr('group')+',' //store groups with which at least one DIV has persistance enabled: 'group1,group2,etc'
		})
		opendivids=(opendivids=='')? 'nada' : opendivids.replace(/,$/, '')
		groupswithpersist=(groupswithpersist=='')? 'nada' : groupswithpersist.replace(/,$/, '')
		this.setCookie('acopendivids', opendivids)
		this.setCookie('acgroupswithpersist', groupswithpersist)
	},
	getCookie:function(Name){
		var re=new RegExp(Name+"=[^;]*", "i"); //construct RE to search for target name/value pair
		if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
		return null
	},
	setCookie:function(name, value, days){
		if (typeof days!="undefined"){ //if set persistent cookie
			var expireDate = new Date()
			expireDate.setDate(expireDate.getDate()+days)
			document.cookie = name+"="+value+"; path=/; expires="+expireDate.toGMTString()
		}
		else //else if this is a session only cookie
		document.cookie = name+"="+value+"; path=/"
	}
}

$(document).ready( function() {

	//external window
	$('A[class="external"]').click( function() {
		window.open( $(this).attr('href') );
		return false;
	});

	//popup window
	$('A[id="popup"]').click(function(){
		window.open(this.href,'Popup','height=250,width=310,scrollTo,resizable=0,scrollbars=0,location=0','false');
		return false;
	});

	//print link
	$('A[class="print"]').click(function() {
		window.print();
		return false;
	});

	//media object
	$('.media').media({
		caption: false
	});

	//rollover
	$("img.rollover").hover(
	function() {
		this.src = this.src.replace("-off.","-on.");
	},
	function() {
		this.src = this.src.replace("-on.","-off.");
	});

	//forms - focus
	$("input[type=password], input[type=text], textarea").focus(function()
	{
		$(this).addClass("focus");
	});
	$("input[type=password], input[type=text], textarea").blur(function()
	{
		if ($(this).find(".focus")) { $(this).removeClass("focus");
		}
	});

	//forms - hover
	$("input.submit").hover(function()
	{
		$(this).addClass("hover");
	},
	function()
	{
		$(this).removeClass("hover");
	});

	//lightbox
	$(function() { $('a.lightbox').lightBox(); });
	$(function() { $('a.lightbox1').lightBox(); });
	$(function() { $('a.lightbox2').lightBox(); });

	getTwitters('otisotis', {
		id: 'otisotis',
		count: 1,
		withFriends: true,
		enableLinks: false,
		ignoreReplies: true,
		template: '<span class="twitterstatus">"%text%"</span> <em class="twittertime">&nbsp;&nbsp;<a target="_blank" href="http://www.twitter.com/%user_screen_name%/statuses/%id%">(%time%)</a></em>'
	});

	$(function() {
		$('#nav').droppy({speed: 1});
	});

});

animatedcollapse.addDiv('one')
animatedcollapse.addDiv('two')
animatedcollapse.addDiv('three')
animatedcollapse.addDiv('four')
animatedcollapse.addDiv('five')
animatedcollapse.addDiv('six')
animatedcollapse.addDiv('seven')
animatedcollapse.addDiv('eight')
animatedcollapse.addDiv('nine')
animatedcollapse.addDiv('ten')
animatedcollapse.addDiv('eleven')
animatedcollapse.addDiv('twelve')
animatedcollapse.addDiv('thirteen')
animatedcollapse.addDiv('fourteen')
animatedcollapse.addDiv('fifteen')
animatedcollapse.addDiv('sixteen')
animatedcollapse.addDiv('seventeen')
animatedcollapse.addDiv('eightteen')
animatedcollapse.addDiv('nineteen')
animatedcollapse.addDiv('twenty')
animatedcollapse.addDiv('twentyone')
animatedcollapse.addDiv('twentytwo')
animatedcollapse.addDiv('twentythree')
animatedcollapse.addDiv('twentyfour')
animatedcollapse.addDiv('twentyfive')
animatedcollapse.addDiv('twentysix')
animatedcollapse.addDiv('twentyseven')
animatedcollapse.addDiv('twentyeight')
animatedcollapse.addDiv('twentynine')
animatedcollapse.addDiv('thirty')
animatedcollapse.addDiv('thirtyone')
animatedcollapse.addDiv('thirtytwo')
animatedcollapse.addDiv('thirtythree')
animatedcollapse.addDiv('thirtyfour')
animatedcollapse.addDiv('thirtyfive')
animatedcollapse.addDiv('thirtysix')
animatedcollapse.addDiv('thirtyseven')
animatedcollapse.addDiv('thirtyeight')
animatedcollapse.addDiv('thirtynine')
animatedcollapse.addDiv('forty')
animatedcollapse.addDiv('fortyone')
animatedcollapse.addDiv('fortytwo')
animatedcollapse.addDiv('fortythree')
animatedcollapse.addDiv('fortyfour')
animatedcollapse.addDiv('fortyfive')
animatedcollapse.addDiv('fortysix')
animatedcollapse.addDiv('fortyseven')
animatedcollapse.addDiv('fortyeight')
animatedcollapse.addDiv('fortynine')
animatedcollapse.addDiv('fifty')
animatedcollapse.init()

/**
* SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
*
* SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
*/
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

/**
* remy sharp / http://remysharp.com
* http://remysharp.com/2007/05/18/add-twitter-to-your-blog-step-by-step/
*
* @params
*   cssIdOfContainer: e.g. twitters
*   options:
*       {
*           id: {String} username,
*           count: {Int} 1-20, defaults to 1 - max limit 20
*           prefix: {String} '%name% said', defaults to blank
*           clearContents: {Boolean} true, removes contents of element specified in cssIdOfContainer, defaults to true
*           ignoreReplies: {Boolean}, skips over tweets starting with '@', defaults to false
*           template: {String} HTML template to use for LI element (see URL above for examples), defaults to predefined template
*           enableLinks: {Boolean} linkifies text, defaults to true,
*           timeout: {Int} How long before triggering onTimeout, defaults to 10 seconds if onTimeout is set
*           onTimeoutCancel: {Boolean} Completely cancel twitter call if timedout, defaults to false
*           onTimeout: {Function} Function to run when the timeout occurs. Function is bound to element specified with
*              cssIdOfContainer (i.e. 'this' keyword)
*
*      CURRENTLY DISABLED DUE TO CHANGE IN TWITTER API:
*           withFriends: {Boolean} includes friend's status
*
*       }
*
* @license MIT (MIT-LICENSE.txt)
* @version 1.11 - Added timeout functionality, and removed withFriends while Twitter works out API changes
* @date $Date: 2008-10-16 18:49:40 +0100 (Thu, 16 Oct 2008) $
*/

// to protect variables from resetting if included more than once
if (typeof renderTwitters != 'function') (function () {
	/** Private variables */
	var browser = (function() {
		var b = navigator.userAgent.toLowerCase();

		// Figure out what browser is being used
		return {
			safari: /webkit/.test(b),
			opera: /opera/.test(b),
			msie: /msie/.test(b) && !(/opera/).test(b),
			mozilla: /mozilla/.test(b) && !(/(compatible|webkit)/).test(b)
		};
	})();

	var guid = 0;
	var readyList = [];
	var isReady = false;

	/** Global functions */

	// to create a public function within our private scope, we attach the
	// the function to the window object
	window.renderTwitters = function (obj, options) {
		// private shortcuts
		function node(e) {
			return document.createElement(e);
		}

		function text(t) {
			return document.createTextNode(t);
		}

		var target = document.getElementById(options.twitterTarget);
		var data = null;
		var ul = node('ul'), li, statusSpan, timeSpan, i, max = obj.length > options.count ? options.count : obj.length;

		for (i = 0; i < max && obj[i]; i++) {
			data = getTwitterData(obj[i]);

			if (options.ignoreReplies && obj[i].text.substr(0, 1) == '@') {
				max++;
				continue; // skip
			}

			li = node('li');

			if (options.template) {
				li.innerHTML = options.template.replace(/%([a-z_\-\.]*)%/ig, function (m, l) {
					var r = data[l] + "" || "";
					if (l == 'text' && options.enableLinks) r = linkify(r);
					return r;
				});
			} else {
				statusSpan = node('span');
				statusSpan.className = 'twitterstatus';
				timeSpan = node('span');
				timeSpan.className = 'twittertime';
				statusSpan.innerHTML = obj[i].text; // forces the entities to be converted correctly

				if (options.enableLinks == true) {
					statusSpan.innerHTML = linkify(statusSpan.innerHTML);
				}

				timeSpan.innerHTML = relative_time(obj[i].created_at);

				if (options.prefix) {
					var s = node('span');
					s.className = 'twitterPrefix';
					s.innerHTML = options.prefix.replace(/%(.*?)%/g, function (m, l) {
						return obj[i].user[l];
					});
					li.appendChild(s);
					li.appendChild(text(' ')); // spacer :-(
				}

				li.appendChild(statusSpan);
				li.appendChild(text(' '));
				li.appendChild(timeSpan);
			}

			ul.appendChild(li);
		}

		if (options.clearContents) {
			while (target.firstChild) {
				target.removeChild(target.firstChild);
			}
		}

		target.appendChild(ul);
	};

	window.getTwitters = function (target, id, count, options) {
		guid++;


		if (typeof id == 'object') {
			options = id;
			id = options.id;
			count = options.count;
		}

		// defaulting options
		if (!count) count = 1;

		if (options) {
			options.count = count;
		} else {
			options = {};
		}

		if (!options.timeout && typeof options.onTimeout == 'function') {
			options.timeout = 10;
		}

		if (typeof options.clearContents == 'undefined') {
			options.clearContents = true;
		}

		// Hack to disable withFriends, twitter changed their API so this requires auth
		// http://getsatisfaction.com/twitter/topics/friends_timeline_api_call_suddenly_requires_auth
		if (options.withFriends) options.withFriends = false;

		// need to make these global since we can't pass in to the twitter callback
		options['twitterTarget'] = target;

		// default enable links
		if (typeof options.enableLinks == 'undefined') options.enableLinks = true;

		// this looks scary, but it actually allows us to have more than one twitter
		// status on the page, which in the case of my example blog - I do!
		window['twitterCallback' + guid] = function (obj) {
			if (options.timeout) {
				clearTimeout(window['twittertimeout' + guid]);
			}
			renderTwitters(obj, options);
		};

		// check out the mad currying!
		ready((function(options, guid) {
			return function () {
				// if the element isn't on the DOM, don't bother
				if (!document.getElementById(options.twitterTarget)) {
					return;
				}

				var url = 'http://www.twitter.com/statuses/' + (options.withFriends ? 'friends_timeline' : 'user_timeline') + '/' + id + '.json?callback=twitterCallback' + guid + '&count=20';

				if (options.timeout) {
					window['twittertimeout' + guid] = setTimeout(function () {
						// cancel callback
						if (options.onTimeoutCancel) window['twitterCallback' + guid] = function () {};
						options.onTimeout.call(document.getElementById(options.twitterTarget));
					}, options.timeout * 1000);
				}

				var script = document.createElement('script');
				script.setAttribute('src', url);
				document.getElementsByTagName('head')[0].appendChild(script);
			};
		})(options, guid));
	};

	// GO!
	DOMReady();


	/** Private functions */

	function getTwitterData(orig) {
		var data = orig, i;
		for (i in orig.user) {
			data['user_' + i] = orig.user[i];
		}

		data.time = relative_time(orig.created_at);

		return data;
	}

	function ready(callback) {
		if (!isReady) {
			readyList.push(callback);
		} else {
			callback.call();
		}
	}

	function fireReady() {
		isReady = true;
		var fn;
		while (fn = readyList.shift()) {
			fn.call();
		}
	}

	// ready and browser adapted from John Resig's jQuery library (http://jquery.com)
	function DOMReady() {
		if ( browser.mozilla || browser.opera ) {
			document.addEventListener( "DOMContentLoaded", fireReady, false );
		} else if ( browser.msie ) {
			// If IE is used, use the excellent hack by Matthias Miller
			// http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited

			// Only works if you document.write() it
			document.write("<scr" + "ipt id=__ie_init defer=true src=//:><\/script>");

// Use the defer script hack
var script = document.getElementById("__ie_init");

// script does not exist if jQuery is loaded dynamically
if (script) {
	script.onreadystatechange = function() {
		if ( this.readyState != "complete" ) return;
		this.parentNode.removeChild( this );
		fireReady.call();
	};
}

// Clear from memory
script = null;

// If Safari  is used
} else if ( browser.safari ) {
	// Continually check to see if the document.readyState is valid
	var safariTimer = setInterval(function () {
		// loaded and complete are both valid states
		if ( document.readyState == "loaded" ||
		document.readyState == "complete" ) {

			// If either one are found, remove the timer
			clearInterval( safariTimer );
			safariTimer = null;
			// and execute any waiting functions
			fireReady.call();
		}
	}, 10);
}
}

function relative_time(time_value) {
	var values = time_value.split(" ");
	time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
	var parsed_date = Date.parse(time_value);
	var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
	var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
	delta = delta + (relative_to.getTimezoneOffset() * 60);

	var r = '';
	if (delta < 60) {
		r = 'less than a minute ago';
	} else if(delta < 120) {
		r = 'about a minute ago';
	} else if(delta < (45*60)) {
		r = (parseInt(delta / 60)).toString() + ' minutes ago';
	} else if(delta < (2*90*60)) { // 2* because sometimes read 1 hours ago
		r = 'about an hour ago';
	} else if(delta < (24*60*60)) {
		r = 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
	} else if(delta < (48*60*60)) {
		r = '1 day ago';
	} else {
		r = (parseInt(delta / 86400)).toString() + ' days ago';
	}

	return r;
}

function linkify(s) {
	return s.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/g, function(m) {
		return m.link(m);
	}).replace(/@[\S]+/g, function(m) {
		return '<a target="_blank" href="http://www.twitter.com/' + m.substr(1) + '">' + m + '</a>';
	});
}
})();

