/**
 * JS for "Nelly Furtado Fanclub"
 * @author David Donath - http://www.david-donath.de
 * @copyright (c) 2009 by David Donath
 */

// For Debug on FF Console
 function jsDebug(_content){
 	window.console.log(_content);
 }


document.observe("dom:loaded", function() {
  nffc.init.page(nffc.vars.currentPage);
});

var nffc = {};

// Global Vars
nffc.vars = {
	currentPage: 'index',
	contentBgStatus: false
};

// Init functions
nffc.init = {
	page: function(_page){
		eval('nffc.init.'+_page+'()');
	},
	
	index: function(){
		$('header').observe('click', nffc.action.select.bindAsEventListener(this, 'index'));
		$('close').observe('click', nffc.action.select.bindAsEventListener(this, 'index'));
		
		$('infos').observe('click', nffc.action.goToUrl.bindAsEventListener(this, 'http://www.rememberthedays.de'));
		$('concerts').observe('click', nffc.action.select.bindAsEventListener(this, 'concerts'));
		$('fanbase').observe('click', nffc.action.select.bindAsEventListener(this, 'fanbase'));
		$('ask').observe('click', nffc.action.select.bindAsEventListener(this, 'ask'));
		
		$('imprint').observe('click', nffc.action.select.bindAsEventListener(this, 'imprint'));
		$('privacy').observe('click', nffc.action.select.bindAsEventListener(this, 'privacy'));
		$('license').observe('click', nffc.action.select.bindAsEventListener(this, 'license'));
	}
	
};

// Event Actions
nffc.action = {
	select: function(_event, _page){
		nffc.content.showPage(_page);
	},
	
	goToUrl: function(_event, _url){
		window.location.href = _url;
	}
};


// Content Stuff
nffc.content = {
	
	showPage: function(_page){
		eval('nffc.content.pages.'+_page+'()');
		this.changeBackground();
	},
	
	changeBackground : function(){
		if(nffc.vars.contentBgStatus){
			nffc.vars.contentBgStatus = false;
			$("contentBg").setStyle({
				display: 'none',
			});
			$("contentBox").setStyle({
				display: 'none',
			});
		} else {
			nffc.vars.contentBgStatus = true;
			$("contentBg").setStyle({
				display: 'inline',
			});
			$("contentBox").setStyle({
				display: 'inline',
			});
		}
	},
	
	pages: {
		index: function(){
			nffc.vars.contentBgStatus = true;	
		},
		infos: function(){
			$('content').innerHTML = $('storageInfos').innerHTML;
		},
		concerts: function(){
			$('content').innerHTML = $('storageConcerts').innerHTML;
		},
		fanbase: function(){
			$('content').innerHTML = $('storageFanbase').innerHTML;
		},
		ask: function(){
			$('content').innerHTML = $('storageAsk').innerHTML;
		},
		imprint: function(){
			nffc.vars.contentBgStatus = false;
			$('content').innerHTML = $('storageImprint').innerHTML;
		},
		privacy: function(){
			nffc.vars.contentBgStatus = false;
			$('content').innerHTML = $('storagePrivacy').innerHTML;
		},
		license: function(){
			nffc.vars.contentBgStatus = false;
			$('content').innerHTML = $('storageLicense').innerHTML;
			
		},
	}
};
