// JavaScript Document

window.addEvent('domready', function(){

	var newsbox = $('header_right_news');
	var fx = newsbox.effects({duration: 1000, transition: Fx.Transitions.Quart.easeOut});
	var periodical;
	var newsid = 0;
	
	var newsboxdo = function() {
		fx.start({
			'opacity': .01
		}).chain(function() {
			newsbox.setHTML('<a href="http://www.wiimedia.com/news/view/' + newspermalinks[newsid] + '/">' + newscontent[newsid] + '</a>');
			this.start({
				'opacity': 1
			});
		}).chain(function() {
			this.start.delay(3000, this, {
				'opacity': .01
			});
		}).chain(function() {
			this.start.delay(100, this, {
				'opacity': .01
			});
			newsid++;
			if(newsid > 6) {newsid = 0;}
			newsboxdo();
		});
	}
	
	newsboxdo();
	
	//---------------------------
	
	var accordion = new Accordion('h3.atStart', 'div.atStart', {
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#236385');
		},
	 
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#3E9ACC');
		}
	}, $('accordion'));
	
	//---------------------------
	
	var Tips1 = new Tips($$('.ntips'), {
		className: 'ntipsc',
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});
					
}); 

var FxScrollObject = new Fx.Scroll(window, {duration: 1000});

function displaywarning(content) {

	var cdgoverlay = new Element('div', {'id': 'cbOverlay'}).injectInside(document.body);
	if(window.getScrollTop() == 0) {
		cdgoverlay.setStyles({'top': 30, 'height': window.getScrollHeight() - 30});
	} else {
		cdgoverlay.setStyles({'top': 30, 'height': window.getScrollHeight()});
	}
	
	var cdgcenter = new Element('div', {'id': 'cbCenter'}).injectInside(document.body);
	cdgcenter.setStyles({top: window.getScrollTop() + 150});
	cdgcenter.innerHTML = content;

	var cdgoverlay = new Fx.Style('cbOverlay', 'opacity', {duration:500});
	cdgoverlay.hide();
	
	var cdgcenterfx = new Fx.Style('cbCenter', 'opacity', {duration:250});
	cdgcenterfx.hide();
	
	cdgoverlay.start(0, 0.8);
	cdgcenterfx.start(0, 1);

}

function displaycs() {
	alert("Sorry, this feature is not yet available. We are sorry for the inconvenience.\n\nWe are adding multiple new features every day!");
	return false;	
}
