/* 
**	simple ajax function that requires a url to a page that will do some sort of 
**	processing and return it.  This function expects a html return, not json.
**	This allows us to just do a simple innerHTML to replace a section of the
**	currently displayed page.
*/
function  ajaxhtmlLoad(URL, Area){	

	// create a function to handle the return data
	var handler = function(response, ioArgs){dojo.byId(Area).innerHTML = response;}
	
	// create a dictionary that we will use to setup
	// the ajax calls parameters
	var kw = {	url: URL,
			method: "post",
			load: handler ,
			mimetype: "text/html"
	};

	// do a post xmlhttprequest
	dojo.xhrPost(kw); 
}


/*
**	need to redo and instead of passing through fields, pass an array in
** used on the directory page for the searches that use text boxes
** the type of <> == 'undefined' allows for a default value to be set.
*/
function ajaxhtmlLoadTextBox(URL, Area, type, field1, field2, field3){
	var action = {};

	if (typeof type == "undefined") type = "";

	if (typeof field1 != "undefined") 
		action[field1] = dojo.byId(field1).value;
	if (typeof field2 != "undefined") 
		action[field2] = dojo.byId(field2).value;
	if (typeof field3 != "undefined") 
		action[field3] = dojo.byId(field3).value;

	action['type'] = type;
	action['action'] = type;
	
	// create a function to handle the return data
	var handler = function(response, ioArgs){dojo.byId(Area).innerHTML = response;}

	// create a dictionary that we will use to setup
	// the ajax calls parameters
	var kw = {	url: URL,
			method: "post",
			content: action,
			load: handler ,
			mimetype: "text/html"
	};

	// do a post xmlhttprequest
	dojo.xhrPost(kw); 
}



/*
**	used on the directory page for all combo boxes.
**	it finds what option is selected and passes along that value
**	for processing
*/
function ajaxhtmlLoadComboBox(URL, Area, cBox, type){
	if (typeof type == "undefined") 
		type = "";
	var action = {};
	action['type'] = type;
	action['action'] = dojo.byId(cBox).options[dojo.byId(cBox).selectedIndex].value;
	
	// create a function to handle the return data
	var handler = function(response, ioArgs){dojo.byId(Area).innerHTML = response;}

	// create a dictionary that we will use to setup
	// the ajax calls parameters
	var kw = {	url: URL,
			method: "post",
			content: action,
			load: handler ,
			mimetype: "text/html"
	};

	// do a post xmlhttprequest
	dojo.xhrPost(kw); 
}



/* 
**	very simple function that is used to switch
**	the + - images from beign displayed or hidden
*/
function showhide(Area, minusID, plusID){
	var list = dojo.byId(Area);
	if(list.style.display == 'none'){
		list.style.display = 'block';
		dojo.byId(plusID).style.display = 'none';
		dojo.byId(minusID).style.display = 'inline';
	}else{
		list.style.display = 'none';
		dojo.byId(minusID).style.display = 'none';
		dojo.byId(plusID).style.display = 'inline';
	}
}

