<!--
/*
 * Filename:     script.js
 * Author:       Mark Pumphrey
 * Date:         20 April 2008
 * History:      2.0b - Deploy Release
 * Description:  This is the JavaScript functions used by the
 *               Handicapped Unlimited Website which was designed
 *               for the SWE632 class.
 */

  function Initialize(state, topic) {

    setCookie('probe','set');
    var item = getCookie('probe');
    delCookie('probe');

    if (item == undefined) {
      //No cookies enabled!
      setStatus('Please enable cookies so this site can remember your settings!');
    }
    else
    {
      var size = getCookie('font');
      if (size == '10') {
        document.form_1.fontSize[0].checked=true;
        document.form_2.style.fontSize='10pt';
      }
      if (size == '12') {
        document.form_1.fontSize[1].checked=true;
        document.form_2.style.fontSize='12pt';
      }
      if (size == '14') {
        document.form_1.fontSize[2].checked=true;
        document.form_2.style.fontSize='14pt';
      }
      if (state == 'true') {
        document.form_2.location.selectedIndex=getCookie('state');
        var cat = getCookie('category');
        if (cat == 'all') {
          document.form_2.category1.checked=true;
        }
        if (cat == 'advocacy') {
          document.form_2.category2.checked=true;
        }
        if (cat == 'devices') {
          document.form_2.category3.checked=true;
        }
        if (cat == 'financial') {
          document.form_2.category4.checked=true;
        }
        if (cat == 'rehabilitation') {
          document.form_2.category5.checked=true;
        }
        if (cat == 'software') {
          document.form_2.category6.checked=true;
        }
        if (cat == 'support groups') {
          document.form_2.category7.checked=true;
        }
        if (cat == 'vacationing') {
          document.form_2.category8.checked=true;
        }
      }
      if (topic == 'true') {
        var item = getCookie('topic');
        if (item == 'Add a link') {
          document.form_2.topic1.checked=true;
        }  
        if (item == 'Bad link') {
          document.form_2.topic2.checked=true;
        }    
        if (item == 'General comment') {
          document.form_2.topic3.checked=true;
        }

        var item = getCookie('details');
        if (item == undefined) {
          document.form_2.details.value = "Details:";
        }
        else {
          document.form_2.details.value = item;
        }
       
      }
    }
  } /* End of function Initialize */


  function setStatus(msg) {
    //Show a status message
    d = document.getElementById('status');
    d.innerHTML = msg;
  } /* End of function setStatus */


  function setCookie(name, value) {
    document.cookie = name + "=" + escape(value);
  } /* End of function setCookie */

  function delCookie(name) {
    document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMU" + "; path=/";
  } /* End of function delCookie */


  function getCookie(name) {
    var result;

    var myCookie = " " + document.cookie + ";";
    var searchName = " " + name + "=";
    var startOfCookie = myCookie.indexOf(searchName);
    var endOfCookie;
    if (startOfCookie != -1) {
      startOfCookie += searchName.length;
      endOfCookie = myCookie.indexOf(";", startOfCookie);
      result =
        unescape(myCookie.substring(startOfCookie, endOfCookie));
    }

    if (result == undefined) {
      if (name == 'font') {
        result="12";
        setCookie('font','12');
      }
      if (name == 'state') {
        result="0";
        setCookie('state','0');
      }
    }
    return(result);

  } /* End of function getCookie */


  function smallFont() {
    setCookie('font','10');
    document.form_1.fontSize[0].checked=true;
    document.form_2.style.fontSize='10pt';
  } /* End of function smallFont */


  function mediumFont() {
    setCookie('font','12');
    document.form_1.fontSize[1].checked=true;
    document.form_2.style.fontSize='12pt';
  } /* End of function mediumFont */


  function largeFont() {
    setCookie('font','14');
    document.form_1.fontSize[2].checked=true;
    document.form_2.style.fontSize='14pt';
  } /* End of function largeFont */


  function Help() {
    alert("             Categories\n" +
          "advocacy -       legal protection/rights\n" +
          "devices -         wheelchairs, lifts, etc\n" +
          "financial -        information on monetary assistance\n" +
          "rehabilitation - services for training and reintegration\n" +
          "software -       enabling computer usage for disabled\n" +
          "support groups - peer collaboration\n" +
          "vacationing -    tours and hotels catering to disabled");
  } /* End of function Help */


  function selectset(which) {
    var sel = document.form_2.location;
    sel.selectedIndex = which;
    setCookie('state',which);
  }  /* End of function selectset */


  function Focus(widget) {
    document.getElementById(widget).style.background="blue";
  } /* End of function Focus */


  function Unfocus(widget) {
    var item = document.getElementById('ident');
    if (item.value == widget)
    {
      document.getElementById(widget).style.background="#000099";
    }
    else
    {
      document.getElementById(widget).style.background="#666666";
    }

  } /* End of function Unfocus */

-->
