function navigate(URI, target) {
	$(target).innerHTML='';
	$('onpageload').style.display='block';
	var processURI    = URI;	
	new ajax (processURI, {onComplete: completepageload, update: target});
	return;
}

function loadform(URI,id,action,target) {
	params='id='+id;
	params=params+'&action='+action;
	$(target).innerHTML='';
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: completepageload, update: target});
	return;
}

function forms(form, URI, target) {
	//params='username='+$('username').value;
	//params=params+'&password='+$('password').value;
	params=formData2QueryString(form); // in parse.jss
	$(target).innerHTML='';
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: completepageload, update: target});
	return;
}

///form: form_name
///URI: URI where the form goes
///URI2: URI where you go after the form
///taget: target where the form is checking
function form_navigate(form, URI, URI2, target) {
	params=formData2QueryString(form); // in parse.jss
	$(target).innerHTML='';
	$('onpageload').style.display='block';
	$('p_URL').value = URI2;	
	$('p_target').value = target;
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: make_navigate, update: target});
	return;
}

function make_navigate(){
	URI = $('p_URL').value;
	target = $('p_target').value;
	navigate(URI,target);
}

///form: form_name
///URI: URI where the form goes
///p_oncomplete: javascript function you will use after the login form
///taget: target where the form is checking
function form_oncomplete(form, URI, p_oncomplete, target) {
	params=formData2QueryString(form); // in parse.jss
	$(target).innerHTML='';
	$('onpageload').style.display='block';
	$('p_target').value = target;
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: p_oncomplete, update: target});
	return;
}

function session_search_associate(){
	target = $('p_target').value;
	search_associate('associates.php', target);
}

function search_associate(URI, target) {
	$(target).innerHTML='';
	$('onpageload').style.display='block';
	$('processURI').value = '../include_search/associate_sxml.php';// this is the file that you request data from.
	$('processURI2').value = '../agency/associate_results.php';// this is the results.
	$('mysearch').value = 'associate_id=';// this is the index in the XML file.
	
	var processURI    = URI;	
	new ajax (processURI, {onComplete: init_search, update: target});
	$('onpageload').style.display='none';	
	return;
}

function session_search_agency(){
	target = $('p_target').value;
	search_agency('agencies.php', target);
}
function search_agency(URI, target) {
	$(target).innerHTML='';
	$('onpageload').style.display='block';
	$('processURI').value = '../include_search/agency_sxml.php';// this is the file that you request data from.
	$('processURI2').value = '../agency/agency_results.php';// this is the results.
	$('mysearch').value = 'agency_id=';// this is the index in the XML file.
	
	var processURI    = URI;	
	new ajax (processURI, {onComplete: init_search, update: target});
	$('onpageload').style.display='none';	
	return;
}


function session_search_application(){
	target = $('p_target').value;
	search_application('applications.php', target);
}

function search_application(URI, target) {
	$(target).innerHTML='';
	$('onpageload').style.display='block';
	$('processURI').value = '../include_search/application_sxml.php';// this is the file that you request data from.
	$('processURI2').value = '../agency/application_results.php';// this is the results.
	$('mysearch').value = 'application_id=';// this is the index in the XML file.
	
	var processURI    = URI;	
	new ajax (processURI, {onComplete: init_search, update: target});
	$('onpageload').style.display='none';	
	return;
}

function session_search_note(){
	target = $('p_target').value;
	search_note('notes.php', target);
}

function search_note(URI, target) {
	$(target).innerHTML='';
	$('onpageload').style.display='block';
	$('processURI').value = '../include_search/note_sxml.php';// this is the file that you request data from.
	$('processURI2').value = '../agency/note_results.php';// this is the results.
	$('mysearch').value = 'note_id=';// this is the index in the XML file.
	
	var processURI    = URI;	
	new ajax (processURI, {onComplete: init_search, update: target});
	$('onpageload').style.display='none';	
	return;
}
function session_search_property(){
	target = $('p_target').value;
	search_property('properties.php', target);
}
function search_property(URI, target) {
	$(target).innerHTML='';
	$('onpageload').style.display='block';
	$('processURI').value = '../include_search/property_sxml.php';// this is the file that you request data from.
	$('processURI2').value = '../agency/property_results.php';// this is the results.
	$('mysearch').value = 'property_id=';// this is the index in the XML file.
	
	var processURI    = URI;	
	new ajax (processURI, {onComplete: init_search, update: target});
	$('onpageload').style.display='none';	
	return;
}

function re_search_property(){
	search_property('properties.php', 'content');	
}

function changefield(table,index,indexvalue,field,value,target){
		mysearch='table=' + table + '&index=' + index + '&indexvalue=' + indexvalue +  '&field=' + field + '&value=' + value;
		var processURI    = '../include/save_field.php';
		new ajax (processURI, {postBody: mysearch, update: target});
}
function changetextfield(table,index,indexvalue,field,value,target){
		mysearch='table=' + table + '&index=' + index + '&indexvalue=' + indexvalue +  '&field=' + field + '&value=' + value + '&text=yes';
		//alert(mysearch);
		var processURI    = '../include/save_field.php';
		new ajax (processURI, {postBody: mysearch, update: target});
}
function changetextfield_oncomplete(table,index,indexvalue,field,value,target,p_complete){
		mysearch='table=' + table + '&index=' + index + '&indexvalue=' + indexvalue +  '&field=' + field + '&value=' + value + '&text=yes';
		var processURI    = '../include/save_field.php';
		new ajax (processURI, {postBody: mysearch, update: target, onComplete: p_complete});
}
function completepageload () {
	$('onpageload').style.display='none';	
	return;
}

function GoToPage(URI,target,page)
{
	params='page='+page;
	$(target).innerHTML='';
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: completepageload, update: target});
	return;		
}
