Event.observe(window, 'load', init, false);

_dynarch_menu_url = "/hmenu/";
var menuBottomWidth=960;
var menuBottomLineHeight=84;
var menuBottomDiv='bottom';
var offersId = 0;
var offers2fade = [];
var imgId = 0;
var imgs2fade = [];
var faderTimer = null;

function init() {
	if ( $('sitemap') ) {
		var mainmenu = DynarchMenu.setup('sitemap', { lazy: true, shadows: false, electric: 250 });
	}
	$$('.donate').each(
		function(elem)
		{
			elem.observe('click', openDonateWindow);
		}
	);

	offers2fade = $$('div.testimonial');
	if (offers2fade.length == 1)
	{
		//offers2fade.first().show(); // first element is visible by default, manual setting absolete
	}
	else if (offers2fade.length > 1)
	{
		offersId = offers2fade.length-1;
		fadeOffers();
		setInterval('fadeOffers()', 4000);
	}
	
	imgs2fade = $$('#imgFader div.imgFader');
	if (imgs2fade.length > 1)
	{
		imgId = imgs2fade.length-1;
		fadePictures();
		faderTimer = setInterval('fadePictures()', 4000);
	}

}

function fadeOffers()
{
	Effect.Fade(offers2fade[offersId], { duration:1, from:1.0, to:0.0 });
	if (offersId++ >= offers2fade.length-1) offersId=0;
	Effect.Appear(offers2fade[offersId], { duration:1, from:0.0, to:1.0 });
}

function openDonateWindow(event) {
	Event.stop(event);
	loadDonateWindow();
}

function loadDonateWindow() {
	Lightview.show({
		href: '/donate/',
		rel: 'iframe',
		options: {
			resizeDuration: 0,
			menubar: false,
			topclose: true,
			width: 600,
			height: 400,
			keyboard: false,
			overlayClose: false
		}
	});
}

function fadePictures()
{
	Effect.Fade(imgs2fade[imgId], { duration:0.5, from:1.0, to:0.0 });
	if (imgId++ >= imgs2fade.length-1) 
	{
		imgId=0;
//		clearInterval(faderTimer);
	}
	Effect.Appear(imgs2fade[imgId], { duration:0.5, from:0.0, to:1.0 });
}

