/////////////////////////////////////////////////////////////////////////////
//                                                                         //
//          COPYRIGHT 2005 KNXU COMMUNICATIONS, ALL RIGHTS RESERVED        //
//                                                                         //
/////////////////////////////////////////////////////////////////////////////
//
//          4 DEC 2005
//

var totalGraphics=0;
var mbarOffset=0;
var menuOffset=0;
var graphic = new Array();
var selected=0;
var mbarselected=0;
var lastnum=0;
var lastmbar=0;
var imageSubdirectory = "images/";
var imagePrefix       = "IMT_";
var onSuffix          = "_ON.gif";
var offSuffix         = "_OFF.gif";
var overSuffix        = "_SEL.gif";
var iconSuffix        = "_icon.gif";
var frameTarget       = "_top";

var num;
var doflash = false;
var today = new Date();
var page;
var bgcol   = "#111166";
var Lbg     = "white";
var sideBar = "white";
var setIcon = "images/HDC_main_icon.gif";
var menuSet;
var titleMenu = "";
var lastSet   = "";
var txtc = "#111111";
var hdrc = "#181844";
var ftrc = "#eeeeff";
var bgc = "#181822";
var mbarName  = "exhibits"; // This defines the Mbar button as always on for this 
                            // hdr.js file. There would be other hdr.js files for 
                            // the other Mbar buttons.



// --------------------- MAKE CHANGES ---------------------------------------


loadIcon(100,100,"welcome");
loadIcon(100,100,"truss");
loadIcon(100,100,"wedo");
loadIcon(100,100,"quality");
loadIcon(100,100,"package");
loadIcon(100,100,"require");
loadIcon(100,100,"contact");

mbarOffset = totalGraphics;

loadMbar(30, 90, "welcome", "Welcome", "Welcome","index.html");

/*
loadMbar(30, 100, "main", "education", "Education","education.html");
loadMbar(30, 110, "main", "facilities", "Facilities","facilities.html");
loadMbar(30, 80, "main", "museum", "Museum","museum.html");
loadMbar(30, 50, "main", "shop", "Shop","shop.html");
loadMbar(30, 70, "main", "about", "About HDC","about.html");
loadMbar(30, 50, "main", "kids", "For Kids","kids.html");
*/

menuOffset = totalGraphics;

loadMenu(30, 174, 1, "welcome", "welcome", "Intermountain Truss", "index.html");
loadMenu(30, 174, 1, "truss", "truss", "Truss benefits", "truss.html");
loadMenu(30, 174, 1, "wedo", "wedo", "What we do", "wedo.html");
loadMenu(30, 174, 1, "quality", "quality", "IMT quality", "quality.html");
loadMenu(30, 174, 1, "package", "package", "Truss package", "package.html");
loadMenu(30, 174, 1, "require", "require", "Requirements", "require.html");
loadMenu(30, 174, 1, "contact", "contact", "Planning and Form", "contact.html");


// --------------------- END CHANGES -----------------------------------------

function doOnLoad()
{
  doClick(page);
}

function initpage(p)
{
  var p;
  page = p + menuOffset;
  if(p==0){doflash = true;}

  with(this.document)
  {

    pagespec(p);

    write('<scr'+'ipt type="text/javascript" src="http://knxu.com/mon.js"></scr'+'ipt>');
    write('</head><body topmargin="0" bgcolor="'+ bgcol +'" text="'+txtc+'" link="#8811aa" vlink="#ff1111" alink="#1188ff">');
    write('<center>');
    dheader();
    write('<table border="0" bordercolor="green" cellpadding="0" cellspacing="0" width="820"><tr>');
//    write('<td width="20" background="images/13_left_bg.gif"></td>');
    write('<td valign="top" width="190" bgcolor="'+bgc+'" background="images/IMT_menu_bg.gif">');
    write('<img src="images/IMT_menu_top_bg.gif" height="6" width="190">');
    writemenu();
    doClick(page);
  }
}

function pagespec(p)
{
  var item = menuOffset + p;
  var pageSet = graphic[item].set;

  var i=0;

  while(i< menuOffset && graphic[i].name != pageSet)
  {
    i++;
  }
  setIcon = graphic[i].icon.src;
  menuSet = pageSet;
}

function dheader()
{
  with(this.document)
  {
    write('<table border="0" bordercolor="red" cellpadding="0" cellspacing="0" width="820"><tr>');
//    write('<td width="20" height="125" background="images/IMT_left_bg.gif"></td>');
//    if(doflash)
//    {
//    write('<td bgcolor="black">');
//    }
//    else
//    {
      write('<td height="125" width="810" background="images/IMT_hdr1.jpg">');
//    }
    write('</td><td width="10" background="images/IMT_right_bg.gif"></td>');    
    write('</tr></table>');
    write('<table border="0" bordercolor="yellow" cellpadding="0" cellspacing="0" width="820" height="30"><tr>');
    write('<td width="5" background="images/IMT_hdr2_left.gif">');
    write('<td height="30" width="800" valign="middle" bgcolor="black" background="images/IMT_hdr2.gif">');
    write('<div style="color:'+hdrc+';font-family:arial;font-size:11pt;margin-left:0px;margin-right:0px"><center><b>');
    doDate();
    write('</b></center></div></td>');
    write('<td width="5" background="images/IMT_hdr2_right.gif"></td>');    
    write('<td width="10" background="images/IMT_right_bg.gif"></td>');    
    write('</tr></table>');


<!-- END OF MIDDLE LEVEL -->
  }
}

function writemenu()
{
    var vsp=3;
	with(this.document)
	{
//		write('<table border="0" bordercolor="blue" cellpadding="0" cellspacing="0" width="180" valign="top"><tr>');
//		write('<td valign="top" bgcolor="'+bgc+'" background="images/13_menu_bg.gif">');
		write('<div style="margin-left:'+vsp+'">');
		for(i = menuOffset; i < totalGraphics; i++)
		{
		    if(graphic[i].set == menuSet || graphic[i].set != lastSet)
		    {
			write ('<a target="' + frameTarget + '" href="' + graphic[i].link + '" onMouseOver="doMouseOver(' + i + '); return true" onMouseOut="doMouseOut(' + i + ')" onClick="doClick(' + i + ')">');
			write ('<img name="' + graphic[i].name + '" src="' + graphic[i].offname + '" alt="' + graphic[i].name + '" width="' + graphic[i].width + '" height="' + graphic[i].height + '" border="0" vspace="'+vsp+'">');
			write ('</a><br/>');
			if(titleMenu=="" && graphic[i].set == menuSet){titleMenu = i;}
		    }
		    lastSet = graphic[i].set;
		}
//		write('</div></td></tr><tr><td height="30" background="images/13_menu_bottom.gif"></td></tr></table>');
		write('</div>');
	}
}

function setup_left()
{
    with(this.document)
    {
	write('<div style="color:'+txtc+';font-family:arial;font-size:10pt;text-align:justify;margin-left:5px">');
    }
}

function setup_main()
{
    with(this.document)
    {
	write('</div></td>');
        write('<td valign="top" bgcolor="'+bgc+'" width="620" background="images/IMT_main_bg.gif"><img src="images/IMT_main_top_bg.gif" width="620" height="5">');
        write('<div class="main">');
    }
}

function setup_right()
{   // NOT USING THIS FUNCTION
    with(this.document)
    {
	write('</div></td>');
	write('<td width="200" valign="top" bgcolor="'+ sideBar +'">');
	write('<div style="margin-left:2px;margin-top:2px">');
    }
}

function endpage()
{
  with(this.document)
  {
    write('</div></td><td width="10" background="images/IMT_right_bg.gif"></td></tr></table>');
    write('<table width="820" border="0" bordercolor="red" cellpadding="0" cellspacing="0"><tr>');
    write('<td height="30" width="6" background="images/IMT_bottom_left_bg.gif"></td>');
    write('<td width="798" background="images/IMT_bottom_bg.gif">');

    write('<center><span style="color:'+ftrc+';font-family:arial;font-size:8pt;font-weight:500;margin-top:5px">&copy; Copyright 2007  Inter-Mountain Truss, Inc.</span></center></td>');

    write('</td>');
    write('<td width="6" background="images/IMT_bottom_right_bg.gif">');
    write('<td width="10" background="images/IMT_bottom_right_edge_bg.gif"></td>');
    write('</tr>');
    write('</table></td></tr>');



    write('</table></center>');
    mon();

    write('<div style="visibility:hidden">');

    for(i=0; i < totalGraphics; i++)
    {
	    this.document.write('<img src="'+ graphic[i].on.src + '" width="' + graphic[i].width + '" height="' + graphic[i].height + '">');
	    this.document.write('<img src="'+ graphic[i].over.src + '" width="' + graphic[i].width + '" height="' + graphic[i].height + '">');
    }
    write('</div>');
  }
}

<!-- loadMenu(20, 300, 1, "main", "exhibits", "Exhibits", "index.html"); -->

function loadMenu (height, width, selOK, set, name, infoText, link)
{
  graphic[totalGraphics] = new MenuItem(height, width, selOK, set, name, infoText, link);
  totalGraphics++;
}

function MenuItem (height, width, sel, set, name, infoText, link)
{
  this.height   = height;
  this.width    = width;
  this.set	= set;
  this.name     = name;
  this.selOK	= sel;
  this.info     = infoText;
  this.link     = link;
  this.on       = new Image (width, height);
  this.on.src   = imageSubdirectory + imagePrefix + name + onSuffix;
  this.off      = new Image (width, height);
  this.off.src  = imageSubdirectory + imagePrefix + name + offSuffix;
  this.offname  = imageSubdirectory + imagePrefix + name + offSuffix;
  this.over     = new Image (width, height);
  this.over.src = imageSubdirectory + imagePrefix + name + overSuffix;
  this.info     = infoText;
  this.selected   = 0;
}

<!-- loadIcon(100,100,"main"); -->

function loadIcon (height, width, name)
{
  graphic[totalGraphics] = new MenuIcon(height, width, name);
  totalGraphics++;
}

function MenuIcon (height, width, name)
{
  this.height   = height;
  this.width    = width;
  this.name     = name;
  this.icon       = new Image (width, height);
  this.icon.src   = imageSubdirectory + imagePrefix + name + iconSuffix;
}

<!-- loadMbar(30, 90, "main", "exhibits", "Exhibits","index.html"); -->

function loadMbar (height, width, set, name, infoText, link)
{
  graphic[totalGraphics] = new MbarItem(height, width, set, name, infoText, link);
  totalGraphics++;
}

function MbarItem (height, width, set, name, infoText, link)
{
  this.height   = height;
  this.width    = width;
  this.set	= set;
  this.name     = name;
  this.info     = infoText;
  this.link     = link;
  this.on       = new Image (width, height);
  this.on.src   = imageSubdirectory + imagePrefix + name + onSuffix;
  this.off      = new Image (width, height);
  this.off.src  = imageSubdirectory + imagePrefix + name + offSuffix;
  this.offname  = imageSubdirectory + imagePrefix + name + offSuffix;
  this.over     = new Image (width, height);
  this.over.src = imageSubdirectory + imagePrefix + name + overSuffix;
  this.info     = infoText;
}


function doClick (num)
{
  if(num >= mbarOffset && num < menuOffset)
  {
    document.images[graphic[num].name].src = graphic[num].on.src;
    if(lastmbar != 0 && lastmbar != num)
    {
	document.images[graphic[lastmbar].name].src = graphic[lastmbar].off.src;
    }
    lastmbar = num;
    mbarselected = num;
  }
  else if(num >= menuOffset && num < totalGraphics)
  {
    document.images[graphic[num].name].src = graphic[num].on.src;
    document.images[graphic[titleMenu].name].src = graphic[titleMenu].on.src;
    if(lastnum !=0 && lastnum != num){document.images[graphic[lastnum].name].src = graphic[lastnum].off.src;}
    lastnum = num;
    selected = num;
  }
}

function doMouseOver(num)
{
  if(num >= mbarOffset && num < menuOffset)
  {
    if (num != mbarselected && graphic[num].name != mbarName)
    {
      document.images[graphic[num].name].src = graphic[num].over.src;
    }
    else if(graphic[num].name == mbarName)
    {
      document.images[graphic[num].name].src = graphic[num].on.src;
    }	
  }
  else if(num >= menuOffset && num < totalGraphics)
  {
    if (num != selected && num != titleMenu)
    {
      document.images[graphic[num].name].src = graphic[num].over.src;
    }
    self.status = graphic[num].info;
  }
}

function doMouseOut(num)
{
  if(num >= mbarOffset && num < menuOffset)
  {
    if (num != mbarselected && graphic[num].name != mbarName)
    {
      document.images[graphic[num].name].src = graphic[num].off.src;
    }
    else if(graphic[num].name == mbarName)
    {
      document.images[graphic[num].name].src = graphic[num].on.src;
    }	
  }
  else if(num >= menuOffset && num < totalGraphics)
  {
    if (num != selected && num != titleMenu)
    {
      document.images[graphic[num].name].src = graphic[num].off.src;
    }
    else if(num == titleMenu)
    {
      document.images[graphic[titleMenu].name].src = graphic[titleMenu].on.src;
    }	
    self.status = graphic[selected].info;
//    alert("OUT "+num+", selected is "+ selected);
  }
}


function doDate()
{
	this.document.write(getDayStr(today.getDay()).toString() +', ');
	this.document.write(getLongMonth(today.getMonth()) + ' ' + today.getDate().toString() + ', ');
	this.document.write(today.getFullYear().toString());
}
function getMon(mon)
{
	var month = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	return month[mon];
}
function getLongMonth(mon)
{
	var month = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	return month[mon];
}
function getDayStr(day)
{
	var week = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	return week[day];
}

