
<script language="JavaScript">

<? include ../html/setup/wst.js ?>
<? include ../html/js/jsl.js ?>
<? include ../html/js/error.js ?>

var ConnectionDatabase = new Array();
var MaxConnections;
var CurrentConnectionSelection = -1;

function uiDoOnLoad()
{ 
  var i = 0;
  var currConn;
  <? multiquery manager:command/connection/list "ConnectionDatabase[i++]='$01';" ?>
  MaxConnections = i;

  uiSetIGMPStatus (document.getElementById("uiPostIGMPStatus").value);

  currConn = document.getElementById("uiPostIGMPConnection").value;  
  for(i=0;i< MaxConnections;i++)
  {
    if(ConnectionDatabase[i]==currConn)
    {
      uiChangeConnection(i);
	  break;
	}
  }
}

function uiChangeConnection (arg)
{  
  jslDoToggleRadio("uiViewConnection",arg, MaxConnections);

  if (document.getElementById("uiViewConnection" + arg).value == "off")
	CurrentConnectionSelection = -1;
  else
    CurrentConnectionSelection = arg;
}

function uiDoSave()
{
   if (document.getElementById("uiPostIGMPStatus").value == "1")
   {
	if (CurrentConnectionSelection == -1)
	{
     alert ("You must select a connection.");
	 return;
	}
   }

  document.getElementById("uiPostIGMPConnection").value = ConnectionDatabase[CurrentConnectionSelection];
  document.getElementById("uiPostForm").submit();
  return;
}

function uiDoCancel()
{
    jslGoTo(null,"home");
}

function uiSetIGMPStatus(arg)
{
  if(arg=="1") 
    uiInitializeIGMPStatus('on');
  else
    uiInitializeIGMPStatus('off');
}

function uiInitializeIGMPStatus(arg)
{ 
  var checkbox = document.getElementById("uiViewIGMP");
  if (checkbox.value != arg)
    jslDoToggleCheckBox ("uiViewIGMP");
  if (arg == "on")
    document.getElementById("uiPostIGMPStatus").value = "1";
  else
    document.getElementById("uiPostIGMPStatus").value = "0";
}

function uiChangeIGMPStatus(arg)
{
  if (arg == "on")  
	document.getElementById("uiPostIGMPStatus").value = "1";
  else
    document.getElementById("uiPostIGMPStatus").value = "0";
}
</script>
