// Preloading
(new Image()).src = SITE_URI + '/images/AUCC-hardcore.png';

window.addEvent('domready', function() {
	var makeHardcore = function() {
		var hardcoreStyleLink = new Element('link', {href: SITE_URI + '/styles/hardcore.css', rel: 'stylesheet', type: 'text/css'});
		hardcoreStyleLink.inject($$('head')[0]);
		// IE is a knob and needs the width. Dunno if general case, or all this filter mess.
		var hardcoreLogo = new Element('img', {src: SITE_URI + '/images/AUCC-hardcore.png', width: 394, alt: 'AUCC HARDCORE!'});
		hardcoreLogo.replaces($$('img[src$=/images/AUCC-sun.png]')[0]);
		hardcoreDiv.set('text', 'Turns out I\'m not as hardcore as I thought I was.');
		Cookie.write('hardcore', 1, {duration: 365, domain: SITE_FQDN, path: '/' + SITE_PATH});
	};
	
	var makeSoftcore = function() {
		$$('head link[href$=hardcore.css]')[0].dispose();
		var sunLogo = new Element('img', {src: SITE_URI + '/images/AUCC-sun.png', width: 271, alt: 'AUCC!'});
		sunLogo.replaces($$('img[src$=/images/AUCC-hardcore.png]')[0]);
		hardcoreDiv.set('text', 'I am too HARDCORE for this website!');
		Cookie.dispose('hardcore', {domain: SITE_FQDN, path: '/' + SITE_PATH});
	};
	
	var hardcoreDiv = new Element('div');
	hardcoreDiv.setStyles({position: 'absolute', top: 8, right: 8, cursor: 'pointer'});
	hardcoreDiv.set('text', 'I am too HARDCORE for this website!');
	hardcoreDiv.inject(document.body);
	
	if (Cookie.read('hardcore')) {
		makeHardcore();
	}
	
	hardcoreDiv.addEvent('click', function() {
		if (!Cookie.read('hardcore')) {
			makeHardcore();
		}
		else {
			makeSoftcore();
		}
	});
});

