var menuimagenames = new Array('etusivu', 'yritys', 'tuotteet', 'palvelut', 'sovelluskohteet', 'suunnittelijoille', 'jakelijat', 'yhteystiedot');
var menuimages = new Array();
for(i=0;i<menuimagenames.length;i++)
{
	imgoff = new Image();
	imgoff.src = 'gfx/'+menuimagenames[i]+'.gif';
	imgon = new Image();
	imgon.src = 'gfx/'+menuimagenames[i]+'_hl.gif';
	menuimages[menuimagenames[i]] = new Array(imgoff.src, imgon.src);
}


$(function()
{
    $('.menuitem').mouseover(function()
    {
	    clearTimeout(this.timeout);
	    var id = $(this).attr('id');
	    $(this).children('a').first().children('img').first().attr('src', menuimages[id][1]);
        $(this).children('.dropdownmenu').first().fadeIn(400);
    });
    $('.menuitem').mouseout(function()
    {
	    var item = $(this);
	    var hide = function() 
	    { 
		    var id = $(item).attr('id');
	    	$(item).children('a').first().children('img').first().attr('src', menuimages[id][0]);
			try
			{
		    	$(item).children('.dropdownmenu').first().hide();
	    	}
	    	catch(e)
	    	{
		    	
	    	}
	    };
	    this.timeout = setTimeout(hide, 1);
    });
    
    $('.menuitemsel').mouseover(function()
    {
	    clearTimeout(this.timeout);
	    var id = $(this).attr('id');
        $(this).children('.dropdownmenu').first().fadeIn(400);
    });
    $('.menuitemsel').mouseout(function()
    {
	    var item = $(this);
	    var hide = function() 
	    { 
			try
			{
		    	$(item).children('.dropdownmenu').first().hide();
	    	}
	    	catch(e)
	    	{
		    	
	    	}
	    };
	    this.timeout = setTimeout(hide, 1);
    });
    
})

