

function updateLanguage()
{
	id=document.getElementById("languageajax");
	v=id.value;
	//alert('>'+v);
	call_xml (v);
	show_drop();
	
}

function show_drop ()
{
    id=document.getElementById("langlist");
    id.style.display='block';
}

function hide_drop ()
{
    id=document.getElementById("langlist");
    id.style.display='none';
}


function langselected(itemn)
{
	id=document.getElementById("languageajax");
	//alert('>>>>'+itemn);
	id.value=itemn;
	hide_drop();
	id.value=itemn;
//alert(">"+id.value);
}



function xmlhttpPost(strURL, strSubmit, strResultFunc) {

        // the URL for the processing page on the server, 
		// the query-string formatted data to submit, and 
		// name of the JavaScript function that will process the response from the server (to invoke later through eval).

        var xmlHttpReq = false;
        
        // Mozilla/Safari
        if (window.XMLHttpRequest) {
                xmlHttpReq = new XMLHttpRequest();
				try {
                   xmlHttpReq.overrideMimeType('text/xml');
				   }
				catch (err)
		           {
					   a=1;
				   }
				}
        // IE
        else if (window.ActiveXObject) {
                xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
        }
		
	    xmlHttpReq.open('POST', strURL, true);
        xmlHttpReq.setRequestHeader('Content-Type', 
		     'application/x-www-form-urlencoded');
        xmlHttpReq.onreadystatechange = function() {
                if (xmlHttpReq.readyState == 4) {
                        eval(strResultFunc + '(xmlHttpReq.responseText);');
						// status = xmlHttpReq.status; // get return status 404 500 etc
                }
        }
        xmlHttpReq.send(strSubmit);
}

function handleResult (param)
{
	
  // alert('>>' + param);	 
   var res = param.replace('<data>','');
   res = res.replace('</data>','');
   res = res.replace('<?xml version="1.0" encoding="UTF-8"?>','');
   
   id=document.getElementById("langlist");
   
   id.innerHTML = res;

  // alert('>>>' + res);

//   f = addResultsToPage(res,idforlist);
}

function clear_lang_ajax()
{
    id=document.getElementById("langlist");
    id.innerHTML = '';
}

function call_xml (searcht) {

	if (''+searcht!='') {
	
		strURL = '/clients/infostore/MODULES/COMBINED/interface/COMBINEDMOD_getLanguages.aspx?langsearch=' + searcht;
		strSubmit = ''; // not passing params
		strResultFunc = 'handleResult';
		s = xmlhttpPost(strURL, strSubmit, strResultFunc) ;
	}
	else
	{
       clear_lang_ajax();
    }
}


