function update(element_id, action, id)
{ 
  var url = '/includes/process-xml-distributor.php?action=' + action
             + '&id=' + id;
  loadFragmentInToElement(url, element_id);
}
function show_delete(action, element_id, dist)
{
  var url = '/includes/process-xml-delete-distributor.php?action=' + action
             + '&id=' + element_id + '&distributor=' + dist;
  loadFragmentInToElement(url, element_id);
}
function update_edit(element_id, action, id, dist)
{
  var url = '/includes/process-xml-edit-distributor.php?action=' + action
             + '&id=' + id + '&distributor=' + dist;
  loadFragmentInToElement(url, element_id);
}
function perform_action(fragment_url)
{
   var xmlhttp=false;
   /*@cc_on @*/
   /*@if (@_jscript_version >= 5)
   // JScript gives us Conditional compilation, we can cope with old IE versions.
   // and security blocked creation of the objects.
     try {     
     xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {       
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }  
     }   
   @end @*/
   if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
     xmlhttp = new XMLHttpRequest();
   }
   if(xmlhttp.overrideMimeType)
   {
      xmlhttp.overrideMimeType('text/xml');
   }

   if(fragment_url != "")
   {
      xmlhttp.open("GET", fragment_url, false);
      xmlhttp.send(null);
      return xmlhttp.responseText;
   }
}

function loadFragmentInToElement(fragment_url, element_id) {
   var xmlhttp=false;
   /*@cc_on @*/
   /*@if (@_jscript_version >= 5)
   // JScript gives us Conditional compilation, we can cope with old IE versions.
   // and security blocked creation of the objects.
     try {
     xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
     }
   @end @*/
   if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
     xmlhttp = new XMLHttpRequest();
   }
   if(xmlhttp.overrideMimeType)
   {
      xmlhttp.overrideMimeType('text/xml');
   }
   
   //var element = document.getElementById(element_id);
   
   if(fragment_url != "" && element != "")
   {  
      var element = document.getElementById(element_id);
   if(element){
      element.innerHTML = get_inner_html();
      xmlhttp.open("GET", fragment_url, true);
      xmlhttp.onreadystatechange = function() {
         if (xmlhttp.readyState == 4)
         {  
            if(xmlhttp.status == 200)
            {  
               element.innerHTML = xmlhttp.responseText;
               return 1;
            }
            else
            {  
               element.innerHTML = '';
               xmlhttp.abort();
            }
         }
      }
   
      xmlhttp.send(null);
      }
   }
   else if(element_id != "")
   {  
      var element = document.getElementById(element_id);
      if(element){element.innerHTML = '';}
   }
   return 1;
}

function pausecomp() 
{
   var i = 29;
}

function get_inner_html()
{
   var html = '<div align="center">';  
   html = html + '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="90" height="25" title="LIT Loading" style="height:25px">';
   html = html + '<param name="movie" value="/application/images/lit-loading.swf">';
   html = html + '<param name="quality" value="high">';
   html = html + '<param name="wmode" value="transparent">';
   html = html + '<embed src="/application/images/lit-loading.swf" quality="high" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="90" height="25" wmode="transparent"></embed>';
   html = html + '</object>';
   html = html + '</div>';
   return html;

}

function show_step2_radio(value)
{  
   var radio = document.form1.how_learn_pos;
   for(var i=0; i<radio.length; i++)
   {
      if(radio[i].checked)
      {
          loadFragmentInToElement('/application/includes/process_xml.php?token=' + token + '&type=' + radio[i].value + '&value=' + value, radio[i].value + '_div');
      }
      else
      {
         var element = document.getElementById(radio[i].value + '_div');
         if(element){element.innerHTML = '&nbsp;';}
      }
   }
}


function show_desc(radio_value, value, element_id, type)
{
      loadFragmentInToElement('/includes/process_xml.php?token=' + token + '&type=' + type + '&value=' + value, element_id);
}

function show_desc2(radio_value, value, element_id, type)
{
   if(radio_value == 'no')
   {
      loadFragmentInToElement('/application/includes/process_xml.php?token=' + token + '&type=' + type + '&value=' + value, element_id);
   }
   else
   {
      var element = document.getElementById(element_id);
      element.innerHTML = '';
   }
}

function show_check_option(check_value, value, type)
{
   if(check_value)
   {
      loadFragmentInToElement('/application/includes/process_xml.php?token=' + token + '&type=' + type + '&value=' + value, type + '_div');
   }
   else
   {
      var element = document.getElementById(type + '_div');
      element.innerHTML = '';
   }

}

function add_license(id, num)
{
   loadFragmentInToElement('/application/includes/process_xml.php?token=' + token + '&type=add_license&id=' + id + '&num=' + num, id + num);
}

function remove_license(id, num)
{
   loadFragmentInToElement('/application/includes/process_xml.php?token=' + token + '&type=remove_license&id=' + id + '&num=' + num, id + num);
}

function add_another_ed(selected_index, id)
{
   //get select
   var select = document.getElementById('add_another_select');
   var selected = select.options[selected_index].value;

   //get new div id for old div
   var new_id = id + '_' + Math.round(Math.random() *  100000);

   //reset selected
   select.options[0].selected = true;   
   loadFragmentInToElement('/application/includes/process_xml.php?token=' + token + '&type=add_' + selected + '&selected=' + selected + '&new_id=' + new_id, id);

   setTimeout('change_divs("' + id + '")', 500);
}

function change_divs(id)
{
   //changed ids
   var element = document.getElementById(id);
   if(element){
      element.id = 'old' + Math.round(Math.random() * 100000);
   }
   var new_element = document.getElementById('new_id');
   if(new_element){
      new_element.id = id;
   }
}


function remove_another(id)
{
   var element=document.getElementById(id);
   element.innerHTML = '';
   element.style.visibility='hidden';
   element.style.height='0px';
}


function add_another_emp(id)
{
   //get new div
   var new_id = id + '_' + Math.round(Math.random() * 100000);
   
   if(loadFragmentInToElement('/application/includes/process_xml.php?token=' + token + '&type=add_emp&new_id=' + new_id, id))
   {
      setTimeout('change_divs("' + id + '")', 500);
      //change_divs(id);
   }  
}


function show_dates(value, id)
{
   if(value == 'yes')
   {
      loadFragmentInToElement('/application/includes/process_xml.php?token=' + token + '&type=show_dates&id=' + id, id + '_dates');
   }
   else
   {
      var element = document.getElementById(id + '_dates');
      element.innerHTML = '';
   }
}


function disable_to_date(id, checked)
{
   var element= document.getElementById('to_date_mon_' + id);
   element.disabled = checked;
   element= document.getElementById('to_date_day_' + id);
   element.disabled = checked;
   element= document.getElementById('to_date_yr_' + id);
   element.disabled = checked;
}

function disable_desired(checked, element_id)
{
   if(checked == true)
   {
      var element = document.getElementById(element_id);
      element.disabled = true;
   }
   else
   {
      var element = document.getElementById(element_id);
      element.disabled = false;
   }
}

