// JavaScript Document

function showList(id,e){
	var list = document.getElementById('droplist_'+id);
	if (list.className=="activeLst_"+id) list.className="hiddenLst"; else list.className="activeLst_"+id;
	if (e) {if(e.stopPropagation) e.stopPropagation(); else event.cancelBubble=true;};	
}


function selectListObject(id, val, e){
	var list = document.getElementById('droplist_'+id);
	var listname = 'droplist_'+id;
	var img    = document.getElementById('sel_dist_'+id);
	var form   = document.getElementById('form.droplist_'+id);
	var input  = document.getElementById('value.droplist_'+id);
	
	img.src = "images/dist/"+val+".gif";

	if(input.value == val){
		showList(id);
		if (e) {if(e.stopPropagation) e.stopPropagation(); else event.cancelBubble=true;};
	}else{
		input.value = val;
		form.submit();
	};
}


function highlightimg(e){
      var img;
      if(e.target) img=e.target;else img=event.srcElement;
      img.className="droplistimg_set";
}

function unhighlightimg(e){
      var img;
      if(e.target) img=e.target;else img=event.srcElement;
      img.className="droplistimg";
} 


function selectListObjectSearch(id, val, e){
	var list = document.getElementById('droplist_'+id);
	//var listname = 'droplist_'+id;
	var img    = document.getElementById('sel_dist_'+id);
	var input  = document.f_search.place_district;	//document.getElementById('value.droplist_'+id);
	
	if(input.value == val){
		showList(id);
		if (e) {if(e.stopPropagation) e.stopPropagation(); else event.cancelBubble=true;};
	}else{
		//need to set up variable "place_district" in form document.f_search
		//alert(val);
		img.src = "images/dist/"+val+".gif";
		input.value = val;
		//alert(input.value);
		//form.submit();
	};
}

function hideList(){
	var list;
	for (i=1; i<11; i++){
		list = document.getElementById('droplist_'+i);
		if(list) list.className="hiddenLst";
	}
}

window.onclick = hideList;

