
window.addEvent('domready', function() {
	initDom();
});

function initDom() {
	setSideMenu();
}

window.addEvent('load', function() {
	initHomeSlide();
});
function initHomeSlide() {
	if ($$('.headerimgs').length > 0) {
		initImgSlide();
	}
}

function setSideMenu() {
	if ($('sideimg').getElement('img')) {
		$('sideimgWrap').setStyle('height', $('sideimg').getElement('img').getStyle('height').toInt());
	}

	if (window.ie6) {
		$('sideBar').setStyle('height', $('contentBox').getStyle('height').toInt());
	}
}

function initImgSlide() {
	iC = $$('.headerimgs').length;
	var i = 1;
	$$('.headerimgs').each(function(el) {
		el.setProperty('id', 'himg' + i);
		i++;
	});

	if (iC > 1) {
		doImgSlide.delay(5000, null, [1, iC]);
	}
}
function doImgSlide(iNr, iC) {
	$('himg' + iNr).effect('opacity', {duration: 1500, transition:Fx.Transitions.linear}).start(1, 0);

	if (iNr==iC) {
		iNr = 0;
	}
	iNr = iNr + 1;

	function doSlideIn(iNr, iC) {
		$('himg' + iNr).effect('opacity', {duration: 1500, transition:Fx.Transitions.linear}).start(0, 1).chain(function() {
			doImgSlide.delay(5000, null, [iNr, iC]);
		});
	}
	doSlideIn.delay(0, null, [iNr, iC]);
}


