/**
 * Shows the loading message. Put this code before loading does complete.
 * $Id: loading.js,v 0.10 2009/09/13 15:27:25 polygon Exp $
 * Licensed under The MIT License
 */
(function(){
  var A = window, d = document, F = location, e = d.documentElement,
      o = "px", p = "absolute", q = "loading" + (new Date).getTime(),
      r = "STRONG", s = "#fff", t = "DIV", B = "<", C = ">", G = "on",
      i = "\v" == "v", D = "Body", M = "scroll", N = "none", n = parseInt,
      $ = function(a, b){
        return     b          ? B + a + C + b + B + "/" + a + C : 
           /^[A-Z]+$/.test(a) ? d.createElement(a)              :
           !/[A-Z]/.test(a)   ? d.getElementById(a)             :
                                d.getElementsByTagName(a)[0]
      },
      g = $(t), j = $(t), k = $(r),
      m = function(){
        with (k.style)
          display = display == N ? "" : N;
        setTimeout(m, 500)
      },
      u = function(a, b, c){
        b = a.addEventListener ? a.addEventListener(b, c, 0) : 
            a.attachEvent      ? a.attachEvent(G + b, c)     : 0
      },
      l = function(a, b, c){
        b = a.removeEventListener ? a.removeEventListener(b, c, 0) :
            a.detachEvent         ? a.detachEvent(G + b, c)        : 0
      },
      f, w, h, x, y, z, v, H, I = 0, J, K = 0, L = 3000; // 30 Sec.
      
      v = function(){
        if (!$(q)) {
          z = $(D);
          if (!z)
            setTimeout(v, 1);
          else {
            f = d.body;
            w = (i ? e.clientWidth  || f.clientWidth  || f.scrollWidth  :
                     innerWidth)    || 950;
            h = (i ? e.clientHeight || f.clientHeight || f.scrollHeight :
                     innerHeight)   || 440;
            x = n(w / 2 * 0.86) + o;
            y = n(h / 2 * 0.82) + o;
            with (g.style) {
              position        = p;
              left            = 0;
              top             = 0;
              width           = w + o;
              height          = h + o;
              backgroundColor = "#2C2C29";
              zIndex          = 998
            }
            with (j.style) {
              position        = p;
              left            = x;
              top             = y;
              color           = "#666";
              backgroundColor = "#2C2C29";
              zIndex          = 999;
              fontSize        = 12 + o
            }
            g.id = q;
            j.innerHTML = $(r, "<center><img src='loader.gif'><br><br><p>http://seidojun.com/</p></center>");
            g.appendChild(j);
			z.insertBefore(g, z.firstChild);
            H = function(){
              g.style.top = f.scrollTop || A.pageYOffset || 0
            };
            u(A, M, H);
            m();
            J = function(){
              if (I) {
                I = 0;
                z.removeChild(g);
                A.scrollTo(0, 0);
                if (F.hash)
                  F.hash = F.hash;
                l(A, M, H)
              } else {
                if (++K == L)
                  I = 1;
                setTimeout(J, 10)
              }
            };
            J()
          }
        }
      };
  u(A, "load", function(){
    I = 1
  });
  v();
})();

