		
		
		
		
		//alert ("javascript.js has loaded");
		//alert ('the_section = ' + the_section);
		//alert ('the_section_sub = ' + the_section_sub);
		
		
		
		
//	VARS

//	This path helps us move the site from server to server, use consistent root-level links, etc.
	var path = '/';

	// CHANGE THIS IN __global/page_setup.php AS WELL!!!!






//	PRELOAD ROLLOVER GRAPHICS

	var images_to_preload = [
		'___media/__global/_page_bottom/quick_link_advisory_over.gif',
		'___media/__global/_page_bottom/quick_link_computer_over.gif',
		'___media/__global/_page_bottom/quick_link_investigative_over.gif',
		'___media/__global/_page_bottom/quick_link_electronic_over.gif',
		'___media/__global/_page_top/nav_about_over.gif',
		'___media/__global/_page_top/nav_contact_over.gif',
		'___media/__global/_page_top/nav_news_over.gif',
		'___media/__global/_page_top/nav_services_over.gif',
		'___media/_index/quick_link_advisory_over.jpg',
		'___media/_index/quick_link_computer_over.jpg',
		'___media/_index/quick_link_investigative_over.jpg',
		'___media/_index/quick_link_electronic_over.jpg',
		'___media/_index/bottom_advisory.jpg',
		'___media/_index/bottom_computer.jpg',
		'___media/_index/bottom_investigative.jpg',
		'___media/_index/bottom_electronic.jpg'
	];
	
		//alert ("preloaded_images = " + images_to_preload.length);
	
	for (var i=0; i<images_to_preload.length; i++) {
		
		var preloaded_image = new Image();
		
		preloaded_image.src = path + images_to_preload[i];
	}
	
		//alert ("Not broken...");
		
		
		
		
		
		
		
		

//	GENERAL FUNCTIONS

	function image_swap (id, src) {
		
			//alert ("rolling over " + id + ", swapping with " + src);
			
		document.getElementById(id).src = src;
	}
	
	function popup (link, name, width, height, features) {
	
			//alert ("opening a popup");
	
		window.open(link, name, "width="+width+","+"height="+height+","+features);
	}
	
	function toggle (id, state) {
	
			//alert ("toggling " + id + " to " + state);
	
		document.getElementById(id).style.display = state;
	}
	
	
	
	



//	UTILITY FUNCTIONS
	
	function getElementsByClass(elem, classname){
		
		classes = new Array();
		
		alltags = document.getElementsByTagName(elem);
		
		for (i=0; i<alltags.length; i++) {
		
			if (alltags[i].className == classname) {
				
				classes[classes.length] = alltags[i];
			}
		}
		
		return classes;
	}
	
	
	
	
	
	
//	MENU VARS & FUNCTIONS	
	
//	List all the nav items we're going to be dealing with.
//	These references match the ID of each nav item's IMG.
//	Ideally, this list should be assembled automatically by looping through and getting anything which has an ID starting with "nav_".
	var nav_items = ['nav_about','nav_services','nav_news','nav_contact'];
	

//	List all the subnavs we're going to be dealing with.
//	These references match the ID of each subnav's surrounding DIV.
//	Ideally, this list should be assembled automatically by looping through and getting anything which has an ID starting with "subnav_".
	var subnavs = ['subnav_about','subnav_services'];
	
	
//	List all the subnavs we're going to be dealing with.
	var subnav_items = getElementsByClass('a','subnav_item');
	
	
	
	function nav_highlight_current_section(){
	
			//alert ("highlighting current section's nav item");
		
	//	Turn off all other nav items
		for (var i=0; i<nav_items.length; i++) {
			image_swap(nav_items[i], path + '___media/__global/_page_top/' + nav_items[i] + '.gif');
		}
	
		if (the_section != '' && the_section != 'home') {
		
		//	Highlight the currect section's nav item
			image_swap('nav_' + the_section, path + '___media/__global/_page_top/nav_' + the_section + '_over.gif');
		}
	}
	
	function subnav_open(subnav) {
	
		subnav = 'sub' + subnav;
	
			//alert ("opening " + subnav);

		for (var i=0; i<subnavs.length; i++){
		
				//alert ('subnavs[i] = ' + subnavs[i]);

			if (subnavs[i] == subnav) {
				
					//alert ('opening ' + subnavs[i]);
				
				document.getElementById(subnavs[i]).style.display = 'inline';
			
			} else {
				
					//alert ('closing ' + subnavs[i]);
				
				document.getElementById(subnavs[i]).style.display = 'none';
			}
		}
	}
	
	function subnav_cleanup(event) {
	
			//alert('subnav_cleanup' + event);
	
		if (	(event.clientY < 70) 	||		(event.clientY > 150)	){
				
				//alert ('cleaning up the subnavs');
			
			nav_highlight_current_section();
				
			for (var i=0; i< subnavs.length; i++) {
				
				if (subnavs[i] != ('subnav_' + the_section)){
					
					document.getElementById(subnavs[i]).style.display = 'none';
				
				} else {
					
					document.getElementById(subnavs[i]).style.display = 'inline';
				}
 			}
		}
	}
	
	function subnav_highlight_current_section_sub() {
	
		if (the_section_sub != '') {
			
			document.getElementById('subnav_'+the_section_sub).className = 'selected';
		}
	}


	
	
	
		
//	PAGE SETUP

	function prepare_elements(){
	
			
			
			//alert ("preparing elements...");
	
	
	
	//	Highlight nav button for the current section
		nav_highlight_current_section();
	
	
	
	//	Highlight subnav item for the current sub-section
		subnav_highlight_current_section_sub();

	
	
	//	Turn on subnav for the current section
		subnav_open('nav_'+the_section);
		
		
		
		
	//	Attach functionality to various images
	
		var images = document.getElementsByTagName("img");
		
		for (var i=0; i<images.length; i++) {
			
		//	Wire the nav buttons for image_swap & subnav reveals
			
			if (images[i].getAttribute("class") == "nav_button" || images[i].getAttribute("className") == "nav_button") {
				
				images[i].onmouseover = function () {
				
						//alert ('rolling over ' + path + '___media/__global/_page_top/' + this.getAttribute('id') + '_over.gif');
				
				//	Turn off all other buttons
					for (var i=0; i<nav_items.length; i++) {
						image_swap(nav_items[i], path + '___media/__global/_page_top/' + nav_items[i] + '.gif');
					}
				
				//	HIghlight this button
					image_swap(this.getAttribute('id'), path + '___media/__global/_page_top/' + this.getAttribute('id') + '_over.gif');
				
				//	Open the subnav
					subnav_open(this.getAttribute('id'));
				}
				
				images[i].onmouseout = function () {
					
						//alert ('rolling out');
					
					//image_swap(this.getAttribute('id'), path + '___media/__global/_page_top/' + this.getAttribute('id') + '.gif');
				}
			}
			
		//	Wire the quick link buttons for image_swap
			
			if (images[i].getAttribute("class") == "quick_link" || images[i].getAttribute("className") == "quick_link") {
				
				images[i].onmouseover = function () {
				
						//alert ('rolling over ' + path + '___media/__global/_page_top/' + this.getAttribute('id') + '_over.gif');
					
					image_swap(this.getAttribute('id'), path + '___media/__global/_page_bottom/quick_link_' + this.getAttribute('id') + '_over.gif');
				}
				
				images[i].onmouseout = function () {
					
						//alert ('rolling out');
					
					image_swap(this.getAttribute('id'), path + '___media/__global/_page_bottom/quick_link_' + this.getAttribute('id') + '.gif');
				}
			}
			
		//	Wire the quick link buttons on the home page for image_swap
		//	There is a companion to this bit further down when the links are set which rewires the <a> surrounding bottom.jpg as it changes on image_swap
			
			if (images[i].getAttribute("class") == "quick_link_home" || images[i].getAttribute("className") == "quick_link_home") {
				
				images[i].onmouseover = function () {
				
					image_swap(this.getAttribute('id'), path + '___media/_index/quick_link_' + this.getAttribute('id') + '_over.jpg');
					image_swap('bottom', path + '___media/_index/bottom_' + this.getAttribute('id') + '.jpg');
				}
				
				images[i].onmouseout = function () {
				
					image_swap(this.getAttribute('id'), path + '___media/_index/quick_link_' + this.getAttribute('id') + '.jpg');
					image_swap('bottom', path + '___media/_index/bottom.jpg');
				}
			}
		}
		
	//	Attach functionality to various links
	
		var links = document.getElementsByTagName("a");
		
		for (var i=0; i<links.length; i++) {
		
		//	Wire the popup links
		
			if (links[i].getAttribute("class") == "popup" || links[i].getAttribute("className") == "popup") {
				
				links[i].onclick = function () {
					
					popup(this,'popup','650','500','scrollbars=auto,resizable=yes');
					
					return false;
				}
			}
		}
 	}	
	
	
//	This function adds our prepare_elements function to the list of functions to execute onLoad.
//	This is necessary because when Geo adds rollovers, etc. w/ Dreamweaver, DW adds an onLoad call in the body. 	
	function add_load_event(func) {
	
		var old_onload = window.onload;
		
		if (typeof window.onload != 'function') {
			
			window.onload = func;
		
		} else {
		
			window.onload = function () {
				old_onload();
				func();
			}
		}
	}
	
	
//	Trigger the prepare_elements script as soon as the page loads
	add_load_event(prepare_elements);
	
	
	
	
	
