var Login = new Class({
	Implements: [Options, Events, Chain],
	options: {
		// onFinish: $empty,
		url: null,
		required: 3,
		error: {
			'email': 'Please enter your email address.',
			'password': 'Please enter your password.',
			'incorrect': 'Sorry, you are not logged in. Your e-mail address and/or password was invalid.'
		}
	},
	initialize: function(forms, options) {
		this.setOptions(options);
		this.forms = $$(forms);
		this.forms.each(function(form, index) {
			form.addEvent('submit', function(event) {
				event.preventDefault();
				this.checkForm(form);
			}.bind(this));
		}, this);
	},
	checkForm: function(form) {
		var params = [],
			inputs = form.getElements('input');
		inputs.each(function(input) {
			if (input.get('type') !== 'submit' && input.get('type') !== 'image') {
				if ( input.value !== '') {
					params.push(input.get('name') + '=' + encodeURIComponent(input.value));
				} else {
					alert(this.options.error[input.get('name')]);
				}
			}
		}, this);
		if (params.length === this.options.required) this.sendForm(form, params);
	},
	sendForm: function(form, params) {
		var url = this.options.url;
		var requester = new Request({
			url: url,
			onComplete: function(responseText) {
				if (responseText.length === 0) {
					alert(this.options.error['incorrect']);
				} else {
					this.fireEvent('onFinish', [this.forms, this.forms.indexOf(form)]);
				}
			}.bind(this)
		});
		requester.send(params.join('&'));
	}
});

var Accordion = new Class({
	Implements: [Chain, Options, Events],
	options: {
		// onActive: $empty,
		trigger: 'click',
		direction: 'vertical',
		openedClass: 'expanded',
		closedClass: 'collapsed',
		duration: 'normal',
		opacity: true,
		fixedHeight: false,
		fixedWidth: false,
		multiOpen: false,
		allClosed: false,
		startOpen: 0
	},
	initialize: function(togglers, folds, options) {
		this.setOptions(options);
		this.params = this.options.opacity ? {'opacity': '0'}: {};
		this.dimension = this.options.direction === 'vertical' ? 'height': 'width';
		this.params[this.dimension] = '0';
		this.folds = $$(folds);
		this.folds.each(function(fold, index) {
			var h = this.options.fixedHeight ? this.options.fixedHeight: fold.scrollHeight + 'px';
			var w = this.options.fixedWidth ? this.options.fixedWidth: fold.offsetWidth + 'px';
			var d = this.options.direction === 'vertical' ? h: w;
			fold.store('dimension', d);
			if (this.options.allClosed || index !== this.options.startOpen && !this.options.multiOpen) {
				this.collapse(fold);
			} else {
				this.expand(fold);
			}
		}, this);
		$$(togglers).each(function(toggler, index) {
			toggler.addEvent(this.options.trigger, function(event) {
				event.preventDefault();
				this.display(this.folds[index]);
			}.bind(this));
		}, this);
	},
	display: function(fold) {
		if (fold.hasClass('collapsed')) {
			this.expand(fold);
		} else {
			this.collapse(fold);
		}
		this.fireEvent('active', [this.togglers, this.folds, this.folds.indexOf(fold)]);
	},
	collapse: function(fold) {
		fold.set('morph', { duration: this.options.duration, onComplete: function() { 
			fold.removeClass(this.options.openedClass).addClass(this.options.closedClass);
		}.bind(this)});
		for (var fx in this.params) this.params[fx] = '0';
		fold.morph(this.params);
	},
	expand: function(fold) {
		if (!this.options.multiOpen) for (var i = 0, l = this.folds.length; i < l; i++) this.collapse(this.folds[i]);
		fold.set('morph', { duration: this.options.duration});
		if (this.options.opacity) this.params.opacity = '1';
		this.params[this.dimension] = fold.retrieve('dimension');
		fold.removeClass(this.options.closedClass).addClass(this.options.openedClass).morph(this.params);
	}
});

/*
I took this out of more.js so that we didn't have to include the entire more library on every page.
Script: Tips.js
	Class for creating nice tips that follow the mouse cursor when hovering an element.
	License:
		MIT-style license.
	Authors:
		Valerio Proietti
		Christoph Pojer
*/
var Tips = new Class({
	Implements: [Events, Options],
	options: {
		onShow: function(tip){
			tip.setStyle('visibility', 'visible');
		},
		onHide: function(tip){
			tip.setStyle('visibility', 'hidden');
		},
		title: 'title',
		text: function(el){
			return el.get('rel') || el.get('href');
		},
		showDelay: 100,
		hideDelay: 100,
		className: null,
		offset: {x: 16, y: 16},
		fixed: false
	},
	initialize: function(){
		var params = Array.link(arguments, {options: Object.type, elements: $defined});
		if (params.options && params.options.offsets) params.options.offset = params.options.offsets;
		this.setOptions(params.options);
		this.container = new Element('div', {'class': 'tip'});
		this.tip = this.getTip();
		
		if (params.elements) this.attach(params.elements);
	},
	getTip: function(){
		return new Element('div', {
			'class': this.options.className,
			styles: {
				visibility: 'hidden',
				display: 'none',
				position: 'absolute',
				top: 0,
				left: 0
			}
		}).adopt(
			new Element('div', {'class': 'tip-top'}),
			this.container,
			new Element('div', {'class': 'tip-bottom'})
		).inject(document.body);
	},
	attach: function(elements){
		var read = function(option, element){
			if (option == null) return '';
			return $type(option) == 'function' ? option(element) : element.get(option);
		};
		$$(elements).each(function(element){
			var title = read(this.options.title, element);
			element.erase('title').store('tip:native', title).retrieve('tip:title', title);
			element.retrieve('tip:text', read(this.options.text, element));
			
			var events = ['enter', 'leave'];
			if (!this.options.fixed) events.push('move');
			
			events.each(function(value){
				element.addEvent('mouse' + value, element.retrieve('tip:' + value, this['element' + value.capitalize()].bindWithEvent(this, element)));
			}, this);
		}, this);
		
		return this;
	},
	detach: function(elements){
		$$(elements).each(function(element){
			['enter', 'leave', 'move'].each(function(value){
				element.removeEvent('mouse' + value, element.retrieve('tip:' + value) || $empty);
			});
			
			element.eliminate('tip:enter').eliminate('tip:leave').eliminate('tip:move');
			
			if ($type(this.options.title) == 'string' && this.options.title == 'title'){
				var original = element.retrieve('tip:native');
				if (original) element.set('title', original);
			}
		}, this);
		
		return this;
	},
	elementEnter: function(event, element){
		$A(this.container.childNodes).each(Element.dispose);
		
		['title', 'text'].each(function(value){
			var content = element.retrieve('tip:' + value);
			if (!content) return;
			
			this[value + 'Element'] = new Element('div', {'class': 'tip-' + value}).inject(this.container);
			this.fill(this[value + 'Element'], content);
		}, this);
		
		this.timer = $clear(this.timer);
		this.timer = this.show.delay(this.options.showDelay, this, element);
		this.tip.setStyle('display', 'block');
		this.position((!this.options.fixed) ? event : {page: element.getPosition()});
	},
	elementLeave: function(event, element){
		$clear(this.timer);
		this.tip.setStyle('display', 'none');
		this.timer = this.hide.delay(this.options.hideDelay, this, element);
	},
	elementMove: function(event){
		this.position(event);
	},
	position: function(event){
		var size = window.getSize(), scroll = window.getScroll(),
			tip = {x: this.tip.offsetWidth, y: this.tip.offsetHeight},
			props = {x: 'left', y: 'top'},
			obj = {};
		
		for (var z in props){
			obj[props[z]] = event.page[z] + this.options.offset[z];
			if ((obj[props[z]] + tip[z] - scroll[z]) > size[z]) obj[props[z]] = event.page[z] - this.options.offset[z] - tip[z];
		}
		
		this.tip.setStyles(obj);
	},
	fill: function(element, contents){
		if(typeof contents == 'string') element.set('html', contents);
		else element.adopt(contents);
	},
	show: function(el){
		this.fireEvent('show', [this.tip, el]);
	},
	hide: function(el){
		this.fireEvent('hide', [this.tip, el]);
	}
});

var Search = new Class({
	Implements: [Options, Events],
	options: {
		// onFinish: $empty,
		url: null,
		delay: 400,
		events: 'submit',
		preventDefault: true,
		cache: true,
		params: null,
		query: 'value',
		container: null,
		containerID: null
	},
	initialize: function(elems, containers, options) {
		this.setOptions(options);
		this.elems = $$(elems);
		var containers = $$(containers);
		this.elems.each(function(elem, index) {
			if (this.elems.length === containers.length) {
				this.addSection(elem, containers[index]);
			} else {
				this.addSection(elem, containers[0]);
			}
		}, this);
	},
	addSection: function(elem, container) {
		elem.store('container', container);
		this.attach(elem);
	},
	attach: function(elem) {
		var es = this.options.events;
		if (typeof es === 'object' && es.constructor === Array) {
			es.each(function(e) {
				elem.addEvent(e, function(event) {
					this.getResults(elem, event);
				}.bind(this));
			});
		} else {
			elem.addEvent(es, function(event) {
				this.getResults(elem, event);
			}.bind(this));
		}
	},
	serialize: function(elem) {
		var i = this.elems.indexOf(elem);
		var params = [];
		$H(this.options.params).each(function(value, key) {
			if ($type(key) === 'object') {
				$H(key).each(function(v, k) {
					params.include(key + '=' + $$(k)[i].get(v));
				});
			} else {
				params.include(key + '=' + value);
			}
		});
		var serialized = params.join('&');
		var e = (elem.nodeName === 'FORM') ? elem.getElements('input[type^=text]')[0]: elem;
		var url = (this.options.params) ? this.options.url + e.get(this.options.query) + '&' + serialized :
			this.options.url + e.get(this.options.query);
		return url;
	},
	getResults: function(elem, e) {
		if (this.options.preventDefault) { e.preventDefault() }
		var container = elem.retrieve('container');
		if (!container.retrieve('hasResults')) {
			var requester = new Request({
				method: 'get',
				url: this.serialize(elem),
				onSuccess: function(responseText) {
					container.innerHTML = responseText;
					if (this.options.cache) container.store('hasResults', true);
					this.fireEvent('onFinish', [elem, container]);
				}.bind(this)
			});
			requester.send();
		}
	}
});

var Autocomplete = new Class({
	Extends: Search,
	options: {
		// onFormSubmit: $empty,
		chars: 1,
		events: 'keyup',
		resultsElement: 'li',
		clickSubmit: false,
		resultsClass: 'highlighted',
		container: 'ul',
		containerClass: 'autocomplete'
	},
	initialize: function(elems, options) {
		this.setOptions(options);
		this.elems = $$(elems);
		this.elems.each(function(elem) {
			var input = elem.getElements('input[type^=text]')[0];
			input.store('form', elem);
			this.attach(input);
		}, this);
	},
	getResults: function(elem, event) {
		if (this.requester) this.requester.cancel();
		var keys = [9, 16, 17, 18, 19, 20, 27, 33, 34, 35, 36, 37, 38, 39, 40, 91, 92, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 145];
		if (keys.indexOf(event.code) === -1) {
			var containerClass = this.options.containerClass;
			var container = $('autocomplete') || new Element(this.options.container, {'id': 'autocomplete', 'className': containerClass});
			container.setStyle('visibility', 'visible');
			this.cur = elem.get('value');
			var url = this.options.url + this.cur;
			this.requester = new Request({
				method: 'get',
				url: url,
				onSuccess: function(responseText) {
					container.innerHTML = responseText;
					container.inject(elem.parentNode);
					var position = -1;
					this.resultsListeners(elem, container, position);
				}.bind(this)
			});
			if (this.cur.length >= this.options.chars) this.requester.send();
		}
	},
	resultsListeners: function(elem, container, position) {
		var searchForm = elem.retrieve('form');
		var results = container.getElements(this.options.resultsElement);
		results.each(function(result) {
			result.addEvents({
				'mouseover': function(event) {
					position = results.indexOf(result);
					this.updatePosition(elem, results, results.indexOf(result));
				}.bind(this),
				'mousedown': function(event) {
					event.preventDefault();
					elem.set('value', result.firstChild.nodeValue);
					container.setStyle('visibility', 'hidden').empty();
					if (this.options.clickSubmit) searchForm.submit();
				}.bind(this)
			});
		}, this);
		elem.addEvents({
			'keyup': function(event) {
				if (event.code === 38) {
					if (position === -1 || position === 0) {
						position = results.length - 1;
					} else {
						position -= 1;
					}
					this.updatePosition(elem, results, position, true);
				} else if (event.code === 40 ) {
					if (position === results.length - 1) {
						position = 0;
					} else {
						position += 1;
					}
					this.updatePosition(elem, results, position, true);
				} else if (event.code === 8 && elem.get('value').length === 0) {
					container.setStyle('visibility', 'hidden').empty();
				}
			}.bind(this),
			'blur': function(event) {
				setTimeout(function() { container.setStyle('visibility', 'hidden').empty(); }, 100);
			}
		});
	},
	updatePosition: function(elem, results, position, setvalue) {
		for (var i = 0, l = results.length; i < l; i+=1) results[i].removeClass(this.options.resultsClass);
		results[position].addClass(this.options.resultsClass);
		if (setvalue) elem.set('value', results[position].firstChild.nodeValue);
	}
});

var CheckboxSearch = new Class({
	Extends: Search,
	options: {
		events: 'click',
		indexify: false,
		cache: false
	},
	getResults: function(elem) {
		var container = elem.retrieve('container');
		var checkNum = this.getChecked();
		var url = (this.options.params) ? this.options.url + checkNum + '&' + this.serialize(elem) :
			this.options.url + checkNum;
		if (!this.timer) $clear(this.timer);
		if (checkNum.length > 0) {
			var requester = new Request({
				method: 'get',
				url: url,
				onSuccess: function(responseText) {
					container.innerHTML = responseText;
					this.fireEvent('onFinish', [elem, container]);
				}.bind(this)
			});
			if (this.options.delay) {
				setTimeout(function() {
					requester.send();
				}, this.options.delay)
			} else { requester.send(); }
		} else {
			container.empty();
		}
	},
	getChecked: function() {
		var checkedArray = [];
		this.elems.each(function(elem) {
			var c = elem.get('checked');
			if (c === 'checked' || c === true) { checkedArray.push(elem.get(this.options.query)); }
		}, this);
		return checkedArray.join(',');
	}
});

var Tabs = new Class({
	Implements: [Events, Options],
	options: {
		// onShow: $empty,
		// onHide: $empty,
		showClass: 'showTab',
		hideClass: 'hideTab'
	},
	initialize: function(tabs, containers, options) {
		this.setOptions(options);
		this.fireEvent('onInit', [tabs, containers]);
		this.tabs = $$(tabs);
		this.containers = $$(containers);
		this.tabs.each(function(tab, index) {
			if (this.containers.length > 1) {
				tab.store('container', this.containers[index]);
			} else {
				tab.store('container', this.containers[0]);
			}
			this.attach(tab, index);
		}, this);
	},
	attach: function(tab, index) {
		var container = tab.retrieve('container');
		tab.addEvent('click', function(event) {
			event.preventDefault();
			this.show(container, index);
		}.bind(this));
	},
	show: function(container, index) {
		this.hideAll(index);
		this.fireEvent('onShow', [this.tabs, this.containers, index]);
		container.removeClass(this.options.hideClass).addClass(this.options.showClass);
	},
	hideAll: function(index) {
		for (var i = 0, l = this.containers.length; i < l; i+=1) this.containers[i].removeClass(this.options.hideClass).addClass(this.options.showClass);
		this.fireEvent('onHide', [this.tabs, this.containers, index]);
	}
});

var AjaxTabs = new Class({
	Extends: Tabs,
	options: {
		urls: null,
		cache: true
	},
	show: function(container, index) {
		var url = this.options.urls[index] || this.tabs[index].get('href');
		this.hideAll(index);
		if (this.tabs[index].retrieve('content')) {
			container.innerHTML = this.tabs[index].retrieve('content');
			this.fireEvent('onShow', [this.tabs, this.containers, index]);
		} else if (!url) {
			 this.parent(container, index);
		} else {
			this.getContent(container, url, index);
		}
	},
	getContent: function(container, url, index) {
		var requester = new Request({
			method: 'get',
			url: url,
			onComplete: function(responseText) {
				container.innerHTML = responseText;
				container.removeClass(this.options.hideClass).addClass(this.options.showClass);
				if (this.options.cache) this.tabs[index].store('content', responseText);
				this.fireEvent('onShow', [this.tabs, this.containers, index]);
			}.bind(this)
		});
		requester.send();
	}
});

var AjaxPaging = new Class({
	Implements: [Options, Events],
	options: {
		// onFinish: $empty,
		url: false
	},
	initialize: function(links, container, options) {
		this.setOptions(options);
		$$(links).each(function(a) {
			a.addEvent('click', function(event) {
				event.preventDefault();
				var url = (this.options.url) ? this.options.url: a.get('href');
				var requester = new Request.HTML({
					method: 'get',
					url: url,
					update: container,
					onSuccess: function(responseText) {
						this.initialize(links, container, options);
						this.fireEvent('onFinish', [links, container]);
					}.bind(this)
				});
				requester.send();
			}.bind(this));	
		}, this);
	}
});
var SlideShow = new Class({
	Implements: [Options, Chain],
	options: {
		buttonClass: null,
		buttonLocation: null,
		startIndex: 0,
		hideClass: 'hideSlide',
		showClass: 'showSlide',
		previous: 'previousSlide',
		pause: 'pauseSlide',
		next: 'nextSlide',
		delay: 7000,
		duration: '200',
		opacity: true
	},
	initialize: function(slides, options) {
		this.setOptions(options);
		this.slides = $$(slides);
		this.now = this.options.startIndex;
		var styles;
		this.slides.each(function(slide, index) {
			slide.store('button', new Element('a').inject($('panelProgress')));
			if (index === this.options.startIndex) slide.retrieve('button').setStyle('background-position', 'bottom');
			styles = (index === this.options.startIndex) ? [this.options.showClass, '1']: [this.options.hideClass, '0'];
			slide.setStyle('opacity', styles[1]).addClass(styles[0]).set('tween', {
				duration: this.options.duration,
				onComplete: function() {
					this.callChain();
				}.bind(this)
			});
			slide.retrieve('button').addEvents({
				'click': function(event) {
					event.preventDefault();
					this.display([index], true, false);
				}.bind(this),
				'mouseover': function() {
					if (this.now !== index) slide.retrieve('button').setStyle('background-position', 'bottom');
				}.bind(this),
				'mouseout': function() {
					if (this.now !== index) slide.retrieve('button').setStyle('background-position', 'top');
				}.bind(this)
			});
		}, this);
		this.timer = setInterval(function() {
			this.display('1', false, this.options.opacity);
		}.bind(this), this.options.delay);
		this.setControls(this.options.previous, this.options.pause, this.options.next);
	},
	display: function(add, pause, effects) {
		if ($type(add) === 'array') {
			this.now = add[0];
		} else {
			if (add === '-1') {
				this.now = (this.now === 0) ? this.slides.length - 1: this.now - 1;
			} else {
				this.now = (this.now === this.slides.length - 1) ? 0: this.now + 1;
			}	
		}
		this.hideSlides(this.slides, effects);
		this.showSlide(this.slides[this.now], effects);
		if (pause) clearTimeout(this.timer);
	},
	hideSlides: function(slides, effects) {
		slides.each(function(slide) {
			this.chain(
				function() {
					if (effects) {
						slide.tween('opacity', '0');
					} else {
						slide.setStyle('opacity', '1');
						this.callChain();
					}
				},
				function() { slide.removeClass(this.options.showClass).addClass(this.options.hideClass); this.callChain(); },
				function() { slide.retrieve('button').setStyle('background-position', 'top'); this.callChain(); }
			);
		}, this);
	},
	showSlide: function(slide, effects) {
		this.chain(
			function() { slide.retrieve('button').setStyle('background-position', 'bottom'); this.callChain(); },
			function() { slide.removeClass(this.options.hideClass).addClass(this.options.showClass); this.callChain(); },
			function() {
				if (effects) {
					slide.tween('opacity', '1');
				} else {
					slide.setStyle('opacity', '1');
					this.callChain();
				}
			}
		);
		this.callChain();
	},
	setControls: function(prevLink, pauseLink, nextLink) {
		if (prevLink) {
			$(prevLink).addEvent('click', function(event) {
				event.preventDefault();
				this.display(-1, true, false);
			}.bind(this));
		}
		if (nextLink) {
			$(nextLink).addEvent('click', function(event) {
				event.preventDefault();
				this.display(1, true, false);
			}.bind(this));
		}
		if(pauseLink) $(pauseLink).addEvent('click', function(event) { event.preventDefault(); clearTimeout(this.timer); }.bind(this));
	}
});

var Overlay = new Class({
	overlay: function(elem, id) {
		var overlay = new Element('div', {'id': 'overlay', 'styles': {'opacity': '0', 'visibility': 'visible', 'height': '0', 'overflow': 'hidden'}}).inject(document.body);
		var e = new Element(elem, {'id': id, 'class': 'lightbox'}).inject(document.body);
		return e;
	},
	showOverlay: function() {
		$('overlay').set('tween').setStyles({
			'top': -$(window).getScroll().y,
			'height':$(window).getScrollSize().y+$(window).getScroll().y,
			'visibility': 'visible',
			'display': 'block'
		}).tween('opacity', '0.7');
		$E('.lightbox').setStyles({'display': 'block', 'visibility': 'visible'});
		var w = (Browser.Engine.presto) ? window.innerWidth/2: window.getScrollSize().x/2;
		$E('.lightbox').setStyles({'top': '100px', 'left': w - ($E('.lightbox').getScrollSize().x/2) + 'px'});
		$('closeLightbox').addEvent('click', function(event) {
			$E('.lightbox').destroy();
			$('overlay').destroy();
		});
	}
});

var Lightbox = new Class({
	Implements: [Options, Overlay],
	options: {
		containerId: null,
		url: null
	},
	initialize: function(elems, options) {
		this.setOptions(options);
		$$(elems).each(function(elem) {
			elem.addEvent('click', function(event) {
				event.preventDefault();
				var container = this.overlay('div', this.options.containerId);
				this.showForm(elem, container);
			}.bind(this));
		}, this);
	},
	showForm: function(elem, container) {
		var requester = new Request({
			url: this.options.url,
			method: 'get',
			onSuccess: function(responseText) {
				container.innerHTML = responseText;
				this.showOverlay();
			}.bind(this)
		});
		requester.send();
	}
});

var InputClear = new Class({
	Implements: [Options, Events],
	options: {
		elems: 'input[type^=text]',
		reset: true
	},
	initialize: function(options) {
		this.setOptions(options);
		$$(this.options.elems).each(function(elem) {
			this.attach(elem);
		}, this);
	},
	attach: function(elem) {
		elem.addEvent(	'focus', function(event) {
			elem.set('value', '');
			if (elem.get('type') === 'password') elem.setStyle('background-image', 'none');
		});
	}
});

var parseUrl = function parseUrl(url, segment) {
	var parseUrl = /^(?:([A-Za-z]+):)?(?:\/{0,3})?([A-Za-z0-9\.\-]+)?(\/[\.A-Za-z\-0-9\/]+)(?:\?([A-Za-z0-9=\.&@$%\*\(\)!,\+]+))?(?:#([A-Za-z0-9]+))?$/;
	var parts = parseUrl.exec(url);
	var partNames = ['url', 'protocol', 'base', 'path', 'query', 'hash'];
	var partsObject = parts.associate(partNames);
	return (segment) ? partsObject[segment]: partsObject;
};

var parseQuery = function parseQuery(url) {
	var parsed = parseUrl(url, 'query');
	var query = parsed.split('&');
	var queryObject = {};
	var parseQuery = /^([A-Za-z0-9]+)(?:=([A-Za-z0-9\.@$%\*\(\)!,\+]+))$/;
	for (var i = 0, l = query.length; i < l; i +=1) {
		if (parseQuery.test(query[i])) {
			var parts = parseQuery.exec(query[i]);
			queryObject[parts[1]] = parts[2];
		}
	}
	return queryObject;
};

var $E = function $E(selector) {
	return $$(selector)[0];
};

var suckerfish = function suckerfish(elems) {
	if (Browser.Engine.trident4) {
		var sfEls = $$(elems);
		for (var i=0, l = sfEls.length; i < l; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
};

var externalLinks = function externalLinks(items) {
	var links = (items) ? $$(items): $$('a.external');
	links.each(function(a) {
		a.addEvent('click', function(e) {
			e.preventDefault;
			open(a.get('href'));
			return false;
		});
	});	
};

var printPage = function printPage(elems) {
	$$(elems).each(function(elem) {
		elem.addEvent('click', function(event) {
			event.preventDefault();
			window.open(elem.get('href'), 'printWindow', 'width=625,height=400,toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1');
		});
	});	
};
var emailPage = function emailPage(elems) {
	$$(elems).each(function(elem) {
		elem.addEvent('click', function(event) {
			event.preventDefault();
			window.open(elem.get('href'), 'printWindow', 'width=625,height=400,toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1');
		});
	});	
};
var smallWindow = function smallWindow(elems, width, height) {
	$$(elems).each(function(elem) {
		elem.addEvent('click', function(event) {
			event.preventDefault();
			var w = (width) ? width: '520';
			var h = (height) ? height: '450';
			window.open(elem.get('href'), 'printWindow', 'width=' + w + ',height=' + h + ',toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1');
		});
	});	
};
var createOverlay = function createOverlay(elem, id) {
	var overlay = new Element('div', {'id': 'overlay', 'styles': {'opacity': '0', 'visibility': 'visible', 'height': '0', 'overflow': 'hidden'}}).inject(document.body);
	var e = new Element(elem, {'id': id}).inject(document.body);
	return e;
};

window.addEvent('domready', function() {
	suckerfish($$('#globalheader li'));
	new InputClear({ elems: $$('.clearField')});
	externalLinks();
	var tooltips = new Tips ($$('.tooltip'), {
		className: 'tipContainer',
		text: null
	});
	if (window.showPromo) showPromo();
});

