window.addEvent('load',function(){
	contentLinks.delay(0);
//	createSIFR.delay(0);
	createEvents.delay(0);
});
var linkReq = new Request.HTML({
	onSuccess: function(html) {
		$('content').set('text', '');
		$('content').adopt(html);
	},
	onFailure: function() {
		$('content').set('html', '<h3>The webpage cannot be found</h3><p>The requested URL was not found on this server.</p><hr /><p><em>HTTP 404 - Not Found</em></p>');
	}
});
var contentLinks = function() {
	var anchors = $('container').getElements('a[rel=external]');
	$each(anchors,function(anchor) { anchor.target = "_blank"; });
	var lyteAnchors = $('container').getElements('a[rel^=lyte]');
	$each(lyteAnchors,function(anchor) { anchor.target = "_blank"; });
	$('content').getElements('a').addEvents({
		'mouseenter': function() {
			if (!this.getParent('div#credits') && !this.getParent('div#archive')) {
				this.set('tween', {property: 'color', duration: '150'}).tween('#000000');
			}
		},
		'mouseleave': function() {
			if (!this.getParent('div#credits') && !this.getParent('div#archive')) {
				this.set('tween', {property: 'color', duration: '400'}).tween('#EF600B');
			}
		}
	});
};
var createSIFR = function() {
	if (typeof sIFR == "function") {
		var template = named({sFlashSrc : "/scripts/sifr/sifr.swf", sColor : "#4384c5", sWmode : "transparent"});
		sIFR.replaceElement("h1 span", template);
	};
};
var createEvents = function() {
	$('nav').getElements('div.overlay').setStyles({
		'display': 'block',
		'opacity': 0.35
	});
	$('nav').getElements('div.nav').addEvents({
		'mouseenter': function() {
			this.getElements('div.overlay').set('tween', {property: 'opacity', duration: '100'}).tween(0);
		},
		'mouseleave': function() {
			this.getElements('div.overlay').set('tween', {property: 'opacity', duration: '300'}).tween(0.35);
		}
	});
	$('mininav').getElements('a').addEvents({
		'mouseenter': function() {
			this.set('tween', {property: 'color', duration: '50'}).tween('#7db4ec');
		},
		'mouseleave': function() {
			this.set('tween', {property: 'color', duration: '200'}).tween('#4384c5');
		}
	});
	$('nav').getElements('div#login a#tab_cms').addEvents({
		'click': function(e) {
			if (e) e.stop();
			$('nav').getElements('div#login div.container').setStyle('background-position', 'top left');
			$('nav').getElements('div#login div#login_cms').setStyle('opacity', 1);
			$('nav').getElements('div#login div#login_mail').setStyle('opacity', 0);
		}
	});
	$('nav').getElements('div#login a#tab_mail').addEvents({
		'click': function(e) {
			if (e) e.stop();
			$('nav').getElements('div#login div.container').setStyle('background-position', 'top right');
			$('nav').getElements('div#login div#login_cms').setStyle('opacity', 0);
			$('nav').getElements('div#login div#login_mail').setStyle('opacity', 1);
		}
	});
	$('nav').getElements('div#login input.text').addEvents({
		'focus': function() {
			if (this.getProperty('value') == this.getProperty('rel')) {
				this.setProperty('value','');
			}
		},
		'blur': function() {
			if (this.getProperty('value') == '') {
				this.setProperty('value',this.getProperty('rel'));
			}
		}
	});
	$('content').getElements('div#archive a').addEvents({
		'mouseenter': function() {
			this.set('tween', {property: 'color', duration: '50'}).tween('#7db4ec');
		},
		'mouseleave': function() {
			this.set('tween', {property: 'color', duration: '200'}).tween('#4384c5');
		}
	});
	/*
	$('nav').getElements('a').addEvents({
		'mouseenter': function() {
			if (!this.getParent('li').hasClass('active')) {
				this.set('tween', {property: 'background-color', duration: '250'}).tween('#0b508b');
			}
		},
		'mouseleave': function() {
			if (!this.getParent('li').hasClass('active')) {
				this.set('tween', {property: 'background-color', duration: '200'}).tween('transparent');
			}
		}
	});
	*/
};