//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

var CurrentMenuSelected = null;

function MenuButton( rowid,targetid,src,imgout,imgover,imgsel )
{
	// variable
	this.FrameId      = null;
	this.ParentRow    = rowid;
	
	this.Target		  = targetid;
	this.SelectedLink = src;
	
	this.ImgOut       = imgout;
	this.ImgOver      = imgover;
	this.ImgSel       = imgsel;
	
	this.bSelect      = false;
	
	// UI
	this.Cell = null;
	this.Area = null;
	this.Img  = null;

	// Constructor
	this.Constructor = MenuButton_Constructor;
	this.Destructor  = MenuButton_Destructor;
	
	// Events
	this.OnMouseOver = MenuButton_OnMouseOver;
	this.OnMouseOut  = MenuButton_OnMouseOut;
	this.OnClick     = MenuButton_OnClick;
	
	this.Constructor( false );
}

function MenuButton_Constructor( bSelect )
{
	this.bSelect = bSelect;
	
	this.Cell = this.ParentRow.insertCell( this.ParentRow.cells.length );
	this.Cell.width = '126';
	
	this.Area = document.createElement("a");
	this.Area.href = this.SelectedLink;
	this.Area.target = this.Target;
	
	this.Img  = document.createElement("img");
	this.Img.width = '126';
	this.Img.height = '48';
	this.Img.style.border = 'none';
	
	this.Area.appendChild( this.Img );
	this.Cell.appendChild( this.Area );
	
	var ObjTHIS = this;
	this.Cell.onmouseover = function() { ObjTHIS.OnMouseOver() };
	this.Cell.onmouseout  = function() { ObjTHIS.OnMouseOut()  };
	this.Cell.onclick     = function() { ObjTHIS.OnClick() };
	
	if( this.bSelect )
	{
		this.OnClick();
		this.FrameId.src = this.SelectedLink;
	}
	else
	{
		this.OnMouseOut();
	}
}

function MenuButton_Destructor( )
{
	this.ParentRow.deleteCell( this.Cell.cellIndex );
	this.Img = null;
	this.Cell = null;
}

// Events
function MenuButton_OnMouseOver( )
{
	if( this.bSelect == false )
		this.Img.src = this.ImgOver;
}

function MenuButton_OnMouseOut( )
{
	if( this.bSelect == false )
		this.Img.src = this.ImgOut;
}

function MenuButton_OnClick( )
{
	this.bSelect = true;
	this.Img.src = this.ImgSel;
	if( CurrentMenuSelected != this )
	{
		if( CurrentMenuSelected != null )
		{
			CurrentMenuSelected.bSelect = false;
			CurrentMenuSelected.OnMouseOut();
		}
		CurrentMenuSelected = this;
		//this.FrameId.src = this.SelectedLink;
	}
}


