// JavaScript Document

var currentSectionLogo = 'aiet';

window.addEvent('domready', function() {
									 
	if ($('section-link-aiet')) { 
		$('section-link-aiet').addEvent('mouseenter', function(){ setSectionLogo('aiet'); });
	}

	if ($('section-link-ss')) { 
		$('section-link-ss').addEvent('mouseenter', function(){ setSectionLogo('ss'); });
		$('section-icon-ss').setStyles({zIndex:1, opacity:0});
	}

	if ($('section-link-scas')) { 
		$('section-link-scas').addEvent('mouseenter', function(){ setSectionLogo('scas'); });
		$('section-icon-scas').setStyles({zIndex:1, opacity:0});
	}

	if ($('section-link-aie')) { 
		$('section-link-aie').addEvent('mouseenter', function(){ setSectionLogo('aie'); });
		$('section-icon-aie').setStyles({zIndex:1, opacity:0});
	}

	if ($('section-link-lns')) { 
		$('section-link-lns').addEvent('mouseenter', function(){ setSectionLogo('lns'); });
		$('section-icon-lns').setStyles({zIndex:1, opacity:0});
	}

	if ($('refreshCaptcha')) {
		$('refreshCaptcha').addEvent('click', function(event){event=new Event(event).stop();});
		$('refreshCaptcha').addEvent('click', function(){
			$('captchaImage').setProperty('src','/images/captcha.php?width=80&height=35&characters=4&request='+dateStamp());
		});
	}

});

function dateStamp() { var tmpDate = new Date(); return tmpDate.getTime(); }

function setSectionLogo(section) {

	if (currentSectionLogo == section) { return; }
	
	$('section-icon-'+section).setStyles({zIndex:5, opacity:0});
	$('section-icon-'+currentSectionLogo).setStyles({zIndex:1, opacity:1});
	new Fx.Style($('section-icon-'+section), 'opacity', {duration: 400} ).start(1);	
	new Fx.Style($('section-icon-'+currentSectionLogo), 'opacity', {duration: 400} ).start(0);	

	currentSectionLogo = section;

}

function changePage (url, element, curPage) {
	var newPage = document.getElementById(element).value;
	if (newPage == curPage) { return; }
	window.open (url+newPage,'_self');
}
