function show_props(obj, objName) {
   var result = "";
   for (var i in obj) {
      result += objName + "." + i + " = " + obj[i] + "\n";
   }
   return result;
}
function zoom(an_image)
{
	var url = base + '/image.html?image='+an_image;
	var width = 200;
	var height = 200;
	var screen_x = (top.window.screen.width-width)/2;
	var screen_y = (top.window.screen.height-height)/2;
	top.window.open(url, 'zoomed', 'width='+width+',height='+height+',resizable=yes,left='+screen_x+',top='+screen_y);	
}

function filter_grid(prefix)
{
	//alert(prefix + 'action_grid');
	document.forms[0].elements[prefix + 'action_grid'].value = 'filter';
	submit_kernel_form();
}

function reset_filters(prefix)
{
	document.forms[0].elements[prefix + 'action_grid'].value = 'ResetFilters';
	submit_kernel_form();
}

function submit_kernel_form()
{
	if (typeof document.forms[0].onsubmit == "function") {
		document.forms[0].onsubmit();
	}
	document.forms[0].submit();
}

function submit_action(prefix, action_field, action)
{
	document.forms[0].elements[prefix + action_field].value = action;
	submit_kernel_form();
}

function select_selected(list, selected_value) 
{
	var count = list.options.length;
 	for (var current = 0; current < count; current ++) 
 	{
  	if (list.options[current].value == selected_value) 
  	{
   		list.options[current].selected = "1";
   		break;
  	}
 	}
}

function ischecked(list) 
{
	var count = list.length;
 	for (var current = 0; current < count; current ++) {
  	if (list[current].checked) 
  		return true;
 	}
 	
 	return false;
}

function Login()
{
	document.forms[0].login__action.value = 'login';
	document.forms[0].submit();
}

function Logout()
{
	document.forms[0].login__action.value = 'logout';
	document.forms[0].submit();
}

function update_checkbox(cb, cb_hidden)
{
	cb_hidden.value = cb.checked ? 1 : 0;
}

function clearFormText(obj)
{
	if(obj.value == obj.defaultValue && !obj.className.match(/_on$/)) {
		obj.value = '';
		obj.className += '_on';
	}
}

function setFormText(obj)
{
	if(obj.value == '') {
		obj.value = obj.defaultValue;
		obj.className = obj.className.replace(/_on$/,'');
	}else{ if(obj.value != obj.defaultValue && !obj.className.match(/_on$/))
		obj.className += '_on';
	}
}