function sendData_get_subinterest(interest_id, subinterest_id)
{
  interest = document.getElementById("hidden_select_"+interest_id);
  subinterest = document.getElementById("hidden_select_"+subinterest_id);


  interest_http.open('post', 'index.php', true);
  interest_http.onreadystatechange = handlePostData_get_subinterest;
  interest_http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  query="page_id=1002&interest_id="+interest_id+"&subinterest_id="+subinterest_id+"&current_interest="+interest.value+"&current_subinterest="+subinterest.value;
  //document.getElementById("testint").value = query;
  interest_http.send(query);
}

function handlePostData_get_subinterest()
{
  if(interest_http.readyState == 4)
  { //Finished loading the response
    if (interest_http.status==200)
    {
      //document.getElementById("testint").value = interest_http.responseText;
      interest_id = interest_http.responseXML.getElementsByTagName('interest_id')[0].firstChild.data;
      subinterest_id = interest_http.responseXML.getElementsByTagName('subinterest_id')[0].firstChild.data;
      source = document.getElementById("source_select_"+subinterest_id);
      target = document.getElementById("target_select_"+subinterest_id);

      source.options.length = 0;
      target.options.length = 0;

      source_array = interest_http.responseXML.getElementsByTagName('source')[0];
      target_array = interest_http.responseXML.getElementsByTagName('target')[0];
      add_options( source_array, source );
      add_options( target_array, target );
      
    }
    else
    {
      alert("Error Saving Infomation");
    }
  }
}

function add_options( source_array, target_option )
{
   items = source_array.getElementsByTagName("subinterest");

   for ( i = 0 ; i < items.length; i++)
   {
     var item = items[i];
     var sub_id = item.getElementsByTagName("sub_id")[0].firstChild.nodeValue;
     var name = item.getElementsByTagName("name")[0].firstChild.nodeValue;
     var selectOption = document.createElement('option');
   
     selectOption.value = sub_id;
     selectOption.text = name;
     
     try {
       target_option.add(selectOption,null);
     }catch(ex){
       target_option.add(selectOption);
     } 
   }

}
