nav1_off = new Image();
nav1_on = new Image();
nav2_off = new Image();
nav2_on = new Image();
nav3_off = new Image();
nav3_on = new Image();
nav4_off = new Image();
nav4_on = new Image();
nav5_off = new Image();
nav5_on = new Image();
nav6_off = new Image();
nav6_on = new Image();
con_off = new Image();
con_on = new Image();

nav1_off.src = "images/nav1_off.gif";
nav1_on.src = "images/nav1_on.gif";
nav2_off.src = "images/nav2_off.gif";
nav2_on.src = "images/nav2_on.gif";
nav3_off.src = "images/nav3_off.gif";
nav3_on.src = "images/nav3_on.gif";
nav4_off.src = "images/nav4_off.gif";
nav4_on.src = "images/nav4_on.gif";
nav5_off.src = "images/nav5_off.gif";
nav5_on.src = "images/nav5_on.gif";
nav6_off.src = "images/nav6_off.gif";
nav6_on.src = "images/nav6_on.gif";
con_off.src = "images/contact.gif";
con_on.src = "images/contact_on.gif";

function roll(sname,rname){
    sname.src = rname.src;
}

function submenu(menuId,direction){
	var menu = document.getElementById('submenu'+menuId);
	if (direction==1){
    	menu.style.visibility = 'visible';
		}else {
		menu.style.visibility = 'hidden';
		}
}

function mainmenu(menuId,direction){
    if (direction==1){
		document.getElementById('main_'+menuId).className = 'practices_button on';
		}else{
		document.getElementById('main_'+menuId).className = 'practices_button';
		}
}


function id2elem(id) {
	// This is what most folks call "xGetElementById", but
	// again, I wanted to save myself some typing.
	if (typeof(id) != 'string') {
		return id;
	}
	if (document.getElementById) {
		id = document.getElementById(id);
	} else if (document.all) {
		id=document.all[id];
	} else {
		id = null;
	}
	return id;
}

function color_links(elem) {
//alert("running color_links(" + typeof elem + ").");
	var links = document.getElementsByTagName('a');
	for (var i = 0; i < links.length; i++) {
var elem_id = links[i].id;
		if (links[i].id.search(/^officelink\d/) == -1) {
//alert("Skipping link " + elem_id);
			continue;
		}
		if (links[i] == elem) {
			links[i].parentNode.className = 'on';
//alert("Turned on link " + elem_id);
		} else {
//alert("Turned off link " + elem_id);
			links[i].parentNode.className = '';
		}
	}
}


function get_XH_obj() {
	var xhreq;
	if (window.XMLHttpRequest) {
		//alert("Branch 1");
		xhreq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		//alert("Branch 2");
		xhreq = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert("I'm sorry, your browser doesn't seem to support the XMLHttpRequest object, either as part of the W3C DOM or as an ActiveX object. I regret to say that this means you won't be able to use the features on this site.");
	}
	return xhreq;
}

function std_ajax_send(URL, data) {
//alert("std_ajax_send, opening GET " + URL + "?q=" + data);
	xhobj.open("GET", URL + "?q=" + data, true);
	xhobj.onreadystatechange = update_office;
	xhobj.send(null);
}


function update_office() {
	if (xhobj.readyState == 4) {
		var stat = xhobj.status;
		var stat_text = xhobj.statusText;
		var resp_text = xhobj.responseText;
		
		var lines = xhobj.responseText.split(/[\r\n]+/);
		for (var i = 0; i < lines.length; i++) {
			var id = lines[i].substr(0, lines[i].indexOf(':'));
			var data = lines[i].substr(lines[i].indexOf(':') + 2);
			//var data = lines[i].split(/:\s*/, 2);
			id = 'office' + id;
			switch(id) {
			case 'officeemaillink':
				id2elem(id).innerHTML = "<a href=\"mailto:" + data + "\">" + data + "</a>";
				break;
			case 'officedirectionslink':
				if (typeof data == 'string' && data.length > 1) {
					id2elem(id).innerHTML = "<a href=\"" + data + "\" target=\"_blank\">Directions&nbsp;&gt;</a>";
				} else {
					id2elem(id).innerHTML = '';
				}
				break;
			default:
				id2elem(id).innerHTML = data;
			}
		}
		id2elem('officeinfo').style.display = 'block';
	}
}


function clear_office() {
	id2elem('officeinfo').style.display = 'none';
}

