<style>
div.dhtmlxToolbar_ClearSilver#visitTypeToolbarId table.dhtmlxToolbarTable_ClearSilver td.dhtmlxToolbarItem table.itemPressed {
	background-color: #D3E2E5;
	border-bottom: #D3E2E5 1px solid;
}
div.dhtmlxToolbar_ClearSilver#visitTypeToolbarId table.dhtmlxToolbarTable_ClearSilver td.dhtmlxToolbarItem td.dhtmlxToolbarTEXT span {
	margin-left: -10px;
	margin-right: 10px;
}       
</style>
<div id="visitTypeContainerId" style="width:800px;height:100%;overflow:none;">
	<div id="visitTypeToolbarId" style="width:100%;"></div>
	<div id="visitTypeContentId" style="position:relative;width:100%;height:390px;"></div>
</div>
<script>
function visitTypeGetContent(action) {
	dojo.xhrGet({
		url: "<?=$this->baseUrl?>/visit-select.raw/"+action,
		content: {
			"visitId": mainController.getActiveVisit(),
		},
		load: function (data) {
			dojo.setInnerHTML(dojo.byId("visitTypeContentId"),data);
		},
		error: function (error) {
			alert(error);
			console.error ('Error: ', error);
		}
	});
}

var visitTypeToolbar = new dhtmlXToolbarObject("visitTypeToolbarId","ClearSilver");
visitTypeToolbar.setIconsPath("<?=$this->baseUrl?>/img/");
visitTypeToolbar.attachEvent("onClick",visitTypeChangeContent);

function visitTypeChangeContent(id) {
	switch(id) {
		case "visitType":
			visitTypeGetContent("visit-type");
			break;
		case "procedures":
		case "diagnoses":
		case "claim":
			visitTypeGetContent(id);
			break;
		default:
			alert("Invalid event: "+id);
	}
}
visitTypeToolbar.attachEvent("onStateChange",function(id,state){
	if (!state) {
		visitTypeToolbar.setItemState(id,!state);
		return;
	}
	visitTypeToolbar.forEachItem(function(itemId){
		if (itemId != id) {
			visitTypeToolbar.setItemState(itemId,false);
		}
	});
	visitTypeChangeContent(id);
});
var ctr = 1;
visitTypeToolbar.addButtonTwoState("visitType",ctr++,"<?=__('Visit Type')?>  ","newproblem.png","newproblem.png");
visitTypeToolbar.addButtonTwoState("procedures",ctr++,"<?=__('Procedures')?>  ","newproblem.png","newproblem.png");
visitTypeToolbar.addButtonTwoState("diagnoses",ctr++,"<?=__('Diagnoses')?>  ","newproblem.png","newproblem.png");
visitTypeToolbar.addButtonTwoState("claim",ctr++,"<?=__('Claim')?>  ","newproblem.png","newproblem.png");

visitTypeToolbar.setItemState("visitType",true);
visitTypeChangeContent("visitType");
</script>
