<!-- Javascript Section        -->
<!-- Do not edit this section  -->



// This main function is responsible for parsing the query string
// and populating matching fields in this online form.

//---------------------------------------
function preLoadData(strPassedFormName)
//---------------------------------------
{
  var strTemp;
  var strFormType;
  var qsName;
  var qsValue;
  var arrPassedString;
  var intI, intJ;
  var urlPassedString = location.search.substring(1);
  var re = /[+]/gi;
  var blnFoundValidItem = 0;

  // Look for at least one item in the query string that corresponds to
  // PIID, MLID, or MPID.  If we find at least one item with that designation,
  // then continue the preloading of the form.  Otherwise, do not go into the
  // preload script

  arrPassedString = urlPassedString.split("&")
  for (intI = 0; intI < arrPassedString.length; intI++) {
    qsName = '';
    qsName = arrPassedString[intI].substring(0, 4);
    qsName = qsName.toUpperCase();
    if (qsName == 'PIID' || qsName == 'MLID' || qsName == 'MPID') {
      blnFoundValidItem = 1;
    }
  }


  // parse our string of data into it's appropriate name and value pairs

  if (urlPassedString.length != 0 && blnFoundValidItem == 1)
  {
    for (intJ = 0; intJ < window.document.forms[strPassedFormName].length; intJ++) {
      varFormElement = window.document.forms[strPassedFormName][intJ];
      strFormType    = varFormElement.type;
      strFormType = strFormType.toUpperCase();
      if (strFormType == "TEXT"  || strFormType == "HIDDEN") {
        strTemp = varFormElement.name;
        strTemp = strTemp.toUpperCase();
        if (strTemp != "WEBFORMID" && strTemp != "PROCESSPAGE" && strTemp != "W" && strTemp != "CID" && strTemp != "I") {
          varFormElement.value = "";
        }
      } else if (strFormType == "CHECKBOX" || strFormType == "RADIO") {
        varFormElement.checked = false;
      } else if (strFormType == "SELECT-ONE") {
        varFormElement.selectedIndex = -1;
      } else if (strFormType == "TEXTAREA") {
        varFormElement.value = "";
      }
    }
    arrPassedString = urlPassedString.split("&")
    for (intI = 0; intI < arrPassedString.length; intI++) {
      qsValue = '';
      qsName = '';
      qsName = arrPassedString[intI].substring(0, arrPassedString[intI].indexOf("=",1));
      qsValue = arrPassedString[intI].substring(arrPassedString[intI].indexOf("=",1)+1)
      if (qsValue.substring(0, 1) == "+") {
        qsValue = qsValue.substring(1, qsValue.length)
      }
      qsValue = unescape(qsValue.replace(re, " "));
      qsName = unescape(qsName.replace(re, " "));
      if (window.document.forms[strPassedFormName][qsName]) {

        // Determine wether the profile item has been listed on the form multiple
        // times (in the case of a checkbox or radio button or select box with
        // multiple options) or if it's just listed once (in the case of everything else)

        if (window.document.forms[strPassedFormName][qsName].length) {
          strFormType = window.document.forms[strPassedFormName][qsName].type;
          if (strFormType) {
            strFormType = strFormType.toUpperCase();
          }
          if (strFormType == "TEXT"  || strFormType == "HIDDEN") {
            window.document.forms[strPassedFormName][qsName].value = qsValue;
          } else if (strFormType == "RADIO" || strFormType == "CHECKBOX") {
            if (window.document.forms[strPassedFormName][qsName].value == qsValue) {
              window.document.forms[strPassedFormName][qsName].checked = true;
            }
          } else if (strFormType == "SELECT-ONE") {
            for (intJ = 0; intJ < window.document.forms[strPassedFormName][qsName].length; intJ++) {
              strTemp = window.document.forms[strPassedFormName][qsName].options[intJ].value;
              if (strTemp == qsValue) {
                window.document.forms[strPassedFormName][qsName].selectedIndex = intJ;
              }
            }
          } else {

            // We have a checkbox or radio button with multiple values.
            // In each case we know that there will be a value attribute

            for (intJ = 0; intJ < window.document.forms[strPassedFormName][qsName].length; intJ++) {
              if (window.document.forms[strPassedFormName][qsName][intJ].value == qsValue) {
                window.document.forms[strPassedFormName][qsName][intJ].checked = true;
              }
            }
          }
        } else {

          // We know that we either have a select box or we have something else.
          // Test for the selectedIndex property to determine.

          strFormType = window.document.forms[strPassedFormName][qsName].type;
          strFormType = strFormType.toUpperCase();
          if (strFormType == "SELECT-ONE") {
            for (intJ = 0; intJ < window.document.forms[strPassedFormName][qsName].length; intJ++) {
              strTemp = window.document.forms[strPassedFormName][qsName].options[intJ].value;
              if (strTemp == qsValue) {
                window.document.forms[strPassedFormName][qsName].selectedIndex = intJ;
              }
            }
          } else {
            strFormType = window.document.forms[strPassedFormName][qsName].type;
            strFormType = strFormType.toUpperCase();
            if (strFormType == 'RADIO' || strFormType == 'CHECKBOX') {
              if (window.document.forms[strPassedFormName][qsName].value == qsValue) {
                window.document.forms[strPassedFormName][qsName].checked = true;
              }
            } else {
              window.document.forms[strPassedFormName][qsName].value = qsValue;
            }
          }
        }
      }
 else {  qsName = qsName + '_0';       if (window.document.forms[strPassedFormName][qsName]) {

        // Determine wether the profile item has been listed on the form multiple
        // times (in the case of a checkbox or radio button or select box with
        // multiple options) or if it's just listed once (in the case of everything else)

        if (window.document.forms[strPassedFormName][qsName].length) {
          strFormType = window.document.forms[strPassedFormName][qsName].type;
          if (strFormType) {
            strFormType = strFormType.toUpperCase();
          }
          if (strFormType == "TEXT"  || strFormType == "HIDDEN") {
            window.document.forms[strPassedFormName][qsName].value = qsValue;
          } else if (strFormType == "RADIO" || strFormType == "CHECKBOX") {
            if (window.document.forms[strPassedFormName][qsName].value == qsValue) {
              window.document.forms[strPassedFormName][qsName].checked = true;
            }
          } else if (strFormType == "SELECT-ONE") {
            for (intJ = 0; intJ < window.document.forms[strPassedFormName][qsName].length; intJ++) {
              strTemp = window.document.forms[strPassedFormName][qsName].options[intJ].value;
              if (strTemp == qsValue) {
                window.document.forms[strPassedFormName][qsName].selectedIndex = intJ;
              }
            }
          } else {

            // We have a checkbox or radio button with multiple values.
            // In each case we know that there will be a value attribute

            for (intJ = 0; intJ < window.document.forms[strPassedFormName][qsName].length; intJ++) {
              if (window.document.forms[strPassedFormName][qsName][intJ].value == qsValue) {
                window.document.forms[strPassedFormName][qsName][intJ].checked = true;
              }
            }
          }
        } else {

          // We know that we either have a select box or we have something else.
          // Test for the selectedIndex property to determine.

          strFormType = window.document.forms[strPassedFormName][qsName].type;
          strFormType = strFormType.toUpperCase();
          if (strFormType == "SELECT-ONE") {
            for (intJ = 0; intJ < window.document.forms[strPassedFormName][qsName].length; intJ++) {
              strTemp = window.document.forms[strPassedFormName][qsName].options[intJ].value;
              if (strTemp == qsValue) {
                window.document.forms[strPassedFormName][qsName].selectedIndex = intJ;
              }
            }
          } else {
            strFormType = window.document.forms[strPassedFormName][qsName].type;
            strFormType = strFormType.toUpperCase();
            if (strFormType == 'RADIO' || strFormType == 'CHECKBOX') {
              if (window.document.forms[strPassedFormName][qsName].value == qsValue) {
                window.document.forms[strPassedFormName][qsName].checked = true;
              }
            } else {
              window.document.forms[strPassedFormName][qsName].value = qsValue;
            }
          }
        }
      }
    }     }
  }
}

// Call the routine to do our replacement of text values

preLoadData('testOnlineFormName')



//------------------------------------------
function testPreLoadToken(strPassedFormName)
//------------------------------------------
{
  var urlPassedString = location.search.substring(1);
  var re = /[+]/gi;
  var strWebFormID = "";
  var strINST = "";
  var strTemp = "";
  var intFoundToken = 0;
  var varElement;
  var strCompanyID = "";


  // parse our string of data into it's appropriate name and value pairs

  if (urlPassedString.length != 0)
  {
    arrPassedString = urlPassedString.split("&")
    for (intI = 0; intI < arrPassedString.length; intI++) {
      qsValue = '';
      qsName = '';
      qsName = arrPassedString[intI].substring(0, arrPassedString[intI].indexOf("=",1));
      qsValue = arrPassedString[intI].substring(arrPassedString[intI].indexOf("=",1)+1)
      if (qsValue.substring(0, 1) == "+") {
        qsValue = qsValue.substring(1, qsValue.length)
      }
      qsValue = unescape(qsValue.replace(re, " "));
      qsName = unescape(qsName.replace(re, " "));
      qsName = qsName.toUpperCase();
      if (qsValue == "") qsValue="1";
      if (qsName == "TOKEN" && qsValue != "") {
        intFoundToken = 1;

        // Find the original Online Form ID

        if (window.document.forms[strPassedFormName]["W"]) {
          strWebFormID = window.document.forms[strPassedFormName]["W"].value;
        }
        if (window.document.forms[strPassedFormName]["I"]) {
          strINST = window.document.forms[strPassedFormName]["I"].value;
        }
        if (strWebFormID != "") {
          strTemp = "http://links.cancer.ca/a/y.x?S=" + qsValue + "&W=" + strWebFormID + "&I=" + strINST + "&U="  + escape(window.location);
          window.location = strTemp;
        }
      }
    }
  }
}

testPreLoadToken('testOnlineFormName');




<!-- Start of the MIME Selector Code. This will make sure that use can only pick -->
<!-- one mime type and subscribe to only one mime type.                          -->



//---------------------------------------------------------------------
 function TurnOtherOff(intMimeTypeId,lngMailinglistId,objthis,thisform)
//---------------------------------------------------------------------
{
   var strTextTypeBox = 'MLID_' + lngMailinglistId + '_2';
   var strHTMLTypebox = 'MLID_' + lngMailinglistId + '_4';
   var frmWebform = window.document.forms[thisform];

   if(intMimeTypeId==2)
   {
     for(i=0;i<frmWebform.length;i++)
     {
       if(frmWebform.elements[i].name.indexOf(strHTMLTypebox)!=-1)
       {
         if (objthis.checked == true)
         {
           frmWebform.elements[i].checked = false;
         }
       }
    }
  }

   if(intMimeTypeId==4)
   {
     for(i=0;i<frmWebform.length;i++)
     {        if(frmWebform.elements[i].name.indexOf(strTextTypeBox)!=-1)
       {          if (objthis.checked == true)
         {
            frmWebform.elements[i].checked = false;
         }
       }
     }
   }
 } //end function


