var classNameTempVar;
var tempObject;
var tempTimeoutId;
var tempShow;
tempShow = 0;
/*
img1 = new Image();
img2 = new Image();
img3 = new Image();
img4 = new Image();
img5 = new Image();


img1.src = location.protocol + "://" + location.host + "/sites/all/themes/custom/metavisnew/img/menu_product_fon.png";
img2.src = location.protocol + "://" + location.host + "sites/all/themes/custom/metavisnew/img/menu_solutions_fon.png";
img3.src = location.protocol + "://" + location.host + "sites/all/themes/custom/metavisnew/img/menu_support_fon.png";
img4.src = location.protocol + "://" + location.host + "sites/all/themes/custom/metavisnew/img/menu_resources_fon.png";
img5.src = location.protocol + "://" + location.host + "sites/all/themes/custom/metavisnew/img/menu_video_fon.png";*/


function initMenu(menuName) {
	var block_menu = document.getElementById(menuName).childNodes;
	for(var i = 0; i < block_menu.length; i++) {
		if((block_menu[i].className == "content") || (block_menu[i].nodeName == "DIV")) {
			for(var y = 0; y < block_menu[i].childNodes.length; y++) {
				if((block_menu[i].childNodes[y].className == "menu") || (block_menu[i].childNodes[y].nodeName == "UL")) {
					menu = block_menu[i].childNodes[y];
				}
			}
			
		}
	}
	addEvents(menu);
}

function addEvents(menu){
	for(var i = 0; i < menu.childNodes.length; i++) {
		if(menu.childNodes[i].nodeName == "LI") {
			var obj = menu.childNodes[i];
			$(obj).hover(function(){
				tempObject = this;
				childSmallShow(tempObject);
				tempTimeoutId = setTimeout(function() {
					childShow(tempObject);
				}, 500);
			},function(){
				clearTimeout(tempTimeoutId);
				if(tempShow == 1) {
					childHide(this);
				} else {
					childSmallHide(this);
				}
			})
		}
	}
}


function childSmallShow(obj) {
	classNameTempVar = obj.className;
	obj.className = classNameTempVar + " active activeSmall";
}

function childSmallHide(obj) {
	obj.className = classNameTempVar;
}

function childShow(obj) {
	obj.className = classNameTempVar + " active";
	tempShow = 1;
}

function childHide(obj) { 
	obj.className = classNameTempVar;
	tempShow = 0;
}
