
function SplashHomepage()
{
  this.splashTitle = 'Kewlox Systeemmeubelen';
  this.splashPath  = 'opt/splash/';
  this.splashURL   = '/'+this.splashPath;
    
  this.cookieTimeout = 1*60*60*1000; // one hour
  this.cookieName    = 'kewlox_splash';
  
  this.init = function()
  {    
    if(navigator.appName == 'Microsoft Internet Explorer')
    {
       if(navigator.appVersion.indexOf('MSIE 6.0') != -1)
       {
          return;
       }
    }
    
    var cookieValue = this.readCookie(this.cookieName);
    
    // create or update cookie
    
    this.writeCookie(this.cookieName, 'visited', this.cookieTimeout);

    if(cookieValue != 'visited')
    {
      var html = '';
      html += '<html>';
      html += '<head><title>'+this.splashTitle+'</title></head>';
      html += '<frameset><frame src="'+this.splashURL+'"/></frameset>';
      html += '</html>';  
      
      document.clear();
      document.writeln(html);
    }
  };
  
  this.writeCookie = function(name,value,duration)
  {
    var composed = name+"="+value;
    if (typeof duration != 'undefined')
    {
      var date = new Date();
      date.setTime(date.getTime()+duration);
      composed += "; expires="+date.toGMTString();
    }
    composed += "; path=/";
    
    document.cookie = composed;
  };

  this.readCookie = function(name)
  {
    var startswith = name + "=";
    var parts = document.cookie.split(';');
    
    for(var i=0;i < parts.length;i++)
    {
      var part = parts[i];
      
      // trim whitespace before text
      while (part.charAt(0)==' ')
      {
        part = part.substring(1, part.length);
      }
      
      // find cookie name read cookie value
      if (part.indexOf(startswith) == 0)
      {
        return part.substring(startswith.length, part.length);
      }
    }
    
    // cookie not found
    return null;
  };
  
  this.init();
};

//new SplashHomepage();

