/*========================================//
 /  File: Functions.js			  /
 /  Author: Michael Thornhill		  /
 /  Date: 3/24/2005			  /
//========================================*/


//=============================================================OBJECT DEFINITIONS

//-------------------------------------------------------------------image object

function image(name, image_f, w, h, l)
{
	this.name = name;
	this.image_f = image_f;
	this.width = w;
	this.height = h;
	this.load = "";
	this.link = l;
}


//--------------------------------------------------------------------menu object
function menu()
{

	//image_l contains the menu items

	this.image_l = Array(
			     photo,
			     home_b, 
			     attorney_b, 
			     practice_b, 
			     client_b, 
			     staff_b,
			     links_b,
			     contact_b, 
			     SMaddress,
			     MTaddress
			     );
}



//====================================================================MENU ITEMS


//-------------------------------------------------------------------------photo 

var photo = new image('photo','images/menu/menuTop_01.gif', 155, 212, 'NULL');


//------------------------------------------------------------------------home_b

var home_b = new image('home_b','images/menu/menuSlice_02.gif',155,47,'index.htm');
home_b.load="revertMenu();" + home_b.name + ".image_f='images/menu/menuSlice_02d.gif';drawMenu(menu_div);";


//--------------------------------------------------------------------attorney_b

var attorney_b = new image('attorney_b','images/menu/menuSlice_03.gif',155,39,'attorneys.htm');
attorney_b.load="revertMenu();" + attorney_b.name + ".image_f='images/menu/menuSlice_03d.gif';drawMenu(menu_div);";



//--------------------------------------------------------------------practice_b

var practice_b = new image('practice_b','images/menu/menuSlice_04.gif', 155, 36,'practices.htm');

practice_b.load= "revertMenu();" + practice_b.name + ".image_f='images/menu/menuSlice_04d.gif';drawMenu(menu_div);";



//----------------------------------------------------------------------client_b

var client_b = new image('client_b','images/menu/menuSlice_05.gif', 155, 36,'clients.htm');

client_b.load= "revertMenu();" + client_b.name + ".image_f='images/menu/menuSlice_05d.gif';drawMenu(menu_div);";



//---------------------------------------------------------------------staff_b

var staff_b = new image('staff_b','images/menu/menuSlice_06.gif', 155, 37,'staff.htm');
staff_b.load= "revertMenu();" + staff_b.name + ".image_f='images/menu/menuSlice_06d.gif';drawMenu(menu_div);";


//---------------------------------------------------------------------links_b

var links_b = new image('links_b','images/menu/menuSlice_07.gif', 155, 35,'links.htm');
links_b.load= "revertMenu();" + links_b.name + ".image_f='images/menu/menuSlice_07d.gif';drawMenu(menu_div);";


//---------------------------------------------------------------------contact_b

var contact_b = new image('contact_b','images/menu/menuSlice_08.gif', 155, 38,'contact.htm');
contact_b.load= "revertMenu();" + contact_b.name + ".image_f='images/menu/menuSlice_08d.gif';drawMenu(menu_div);";



//-------------------------------------------------------------------------SMaddress

var SMaddress = new image('SMaddress', 'images/menu/menuSlice_09.gif', 155, 183, 'NULL');


//-------------------------------------------------------------------------MTaddress

var MTaddress = new image('MTaddress', 'images/menu/menuSlice_10.gif', 155, 126, 'NULL');



//----------------------------------------------------------------------menu_bar

var menu_bar = new menu();








//=====================================================================FUNCTIONS



/*******************************************************************************
 * Function: revertMenu()          					       *
 * Preconditions: menu item default files must begin with 'menuSlice_0' and be *
 *                in numerical order in the menu_bar.image_l array.	       *
 * Postconditions: the images are set to their default files.		       *
 *									       *
********************************************************************************/
function revertMenu()
{
      var j = 1;

      for(i in menu_bar.image_l) 
      {  
         menu_bar.image_l[i].image_f = "images/menu/menuSlice_0" + j + ".gif";
	 j = j +1;
      }
}



function display_div(theDiv)
{
	banking_d.style.display="none";
	bankruptcy_d.style.display="none";
	business_d.style.display="none";
	commercial_d.style.display="none";
	custody_d.style.display="none";
	divorce_d.style.display="none";
	employment_d.style.display="none";
	litigation_d.style.display="none";
	municipal_d.style.display="none";
	personal_d.style.display="none";
	probate_d.style.display="none";
	real_d.style.display="none";
	tax_d.style.display="none";
	workers_d.style.display="none";

	theDiv.style.display="";

}


function drawMenuImage(theImage)
{
	var str = "";
	var link_str = "";        
	str += " <TR>\n";
	str += "  <TD>\n";

	if(theImage.link != 'NULL')
	{
		str += "<a href=" + theImage.link + " >";
		link_str = "</a>";

	}

	str += "   <IMG SRC=";
	str += theImage.image_f;
	str += " WIDTH=" + theImage.width + " HEIGHT=" + theImage.height;
        str += " border=0>" + link_str + "</TD>\n";
	str += " </TR>\n";




	return str;
}

function drawMenu(div)
{
        var menu_string = "";


	menu_string += "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>\n";

        for(i in menu_bar.image_l)
	  menu_string += drawMenuImage(menu_bar.image_l[i]);


	menu_string += "</TABLE>\n";

	div.innerHTML = menu_string;
}


function b_load(name)
{
	var j = 1;
	for(i in menu_bar.image_l)
	{
		if(menu_bar.image_l[i].name == name)
		{
		   menu_bar.image_l[i].image_f = "images/menu/menuSlice_0" + j + "d.gif";
		   menu_bar.image_l[0].image_f = "images/menu/menuTop_0" + (j-1) + ".gif";
		}
		++j;
	}
}