// *** Copyright (c)2002 Jim Massey. All rights reserved  ***********
// *** massey@stlouis-shopper.com **************
// *** No Warranty - certified to work with nothing ***
// *** developed to work with mozilla kiosk **** 

var urlbar_list_array = new Array();

 function uri_list() {
// **** Reads the value of the menulist item clicked on
// **** and calls new_page with the uri.

	//dump("DropDownListAA @@@@@@@@@@@@@@@@@@@@@@@\n");
	var temp = document.getElementById("uriBarList");
	var site = temp.selectedItem.value
	new_page(site);
	temp.inputField.value = site;
}

function list_got_focus() {

	var tempList = document.getElementById("uriBarList");
	//var tempout = tempList.getAttribute("focused");
	//dump("LIST GOT FOCUS **** :" + tempout + "***\n");
	if (tempList.getAttribute("focused")) {
	  uri_list_inputField();
	}

}

// **** Loads the uri entered into the uribar inputField ****
function uri_list_inputField() {
	var temp = document.getElementById("uriBarList");
	var site = temp.inputField.value;
	var RegexpControl = document.getElementById("kioskDefaults");
	//temp.setAttribute("editable", false);
	//var filter = /^file:/i;
	var filter = new RegExp(document.getElementById("kioskDefaults").getString("uriFilterRegexp"), "i");
	//alert(site + filter);
	if ((site.match(filter)) != null) {
	      if (RegexpControl.getString("uriFilterErrMsg") != "null") {
	     alert("Invalid URI type: " + site.match(filter) + "\n" + RegexpControl.getString("uriFilterErrMsg"));
	   }
	     site = "";
	}
	if (site != "") {
	   new_page(site);
	   //new_page(temp.inputField.value);
	   uribar_drop_down(site, site);
	}
	//dump("@@@** TEXT LENGTH: " + temp.inputField.textLength + "**\n");
}

function enable_uri_inputField() {
	var temp = document.getElementById("uriBarList");
	//temp.setAttribute("disabled", false);
	//temp.setAttribute("editable", true);
}

// *** appends a uri to the dropdown list *****
function uribar_drop_down(temp, tempV) {
var i = 0
var tempB = document.getElementById("uriBarList");
//dump("****** HISTORY DROP DOWN URI LIST : " + tempB + tempV + "\n");
	//tempB.setAttribute("editable", false);
	//tempB.setAttribute("label", temp);
	//tempB.setAttribute("value", tempV);
	//var report = tempB.getAttribute("value");
	for ( i = 0; i <=  urlbar_list_array.length; i++) {
	  if (urlbar_list_array[i] == temp) { return; }
	} 
	tempB.appendItem(temp, tempV);
	 urlbar_list_array.push(temp);
	//tempB.setAttribute("editable", true);
//dump("** --" + urlbar_list_array.length + "--*** report\n");
}

// **** Dump the contents of the uribar dropdowm *******
function uribar_list_dump() {
	var uribar_drop_down_count = urlbar_list_array.length;
	//dump("*$*$*$ URI LIST DUMP 1 ***$*$*$\n");
	var ed = document.getElementById("uriBarList");
	while ( uribar_drop_down_count > 0 ) {
	  var item = ed.removeItemAt(0);
	 //dump("*$*$*$ URI LIST DUMP INside ***$*$*$\n");
	  uribar_drop_down_count--;
	}
	urlbar_list_array.length = 0;
	ed.inputField.value = "";
}



