// get path from root to correct loading issues from sub-folders of the site
// this needs to be included on any page that needs to load a file path for any reason
var pathToRoot = ( $("#admin").length ) ? '../' : './';
// global vars
var currentLevel, currentMapImg, clonedMap, number;
var maxZoom = 0; //max zoom level for the maps
var minZoom = 0; //min zoom level for the maps
var mouse_x = 0; //mouse x position
var mouse_y = 0; //mouse y position

// Preload images by creating an image object and setting the source.
var image1 = new Image(); image1.src = pathToRoot+"img/bg_chrome.png";
var image2 = new Image(); image2.src = pathToRoot+"img/menu.png";
var image3 = new Image(); image3.src = pathToRoot+"img/site-bg.png";

/* For local files if you use async false then you don't have to do the callback timer
 * (js stops execution until the file is loaded). working in IE6, FF2, & Safari.
**/
function loadScript(path) {
	var js = document.createElement('script');
	js.setAttribute('language', 'javascript');
	js.setAttribute('type', 'text/javascript');
	js.setAttribute('src', path);
	window.document.body.appendChild(js);
	return true;
}

// load scripts that need to be loaded before dom ready
loadScript(pathToRoot+"js/core.js");

/********** DOM READY **********/
$(function() {
// load helper functions - for the most part this is the general drop box for code snipits used
// throughout this site template & other helper functions that would span across multiple pages
loadScript(pathToRoot+"js/helpers.js");

// personnel picker --------
	if( $("#personnelPicker").length ) {
		loadScript(pathToRoot+"js/personnel.js");
	}
// map --------------------- 
	if( $("#map").length ) {
		loadScript(pathToRoot+"js/territory.js");
	}
// dictionary --------------
	$("#dictionary ul li a").live("click", function(){
		$("#dictionary ul li span").hide();
		$(this).next("span").show();
		return false;
	});	
// safety page -------------
	$("#safetyList dt a").live("click", function(){
		//remove this styles from all <a> and hide all <dd>
		$("#safetyList dt a").removeAttr("style").parent().parent().children("dd").hide();			
		//show dd after the 'this' has been clicked
		$(this).css("color","#005596").parent().next("dd").show();
		return false;
	});

});

