// JavaScript Document
var base = "http://www.matriximaging.com/";
var images = base + "images/nav/";
var myItems = new myHash( 
	0, new myHash(
		'contents', 'Products & Services',
		'uri', base+'products.htm',
		'btn', images+'btn_products.gif',
		'over', images+'btn_products-over.gif',
		'down', images+'btn_products-down.gif',
		0, new myHash(
			'contents', 'Document Processing',
			'uri', base+'products.docprocessing.htm',
			0, new myHash(
				'contents', 'Invoice/Statement',
				'uri', base+'products.docprocessing.s2.htm'),
			1, new myHash(
				'contents', 'Collection Letter',
				'uri', base+'products.docprocessing.s4.htm'),
			2, new myHash(
				'contents', 'Medical Statement',
				'uri', base+'products.docprocessing.s5.htm'),
			3, new myHash(
				'contents', 'Hospital Statement',
				'uri', base+'products.docprocessing.s8.htm'),
			4, new myHash(
				'contents', 'Manufacturing Statement',
				'uri', base+'products.docprocessing.s6.htm'),
			5, new myHash(
				'contents', 'Utility  Statement',
				'uri', base+'products.docprocessing.s7.htm')),
		1, new myHash(
			'contents', 'Web Archiving & Retrieval',
			'uri', base+'products.dars.htm'),
		2, new myHash(
			'contents', 'E-billing',
			'uri', base+'products.ebilling.htm'),
		3, new myHash(
			'contents', 'Direct Mail Processing',
			'uri', base+'products.directmail.htm')),
	1, new myHash(
		'contents', 'Company',
		'uri', base+'company.htm',
		'btn', images+'btn_company.gif',
		'over', images+'btn_company-over.gif',
		'down', images+'btn_company-down.gif',
		0, new myHash(
			'contents', 'Locations',
			'uri', 'company.locations.htm'),
		1, new myHash(
			'contents', 'Brochures',
			'uri', 'company.brochures.htm')),
	2, new myHash(
		'contents', 'Client Access',
		'uri', 'client.htm',
		'btn', images+'btn_client.gif',
		'over', images+'btn_client-over.gif',
		'down', images+'btn_client-down.gif'),
	3, new myHash(
		'contents', 'Contact Us',
		'uri', base+'contact.htm',
		'btn', images+'btn_contact.gif',
		'over', images+'btn_contact-over.gif',
		'down', images+'btn_contact-down.gif')
);

/* SHOW NAVBAR */
function show( containerID, navbar_sel )
{
	/* get the element where the menu should be created */
	var container = document.getElementById( containerID );

	for( var i=0; mItem=myItems.getItem(i); i++ )
	{
		myImg = document.createElement("IMG");
		if ( navbar_sel == i )
		{
			myImg.src = mItem.getItem('down');
			myImg.onmouseover = function() { this.className = "navbar_btn_over"; };
		}
		else
		{
			myImg.btn = myImg.src = mItem.getItem('btn');
			myImg.over = mItem.getItem('over');
			myImg.down = mItem.getItem('down');
			myImg.onmouseover = function() { this.className = "navbar_btn_over"; this.src = this.over;};
			myImg.onmouseout = function() {  this.src = this.btn; };
		}
		
		myImg.alt = mItem.getItem('contents');
		myImg.uri = mItem.getItem('uri');
		myImg.onclick = function() { if ( this.uri ) window.location = this.uri; };
		
		container.appendChild( myImg );
	}
}
/* SHOW NAVBAR */
function show_navbar( containerID, navbar_sel )
{
	/* get the element where the menu should be created */
	var container = document.getElementById( containerID );

	for( var i=0; mItem=myItems.getItem(i); i++ )
	{
		myImg = document.createElement("IMG");
		if ( navbar_sel == i )
		{
			myImg.src = mItem.getItem('down');
			myImg.onmouseover = function() { this.className = "navbar_btn_over"; };
		}
		else
		{
			myImg.btn = myImg.src = mItem.getItem('btn');
			myImg.over = mItem.getItem('over');
			myImg.down = mItem.getItem('down');
			myImg.onmouseover = function() { this.className = "navbar_btn_over"; this.src = this.over;};
			myImg.onmouseout = function() {  this.src = this.btn; };
		}
		
		myImg.alt = mItem.getItem('contents');
		myImg.uri = mItem.getItem('uri');
		myImg.onclick = function() { if ( this.uri ) window.location = this.uri; };
		
		container.appendChild( myImg );
	}
}

/* SHOW SIDEBAR */
function show_sidebar( containerID, navbar_sel, sidebar_sel, subsidebar_sel )
{
	/* get the element where the menu should be created */
	var container = document.getElementById( containerID );
    myTable = document.createElement("TABLE");
    myTablebody = document.createElement("TBODY");

	/* find out how many elements are in the menu */
	if ( navbar_sel == -2 )
	{
		navbar_sel = 0;
	}
	sideItems = myItems.getItem( navbar_sel );
	if ( sideItems )
	{
		for( var i=0; mItem=sideItems.getItem(i); i++ )
		{
			myRow=document.createElement("TR");
			myCell=document.createElement("TD");
			myText = document.createTextNode( mItem.getItem('contents') );
			myCell.appendChild(myText);
				
			myCell.data = mItem.getItem('uri');
			if ( sidebar_sel == i )
			{
				myCell.className = "sidebar_btn_sel";
				myCell.onmouseout = function() {  this.className = "sidebar_btn_sel"; };
			}
			else
			{
				myCell.className = "sidebar_btn";
				myCell.onmouseout = function() {  this.className = "sidebar_btn"; };
			}
			myCell.onclick = function() { if ( this.data ) window.location = this.data; };
			myCell.onmouseover = function() { this.className = "sidebar_btn_over"; };
			
			myRow.appendChild( myCell );
			myTablebody.appendChild( myRow );
	
			/* SHOW THE SUB SIDEBAR MENU if the item is selected and there are sub items */
			if ( sidebar_sel == i && mItem.getItem(0) )
			{
				for( var j=0; sItem=mItem.getItem(j); j++ )
				{
					myRow=document.createElement("TR");
					myCell=document.createElement("TD");
					myText = document.createTextNode( sItem.getItem('contents') );
					myCell.appendChild(myText);
						
					myCell.data = sItem.getItem('uri');
					if ( subsidebar_sel == j )
					{
						myCell.className = "sub_sidebar_btn_sel";
						myCell.onmouseout = function() {  this.className = "sub_sidebar_btn_sel"; };
					}
					else
					{
						myCell.className = "sub_sidebar_btn";
						myCell.onmouseout = function() {  this.className = "sub_sidebar_btn"; };
					}
					myCell.onclick = function() { if ( this.data ) window.location = this.data; };
					myCell.onmouseover = function() { this.className = "sub_sidebar_btn_over"; };
					
					myRow.appendChild( myCell );
					myTablebody.appendChild( myRow );
				}
			}
		}
	}
	myTable.appendChild( myTablebody );
	myTable.style.width = "100%";
	myTable.setAttribute( "cellPadding", "5px" );
	myTable.setAttribute( "border", "0" );
	container.appendChild( myTable );
	
	
/*	
    myTable = document.createElement("TABLE");
    myTablebody = document.createElement("TBODY");

	myRow=document.createElement("TR");
	myCell=document.createElement("TD");
	myText = document.createTextNode( "View Multimedia Presentation" );
	myPic = document.createElement("img")
	myPic.src = "images/presentation_button.gif"
	myCell.appendChild(myPic);
				
	myCell.data = 'flash.demo.htm';
	myCell.className = "sidebar_btn";
	myCell.onclick = function() { if ( this.data ) window.location = this.data; };
	myCell.setAttribute( "border", "0" );
			
	myRow.appendChild( myCell );
	myTablebody.appendChild( myRow );

	myTable.appendChild( myTablebody );
	myTable.style.width = "100%";
	myTable.setAttribute( "cellPadding", "5px" );
	myTable.setAttribute( "border", "0" );
	container.appendChild( myTable );
*/
}



/* This code was modified from Dan Allen <dan@mojavelinux.com>'s dom_menu */
function myHash() {
    var argIndex = 0;
    this.length = 0;
    this.numericLength = 0; 
    this.items = new Array();
    while (arguments.length > argIndex) {
        this.items[arguments[argIndex]] = arguments[argIndex + 1];
        if (arguments[argIndex] == parseInt(arguments[argIndex])) {
            this.numericLength++;
        }

        this.length++;
        argIndex += 2;
    }

    this.removeItem = function(in_key)
    {
        var tmp_value;
        if (typeof(this.items[in_key]) != 'undefined') {
            this.length--;
            if (in_key == parseInt(in_key)) {
                this.numericLength--;
            }

            tmp_value = this.items[in_key];
            delete this.items[in_key];
        }
        
        return tmp_value;
    }

    this.getItem = function(in_key)
    {
        return this.items[in_key];
    }

    this.setItem = function(in_key, in_value)
    {
        if (typeof(this.items[in_key]) == 'undefined') {
            this.length++;
            if (in_key == parseInt(in_key)) {
                this.numericLength++;
            }
        }
        
        this.items[in_key] = in_value;
    }

    this.hasItem = function(in_key)
    {
        return typeof(this.items[in_key]) != 'undefined';
    }
    
    this.merge = function(in_hash)
    {
        for (var tmp_key in in_hash.items) {
            if (typeof(this.items[tmp_key]) == 'undefined') {
                this.length++;
                if (tmp_key == parseInt(tmp_key)) {
                    this.numericLength++;
                }
            }

            this.items[tmp_key] = in_hash.items[tmp_key];
        }
    }

    this.compare = function(in_hash)
    {
        if (this.length != in_hash.length) {
            return false;
        }

        for (var tmp_key in this.items) {
            if (this.items[tmp_key] != in_hash.items[tmp_key]) {
                return false;
            }
        }
        
        return true;
    }
}