var PngFix = {

	filterClasses: function(classNamesArray){

		var arVersion = navigator.appVersion.split("MSIE")

		var version = parseFloat(arVersion[1])



		if ((version >= 5.5) && (document.body.filters))

		{

			classNamesArray.each(function(imgclass){

				$$(imgclass).each(function(img){

					var imgName = img.src.toUpperCase();

					if (imgName.substring(imgName.length-3, imgName.length) == "PNG")

					{

						PngFix.addFilter(img);

					}

				});

			});

		}

	},

	addFilter: function(img){

		try{

			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.width + "px; height:" + img.height + "px;" + imgStyle + ";"

			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"

			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"

			img.outerHTML = strNewHTML

		}

		catch(e){

			// alert(e);
		}

	}

}

function png_fix() {
	PngFix.filterClasses(["img"]);
}

function body_size() {
	var body_size = $('body').getSize();
	$('main').setProperty('height', body_size.y - 158);
}

function image_grow() {
	$$('img').each(function(el){
		if(el.getProperty('class') == 'grow') {
			el.addEvents({
				'mouseover': function(){
					size = this.getSize();
					position = this.getPosition();
					this.setStyle('width', size.x * 1.05);
					this.setStyle('height', size.y * 1.05);
					this.setStyle('top', - size.y * .025);
					this.setStyle('left', - size.x * .025);
				},
				'mouseout': function(){
					size = this.getSize();
					position = this.getPosition();
					this.setStyle('width', size.x / 1.05);
					this.setStyle('height', size.y / 1.05);
					new_size = this.getSize();
					this.setStyle('top', (new_size.y * .025) /2);
					this.setStyle('left',(new_size.x * .025) /2);			  
				}
			});
			el.setProperty('class', '');		
		}		
	});
}



function menu_links() {
	$$('#menu td').each(function(el){
		if(el.getProperty('class') != 'active') {
			el.addEvents({
				'mouseover': function(){this.setProperty('class','active');},
				'mouseout': function(){this.setProperty('class','_');},
				'click': function(e){
					var children = this.getChildren(); 
					document.location = children[0];
				}
			});		
		}
		//e.stop();
	});
}


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

window.addEvent('load', function() {
	image_grow();

   	png_fix();   
});