
function limitsearch(keywords,vals,exactmatch){
	document.forms['control'].refine_limitto.value = keywords;
	document.forms['control'].refine_limitwith.value = vals;
	document.forms['control'].refine_exactmatch.value = exactmatch;
	document.forms['control'].submit();
}

function setvalsubmit(ff,vv){
	fff = eval("document.forms['control']." + ff);
	fff.value = vv;
	document.forms['control'].submit();
}

function sort(){
	alert('NO!!! Do not try to SORT at this time.');
}

function del(realm,id){
	alert('NO!!! Do not try to DELETE ' + realm + ' record #' + id + '.');
}

function add(id){
	alert('NO!!! Do not try to ADD something.');
}

function ctrl_nav(realm,id,nav){
	document.forms['control'].nav.value = nav;
	ctrl(realm,'view','show',id);
}

function ctrl(realm,mode,action,id){
	document.forms['control'].realm.value = realm;
	document.forms['control'].mode.value = mode;
	document.forms['control'].action.value = action;
	document.forms['control'].id.value = id;
	document.forms['control'].target='_self';
	document.forms['control'].submit();
}

function confirmdelete(realm,id){
	var answer = confirm("This will delete the record.\n\nAre you sure?")
	if (answer)
		ctrl(realm,'edit','delete',id);
}

function edit(realm,id){
	ctrl(realm,'edit','edit',id);
}

function view(realm,id){
	ctrl(realm,'view','show',id);
}

function preview(realm,id){
	alert('This is an experimental function that\nwon\'t work at all if there\'s no template.');
	ctrl(realm,'view','preview',id);
}

function print_it(realm,id){
	alert('This is an experimental function that\nwon\'t work at all if there\'s no template.\n\nA new browser window will open.');
	document.forms['control'].target='_print';
	document.forms['control'].realm.value = realm;
	document.forms['control'].mode.value = 'view';
	document.forms['control'].action.value = 'print';
	document.forms['control'].id.value = id;
	document.forms['control'].submit();
}

function browse(realm){
	document.forms['control'].realm.value = realm;
	document.forms['control'].mode.value = 'view';
	document.forms['control'].action.value = 'list';
	document.forms['control'].id.value = '';
	document.forms['control'].refine_limitto.value = '';
	document.forms['control'].refine_limitwith.value = '';
	document.forms['control'].refine_exactmatch.value = '';
	document.forms['control'].target='_self';
	document.forms['control'].submit();
}

function keyhandler(e,s) {
	var key;

	if (document.all) {	e = window.event; }
	if (document.layers){
		key = e.which;
	}else{
		key = e.keyCode
	}

	if(key==13){ // return key
		if(s != 'all'){	document.forms['control'].search_all.value = ''; }
		document.forms['control'].submit();
	}
}

function toggle(aaa) {
/* toggle2 method is via supplied id's show/hide state */
/* call with: toggle2('the_element_id') */
	var the_thing = document.getElementById(aaa).style.display;

	if(the_thing == 'block') {
		var the_div = document.getElementById(aaa).style.display = 'none';
	} else {
		document.getElementById(aaa).style.display = 'block';
	}
}

function toggle1(obj,aaa) {
/* toggle1 method is via checkbox state */
/* call with: toggle1(this) */
	if(obj.checked == true) {
		var the_div = document.getElementById(aaa).style.display = 'block';
	} else {
		document.getElementById(aaa).style.display = 'none';
	}
}

function toggleFN(aaa) {

	var the_thing = document.getElementById(aaa).style.backgroundColor;
	if(the_thing == '') {
		document.getElementById(aaa).style.backgroundColor = '#EEEDE4';
		document.getElementById(aaa).style.color = '#4E4114';

	} else {
		document.getElementById(aaa).style.backgroundColor = '';
		document.getElementById(aaa).style.color = '#000000';
	}

}

function toggleFNon(aaa) {
		document.getElementById(aaa).style.backgroundColor = '#D1D1D1';
		document.getElementById(aaa).style.color = '#4E4114';
}

function toggleFNoff(aaa) {

		document.getElementById(aaa).style.backgroundColor = '';
		document.getElementById(aaa).style.color = '#000000';
}

function textareaHover(){ elemHover('textarea', 'textarea', 'textareaActive'); }
function textareaOut(){ elemOut('textarea', 'textarea', 'textareaActive'); }
function inputHover(){ elemHover('input', 'input', 'inputActive'); }
function inputOut(){ elemOut('input', 'input', 'inputActive'); }

function elemHover(classname, classname1, classname2) 
{ 
   var srcId, srcElement, targetElement; 
   if (window.event) e = window.event; 
   srcElement = ( e.srcElement ) ? e.srcElement : e.target; 

   if ( srcElement.className == classname1 ) 
   { 
         srcElement.className = classname2; 
         classname = classname2; 
   } 
} 

function elemOut(classname, classname1, classname2)
{ 
   var srcId, srcElement, targetElement; 
   if (window.event) e = window.event; 
   srcElement = ( e.srcElement ) ? e.srcElement : e.target; 

   if ( srcElement.className == classname2 ) 
   { 
         srcElement.className = classname1; 
         classname = classname1; 
   } 
} 

