/////////////////////////////////////////////////////////
function checkExternal(linkObj) {
	return window.confirm("You have clicked on an external link and are about to leave the site. Click ok to continue to the new page or cancel to remain at UltraCare-Dialysis.com. The new page will open in a new window, when you are ready to return to UltraCare-Dialysis.com, simply close the window.")

}


function showTab(obj, num) {
	obj.blur();
	var obj;
	
	obj = getObjByID("tabbox_content_" + tabbox_current);
	setClass(obj, "tabbox_content");

	obj = getObjByID("tabbox_tab_" + tabbox_current);
	setClass(obj, "");

	obj = getObjByID("tabbox_content_" + num);
	setClass(obj, "tabbox_content_selected");

	obj = getObjByID("tabbox_tab_" + num);
	setClass(obj, "tabbox_tab_selected");
	
	tabbox_current = num;
	
	return false;	
}

tabbox_current = 1;

/////////////////////////////////////////////////////////
var linkbox_heading;
var linkbox_content;

function drawLinkboxStyle() {

	var txt = "";
	txt += "<STYLE type=\"text/css\">";
	txt += " #linkbox_data {display:none;}";
	txt += " #linkbox_outer {display:block !important;}";
	txt += "</STYLE>";

	//alert("drawLinkboxStyle txt:"+txt);
	return txt;
}



function initLinkBox(content_id) {

	linkbox_heading = getObjByID("linkbox_heading");
	linkbox_content = getObjByID("linkbox_content");
	
	showItem(content_id);


}


function showItem(content_id) {
	//alert("content_id:"+content_id);

	var content_el = getObjByID("c"+content_id);
	var txt = content_el.innerHTML;


	var child_id_arr =  getChildIds(content_id);

	//alert("child_id_arr:"+child_id_arr);
	var txt = "<DIV id=\"linkbox_display\">";

	txt += content_el.innerHTML;

	txt += "<UL class=\"blank\">";
	for (var l = 0; l<child_id_arr.length; l++) {
		var child_id = child_id_arr[l];
		txt += "<LI>";
		txt += "<B>";
		txt += " &gt; ";
		txt += "<A";
		txt += " href=\"#\" onclick=\"return showItem('" +child_id+ "');\"";
		txt += ">";
		var lnk_el = getObjByID("h"+child_id);
		if (lnk_el) {
			txt += lnk_el.innerHTML;
		};
		txt += "</A>";
		txt += "</B>";
		txt += "</LI>";
	}
	txt += "</UL>";
	txt += "</DIV>";


	if (objP(content_el)) {
		setInnerHTML("linkbox_content", txt);
	};



	var parent_id_arr =  getParentIds(content_id);
	parent_id_arr.reverse();
	//alert("parent_id_arr:"+parent_id_arr);

	txt = "<DIV id=\"linkbox_breadcrumb\">";
	for (var l = 0; l<parent_id_arr.length; l++) {
		var child_id = parent_id_arr[l];
		txt += "<B>";
		if ((l+1) != parent_id_arr.length) {
			txt += "<A";
			txt += " href=\"#\" onclick=\"return showItem('" +child_id+ "');\"";
			txt += ">";
		};
		var lnk_el = getObjByID("h"+child_id);
		if (lnk_el) {
			txt += lnk_el.innerHTML;
		};
		if ((l+1) != parent_id_arr.length) {
			txt += "</A>";
			txt += " &gt; ";
		};

		txt += "</B>";
	}
	txt += "</DIV>";


	if (objP(content_el)) {
		setInnerHTML("linkbox_heading", txt);
	};






	return false;
}
/////////////////////////////////////////////////////////

function getParentIds(content_id) {
	var a = [];
	
	var content_el = getObjByID("c"+content_id);


	if (objP(content_el)) {
		var item_el = content_el;

		while (item_el) {
			if (item_el.nodeType == 1) {
				var item_id = item_el.getAttribute("id");
				//alert("item_id:"+item_id)
				if (item_id == "linkbox_data") {
					break;
				} else if (item_id && item_id.indexOf("item_") == 0) {
					a.push(item_id.substr(5));
				};
			}
			var item_el = item_el.parentNode;
		};
	};
	
	return a;

}

/////////////////////////////////////////////////////////



function getChildIds(content_id) {
	var a = [];
	
	var content_el = getObjByID("c"+content_id);


	if (objP(content_el)) {
		var item_el = content_el;

		while (item_el) {
			if (item_el.nodeType == 1) {
				var item_id = item_el.getAttribute("id");
				//alert("item_id:"+item_id)
				if (item_id && item_id.indexOf("item_") == 0) {
					a.push(item_id.substr(5));
				};
			}
			var item_el = item_el.nextSibling;
		};
	};
	
	return a;

}

/////////////////////////////////////////////////////////


