// select the correct navigation button based on the url
var buttons = new Array("home","about","contact","clients","cv");



function select_button() {
	var current_url = window.location.toString();
	current_url = current_url.replace(/index.html/,"");
	var found_button=0;
	for (var loop =0; loop < buttons.length; loop++) {
		
		var link_to = document.getElementById(buttons[loop] + "Link").href.toString();
		link_to = link_to.replace(/index.html/,"");
		
		if (link_to == current_url) {	
			document.getElementById(buttons[loop] + "Link").style.backgroundPosition="0 0px";
			found_button=1;
		}
		
	}
	
	if (!found_button) {
		// try harder - looking to see what this url contains
		for (var loop =0; loop < buttons.length; loop++) {
		
			var link_to = document.getElementById(buttons[loop] + "Link").href.toString();
			link_to = link_to.replace(/index.html/,"");
			link_to = link_to.replace(/.html/,"");
			var bits = link_to.split("/");
			var end = bits[bits.length-1]
			if (end) {
				if (current_url.indexOf("/" + end + "/") != -1) {	
					document.getElementById(buttons[loop] + "Link").style.backgroundPosition="0 0px";
					found_button=1;
				}
			}
		}
	} // end if
	
	if (!found_button) {
		// if we still haven't found a god button to use - check to see if there is a default
		if (default_button != "DEFAULTBUTTON") {
			for (var loop =0; loop < buttons.length; loop++) {
				var link_to = document.getElementById(buttons[loop] + "Link").href.toString();
				if (end) {
					if (link_to.indexOf("/" + default_button) != -1) {	
						document.getElementById(buttons[loop] + "Link").style.backgroundPosition="0 0px";
						found_button=1;
					}
				}
			}
		}
	}
	
	if (typeof(initMap)!='undefined') { initMap()}

}