function submit_work(f)
  {
  var txtError = '';
  // Search form elements for attachments
  for (x=0;x<f.elements.length;x++)
    {
    if (f.elements[x].name.lastIndexOf('_attachment') != -1)
      { 
      // Element is an attachment, so check for a provided filename
      if (f.elements[x].value != '')
        {
        // Filename provided, so check for a proper file extension
        var uploadFile = new String(f.elements[x].value);
        var dotPosition = uploadFile.lastIndexOf('.');
        if (dotPosition == '' || dotPosition == -1)
          { txtError += 'The file you are attempting to upload does not have a proper file extension.\n' }
        //  Turn off file extension type checking
        //else
        //  {
        //  s = uploadFile.substring(uploadFile.lastIndexOf('.')+1,uploadFile.length);
        //  if (!(s == 'doc' || s == 'xls' || s == 'ppt' || s == 'gif' || s == 'jpg'))
        //    { txtError += 'Attachments must have one of the following file extensions: doc, xls, ppt, gif, jpg.\n' }
        //  }
        }
      }
    }
  if (txtError == '')
    {
    w = window.open('../../system/response.html','notification','resizable=yes,width=600, height=300, toolbar=no, location=no, menubar=no');
    f.submit()
    }
  else
    { alert(txtError) }
  }

function submit_review(f)
  {
  // Similar to submit_work, but needs some extra information for sending submit notifications

  var txtError = '';
  // Search form elements for attachments
  for (x=0;x<f.elements.length;x++)
    {
    if (f.elements[x].name.lastIndexOf('_attachment') != -1)
      { 
      // Element is an attachment, so check for a provided filename
      if (f.elements[x].value != '')
        {
        // Filename provided, so check for a proper file extension
        var uploadFile = new String(f.elements[x].value);
        var dotPosition = uploadFile.lastIndexOf('.');
        if (dotPosition == '' || dotPosition == -1)
          { txtError += 'The file you are attempting to upload does not have a proper file extension.\n' }
        //  Turn off file extension type checking
        //else
        //  {
        //  s = uploadFile.substring(uploadFile.lastIndexOf('.')+1,uploadFile.length);
        //  if (!(s == 'doc' || s == 'xls' || s == 'ppt' || s == 'gif' || s == 'jpg'))
        //    { txtError += 'Attachments must have one of the following file extensions: doc, xls, ppt, gif, jpg.\n' }
        //  }
        }
      }
    }
  // Get the Module ID
  s = document.URL;
  s = s.substring(0,s.lastIndexOf('/'));
  s = s.substring(s.lastIndexOf('module')+6,s.length);
  mod_id = parseInt(s);
  // Get the textarea submission name, s_name
  for (x=0;x<f.elements.length;x++)
    {
    if (f.elements[x].type == 'textarea')
      { s_name = f.elements[x].name }
    }
  if (s_name == 's1' || s_name == 's2')
    { s_name = 'm' }
  if (txtError == '')
    {
    w = window.open('../../support/submit_review.pl?m='+mod_id+'&s='+s_name,'notification','resizable=yes,width=600, height=300, toolbar=no, location=no, menubar=no');
    f.submit()
    }
  else
    { alert(txtError) }
  }

function submit_assess()
  {
  // Similar to submit_review, but drops the submission part and defaults to a module submission (s=m)

  var txtError = '';
  // Get the Module ID
  s = document.URL;
  s = s.substring(0,s.lastIndexOf('/'));
  s = s.substring(s.lastIndexOf('module')+6,s.length);
  mod_id = parseInt(s);
  if (txtError == '')
    {
    w = window.open('../../support/submit_review.pl?m='+mod_id+'&s=m','notification','resizable=yes,width=600, height=300, toolbar=no, location=no, menubar=no');
    }
  else
    { alert(txtError) }
  }

function openVideo(location)
  {
  s = document.URL;
  s = s.substring(0,s.lastIndexOf('/'));
  s = s.substring(s.lastIndexOf('module')+6,s.length);
  mod_id = parseInt(s);
  s = document.URL;
  s = s.substring(0,s.lastIndexOf('.html'));
  page = s.substring(s.lastIndexOf('/')+1);
  video = location.substring(location.lastIndexOf('/')+1);
  newWin = window.open('', 'video', 'menubar=no,toolbar=no,scrollbars=no,resizable=yes,width=320,height=260');
  newWin.document.write("<HTML><HEAD></HEAD><frameset rows=*,1 frameborder=no frameborder=0><frame src="+location+" noresize scrolling=no><frame src='../../support/log_videos.pl?url="+video+"&mod_id="+mod_id+"&page="+page+"' noresize scrolling=no></frameset></HTML>");
  newWin.focus()
  }

function openWin(location)
{
newWin=window.open(location, 'win1', 'menubar=1,toolbar=1,scrollbars=1,resizable=yes,width=620,height=400');
newWin.focus()
}

function startpage(url)
  {
  s = document.URL;
  s = s.substring(0,s.lastIndexOf('/'));
  s = s.substring(s.lastIndexOf('module')+6,s.length);
  mod_id = parseInt(s);
  s = document.URL;
  s = s.substring(0,s.lastIndexOf('.html'));
  page = s.substring(s.lastIndexOf('/')+1);
  newWindow = window.open('', 'newWin', 'toolbar=yes,location=no,scrollbars=yes,resizable=yes,width=600,height=450');
  newWindow.document.write("<HTML><HEAD></HEAD><frameset rows=50,*,1><frame src='../../system/disclaimer.html' noresize scrolling=no><frame src="+url+" noresize scrolling=auto><frame src='../../support/log_ext_links.pl?url="+url+"&mod_id="+mod_id+"&page="+page+"' noresize scrolling=no frameborder=no frameborder=0></frameset></HTML>");
  newWindow.focus();
  newWindow.document.close();
  }

function myWorkbook(location)
{
newWin=window.open(location, 'workbook', 'menubar=1,toolbar=1,scrollbars=1,resizable=yes,width=620,height=400');
newWin.focus()
}

function discussions(disc_id,d_re_id)
{
w = window.open('../../forum/forum_topics.pl?disc_id=' + disc_id + '&d_re_id=' + d_re_id,'forum','resizable,width=750,height=400,menubar,toolbar,status,scrollbars')
w.focus()
}

function openVideo_new(vhtml,location,caption)
  {
  caption = escape(caption);
  s = document.URL;
  s = s.substring(0,s.lastIndexOf('/'));
  s = s.substring(s.lastIndexOf('module')+6,s.length);
  mod_id = parseInt(s);
  s = document.URL;
  s = s.substring(0,s.lastIndexOf('.html'));
  page = s.substring(s.lastIndexOf('/')+1);
  video = location.substring(location.lastIndexOf('/')+1);
  newWin = window.open('', 'video', 'menubar=no,toolbar=no,scrollbars=no,resizable=yes,width=320,height=360');
  newWin.document.write("<HTML><HEAD></HEAD><frameset rows=*,1 frameborder=no frameborder=0><frame src="+'../../support/javascript/'+vhtml+'?vid='+location+'&cap='+caption+" noresize scrolling=no><frame src='../../support/log_videos.pl?url="+video+"&mod_id="+mod_id+"&page="+page+"' noresize scrolling=no></frameset></HTML>");
  newWin.focus()
  }

function openVideo_new_nolog(vhtml,location,caption)
  {
  caption = escape(caption);
  newWin = window.open('../../../system/support/javascript/'+vhtml+'?vid='+location+'&cap='+caption, 'video', 'menubar=no,toolbar=no,scrollbars=no,resizable=yes,width=320,height=360');
  newWin.focus()
  }


