// JavaScript Document
// javascript menu for bsb
// date : 17 july 2007
// alnadeem IT Bahrain


function txtColChange(ths)
{
//alert("ht")
//onMouseOver=\"this.style.backgroundColor=\'#77b900\'\"
	ths.style.color='black'
	
}
function rtxtColChange(ths)
{
	ths.style.color='white'
}
function polyMenu(Name)
{
	this.Name = Name;
	this.MenuItems = [];
	this.Config = {
			height: 25
			
	}
};

function polyMenuItem(id, displayName, url, target,  defaultSelected)
{
	this.id = id;
	this.displayName = displayName;
	this.url = url;
	this.target = target;
	this.defaultSelected = defaultSelected;
};

polyMenu.prototype.AddMenuItem = function(id, displayName, url, target, defaultSelected)
{		
	this.MenuItems[this.MenuItems.length] = new polyMenuItem(id, displayName, url, target,  defaultSelected);
}

polyMenu.prototype.toString = function()
{
	var str = "";
	str += "<div class=\"menubar\" id=\"" + this.Name + "MenuBar\">";
	str +=  this.CreateMenuItems();
	str += "</div>";	
	return str;
}

polyMenu.prototype.CreateMenuItems = function()
{
	var str = "";
	str += "<table border=0 cellpadding=0 cellspacing=0 >";
	str += "<tr>";
	for(var i=0; i< this.MenuItems.length; i++)
	{
		
		str += "<td >";
			str += "<table cellspacing=0 cellpadding=0 border=0 vspace=5 >";
			str += "<tr align=center hspace=20>";
			if( i == 0)
			{
				// only first item have the left menu	
				str += "<td ";
				if(this.MenuItems[i].defaultSelected)
				{
					str += " class=\"startleftselected\" ";
				}
				else
				{
					str += " class=\"startleft\" ";
				}
				str += " id=\"" + this.Name + "item" + i  + "0\">&nbsp;";
				str += "</td>";
			}
			
			str += "<td   "
			if(this.MenuItems[i].defaultSelected)
			{
				str += " class=\"selectedContent\" ";
			}
			else
			{
				str += "class=\"unselectedContent\" ";
			}
			str += " height=\"" + this.Config.height + "\" id=\"" + this.Name + "item" + i  + "1\">";
			str += "<a class=\"" ;
			if(this.MenuItems[i].defaultSelected)
			{
				str += "selectedlink\"  ";
			}
			else
			{
				str += "unselectedlink\" onMouseOut=\"rtxtColChange(this)\"  ";
				
			}
			str += " onMouseMove=\"txtColChange(this)\"   href=\"" + this.MenuItems[i].url + "\">"
			str += this.MenuItems[i].displayName;
			str += "</a>";
			str += "</td>";
			if(i == this.MenuItems.length -1)
			{
				str += "<td ";
				if(this.MenuItems[i].defaultSelected)
				{
					str += " class=\"endrightselected\" ";
				}
				else
				{
					str += "class=\"endright\" ";
				}
				str += " id=\"" + this.Name + "item" + i  + "2\">&nbsp;";
				str += "</td>";
			}
			else
			{
				// check whether the next item is selected
				
					
				str += "<td ";
				if(this.MenuItems[i+1].defaultSelected)
				{
					str += " class=\"nextrightselected\" ";
				}
				else if(this.MenuItems[i].defaultSelected)
				{
					str += " class=\"rightselected\" ";
				}
				else
				{
					str += "class=\"right\" ";
				}
				str += " id=\"" + this.Name + "item" + i  + "2\">&nbsp;";
				str += "</td>";
			}
			str += "</tr>";
			str += "</table>";	
		str += "</td>";
		
	}
	str == "</tr>";		
	str += "</table>";
	return str;	
}



function customAlert(str)
{
  if(document.getElementById("tempalert") != null)
  {
	document.getElementById("tempalert").value = str;  
  }
}