function get_bandwidth_cookie_and_write_bandwidth_form()
{
  var
    bandwidth;

  bandwidth = get_bandwidth_cookie();

  document.write( '<FORM NAME="bandwidth_form">' );

  if( bandwidth == "narrow" )
    document.write( '<INPUT TYPE=RADIO NAME="bandwidth" VALUE="narrow" ONCHANGE="set_bandwidth_cookie();" CHECKED>56k/ISDN<BR>' +
                    '<INPUT TYPE=RADIO NAME="bandwidth" VALUE="broad"  ONCHANGE="set_bandwidth_cookie();">xDSL/cable' );

  if( bandwidth == "broad" )
    document.write( '<INPUT TYPE=RADIO NAME="bandwidth" VALUE="narrow" ONCHANGE="set_bandwidth_cookie();">56k/ISDN<BR>' +
                    '<INPUT TYPE=RADIO NAME="bandwidth" VALUE="broad"  ONCHANGE="set_bandwidth_cookie();" CHECKED>xDSL/cable' );

  document.write( '</FORM>' );

  return;
}

function get_bandwidth_cookie()
{
  var
    offset,
    end,
    search;

  search = "csr_bandwidth=";

  if( document.cookie.length > 0 )
  {
    offset = document.cookie.indexOf( search );

    if( offset != -1 )
    {
      offset += search.length;
      end = document.cookie.indexOf( ";", offset ); 
      if( end == -1 )
        end = document.cookie.length

      return( document.cookie.substring(offset, end) );
    } 
  }

  return( "broad" );
}

function set_bandwidth_cookie()
{
  var
    today,
    expires;

  today = new Date();
  expires = new Date();
  expires.setTime( today.getTime() + 1000*60*60*24*365 );

  if( document.bandwidth_form.bandwidth[0].checked == true )
  {
    document.cookie = "csr_bandwidth=" + document.bandwidth_form.bandwidth[0].value + ";expires=" + expires.toGMTString();
    return;
  }

  if( document.bandwidth_form.bandwidth[1].checked == true )
  {
    document.cookie = "csr_bandwidth=" + document.bandwidth_form.bandwidth[1].value + ";expires=" + expires.toGMTString();
    return;
  }

  return;
}

function embed_video( base_name )
{
  var
    page_contents,
    bandwidth;

  bandwidth = get_bandwidth_cookie();

  page_contents = '<EMBED SRC="video/' + bandwidth + '/' + base_name + '_' + bandwidth + '.avi" TYPE="application/x-mplayer2" WIDTH=400 HEIGHT=300 SHOWCONTROLS=0 SHOWDISPLAY=0 SHOWSTATUSBAR=0 AUTOSTART=FALSE>';

  document.write( page_contents );

  return;
}

function embed_1_5x_video( base_name )
{
  var
    page_contents,
    bandwidth;

  bandwidth = get_bandwidth_cookie();

  page_contents = '<EMBED SRC="video/' + bandwidth + '/' + base_name + '_' + bandwidth + '.avi" TYPE="application/x-mplayer2" WIDTH=600 HEIGHT=400 SHOWCONTROLS=0 SHOWDISPLAY=0 SHOWSTATUSBAR=0 AUTOSTART=FALSE>';

  document.write( page_contents );

  return;
}



