// this function gets the cookie, if it exists
function Get_Cookie(name)
{
    var start = document.cookie.indexOf(name + "=");
    var len = start + name.length + 1;
    if ((!start) && (name != document.cookie.substring(0, name.length)))
    {
        return null;
    }
    if (start == -1) return null;
    var end = document.cookie.indexOf(";", len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len, end));
}

// this function writes the cookie
function Set_Cookie(name, value, expires, path, domain, secure)
{
    var today = new Date();
    today.setTime(today.getTime());
    if (expires)
    {
       expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date( today.getTime() + (expires) );

    document.cookie = name + "=" +escape( value ) +
        ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
        ( ( path ) ? ";path=" + path : "" ) + 
        ( ( domain ) ? ";domain=" + domain : "" ) +
        ( ( secure ) ? ";secure" : "" );
}

// this deletes the cookie when called
function Delete_Cookie(name, path, domain)
{
   if (Get_Cookie( name )) document.cookie = name + "=" +
            ( ( path ) ? ";path=" + path : "") +
            ( ( domain ) ? ";domain=" + domain : "" ) +
            ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

// this function displays the warning if cookies is disabled
function DisplayCookieWarning(display_language)
{
   display_language = "EN"
   var outputText = ""
   if (display_language=="EN")
   {
      outputText = "<p><strong><a name=\"top\">Please Note</a>: ";
      outputText = outputText + "<span style=\"color: red;\">Browser Cookies must be enabled for you to login</span>";
      outputText = outputText + ".<br />For more information on how to enable cookies read below.</strong></p>";
      outputText = outputText + "<strong>How to Enable Cookies</strong>";
      outputText = outputText + "<p>To enable cookies, follow the instructions below for the browser version you are using.</p>";
      outputText = outputText + "<a href=\"#firefox\">Mozilla Firefox</a><br />";
      outputText = outputText + "<a href=\"#mozilla\">Netscape 7.1/Mozilla 5.0</a><br />";
      outputText = outputText + "<a href=\"#ie6\">Microsoft Internet Explorer 6.0+</a><br />";
      outputText = outputText + "<a href=\"#ie5\">Microsoft Internet Explorer 5.x</a><br />";
      outputText = outputText + "<a href=\"#ie4\">Microsoft Internet Explorer 4.x</a><br />";
      outputText = outputText + "<a href=\"#netscape4\">Netscape Communicator 4.x</a><br />";

      outputText = outputText + "<p><a name=\"firefox\"><strong>Mozilla Firefox</strong></a>";
      outputText = outputText + "<ul>";
      outputText = outputText + "   <li>Go to the \"Tools\" menu.</li>";
      outputText = outputText + "   <li>Select \"Options\".</li>";
      outputText = outputText + "   <li>Select the \"Privacy\" icon in the left panel.</li>";
      outputText = outputText + "   <li>Check the box corresponding to \"Allow sites to set cookies\".</li>";
      outputText = outputText + "   <li>Click \"OK\" to save changes.</li>";
      outputText = outputText + "</ul><a href=\"#top\">Back to the top</a></p>";

      outputText = outputText + "<p><a name=\"mozilla\"><strong>Netscape 7.1/Mozilla 5.0</strong></a>";
      outputText = outputText + "<ul>";
      outputText = outputText + "   <li>Select \"Preferences\" from the Edit menu.</li>";
      outputText = outputText + "   <li>Click on the arrow next to \"Privacy & Security\" in the scrolling window to expand.</li>";
      outputText = outputText + "   <li>Under \"Privacy & Security\", select \"Cookies.\"</li>";
      outputText = outputText + "   <li>Select \"Enable all cookies\".</li>";
      outputText = outputText + "   <li>Click \"OK\".";
      outputText = outputText + "</ul><a href=\"#top\">Back to the top</a></p>";

      outputText = outputText + "<p><a name=\"ie6\"><strong>Microsoft Internet Explorer 6.0+</strong></a>";
      outputText = outputText + "<ul>";
      outputText = outputText + "   <li>Select \"Internet Options\" from the Tools menu.</li>";
      outputText = outputText + "   <li>Click on the \"Privacy\" tab.</li>";
      outputText = outputText + "   <li>Click the \"Default\" button (or manually slide the bar down to \"Medium\") under \"Settings\".</li>";
      outputText = outputText + "   <li>Click \"OK\". </li>";
      outputText = outputText + "</ul><a href=\"#top\">Back to the top</a></p>";

      outputText = outputText + "<p><a name=\"ie5\"><strong>Microsoft Internet Explorer 5.x</strong></a>";
      outputText = outputText + "<ul>";
      outputText = outputText + "   <li>Select \"Internet Options\" from the Tools menu.</li>";
      outputText = outputText + "   <li>Click on the \"Security\" tab.</li>";
      outputText = outputText + "   <li>Click the \"Custom Level\" button.</li>";
      outputText = outputText + "   <li>Scroll down to the \"Cookies\" section.</li>";
      outputText = outputText + "   <li>To enable:</li>";
      outputText = outputText + "      <ul>";
      outputText = outputText + "         <li>Set \"Allow cookies that are stored on your computer\" to \"Enable\".</li>";
      outputText = outputText + "         <li>Set \"Allow per-session cookies\" to \"Enable\".</li>";
      outputText = outputText + "      </ul>";
      outputText = outputText + "   <li>Click \"OK\".</li>";
      outputText = outputText + "</ul><a href=\"#top\">Back to the top</a></p>";

      outputText = outputText + "<p><a name=\"ie4\"><strong>Microsoft Internet Explorer 4.x</strong></a>";
      outputText = outputText + "<ul>";
      outputText = outputText + "   <li>Select \"Internet Options\" from the View menu.</li>";
      outputText = outputText + "   <li>Click on the \"Advanced\" tab.</li>";
      outputText = outputText + "   <li>Scroll down to find \"Cookies\" within the \"Security\" section.</li>";
      outputText = outputText + "   <li>To enable:</li>";
      outputText = outputText + "      <ul>";
      outputText = outputText + "         <li>Select \"Always accept cookies\".</li>";
      outputText = outputText + "      </ul>";
      outputText = outputText + "   <li>Click \"OK\".</li>";
      outputText = outputText + "</ul><a href=\"#top\">Back to the top</a></p>";

      outputText = outputText + "<p><a name=\"netscape4\"><strong>Netscape Communicator 4.x</strong></a>";
      outputText = outputText + "<ul>";
      outputText = outputText + "   <li>Select \"Preferences\" from the Edit menu.</li>";
      outputText = outputText + "   <li>Find the \"Cookies\" section in the \"Advanced\" category.</li>";
      outputText = outputText + "   <li>To enable:</li>";
      outputText = outputText + "      <ul>";
      outputText = outputText + "         <li>Select \"Accept all cookies\" (or \"Enable all cookies\").</li>";
      outputText = outputText + "      </ul>";
      outputText = outputText + "   <li>Click \"OK\".</li>";
      outputText = outputText + "</ul><a href=\"#top\">Back to the top</a></p>";
   }
   return outputText;
}

function requiredFields()
{
  return "<span class=\"error\">*</span>";
}