function EnableField(field,value)
{
	if (value==true)
	$(field).style.display='block';
	else
	$(field).style.display='none';	
}

function checksessionfieldvalue(sessionfield,value)
{
	if (value==true)
		value = 1;
	else
		value = 0;
	//alert(sessionfield + " " + value);
	params='sessionfield='+sessionfield;
	params+='&value='+value;
	target = 'session_form_aux_div';
	URI = '../libs/forms_aux.php';
	
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: completepageload, update: target});
	return;			
}

function checksessionfieldvalue_softnavigate(sessionfield,value,URI2,target)
{
	$('p_URL').value = URI2;	
	$('p_target').value = target;
	
	if (value==true)
		value = 1;
	else
		value = 0;
	//alert(field + " " + document.getElementById(field).value);
	params='sessionfield='+sessionfield;
	params+='&value='+value;
	target = 'session_form_aux_div';
	URI = '../libs/forms_aux.php';
	
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: make_softnavigate, update: target});
	return;			
}

function checksessionfieldvalue_oncomplete(sessionfield,value,p_oncomplete)
{
	if (value==true)
		value = 1;
	else
		value = 0;
	
	//alert(p_oncomplete);
	
	params='sessionfield='+sessionfield;
	params+='&value='+value;
	target = 'session_form_aux_div';
	URI = '../libs/forms_aux.php';
	
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: p_oncomplete, update: target});
	return;			
}

function sessionfieldvalue(sessionfield,value)
{
	params='sessionfield='+sessionfield;
	params+='&value='+value;
	target = 'session_form_aux_div';
	URI = '../libs/forms_aux.php';
	
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: completepageload, update: target});
	return;			
}

function unsetsessionfieldvalue(sessionfield)
{
	params='sessionfield='+sessionfield;
	target = 'session_form_aux_div';
	URI = '../libs/forms_aux.php';
	
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: completepageload, update: target});
	return;			
}

function unsetsessionfieldvalue_oncomplete(sessionfield,p_oncomplete)
{
	params='sessionfield='+sessionfield;
	target = 'session_form_aux_div';
	URI = '../libs/forms_aux.php';
	
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: p_oncomplete, update: target});
	return;			
}

function unsetsessionfieldvalue_softnavigate(sessionfield,URI2,target)
{
	$('p_URL').value = URI2;	
	$('p_target').value = target;
	
	params='sessionfield='+sessionfield;
	target = 'session_form_aux_div';
	URI = '../libs/forms_aux.php';
	
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: make_softnavigate, update: target});
	return;			
}

function sessionfieldvalue_softnavigate(sessionfield,value,URI2,target)
{
	$('p_URL').value = URI2;	
	$('p_target').value = target;
	
	params='sessionfield='+sessionfield;
	params+='&value='+value;
	target = 'session_form_aux_div';
	URI = '../libs/forms_aux.php';
	
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: make_softnavigate, update: target});
	return;			
}

function search_filter_softnavigate(sessionarray,date_range,date_start, date_end,URI2,target){
	$('p_URL').value = URI2;	
	$('p_target').value = target;
	
	if (date_range==true)
		date_range = 1;
	else
		date_range = 2;
	
	params='sessionarray='+sessionarray;
	params+='&date_range='+date_range;
	params+='&date_start='+date_start;
	params+='&date_end='+date_end;
	target = 'session_form_aux_div';
	URI = '../libs/forms_aux.php';
	
	
	target = 'session_form_aux_div';
	URI = '../libs/forms_aux.php';
	
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: make_softnavigate, update: target});
	return;		
}
function sessionarrayfieldcheck(sessionarray,sessionfield,check)
{
	if (check==true)
		value = 1;
	else
		value = 2;
	 sessionarrayfieldvalue(sessionarray,sessionfield,value);
}

function sessionarrayfieldcheck_softnavigate(sessionarray,sessionfield,check,URI2,target)
{
	if (check==true)
		value = 1;
	else
		value = 2;
	 sessionarrayfieldvalue(sessionarray,sessionfield,value,URI2,target);
}

function sessionarrayfieldvalue(sessionarray,sessionfield,value)
{
	params='sessionarray='+sessionarray;
	params+='&sessionfield='+sessionfield;
	params+='&value='+value;
	target = 'session_form_aux_div';
	URI = '../libs/forms_aux.php';
	
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params, update: target});
	$('onpageload').style.display='none';
	return;			
}

function sessionarrayfieldvalue_softnavigate(sessionarray,sessionfield,value,URI2,target)
{
	$('p_URL').value = URI2;	
	$('p_target').value = target;
	
	params='sessionarray='+sessionarray;
	params+='&sessionfield='+sessionfield;
	params+='&value='+value;
	target = 'session_form_aux_div';
	URI = '../libs/forms_aux.php';
	
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: make_softnavigate, update: target});
	return;			
}

function sessionfieldvalue_oncomplete(sessionfield,value,p_oncomplete)
{
	
	params='sessionfield='+sessionfield;
	params+='&value='+value;
	target = 'session_form_aux_div';
	URI = '../libs/forms_aux.php';
	
	$('onpageload').style.display='block';
	var processURI    = URI;
	new ajax (processURI, {postBody: params,  onComplete: p_oncomplete, update: target});
	return;			
}

function showdetails(value){
	if (value==true)
	$('show_details').style.display='block';
	else
	$('show_details').style.display='none';
}
function showdivdetails(div,value){
	if (value==true)
	$(div).style.display='block';
	else
	$(div).style.display='none';
}

function load_page_ini(URI,id,action) {
	$('onpageload').style.display='block';
	params='id='+id;
	params=params+'&action='+action;
	document.location.href=URI + '.php?'+params;
	$('onpageload').style.display='none';
	return;
}

function load_page(URI,id,action) {
	$('onpageload').style.display='block';
	
	document.href_navigate.action=URI + '.php';
	document.href_navigate.p_href_id.value=id;
	document.href_navigate.p_href_action.value=action;
	document.href_navigate.submit();
	
	$('onpageload').style.display='none';
	return;
}

function load_page_blank(URI,id,action) {
	$('onpageload').style.display='block';
	
	document.href_navigate.action=URI + '.php';
	document.href_navigate.p_href_id.value=id;
	document.href_navigate.p_href_action.value=action;
	document.href_navigate.target = "_blank";
	document.href_navigate.submit();
	document.href_navigate.target = "_self";
	
	$('onpageload').style.display='none';
	return;
}
function navigate(URI, target) {
	$(target).innerHTML='';
	$('onpageload').style.display='block';
	var processURI    = URI;	
	new ajax (processURI, {onComplete: completepageload, update: target});
	return;
}

function softnavigate(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 form_softnavigate(form, URI, URI2, target) {
	params=formData2QueryString(form); // in parse.jss
	$('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);
}

function make_softnavigate(){
	URI = $('p_URL').value;
	target = $('p_target').value;
	softnavigate(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 changefield(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 changefield_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 initpageload(){
	$('onpageload').style.display='block';	
}

function completepageload () {
	$('onpageload').style.display='none';
}


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;		
}

function SubmitForm(FormName,FieldName,Value)
{
	$(FieldName).value = Value;
	$(FormName).submit();
}
