
/*
	Sitemap Toggler v1.0 - Toggles a sitemap located at the bottom of the page
	By Chris Ramakers at Inventis Web Architects @ 26/03/2007
*/
var SitemapToggler = {

	init: function(options){
		this.options = Object.extend({
			sitemapId: 'footer',
			toggleId : 'footerToggle'
		}, options || {});
		
		this.sitemap = $(this.options.sitemapId);
		$(this.options.toggleId).addEvent('click', this.toggle.bind(this));
		
		this.aniMargin = new Fx.Styles(this.sitemap, {duration: 1000, transition: Fx.Transitions.sineOut, onStart: this.startAnim.bind(this), onComplete:this.endAnim.bind(this)});
	},
	
	sitemapOpen: false,
	sitemapInTransition: false,
	
	toggle: function(e) {
		if (this.sitemapInTransition == true)
		{
			return;
		}
		if (this.sitemapOpen == false)
		{
			this.open();
		}
		else
		{
			this.close();
		}
		new Event(e).stop();
	},

	open: function() {
		this.aniMargin.start({
			'margin-top': [-65, -425],
			'height':     [ 65,  425]
		});
		this.sitemapOpen = true;
	},
	close: function() {
		this.aniMargin.start({
			'margin-top': [-425, -65],
			'height':     [ 425,  65]
		});
		this.sitemapOpen = false;
	},
	
	startAnim: function()
	{
		this.sitemapInTransition = true;
	},
	endAnim: function()
	{
		this.sitemapInTransition = false;
	}
}

fireOn = window.ie ? 'load' : 'domready';
window.addEvent(fireOn, SitemapToggler.init.bind(SitemapToggler));
window.addEvent(fireOn, function(){
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") !== null) {
			if(anchor.getAttribute("rel").indexOf("external") >= 0){
				anchor.target = "_blank";
				anchor.style.className = 'external';
			}
		}
	}
});

