var req_test = null;

function test_rsp()
{
  var content = comm_get_result( req_test );
  if( content ) {
  
    document.getElementById( 'idsysVoltSimuEna' ).checked = '';
      
    if( content.curSys && ( content.curSys == 1 ) ) {
      document.getElementById( 'curSysOn' ).checked = 'checked';
      document.getElementById( 'curSysOff' ).checked = '';
    } else {
      document.getElementById( 'curSysOn' ).checked = '';
      document.getElementById( 'curSysOff' ).checked = 'checked';
    }
      
    if( content.cur12 && ( content.cur12 == 1 ) ) {
      document.getElementById( 'cur12On' ).checked = 'checked';
      document.getElementById( 'cur12Off' ).checked = '';
    } else {
      document.getElementById( 'cur12On' ).checked = '';
      document.getElementById( 'cur12Off' ).checked = 'checked';
    }
    
    if( content.cur34 && ( content.cur34 == 1 ) ) {
      document.getElementById( 'cur34On' ).checked = 'checked';
      document.getElementById( 'cur34Off' ).checked = '';
    } else {
      document.getElementById( 'cur34On' ).checked = '';
      document.getElementById( 'cur34Off' ).checked = 'checked';
    }

    if( content.dbg && ( content.dbg == 1 ) ) {
      document.getElementById( 'iddbg' ).checked = 'checked';
    } else {
      document.getElementById( 'iddbg' ).checked = '';
    }

    if( content.simTmpEna && ( content.simTmpEna == 1 ) ) {
      document.getElementById( 'idsimTmpEna' ).checked = 'checked';
    } else {
      document.getElementById( 'idsimTmpEna' ).checked = '';
    }

    if( content.simTmp1 ) {
      document.getElementById( 'idsimTmp1' ).value = content.simTmp1;
    }

    if( content.simTmp2 ) {
      document.getElementById( 'idsimTmp2' ).value = content.simTmp2;
    }

    if( content.simTmp3 ) {
      document.getElementById( 'idsimTmp3' ).value = content.simTmp3;
    }

    if( content.simTmp4 ) {
      document.getElementById( 'idsimTmp4' ).value = content.simTmp4;
    }

    if( content.wfOffset ) {
      document.getElementById( 'idTstWfTempOffset' ).value = content.wfOffset;
    }

    if( content.wfId ) {
      document.frmHeating.tstWfId.value = content.wfId;
    }

    
    if( content.identify && ( content.identify == 1 ) ) {
      document.getElementById( 'idIdentify' ).checked = 'checked';
    } else {
      document.getElementById( 'idIdentify' ).checked = '';
    }

    if( content.mobileEna && ( content.mobileEna == 1 ) ) {
      document.getElementById( 'idMobileEna' ).checked = 'checked';
    } else {
      document.getElementById( 'idMobileEna' ).checked = '';
    }

    if( content.usbHubEna && ( content.usbHubEna == 1 ) ) {
      document.getElementById( 'idUsbHubEna' ).checked = 'checked';
    } else {
      document.getElementById( 'idUsbHubEna' ).checked = '';
    }

    if( content.BBB3VEna && ( content.BBB3VEna == 1 ) ) {
      document.getElementById( 'idBBB3VEna' ).checked = 'checked';
    } else {
      document.getElementById( 'idBBB3VEna' ).checked = '';
    }


    if( content.audioAmplifierEna && ( content.audioAmplifierEna == 1 ) ) {
      document.getElementById( 'idAudioAmplifierEna' ).checked = 'checked';
    } else {
      document.getElementById( 'idAudioAmplifierEna' ).checked = '';
    }

    if( content.audioAmplifierUnmuteEna && ( content.audioAmplifierUnmuteEna == 1 ) ) {
      document.getElementById( 'idAudioAmplifierUnmuteEna' ).checked = 'checked';
    } else {
      document.getElementById( 'idAudioAmplifierUnmuteEna' ).checked = '';
    }

    
    setTimeout( run_page, 3000 );
  }
}
function run_page()
{
  var sUrl = "/ajaxTest?test=1";
  if( document.frmHeating.forceHeating.checked ) { sUrl += "&forceHeat=" + document.frmHeating.radHeat.value; }
  if( document.frmHeating.dbg.checked ) { sUrl += "&dbg=1"; }
  if( document.frmHeating.simTmpEna.checked ) { sUrl += "&simTmpEna=1"; }
  if( document.frmHeating.identify.checked ) { sUrl += "&identify=1"; }
  if( document.frmHeating.mobileEna.checked ) { sUrl += "&mobileEna=1"; } else { sUrl += "&mobileEna=0"; }
  if( document.frmHeating.usbHubEna.checked ) { sUrl += "&usbHubEna=1"; } else { sUrl += "&usbHubEna=0"; }
  if( document.frmHeating.BBB3VEna.checked ) { sUrl += "&BBB3VEna=1"; } else { sUrl += "&BBB3VEna=0"; }
  if( document.frmHeating.audioAmplifierEna.checked ) { sUrl += "&audioAmplifierEna=1"; } else { sUrl += "&audioAmplifierEna=0"; }
  if( document.frmHeating.audioAmplifierUnmuteEna.checked ) { sUrl += "&audioAmplifierUnmuteEna=1"; } else { sUrl += "&audioAmplifierUnmuteEna=0"; }

  sUrl += "&svgTrLevel=" + document.frmHeating.idSvgTrLevel.value;
  sUrl += "&pngTrLevel=" + document.frmHeating.idPngTrLevel.value;
  sUrl += "&dabTrLevel=" + document.frmHeating.idDabTrLevel.value;
  sUrl += "&simTmp1=" + parseInt( document.frmHeating.simTmp1.value );
  sUrl += "&simTmp2=" + parseInt( document.frmHeating.simTmp2.value );
  sUrl += "&simTmp3=" + parseInt( document.frmHeating.simTmp3.value );
  sUrl += "&simTmp4=" + parseInt( document.frmHeating.simTmp4.value );
  sUrl += "&wfId=" + parseInt( document.frmHeating.tstWfId.value );
  sUrl += "&wfOffset=" + parseInt( document.frmHeating.tstWfTempOffset.value );
  req_test = comm_requestCallback( sUrl, test_rsp );
}
