
	function show_screen() {
			my_show_screen();
	}
	
	function my_show_screen() {
		document.getElementById("loading_screen").style.display="block";
	}
	
	function my_hide_screen() {
		document.getElementById("loading_screen").style.display="none";
	}

	function my_appts() {
		var app_path = 'app/clients/my_appts.php';
		update_div('data_div',app_path,'');
	}

	function change_passwd() {
		var app_path = 'app/clients/change_passwd.php';
		update_div('data_div',app_path,'');
	}
	function editaccount() {
		var app_path = 'app/clients/editaccount.php';
		update_div('data_div',app_path,'');
	}
	function tchange_passwd() {
		var app_path = 'app/train/change_passwd.php';
		update_div('data_div',app_path,'');
	}

	function go_nav(app_path) {
		var app_path = 'app/' + app_path + '.php';
		update_div('data_div',app_path,'');
	}
	
	function go_nav_arg(app_path, query_string) {
		var app_path = 'app/' + app_path + '.php';
		update_div('data_div',app_path,query_string);
	}
	
	function start_day(app_path,daystamp,entity_id) {
		go_nav_arg(app_path,'entity_id='+entity_id+'&daystamp='+daystamp);	
	}

	function go_day(app_path,daystamp) {
		var entity_id = document.getElementById('global_entity_id').value;
		go_nav_arg(app_path,'entity_id='+entity_id+"&daystamp="+daystamp);
	}

	function go_hour(app_path,daystamp) {
		//setTimeout("refresh_hour('"+app_path+"','"+daystamp+"')",30000);
		go_nav_arg(app_path,"daystamp="+daystamp);
	}

	function refresh_hour(app_path,daystamp) {
		if(document.getElementById('hour_by_hour_marker')) {
			if(document.getElementById('cur_hour_daystamp').value == daystamp) {
				//setTimeout("refresh_hour('"+app_path+"','"+daystamp+"')",30000);
				go_nav_arg(app_path,"daystamp="+daystamp);
			}
		}
	}
	
	function get_messages() {
		go_nav('appointments/messages');	
	}
	
	function get_new_message_count() {
		update_div('messages_tab','app/appointments/msg_count.php','');
		setTimeout("get_new_message_count()",60000);
	}
	
	function update_div(div_name,app_path,query_string) {
		// var xmlHttpReqs = Array();
		var xmlHttpReq = false;	// Default to false just incase we can't create a req object

		/////////////////////////////
		// Select the browser type //
		/////////////////////////////
		
		if (window.XMLHttpRequest) {					// Non-IE browsers can do XMLHttpRequest
			xmlHttpReq = new XMLHttpRequest();
		} else if (window.ActiveXObject) {				// IE handles an ActiveXObject
			xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		///////////////////////////
		// Send the post request //
		///////////////////////////
		
		xmlHttpReq.open('POST', app_path, true);
		xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		xmlHttpReq.onreadystatechange = function() {
			if (xmlHttpReq.readyState == 4) {
				updatepage(div_name, xmlHttpReq.responseText);
				//hide_screen();
			}
		}
				
		xmlHttpReq.send(query_string);
		//xmlHttpReqs.push(xmlHttpReq);
	}
		
	// updatepage(html_output)
	// Takes the HTML received from our web application and puts it into
	// the receiving div. Also, it makes sure the div is visible!
	
	function updatepage(div_name, html_output){
		//alert(div_name+","+html_output);
		//document.getElementById(div_name).style.display="block";
		document.getElementById(div_name).innerHTML = html_output;
		
	}
	
	function update_entity_selector() {
		var entity_id;
		var q_string;
		if(document.getElementById('global_entity_id')) {
			entity_id = document.getElementById('global_entity_id').value;
			q_string = "entity_id="+entity_id;
		} else {
			q_string = "";	
		}
		update_div('entity_selector','app/entity_selector.php',q_string);
	}
	
	function update_nav() {
		update_div('left_nav','app/update_nav.php','');	
	}
	
	function init_sortable() {
		if(document.getElementById('client_info_fields_list')) {
			var list = document.getElementById("client_info_fields_list");
			DragDrop.makeListContainer( list, 'g1' );
			list.onDragOver = function() { this.style["background"] = "#EEF"; };
		} else {
			setTimeout("init_sortable()",1000);	
		}
	}

	function set_field_order() {
		var order = document.getElementById("client_info_fields_list");
		order.value = DragDrop.serData('g1', null);
		update_div('null_box','app/client_info/update_order.php','div=client_info_fields_list&order='+order.value);
		setTimeout('hide_local_msg()',5000);
	}
	
	function hide_local_msg() {
		var msg = document.getElementById('field_local_message_center');
		msg.style.display='none';
	}
	
	function update_entity_list(theselect) {
		go_nav_arg('entities/schedule','entity_id='+theselect.value);
	}