function initImages() {	
	//
	document.imageOut = new Object();
	document.imageOver = new Object();
	// PNG Fix for IE<7
	var png_fix = "images/png_fix.gif";
	var pngRegExp = new RegExp("\\.png$", "i")
	var f = "DXImageTransform.Microsoft.AlphaImageLoader";
	//
	var imageArray = $$("img", "input");
	imageArray.each(function(item){
		var image = item.src.substr(item.src.lastIndexOf("/")+1);
		var id = item.id || image.replace("_n.", "").replace("_N.", "");
		var hover = (image.toLowerCase().lastIndexOf("_n.") !=-1);
		//
		if (hover && document.imageOut && document.imageOver) {
			document.imageOut[id] = new Image();
			document.imageOut[id].src = item.src;
			document.imageOver[id] = new Image();
			document.imageOver[id].src = item.src.substr(0, item.src.lastIndexOf("/")+1)+image.replace("_n.", "_o.").replace("_N.", "_O.");
		}
		// PNG Fix for IE<7
		if (window.ie && !window.ie7 && image.test(pngRegExp)) {
			item.style.width = item.offsetWidth+"px";
			item.style.height = item.offsetHeight+"px";
			item.style.filter = "progid:"+f+"(src='"+item.src+"', sizingMethod='scale');";
			item.src = png_fix;
		}
		//
		if (hover && document.imageOut && document.imageOver) {
			item.onmouseover = function(){
				if (document.imageOver && document.imageOver[this.id]) setImage(this, document.imageOver[this.id].src);
			}
			item.onmouseout = function(){
				if (document.imageOut && document.imageOut[this.id]) setImage(this, document.imageOut[this.id].src);
			}
			item.id = id;
			//
			function setImage(imageObject, src) {
				if (window.ie && !window.ie7) {
					if (imageObject.filters[f] && imageObject.filters[f].src.test(pngRegExp)) {
						imageObject.filters[f].src = src;
					} else {
						imageObject.src = src;
					}
				} else {
					imageObject.src = src;
				}
			}
		}
	});
}

////////////////////////////////
//
function initMenu(){
	document.menuOver = false;
	document.openedMenu = null;
	document.openedBtn = null;
	document.menuInterval = null;
	//
	$$("a.menuBtn").each(function(btn, i){
		var menuContent = $(btn.getProperty("id")+"Menu");
		btn.subMenu = menuContent.clone().injectInside($$("body")[0]);
		menuContent.remove();
		btn.subMenu.orgH = btn.subMenu.getCoordinates().height;
		btn.subMenu.fx = new Fx.Style(btn.subMenu, "height").set(0);
		btn.subMenu.subUL = btn.subMenu.getElements("ul");
		//
		btn.addEvent("mouseover", function(){
			if (btn.getFirst()) btn.getFirst().swap = false;
			btn.subMenu.setStyles({
				left: btn.getPosition().x+10
			});
			//
			hideMenu();
			//
			btn.subMenu.fx.stop();
			btn.subMenu.fx.options.duration = 500;
			btn.subMenu.fx.start(btn.subMenu.orgH);
			//
			clearInterval(document.menuInterval);
			document.menuOver = true;
			document.openedMenu = btn;
		});
		btn.addEvent("mouseout", function(){
			document.menuOver = false;
			clearInterval(document.menuInterval);
			document.menuInterval = setInterval(hideMenu, 100);
		});
		//
		btn.subMenu.subUL.each(function(sMn){
			var prevLink = sMn.getPrevious();
			prevLink.addEvent("click", function(e){
				new Event(e).stop();
				sMn.fx.stop();
				sMn.fx.start(!sMn.opened ? sMn.orgH : 0);
				sMn.opened = !sMn.opened;
				//
				btn.subMenu.fx.stop();
				btn.subMenu.fx.start(btn.subMenu.getCoordinates().height+(sMn.opened ? sMn.orgH : -sMn.orgH));
				//
			});
			sMn.opened = false;
			sMn.orgH = sMn.getCoordinates().height;
			sMn.setStyle("height", 0);
			sMn.fx = new Fx.Style(sMn, "height");
			btn.subMenu.orgH -= sMn.orgH;
		});
		//
		btn.subMenu.addEvent("mouseover", function(){
			clearInterval(document.menuInterval);
			document.menuOver = true;
		});
		btn.subMenu.addEvent("mouseout", function(){
			document.menuOver = false;
			clearInterval(document.menuInterval);
			document.menuInterval = setInterval(hideMenu, 100);
		});
		btn.subMenu.getElements("a").addEvents({
			"mouseover": function(e){
				clearInterval(document.menuInterval);
				document.menuOver = true;
			},
			"mouseout": function(e){
				document.menuOver = false;
				clearInterval(document.menuInterval);
				document.menuInterval = setInterval(hideMenu, 100);
			}
		});
		//
	});
	$$("#nav a").each(function(item){
		if (!item.hasClass("menuBtn")) {
			item.addEvent("mouseover", function(){
				hideMenu();
			});
		}
	});
	//
	//
	function hideMenu(){
		if (document.menuOver == false) {
			clearInterval(document.menuInterval);
			if (document.openedMenu) {
				var img = document.openedMenu.getFirst()
				if (img) {
					img.swap = true;
					img.fireEvent("mouseout");
				}
				//
				var subOpenedMenu = document.openedMenu.subMenu;
				subOpenedMenu.fx.stop();
				subOpenedMenu.fx.options.duration = 200;
				subOpenedMenu.fx.start(0);
				subOpenedMenu.subUL.each(function(subUL){
					subUL.fx.stop();
					subUL.fx.set(0);
					subUL.opened = false;
				});
				document.openedMenu = null;
			}
		}
	}
}
//////////////////////////////////////////////////
function initBanner() {
	
	if ($('bannerFlash')) {
		var so = new SWFObject("flash/we_banner_home.swf", "movieScript", "665", "204", "7", "");
		so.addParam("wmode", "transparent");
		so.write("bannerFlash");
	}	
}
//////////////////////////////////////////////////

window.addEvent("load", function(){
	initImages();
	initMenu();
	initBanner();
});  