document.onclick = check; 
function check(e) { 
	var target = (e && e.target) || (event && event.srcElement); 
	var obj = document.getElementById('paieska_result'); 
	var obj2 = document.getElementById('search_field'); 
	
	checkParent(target)?obj.style.display = 'none':null; 
	target == obj2?obj.style.display='block':null; 
} 
function checkParent(t) { 
	while(t.parentNode){ 
		if (t == document.getElementById('search_field')) { 
			return false 
		} 
	t = t.parentNode 
	} 
	return true 
}
function CngCol(obj,col){
	if (obj.getAttribute('backgroundColor')){ obj.bg=obj.getAttribute('backgroundColor'); }
	else { obj.bg=obj.style.backgroundColor; }
	obj.style.backgroundColor=col;
	obj.onmouseout=function(){ this.style.backgroundColor=this.bg; }
}
function suggest_high(obj) { // Keicia spalvas pasiulymu meniu paieskos lauke
	obj = document.getElementById(obj);
	obj.style.backgroundColor  = "#BAD68B";
	
	obj.onmouseout = function(){ this.style.backgroundColor  = "#FFFFFF"; }
}
// Pakeicia CSS veiksma hover ant span elementu
function js_hover(css_class_plain, css_class_hover, obj) { // Keicia spalvas pasiulymu meniu paieskos lauke
	obj = document.getElementById(obj);
	obj.className = css_class_hover;
	
	obj.onmouseout = function(){ this.className  = css_class_plain; }
}
// Keicia elemento matomuma
function display_detail(element_id) {
	var kontakto_detales = document.getElementById(element_id);
	if (kontakto_detales.style.display == 'none') {
		kontakto_detales.style.display = 'block';
		ajaxshowHide(element_id, 'block');
	}
	else if (kontakto_detales.style.display == 'block') {
		kontakto_detales.style.display = 'none';
		ajaxshowHide(element_id, 'none');
	}
}
// AJAX showhide
function ajaxshowHide(sh_id, sh_value) {
	var xmlHttp; try { xmlHttp=new XMLHttpRequest(); }
	catch (e) {	try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) { alert("Your browser does not support AJAX!"); return false; } } }
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) { if (xmlHttp.responseText > 0) { /* Veiksmai cia */ } } }
	xmlHttp.open("GET","?form=e_dmshowhide&sh_id="+sh_id+"&sh_value="+sh_value,true);
	xmlHttp.send(null);
}
function change_query(query_field_id, new_value) { // Paieskos lauka uzpildo su pasirinktu variantu is pasiulymo saraso
	query_field = document.getElementById(query_field_id);

	query_field.value = new_value;
}

function paieska_do(result_field, paieksa_string) { // Sugeneruoja pasiulymu sarasa
	var xmlHttp; try { xmlHttp=new XMLHttpRequest(); }
	catch (e) {	try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) { alert("Your browser does not support AJAX!"); return false; } } }
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			if (xmlHttp.responseText) {
				document.getElementById(result_field).style.display = 'block';
				document.getElementById(result_field).innerHTML=''+xmlHttp.responseText+'';
			}
		}
	}
	xmlHttp.open("GET","?form=paieska_do&paieksa_string="+paieksa_string, true);
	xmlHttp.send(null);
}

function action(form, result_field, input, input2) { // Atlieka neapibrezta ajax veiksma
	var xmlHttp; try { xmlHttp=new XMLHttpRequest(); }
	catch (e) {	try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e) { alert("Your browser does not support AJAX!"); return false; } } }
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			if (xmlHttp.responseText) {
				document.getElementById(result_field).innerHTML=''+xmlHttp.responseText+'';
			}
		}
	}
	xmlHttp.open("GET","?form="+form+"&result_field="+result_field+"&input="+input+"&input2="+input2, true);
	xmlHttp.send(null);
}