// JavaScript Document
// 
// the following script creates and launches the URL reading the appended dest to show.
// If no dest is given it sets to the default dest (defined under VARIABLES)
// 
// VARIABLES
// constant data -------------------------------------------------------------
var thePages = new Array("mining.html", "agri-business.html", "waste.html", "trans-dist.html", "hospitality.html", "food-services.html", "manufactoring.html", "property.html", "construction.html", "audit.html", "risk-consulting.html", "captive.html", "claims.html", "remediation.html", "private-client.html") ;
DEFAULT = 0; //first listed in 'thePages Array
// set data
numOfdest = thePages.length
page     = ""; // variable holding the button pushed
buildUrl = ""; // final url on button click
fullURL  = ""; // raw url - before evaluated
mainURL  = ""; // url before '?'
newURL   = ""; // new set url based on selection from dropdown
pagePath  = ""; // taken from url after '?' - validate data
dest      = ""; // path to html directory

// ---------------------------------------------------------------------------
//
function setdest(setChoice){
	var dest = "./dest/" + setChoice;
	document.getElementById("default").href=dest;
	return false;
}
//
// function called by mouse event
function selectPage(newChoice){
	mainURL = fullURL.indexOf('/') + 1;
	if (mainURL == 0){
		baseURL = fullURL + "/"
	}
	else{
		baseURL = fullURL.substring(0, mainURL)
	}
	newURL  = baseURL + newChoice;
	// open up design selected
	location.href = newURL;	
};
// executed when button pushed
function openUrl(page){
	buildUrl = page + testdest(fullURL);
	window.location.href = buildUrl;	
};
//
// test to see if dest is listed in URL, if not, set to default
function testdest(str){
	   pagePath = str.indexOf('?') + 1;
	   if (pagePath == 0){
	   		return (thePages[DEFAULT]);
	   }
		else{
			return(str.substring(pagePath));
		}
} 