var menucfg = new Array;
menucfg['mouse_over'] = new Array;
menucfg['menu_open'] = new Array;
var adcfg = new Array;
adcfg['mouse_over'] = new Array;

function open_menu(menu_id, background_color, font_color) {
	document.getElementById(menu_id).style.backgroundColor = background_color;
	document.getElementById(menu_id).style.cursor = 'pointer';
	document.getElementById(menu_id).style.visibility = 'visible';
	
	setTimeout(function() {
		if(menucfg['mouse_over'][menu_id] == 1) {
			var i = 0;
			while(document.getElementById(menu_id + '_' + i) != null) {
				//alert(menu_id + '_' + i + ": " + document.getElementById(menu_id + '_' + i));
				document.getElementById(menu_id + '_' + i).style.visibility = 'visible';
				menucfg['menu_open'][menu_id + '_' + i] = 1;
				i++;
			}
		}
	}, 300);
	
	menucfg['menu_open'][menu_id] = 1;
	menucfg['mouse_over'][menu_id] = 1;
}

function turn_menu_off(menu_id, background_color, font_color) {
	menucfg['mouse_over'][menu_id] = 0;

	if(document.getElementById(menu_id + '_0') == null) {
		document.getElementById(menu_id).style.backgroundColor = background_color;
	}

	setTimeout(function() {
		var still_over = 0;
		var i = 0;
		var parent_id = menu_id.split('_');
		while(menucfg['menu_open'][parent_id[0] + '_' + i] != undefined) {
			if(menucfg['mouse_over'][parent_id[0] + '_' + i] == 1) {
				still_over = 1;
			}
			i++;
		}

		if(menucfg['mouse_over'][parent_id[0]] == 1) {
			still_over = 1;
		}
		
		i = 0;
		if(still_over == 0) {
			while(document.getElementById(parent_id[0] + '_' + i) != null) {
				document.getElementById(parent_id[0] + '_' + i).style.visibility = 'hidden';
				menucfg['menu_open'][parent_id[0] + '_' + i] = 0;
				i++;
			}
			document.getElementById(parent_id[0]).style.backgroundColor = background_color;
		}

	}, 10);
}

//GENERIC GREEN COLOR HEX IS #3FDC00
function ad_on(parent_ad, color) {
	adcfg['mouse_over'][parent_ad] = 1;
	i = 1;
	document.getElementById(parent_ad).style.cursor = 'pointer';
	
	while(document.getElementById(parent_ad + '_' + i) != null) {
		document.getElementById(parent_ad + '_' + i).style.backgroundColor = color;
		i++;
	}
}

//GENERIC GREEN OFF COLOR IS #32AC01
function ad_off(parent_ad, color) {
	adcfg['mouse_over'][parent_ad] = 0;
	
        setTimeout(function() {
		i = 1;
		if(adcfg['mouse_over'][parent_ad] == 0) {
			while(document.getElementById(parent_ad + '_' + i) != null) {
		                document.getElementById(parent_ad + '_' + i).style.backgroundColor = color;
                		i++;
        		}			
		}
	}, 10);

}


function getarraysize(thearray)
{
        for (i = 0; i < thearray.length; i++)
        {
                if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
                {
                        return i;
                }
        }
        return thearray.length;
}


