
function changeOOCountries(id, target, addblank){
	var select = document.getElementsByName(target)[0];
	select.disabled = true
	var sUrl = "ajaxGetCountries.do?param_region="+id;
	var callback = 
	{
		success: function(o)
		{	
			if(o.responseText.trim().length > 1){
				// split by separator
				var countries = o.responseText.trim().split("|");
				// now, remove all countries from the list:
				clearOptions(select);
				// now add new countries one by one
				if(addblank){
					addToOptionList(select,"","");
				}
				
				for(i = 0; i < countries.length; i++){
					var value = countries[i].split(":")[0].trim();
					var text = countries[i].split(":")[1].trim();
					if(text.length > 0){
						addToOptionList(select, value, text);
					}
				}
			}
			select.disabled = false;
		},
		failure: function(o)
		{
			select.disabled = false;
			alert("There was an error retrieving countries for the region selected.");
			
		}
	}
	
	var transaction = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback, null);

}

function getPercent(){
	var sUrl = "index_count.jsp";
	var callback =
	{
		success: function(o){
			document.getElementById('done').innerHTML = o.responseText.trim() + "% done";
			if(o.responseText.trim() > 99){
				clearInterval(checker);
			}
		},
		failure: function(o){
			document.getElementById('done').innerHTML = "?% done";
		}
	}
	var transaction = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback, null);
}

function startIndex(){
	var sUrl = "startIndexing.jsp";
	var callback =
	{
		success: function(o){},
		failure: function(o){}
	}
	var transaction = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback, null);
}

function clearOptions(OptionList) {
   	// Always clear an option list from the last entry to the first
   	for (x = OptionList.length; x >= 0; x = x - 1) {
	      OptionList[x] = null;
	   }
}

function addToOptionList(OptionList, OptionValue, OptionText) {
   // Add option to the bottom of the list
   OptionList[OptionList.length] = new Option(OptionText, OptionValue);
}

function initializeTooltips(){
		
       $$("*").findAll(function(node){
         return node.getAttribute('title');
       }).each(function(node){
         new Tooltip(node,node.title);
         node.removeAttribute("title");
       });
}