//pake library standar jsgold.js
//ambil data xml ke lit box ada di chapter 5 dummies
var options;
var id;

/******************************************************************************************
Fungsi2 Untuk menagani listbox
getoptions
listoptions1
setoption
******************************************************************************************/
function getoptions(xml)
{	//alert(xml);
	
	options = xml.getElementsByTagName("option");
	listoptions1();
}


function listoptions1()
{
				var loopIndex;
				
				var selectControl = document.getElementById('ListCity');
				
				//alert(selectControl.length);
				
				/*ngilangin index*/
				while(document.getElementById('ListCity').length > 0)
				{
					selectControl.remove(loopIndex);
					loopIndex=loopIndex+1;
				}
				 
				for (loopIndex = 0; loopIndex < options.length; loopIndex++ )
				{
					selectControl.options[loopIndex] = new 
               Option(options[loopIndex].firstChild.data);
				}
}


function setoption()
{
  document.getElementById('targetDiv').style.color = options[document.getElementById('optionList').selectedIndex].firstChild.data;
}





function postDataReturnXml(url, data, callback)
{ 
  var XMLHttpRequestObject = false; 

  if (window.XMLHttpRequest) {                       //if Mozilla, IE7, Safari etc
    XMLHttpRequestObject = new XMLHttpRequest();
  } else if (window.ActiveXObject) {                 // if IE
	XMLHttpRequestObject = new 
     ActiveXObject("Microsoft.XMLHTTP");
  }

  if(XMLHttpRequestObject) {
    XMLHttpRequestObject.open("POST", url); 
    XMLHttpRequestObject.setRequestHeader('Content-Type', 
      'application/x-www-form-urlencoded'); 

    XMLHttpRequestObject.onreadystatechange = function() 
    { 
      if (XMLHttpRequestObject.readyState == 4 && 
        XMLHttpRequestObject.status == 200) {
          callback(XMLHttpRequestObject.responseXML); 
          delete XMLHttpRequestObject;
          XMLHttpRequestObject = null;
      } 
    }

    XMLHttpRequestObject.send(data); 
  }
}
			