$(document).addEvent('domready', function() {
	$$('#topMenu-menu li').each(function(e,i,o) {
		if (e.getChildren('ul.hoverMenu').length > 0) {
			e.addEvent('mouseenter', function() {
				e.addClass('showDropdown');
			});
			e.addEvent('mouseleave', function() {
				e.removeClass('showDropdown');
			});
		}
	});
	
	$$('#partners a').each(function(e,i,o) {
		var img = e.getElements('img')[0];
		if (img == null) return;
		e.addEvent('mouseenter', function() {
			img.set('src', img.get('src').replace('-blue', '-normal'));
		});
		e.addEvent('mouseleave', function() {
			img.set('src', img.get('src').replace('-normal', '-blue'));
		});
	});
	
	// preload images
	var imgsPath = '/images/';
	var imgs = [
		imgsPath + "topMenu-hover-right.png",
		imgsPath + "hoverMenu-repeat.png",
		imgsPath + "hoverMenu-bottom.png",
		imgsPath + "hoverMenu-top.png",
		imgsPath + "buttons/button-left_over.png",
		imgsPath + "buttons/button-left_down.png",
		imgsPath + "buttons/button-repeat_over.png",
		imgsPath + "buttons/button-repeat_down.png"
	];
	var imgsAssets = new Asset.images(imgs);
	
});

// Email obfuscator script 2.1 by Tim Williams, University of Arizona
// Random encryption key feature by Andrew Moulden, Site Engineering Ltd
// This code is freeware provided these four comment lines remain intact
// A wizard to generate this code is at http://www.jottings.com/obfuscator/
function mailtoInfo() {
	coded = "aRVD@aGDRaGN.bu";
	key = "CaNweLgpElVSh8Po6XWuFKtzdO4n12D0BTv7j5xbrQRqkcJUisy3MImAZf9YGH";
	shift=coded.length;
	link="";
	for (i=0; i<coded.length; i++) {
	if (key.indexOf(coded.charAt(i))==-1) {
	  ltr = coded.charAt(i)
	  link += (ltr)
	}
	else {     
	  ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
	  link += (key.charAt(ltr))
	}
	}
	location.href='mailto:'+link;
}


function decryptMail(coded, key) {
	shift=coded.length;
	link="";
	for (i=0; i<coded.length; i++) {
	if (key.indexOf(coded.charAt(i))==-1) {
	  ltr = coded.charAt(i)
	  link += (ltr)
	}
	else {     
	  ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
	  link += (key.charAt(ltr))
	}
	}
	return link;
}
