function StartPortlet(rstrID, rstrTitle, rstrType, rnumLevel, rfMinimize, rfCorner, rfButtons) {
// rstrID ...... Unique ID for this Portlet
// rstrTitle ... Title of the Portlet 
// rstrType .... Type of Portlet (defines which styles will be used)
// rnumLevel ... Level of Portlet (used with blank type to create default styles)
// rfMinimize .. Whether the Portlet should be minimized
// rfCorner .... Whether the Portlet should have a corner
// rfButtons ... Whether the Portlet should have maximise / minimize buttons


// Set defaults 
   var strDBName = "/pfl/sys/webref01.nsf/";
   var strHTML = "";
   var strMinIcon = "block";
   var strMaxIcon = "none";
   var strContent = "block";
   var strType = "";
   var numLevel = 1;
   var fMinimize = false;
   var fCorner = true;
   var fButtons = true;


// Override if the Parameters have NOT been passed
   if (typeof rstrType != "undefined") strType = rstrType; 
   if (typeof rnumLevel != "undefined") numLevel = rnumLevel; 
   if (typeof rfMinimize != "undefined") fMinimize = rfMinimize; 
   if (numLevel == 1) {
       fCorner = true;
   } else {
       fCorner = false;
   }
   if (typeof rfCorner != "undefined") fCorner = rfCorner;
   if (numLevel < 3) {
       fButtons = true;
   } else {
       fButtons = false;
   }
   if (typeof rfButtons != "undefined") fButtons = rfButtons;

// Create the HTML for the Corner .. but only if level 1
   var strCorner = strDBName + "corner.gif?OpenImageResource";
   var strCornerHTML = ""
   if (fCorner) {
       strCornerHTML = '   <div class="null" style="float:left"><img height=15 width=15 ' +
                               'src="' + strCorner + '" border=0></div>\n';
   } 

// If Minimised then we need to override the default styles
   if (fMinimize) {
       strMinIcon = "none";
       strMaxIcon = "block";
       strContent = "none";
   }  

// Create the HTML for the Min / Max .. but only if level 1
   var strMin = strDBName + "min.gif?OpenImageResource";
   var strMax = strDBName + "max.gif?OpenImageResource";
   var strMinHTML = ""
   var strMaxHTML = ""

   if (fButtons) {
       strMinHTML = '   <div class="null" width=15 ID="' + rstrID + '_min" ' +
                             'style="float:right; display:' + strMinIcon + '">\n' +
                             '<img height=15 width=15 alt="minimize" ' +
                             'src="' + strMin + '" border=0 ' +
                             'onClick="MinPortlet(' + "'" + rstrID + "'" + ');"></div>\n';

       strMaxHTML = '   <div class="null" width=15 ID="' + rstrID + '_max" ' +
                             'style="float:right; display:' + strMaxIcon + '">\n' +
                             '<img height=15 width=15 alt="maximize" ' +
                             'src="' + strMax + '" border=0 ' +
                             'onClick="MaxPortlet(' + "'" + rstrID + "'" + ');"></div>\n';
   } 

// See user wants defaults 
   if (strType=="") {
      if (numLevel==1) {
          strType="Main";
      } else {
          strType = "Level" + numLevel;
      }
    }

// Create the HTML for the Header 
   strHTML = strHTML + 
     '<div class="' + strType + 'Outline" ID="' + rstrID + '">\n' + 
     ' <div class="' + strType + 'Title">\n' + 
             strCornerHTML + 
     '   <div class="TitleText" style="float:left">\n' + rstrTitle + '</div>\n' +
             strMinHTML + strMaxHTML + 
     ' </div>\n' +
     ' <div class="' + strType + 'Contents" ID="' + rstrID + '_contents" style="display:' + 
                    strContent + '">\n';

// Return the HTML
// alert (strHTML);
   return strHTML;
}

function EndPortlet(){
// Declare the variable we will be using 
   var strHTML = "";

// Create the HTML for the Footer 
   strHTML = strHTML + 
     '  </div>\n' +
     '</div>\n';

// Return the HTML
// alert (strHTML);
   return strHTML; 
}

function MinPortlet(rstrID){
// rstrID ...... Unique ID for this Portlet

// Hide Minimise Button
   var min = document.getElementById(rstrID + "_min");
   min.style.display = "none";

// Show Maximize Button
   var max = document.getElementById(rstrID + "_max");
   max.style.display = "block";

// Hide the contents
   var contents = document.getElementById(rstrID + "_contents");
   contents.style.display = "none";
}

function MaxPortlet(rstrID){
// Hide Maximize Button
 var max = document.getElementById(rstrID + "_max");
 max.style.display = "none";
// Show Minimise Button
 var min = document.getElementById(rstrID + "_min");
 min.style.display = "block";
// Show the contents
 var contents = document.getElementById(rstrID + "_contents");
 contents.style.display = "block";

}

function CreateButton (rstrColor, rstrTitle, rstrHref) { 
// rstrColor - Color of Background for the Button 
// rstrTitle - Title that should go on the Buutton
// rstrHref - Href for the Button

// Create the Button
    var strBtn = '[&nbsp;<a href="' + rstrHref + '">' + rstrTitle + '</a>&nbsp;]'; 
   return strBtn;   
}

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}
 
// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}
 
// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
      ((path) ? "; path=" + path : "; path=/") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
 
// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}



