function isValidPassword(istrPassword) {
   var strPassword;
   var dtToday = new Date();
   var strSeason;
   var numMonth = dtToday.getMonth() + 1;
   var numYear = dtToday.getFullYear();

   if ((numMonth == 12) || (numMonth == 1) || (numMonth == 2)) {
      strSeason = "winter";
   }
   else {
      if ((numMonth == 3) || (numMonth == 4) || (numMonth == 5)) {
         strSeason = "spring";
      }  
      else {
         if ((numMonth == 6) || (numMonth == 7) || (numMonth == 8)) {
             strSeason = "summer";
         }   
         else {
            strSeason = "fall";
         }
      }
   }   
   strPassword = strSeason + numYear;
 
   if (strPassword == istrPassword) {
      return true;
   }
   else {
      return false;
   }
}

function SetCookie(istrCookieName, istrCookieValue, saveCookie) {
	var date = new Date();
    var days = 365;
    
    date.setTime(date.getTime()+(days*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
 
    if (saveCookie == 'Y') 
       document.cookie = istrCookieName + "=" + istrCookieValue + expires;
    else   
       document.cookie = istrCookieName + "=" + istrCookieValue;
}

function GetCookie(istrCookieName) {
  
  var CookieData = new String(document.cookie);
  var CookieStart = CookieData.indexOf(istrCookieName);
  
  if (CookieStart != -1) {
     return CookieData.substring(CookieStart + istrCookieName.length)
  }
  else {
     return "N"
  }
}

function ValidateUser() {
   var returnValues = new Object();
   var strPassword;
   var saveCookie;
   var isIE;
   var passwordWindow;
   
   isIE = (navigator.appName == "Microsoft Internet Explorer");            
         
   if (GetCookie("ValidUser") == "N") {
      if (isIE) {
         returnValues = window.showModalDialog("password.html", "","dialogHeight: 400px; dialogWidth: 800px; center: Yes; resizable: No; status: No;");
   
         if (returnValues == null) {
            strPassword = "X";
            saveCookie = "N";
         }      
         else {    
           strPassword = returnValues.password;
           saveCookie = returnValues.cookie;
         }   
      }
      else {
         strPassword = prompt("Please enter the Bellevue Park password");
         saveCookie = "N";
      }   
     
      if ( !isValidPassword(strPassword) ) {
         window.location = "error.html";
        return false;
      }
      else {
         SetCookie("ValidUser", "Y", saveCookie);
         return true;
      }
   }  
   else {
      return true;
   }
}

function renderXMLContent(xmldata, xsldata) {
   var isIE;
   
   isIE = (navigator.appName == "Microsoft Internet Explorer");

   if (isIE) {
       var xml = new ActiveXObject("Microsoft.XMLDOM");
       xml.async = false;
       xml.load(xmldata);
       
       var xsl = new ActiveXObject("Microsoft.XMLDOM");
       xsl.async = false;
       xsl.load(xsldata);
       
       XMLContent.innerHTML = xml.transformNode(xsl);
   }
   else {
      try {
          var processor = new XSLTProcessor();
          var xsl = document.implementation.createDocument("", "", null);
          var xml = document.implementation.createDocument("", "", null);

          xsl.async = false;
          xsl.load(xsldata);
          processor.importStylesheet(xsl);
          xml.async = false;
          xml.load(xmldata);
    
          var result;
          result = processor.transformToDocument(xml);      
          XMLContent.innerHTML = result.body;
      }
      catch (exception) {
         alert("Exception caught: " + exception.message);
      }
   }
}
