Shadowbox.init({
    handleOversize: 'resize',
    modal: true
});

function fixpng(){
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	if ((version >= 5.5) && (document.body.filters) && (version < 7)){
		var png_images = $$('.pngfix');	
		png_images.each(function(element) {
			if(!$(element).hasClass('pngfixed')){
				$(element).addClass('pngfixed');
				var img = $(element);
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText 
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + img.getProperty('width') + "px; height:" + img.getProperty('height') + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
				img.outerHTML = strNewHTML					
			}
		});
	} else {
		$$('.pngfix').addClass('pngfixed');
	}
}

var menuFx1; 
var menuFx2;

function preinit(){
	
	$$('.menutable a:not(.active) .orb img').setStyle('opacity', .2);
	
	$$('.menutable a:not(.active)').addEvent('mouseenter', function(){ el = this.getElement('img'); if(el.fx){ el.fx.cancel(); } el.fx = new Fx.Tween(el, {duration: 200}).start('opacity', 0.2, 1); });
	$$('.menutable a:not(.active)').addEvent('mouseleave', function(){ el = this.getElement('img'); if(el.fx){ el.fx.cancel(); } el.setStyle('opacity', .2); });
	
	$('menu').addEvent('mouseenter', function(){
		$('menutable').addClass('pie');
		if(menuFx1) menuFx1.cancel();
		if(menuFx2) menuFx2.cancel();
		menuFx1 = new Fx.Tween($('menutable'), {duration: 750}).start('margin-top', $('menutable').getStyle('margin-top'), 41);
		menuFx2 = new Fx.Tween($('menu'), {duration: 750}).start('height', $('menu').getSize().y, 290);
	});
	
	$('menu').addEvent('mouseleave', function(){
		if(menuFx1) menuFx1.cancel();
		if(menuFx2) menuFx2.cancel();
		menuFx1 = new Fx.Tween($('menutable'), {duration: 750, onComplet: function(){ $('menutable').removeClass('pie'); }}).start('margin-top', $('menutable').getStyle('margin-top'), -160);
		menuFx2 = new Fx.Tween($('menu'), {duration: 750}).start('height', $('menu').getSize().y, 40);
	});
	
}

function init(){
	fix();
	fixpng();
	
}

function fix(){
	
}

window.addEvent('load', init);
window.addEvent('domready', preinit);
window.addEvent('resize', fix);
