/* JavaScript generated with CSS-navimenu-Generator by Andy Tandler */

function initNaviMenu()
{
	if ( browser.isDOM1
	&& !( browser.isMac && browser.isIE )
	&& !( browser.Opera && browser.versionMajor < 7 )
	&& !( browser.isIE && browser.versionMajor < 5 ) )
	{
		// get some element
		var navimenu = document.getElementById('navimenu');

		if(navimenu) {

			var lis = navimenu.getElementsByTagName('li');

			// change the style of the navimenu
			navimenu.className="navimenu";

			// i am searching for ul element in li element
			for ( var i=0; i<lis.length; i++ )
			{
				// is there a ul element ?
				if ( lis.item(i).getElementsByTagName('ul')[0] )
				{
					// improve keyboard navigation with IE
					if ( browser.isIE )
					{
						addAnEvent(lis.item(i),'keyup',visible);
					}

					// apply the method to DOM compliant browsers
					addAnEvent(lis.item(i),'mouseover',visible);
					addAnEvent(lis.item(i),'mouseout',hidden);
					addAnEvent(lis.item(i),'blur',hidden);
					addAnEvent(lis.item(i),'focus',visible);
				}
			}

		}
	}
}

function initFotoMenu()
{
	if ( browser.isDOM1
	&& !( browser.isMac && browser.isIE )
	&& !( browser.Opera && browser.versionMajor < 7 )
	&& !( browser.isIE && browser.versionMajor < 5 ) )
	{
		// get some element
		var navimenu = document.getElementById('fotomenu');

		if(navimenu) {

			var lis = navimenu.getElementsByTagName('li');

			// change the style of the navimenu
			navimenu.className="fotomenu";

			// i am searching for ul element in li element
			for ( var i=0; i<lis.length; i++ )
			{
				// is there a ul element ?
				if ( lis.item(i).getElementsByTagName('ul')[0] )
				{
					// improve keyboard navigation with IE
					if ( browser.isIE )
					{
						addAnEvent(lis.item(i),'keyup',visible);
					}

					// apply the method to DOM compliant browsers
					addAnEvent(lis.item(i),'mouseover',visible);
					addAnEvent(lis.item(i),'mouseout',hidden);
					addAnEvent(lis.item(i),'blur',hidden);
					addAnEvent(lis.item(i),'focus',visible);
				}
			}
		}
	}
}

function addAnEvent( target, eventName, functionName )
{
	// apply the method to IE
	if ( browser.isIE )
	{
		//target.attachEvent( 'on'+eventName, functionName ); // dont work properly with this
		eval('target.on'+eventName+'=functionName');
	}
	// apply the method to DOM compliant browsers
	else
	{
		target.addEventListener( eventName , functionName , true ); // true is important for Opera7
	}
}

/* hide the first ul element of the current element */
function hidden()
{
	/* setAttribute dont work correctly with IE */
	this.getElementsByTagName('ul')[0].style.visibility = "hidden";
}

/* show the first ul element of the current element */
function visible()
{
	this.getElementsByTagName('ul')[0].style.visibility = "visible";
}

/* used to improve keyboard navigation with IE */
function hiddenUl( ul )
{
	if ( browser.isIE )
	{
		var uls = ul.getElementsByTagName('ul');
		for ( var i=0; i<uls.length; i++ )
		{
			uls.item(i).style.visibility = "hidden";
		}
		ul.style.visibility = "hidden";
	}
}

// not very clean but simple
// the function can be run in the HTML for faster display
window.onload=initNaviMenu;
window.onload=initFotoMenu;