var rolloverItem = null;

function OnMouseOver( element )
{
	if ( element == rolloverItem )
	{
		return;
	}

	switch ( element.className )
	{
		case 'std-a':
		case 'menu-item':
		case 'menu-item2':
		case 'image-link':
			element.style.color = "#ff0000";
			break;

		case 'category-blank':
			document.getElementById( "image" + element.attributes[ "index" ].value ).style.borderColor = "#ff0000";
			document.getElementById( "title" + element.attributes[ "index" ].value ).style.color = "#ff0000";
			break;
			
		case 'category-title':
			element.style.color = "#ff0000";
			document.getElementById( "image" + element.attributes[ "index" ].value ).style.borderColor = "#ff0000";
			break;

		case 'subcategory-title':
			element.style.color = "#ff0000";
			document.getElementById( "title" + element.attributes[ "index" ].value ).style.color = "#ff0000";
			document.getElementById( "image" + element.attributes[ "index" ].value ).style.borderColor = "#ff0000";
			break;
		
		case 'category-image':
			element.style.borderColor = "#ff0000";
			document.getElementById( "title" + element.attributes[ "index" ].value ).style.color = "#ff0000";
			break;
	}

	rolloverItem = element;
}

function OnMouseOut( element )
{
	if ( rolloverItem )
	{
		switch ( rolloverItem.className )
		{
			case 'std-a':
			case "menu-item":
			case "menu-item2":
			case "image-link":
				rolloverItem.style.color = "#594D27";
				break;

			case 'category-title':
				document.getElementById( "image" + element.attributes[ "index" ].value ).style.borderColor = "#ffffff";
				document.getElementById( "title" + element.attributes[ "index" ].value ).style.color = "#594D27";
				break;
				
			case 'category-title':
				rolloverItem.style.color = "#594D27";
				document.getElementById( "image" + element.attributes[ "index" ].value ).style.borderColor = "#ffffff";
				break; 
				
			case "subcategory-title":
				rolloverItem.style.color = "#594D27";
				document.getElementById( "image" + element.attributes[ "index" ].value ).style.borderColor = "#ffffff";
				document.getElementById( "title" + element.attributes[ "index" ].value ).style.color = "#594D27";
				break; 
				
			case 'category-image':
				rolloverItem.style.borderColor = "white";
				document.getElementById( "title" + element.attributes[ "index" ].value ).style.color = "#594D27";
				break;
		}
		
		rolloverItem = null;
	}
}

function OnClick( element )
{
	if ( element.attributes[ "link" ] )
	{
		document.location = element.attributes[ "link" ].value;
	}
	else if ( element.attributes[ "imagesrc" ] )
	{
		var imageLinks = document.getElementsByName( "imagelink" );
		for ( var i = 0; i < imageLinks.length; i++ )
		{
			imageLinks[ i ].className = "image-link";
			imageLinks[ i ].style.color = "#594D27";
		}

		element.className = "image-link-selected";
		element.style.color = "#ff0000";

		document.getElementById( "image-target" ).src = element.attributes[ "imagesrc" ].value;
	}
	else
	{
		alert( "No link or imagesrc!" );
	}
}

