
var allLoaded = false ;

var entry = new Array( ) ;

function init( )
{
	if ( NN4 || IE4 || IE5 || NN6 )
	{
		// Products
		entry[ 0 ] = new SubMenu( "layermenu01", 177, 87 ) ;

		// Download
		entry[ 1 ] = new SubMenu( "layermenu02", 271, 87 ) ;

		// Support
		entry[ 2 ] = new SubMenu( "layermenu03", 365, 87 ) ;

		// Press Room
		entry[ 3 ] = new SubMenu( "layermenu04", 459, 87) ;
		
		// About EIZo
		entry[ 4 ] = new SubMenu( "layermenu05", 553, 87 ) ;

		// Purchase
		entry[ 5 ] = new SubMenu( "layermenu06", 647, 87) ;


		preloadImages( ) ;

		allLoaded = true ;
	}
}

function Position( x, y )
{
	this.x = ( !x ) ? 0 : x ;
	this.y = ( !y ) ? 0 : y ;
}

function SubMenu( layerName, posiX, posiY )
{
	this.name = layerName ;
	this.id   = refLayer( layerName ) ;

	this.position = new Position( posiX, posiY ) ;

	shiftLayerTo( this.id, this.getX( ), this.getY( ) ) ;
}

SubMenu.prototype.show = function( )
{
	if ( allLoaded )
	{
		showLayer( this.id ) ;
	}
}

SubMenu.prototype.hide = function( src )
{
	if ( ( IE4 || IE5 ) && src )
	{
		if ( document.all.tags("div")[ src ].contains( event.toElement ) )
		{
			return ;
		}
	}

	if ( allLoaded )
	{
		hideLayer( this.id ) ;
	}
}

SubMenu.prototype.getName = function( )
{
	return this.name ;
}

SubMenu.prototype.getX = function( )
{
	return this.position.x ;
}

SubMenu.prototype.getY = function( )
{
	return this.position.y ;
}


function newImage( arg )
{
	var rslt = null ;

	if ( document.images )
	{
		rslt     = new Image( ) ;
		rslt.src = arg ;
		return rslt ;
	}
}

function preloadImages( )
{
	if ( document.images )
	{
		var imgDir           = 'images/' ;
		var preloadImageObj  = new Array( ) ;
		var preloadImageList = new Array( ) ;

		// Products
		preloadImageList[ 0 ]    = new Array( 'pro_sbt1on.gif', 'pro_sbtnew2on.gif', 'pro_sbt2on.gif', 'pro_sbt3on.gif', 'pro_sbt4on.gif', 'pro_sbt5on.gif', 'pro_sbt6on.gif', 'pro_sbt7on.gif', 'pro_sbt8on.gif', 'pro_sbt9on.gif', 'pro_sbt10on.gif', 'pro_sbt11on.gif', 'pro_sbt12on.gif', 'pro_sbt13on.gif', 'pro_sbt14on.gif', 'pro_sbt15on.gif' ) ;

		// Solution
		preloadImageList[ 1 ]   = new Array( 'sol_sbt1on.gif', 'sol_sbt2on.gif', 'sol_sbtnew3on.gif', 'sol_sbt3on.gif', 'sol_sbt4on.gif') ;

		// Download
		preloadImageList[ 2 ] = new Array( 'dow_sbt1on.gif', 'dow_sbt2on.gif', 'dow_sbt3on.gif' ) ;

		// Support
		preloadImageList[ 3 ]   = new Array( 'sup_sbt1on.gif', 'sup_sbt2on.gif', 'sup_sbt3on.gif', 'sup_sbt4on.gif', 'sup_sbt5on.gif', 'sup_sbt6on.gif' ) ;

		// Contact
		preloadImageList[ 4 ]      = new Array( 'con_sbt1on.gif', 'con_sbt2on.gif', 'con_sbt3on.gif' ) ;

		// NewsRelease
		preloadImageList[ 5 ]      = new Array( 'new_sbt1on.gif' ) ;

		// Eclub
		preloadImageList[ 6 ]      = new Array( 'ecl_sbt1on.gif' ) ;


		for ( var i=0; i<preloadImageList.length; i++ )
		{
			for( var j=0; j<preloadImageList[ i ].length; j++ )
			{
				preloadImageObj[ preloadImageObj.length ] = newImage( imgDir + preloadImageList[ i ][ j ] ) ;
			}
		}

		preloadFlag = true ;

		MM_preloadImages('images/hd_bt1on.gif','images/hd_bt2on.gif','images/hd_bt3on.gif','images/hd_bt4on.gif','images/hd_bt5on.gif','images/hd_bt6on.gif','image/hd_bt7on.gif' ) ;
	}
}

function funcBuffer( jsCode )
{
	if ( allLoaded )
	{
		eval( jsCode ) ;
	}
}

function clearAll( )
{
	if ( allLoaded )
	{
		for ( var i in entry )
		{
			entry[ i ].hide( ) ;
		}
	}
}

function resizeHandler( )
{
	if ( NN4 )
	{
		location.reload( ) ;
		return false ;
	}
}

function setNSEventCapture( )
{
	document.captureEvents( Event.MOUSEUP ) ;

	if ( NN4 )
	{
		document.captureEvents( Event.RESIZE ) ;
	}
}

if( NN4 || NN6 )
{
	setNSEventCapture( ) ;
}

document.onmouseup = clearAll ;

window.onload = init ;
window.onresize = resizeHandler ;

