// JavaScript Document
function mainMenu(menuID, offImage, onImage, imageWidth, imageHeight, href, className, submenu)
{
  this.menuID      = menuID;
  this.offImage    = offImage;
  this.onImage     = onImage;
  this.imageWidth  = imageWidth;
  this.imageHeight = imageHeight;  
  this.href        = href;
  this.className   = className;
  this.submenu     = submenu;
}

function subMenu(menuID, text, href, className, submenu)
{
  this.menuID    = menuID;
  this.text      = text;
  this.href      = href;
  this.className = className;
  this.submenu   = submenu;
}
  
  sub_About = [];
  sub_About[0] = new subMenu ('sub_corp_office', 'Corporate Office', 'about_corpoffice.php', 'classSub', '');

  sub_Partners = [];
  sub_Partners[0] = new subMenu ('sub_partners', 'Partner with Us', 'partners_request.php', 'classSub', '');
  sub_Partners[1] = new subMenu ('sub_partners', 'Avaya&nbsp;DevConnect&nbsp;', 'partners_avaya.php', 'classSub', '');  

  sub_News = [];
  sub_News[0] = new subMenu ('sub_events', 'Events', 'news_events.php', 'classSub', '');
  
  sub_Products = [];
  sub_Products[0] = new subMenu ('sub_products', 'Pricing', 'pricing.php', 'classSub', '');
  
  sub_Contacts = [];
  sub_Contacts[0] = new subMenu ('sub_site_map', 'Site Map', 'sitemap.php', 'classSub', '');
  
  sub_Empty = [];  
  sub_Empty[0] = new subMenu ('empty', 'Site Map', 'sitemap.php', 'classSub', '');

  main_Menu = []; 
  main_Menu[0] = new mainMenu ('main_home', '../images/nav/home.gif', '../images/nav/home-over.gif', 90, 30, 'index.php', '', '');
  main_Menu[1] = new mainMenu ('main_about', '../images/nav/about.gif', '../images/nav/about-over.gif', 105, 30, 'about.php', '', sub_About);
  main_Menu[2] = new mainMenu ('main_cases', '../images/nav/case_studies.gif', '../images/nav/case_studies-over.gif', 129, 30, 'product_info.php', '', sub_Products);
  main_Menu[3] = new mainMenu ('main_partners', '../images/nav/partnership.gif', '../images/nav/partnership-over.gif', 106, 30, 'partners.php', '', sub_Partners);
  main_Menu[4] = new mainMenu ('main_news', '../images/nav/news.gif', '../images/nav/news-over.gif', 144, 30, 'news_releases.php', '', sub_News);
  main_Menu[5] = new mainMenu ('main_contacts', '../images/nav/contact.gif', '../images/nav/contact-over.gif', 126, 30, 'contactus.php', '', sub_Contacts);  
  
  
function Changes(img1, img2, cellShowID, visibility)
{
   img1.src = img2;
   if (cellShowID) {
   document.getElementById(cellShowID.id).style.visibility = visibility;
   }
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	   }
    }

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		home_over = newImage("../images/nav/home-over.gif");
		about_over = newImage("../images/nav/about-over.gif");
		cases_over = newImage("../images/nav/case_stidues-over.gif");
		partnership_on1 = newImage("../images/nav/partnership.gif");
		partnership_over1 = newImage("../images/nav/partnership-over.gif");
		news_over = newImage("../images/nav/news-over.gif");
		contacts_over = newImage("../images/nav/contact-over.gif");		
		preloadFlag = true;
	}
}
  
  function addImage(id, imgSrc, imgWidth, imgHeight, imgAppTo)
  {
    var img = document.createElement('img');
    img.id = id;
	img.src    = imgSrc;
    img.width  = imgWidth;
    img.height = imgHeight;
	img.border = 0;
    document.getElementById(imgAppTo).appendChild(img);
  }
  
function addDiv(id, width, height, xpos, ypos)
  {
    var div = document.createElement('div');
    div.id = id;
    div.style.width = width;	
    div.style.height = height;
	div.style.position = "absolute";
	div.style.left = xpos;
	div.style.top = ypos;
	return(div);
  }

function addAnchor(id, text, href, className, anchorAppTo)
  {
    var a = document.createElement('a');
    a.id = id;
	a.innerHTML    = text;
    a.href  = href;
    a.className = className;
    document.getElementById(anchorAppTo).appendChild(a);
  }
  
  function addTable(id, cellPadding, cellSpacing, tableAppTo)
  {
    var tbl = document.createElement('table');
    tbl.id    = id;
	tbl.cellPadding = cellPadding;
	tbl.cellSpacing = cellSpacing;
    document.getElementById(tableAppTo).appendChild(tbl);
  }
  
  function addTableRow(id, tableAppTo, position)
  {
    var tblRow = document.getElementById(tableAppTo).insertRow(position);
    tblRow.id  = id;
  }
  
  function addTableCell(id, tableRowAppTo, position, className)
  {
    var tblCell = document.getElementById(tableRowAppTo).insertCell(position);
    tblCell.id  = id;
	tblCell.className = className;
  }
  
  function createMainMenu()
  {
	var i;
	var k;
	var x;
	var y;
	var z=0;
	
	var browser=navigator.appName;

	if (browser=="Microsoft Internet Explorer")
      {
		 k=10; //k is added to the xpos of the submenu for correct placement in IE and Mozilla
		 x='linkName';//style of the submenu in Mozilla
		 y=1;//controls the width of the div box for different browsers
		 z=0;//distance from the y position ofv the div from IE
		  }
	else //browser is Opera or Netscape
	 {
		 k=8; 
		 x='linkName2';
		 y=-1;
		 z=-11;
	 }
 
	
	addTable('main_menu_table', 0, 0,'m_menu');
	var row1 = 'main_menu_table_row';
	addTableRow(row1, 'main_menu_table', 0);
	for ( i=0; i < main_Menu.length; i++ ) //creates the main menu
	 
	 { 
		 var menu_name = main_Menu[i].menuID;	  
		 var cell1_id  = menu_name+'cell'; //first row cell id
		 var link1_id  = menu_name+'_a';   //first row link id
		 var img1_id   = menu_name+'_img'; //first row image id
 		 var cell2_id  = "sub_" + menu_name +"_div";
		 
		 addTableCell(cell1_id, row1, i, ''); 
		 addAnchor(link1_id, '', main_Menu[i].href, 'text', cell1_id);
		 addImage(img1_id, main_Menu[i].offImage, main_Menu[i].imageWidth, main_Menu[i].imageHeight, link1_id);

		if (main_Menu[i].submenu != '')
		{
			document.body.appendChild(addDiv("sub_"+ menu_name +"_div",main_Menu[i].imageWidth+y,28,k,188+z));
			addTable("sub_"+ menu_name +"_table", 0, 0,"sub_"+ menu_name +"_div");
			
			for (var j=0; j < main_Menu[i].submenu.length; j++)
			{
				addTableRow("sub_"+ menu_name +"_tr_"+ j, "sub_"+ menu_name +"_table", j);
				
				if (j == (main_Menu[i].submenu.length - 1 ))
				{
					addTableCell("sub_"+ menu_name +"_td_"+ j, "sub_"+ menu_name +"_tr_"+ j, 0, 'submenu_cell_2');
				}
				else
				{
					addTableCell("sub_"+ menu_name +"_td_"+ j, "sub_"+ menu_name +"_tr_"+ j, 0, 'submenu_cell_1');	
				}
				addAnchor("sub_"+ menu_name +"_a_"+ j, main_Menu[i].submenu[j].text, main_Menu[i].submenu[j].href, x, "sub_"+ menu_name +"_td_"+ j);
			}
			
			if (document.getElementById("sub_"+ menu_name +"_table").width < main_Menu[i].imageWidth)
			{
				document.getElementById("sub_"+ menu_name +"_table").width = main_Menu[i].imageWidth;
			}
			
			var value = 'Changes('+ img1_id+ ', "'+main_Menu[i].onImage +'", '+cell2_id +', "visible");';
		    var value2 = 'Changes('+ img1_id+ ', "'+main_Menu[i].offImage +'", '+cell2_id +', "hidden");';
			document.getElementById(cell2_id).onmouseover = new Function (value);
		    document.getElementById(cell2_id).onmouseout = new Function (value2);
			document.getElementById(cell2_id).style.visibility = 'hidden';
		}
		else
		{
			 var value = 'Changes('+ img1_id+ ', "'+main_Menu[i].onImage +'", "", "visible");';
		     var value2 = 'Changes('+ img1_id+ ', "'+main_Menu[i].offImage +'", "", "hidden");';	
		}
		k = k + main_Menu[i].imageWidth;
		document.getElementById(link1_id).onmouseover = new Function (value);
		document.getElementById(link1_id).onmouseout = new Function (value2);
	  }
  }