var g_images = new Array();

function preload_images()
{
	if (document.images)
	{
		for( var i = 0; i < preload_images.arguments.length; i++ )
		{
			var img = new Image();
			img.src = preload_images.arguments[i];
			window.g_images.push( img );
		}
	}
}

function onload_default()
{
	onload_hover();
}

function onload_hover()
{
	var class_name = "hover";
	var objs = document.getElementsByTagName( 'a' );
	
	// loop through all the onmouseover a tags
	for( var i = 0; i < objs.length; i++ )
	{
		var parent = objs[ i ];
		var obj = null;
		if( typeof( parent.childNodes[ 0 ] ) != "undefined" ) obj = parent.childNodes[ 0 ];
		
		if( obj )
		{
			if( parent.className == class_name )
			{	
				var file1 = obj.src;
				var postfix = file1.split( '.' );
				postfix = postfix[ postfix.length - 1 ];
				postfix = "." + postfix;
				
				var file2 = file1.replace( postfix, "_over" + postfix );
				preload_images( new Array( file2 ) );
				
				if( obj.addEventListener )
				{
					obj.addEventListener( "mouseover", function ( a, b ) { return function(){ update_image( a, b ); } }( obj, file2 ), false ); 
					obj.addEventListener( "mouseout", function ( a, b ) { return function(){ update_image( a, b ); } }( obj, file1 ), false );
				}
				else
				{
					obj.attachEvent( "onmouseover", function ( a, b ) { return function(){ update_image( a, b ); } }( obj, file2 ) ); 
					obj.attachEvent( "onmouseout", function ( a, b ) { return function(){ update_image( a, b ); } }( obj, file1 ) );
				}			
			}
		}
	}
}

function update_image( obj, image )
{
	if( typeof( obj ) != "object" )
	{
		obj = get_object( obj );
	}
	obj.src = image;
}


