// Stuff having to do with the user interface
// Written by Andrew Hedges, andrew@clearwired.com
// August 30, 2006

var ui = {
	// Preload rollover states for images
	preload: function (srcs) {
		for (var i = srcs.length-1; i > -1; i--) {
			var img = new Image();
			img.src = '/images/'+srcs[i];
		}
	},
	// Main (front page) navigation
	nav_main: {
		srcs: ['button_big_hi.png'],
		preload: function () { ui.preload(ui.nav_main.srcs); },
		addHovers: function () { addHovers('nav_main', 'DIV'); }
	},
	// Navigation on second level pages (design, technology, projects, people)
	nav_section: {
		srcs: ['button_medium_hi.png'],
		preload: function () { ui.preload(ui.nav_section.srcs); },
		addHovers: function () { addHovers('nav_section', 'DIV'); }
	},
	// Navigation on blog-style pages
	nav_inside: {
		srcs: ['button_small_hi.png'],
		preload: function () { ui.preload(ui.nav_inside.srcs); },
		addHovers: function () { addHovers('nav_inside', 'DIV'); }
	},
	contact_us: {
		// IDs of the various tabs
		ids: ['get_in_touch', 'get_directions', 'work_with_us', 'subscribe'],
		// Mapping of which tabs should get shadows based on which one is selected
		shadow_map: {
			get_in_touch: ['get_directions'],
			get_directions: ['get_in_touch', 'work_with_us'],
			work_with_us: ['get_in_touch', 'subscribe'],
			subscribe: ['get_in_touch']
		},
		switchTab: function (id) {
			// Loop through tabs and unselect/unshadow them and hide the divs
			for (var i = ui.contact_us.ids.length-1; i > -1; i--) {
				(getObj('tab_'+ui.contact_us.ids[i])).className = '';
				(getObj(ui.contact_us.ids[i])).style.display = 'none';
			}
			// Select appropriate tab
			(getObj('tab_'+id)).className = 'selected';
			// Add shadows as necessary
			for (var i = ui.contact_us.shadow_map[id].length-1; i > -1; i--) {
				(getObj('tab_'+ui.contact_us.shadow_map[id][i])).className = 'shadowed';
			}
			// Show the appropriate div
			(getObj(id)).style.display = 'block';
		}
	}
}
