// Buttonize functions
function button_over(eButton)
{
	eButton.style.backgroundColor =	"LightSlateGray";
	eButton.style.borderColor =	"darkblue darkblue darkblue	darkblue";		
}
	
function button_out(eButton)
{
	eButton.style.backgroundColor =	"threedface";
	eButton.style.borderColor =	"threedface";
}
	
function button_down(eButton)
{
	eButton.style.backgroundColor =	"#8494B5";
	eButton.style.borderColor =	"darkblue darkblue darkblue	darkblue";
}
	
function button_up(eButton)
{
	eButton.style.backgroundColor =	"#B5BDD6";
	eButton.style.borderColor =	"darkblue darkblue darkblue	darkblue";
	eButton	= null;	
}

function globalModalDialog(pageName, style)
{
	var arr;
	try
	{
		arr = window.showModalDialog(pageName, null, style);
	}
	catch (err)
	{	
	//	arr = window.open(pageName,'name',style + ',modal=yes');
	   arr = window.open(pageName, null, 'height=400,width=350,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,modal=yes');
	}
	return arr;
} 

function getColor(elementId)
{
	var textBox = document.getElementById(elementId);
	//var	arr	= window.showModalDialog("colorpanel.htm","","font-family:Verdana;	font-size:12; dialogWidth:30em;	dialogHeight:35em" );
	var arr = globalModalDialog("colorpanel.htm","font-family:Verdana;	font-size:12; dialogWidth:30em;	dialogHeight:35em" );
	if (arr	!= null && textBox != null) 
		textBox.value = arr;
} // getColor

function getImage(elementId,playerId)
{
	var textBox = document.getElementById(elementId);	
	var arr=globalModalDialog('SelectImage.aspx?mode=txt&playerId=' + playerId,'status:no;dialogWidth:470px;dialogHeight:450px;dialogHide:true;help:no;scroll:no');
	if (arr	!= null && textBox != null) 
		textBox.value = arr;
}

function changeImage(ImageName,FileName) 
{	
	document[ImageName].src = FileName;
}

function grabFocus(elementId)
{
	document.getElementById(elementId).focus();
}

function menuItem(text, link){
	this.text = text;
	this.link = link;
}
function menuTrigger(name, text, link){
	this.name = name;
	this.text = text;
	this.link = link;
}
function menu(){
	var itemArray = new Array();
	var args = menu.arguments;
	this.name = args[0];
	this.trigger = args[1];
	for(i=2; i<args.length; i++){
		itemArray[i-2] = args[i];
	}
	this.menuItems = itemArray;
	this.write = writeMenu;
	this.position = positionMenu;
}
function writeMenu(){
	var menuText = '<div id="';
	menuText += this.trigger.name;
	menuText += '" class="trigger" style="top: ';
	menuText += this.top;
	menuText += '; left: ';
	menuText += this.left;
	menuText += ';"';
	menuText += 'onMouseOver="showMenu(\'';
	menuText += this.name;
	menuText += '\')" onMouseOut="hideMenu(mnuSelected)">';
	menuText += '<table border="0" width="' + this.width + '">';
	menuText += '<tr><th><a href="' + this.trigger.link + '">' + this.trigger.text + '</a></th></tr></table></div>';
	
	if (this.menuItems.length>0)
	{
	menuText += '<div id="';
	menuText += this.name;
	menuText += '" class="menu" style="top: ';
	menuText += (this.top+33);
	menuText += ';left: ';
	menuText += this.left;
	menuText += ';" '
	menuText += 'onMouseOver="showMenu(mnuSelected)" ';
	menuText += 'onMouseOut="hideMenu(mnuSelected)">';
	menuText += '<table border="0" width="' + this.width + '">';
	for(i=0; i<this.menuItems.length; i++){
		menuText += '<tr>';
		//menuText += '<td onMouseOver="this.style.backgroundColor = \'red\'" onMouseOut="this.style.backgroundColor = \'\'">';
			menuText += '<td>';
		menuText += '<a href="' + this.menuItems[i].link + '">';
		menuText += this.menuItems[i].text + '</a></td>';
		menuText += '</tr>';
	}
	menuText += '</table></div>';
	}
	document.write(menuText);
	document.close();
}

function positionMenu(top,left){ //,width){
	this.top = top;
	this.left = left;
//	this.width = width;
}

var mnuSelected = '';
var fullHeight;
var iterationHeight;


function showMenu(menu){
	hideMenu(mnuSelected);		
	document.getElementById(menu).style.visibility = 'visible';
	mnuSelected = menu;
}

function hideMenu(menu){
	if(mnuSelected!='')
		document.getElementById(menu).style.visibility = 'hidden';
}
