var butImageOut  = new Image();
var butImageOver = new Image();
var butImageOn   = new Image();

butImageOut.src  = '/img/template/menubut.gif';
butImageOver.src = '/img/template/menubut_over.gif';
butImageOn.src   = '/img/template/menubut_on.gif';

var typeValue = new Array();
typeValue['Admin'] = 0;
typeValue['Rolemodel'] = 1;
typeValue['Support'] = 1;
typeValue['Teacher'] = 2;
typeValue['Student'] = 3;
typeValue['Public'] = 4;

function miOver(menuEl,menuBut){
//  menuEl.style.padding='0px';
//  menuEl.style.border='1px outset #CCEEFF';
//  menuEl.style.border='1px outset';
  menuEl.style.cursor  = "hand";
  menuEl.style.backgroundColor='#FCB74C';
  document.images[menuBut].src= butImageOver.src;
}

function miOut(menuEl,menuBut){
//  menuEl.style.padding='1px';
//  menuEl.style.border='none';
  menuEl.style.backgroundColor='#FEC874';
  document.images[menuBut].src= butImageOut.src;
}

function miDown(menuEl,menuBut){
//  menuEl.style.padding='0px';
//  menuEl.style.border='1px inset #A7CBE8';
//  menuEl.style.border='1px inset';
  menuEl.style.backgroundColor='#476a75';
  document.images[menuBut].src= butImageOn.src;
}

function pageLoaded(){
  if(document.all){
    if(document.all.pageTable){
      document.all.pageTable.style.position = 'relative';
      if(document.all.bannerExtBottom){document.all.bannerExtBottom.style.visibility = 'visible'}
      if(document.all.bannerExtCorner){document.all.bannerExtCorner.style.visibility = 'visible'}
      if(document.all.bannerExtension){document.all.bannerExtension.style.visibility = 'visible'}
    }
  }
}

var dreamStreamWindow = null;
function openDreamStream(){
  // var d;
  // d = new Date();
  // var ui = "t"+d.getTime();
  if(!dreamStreamWindow || dreamStreamWindow.closed){
    dreamStreamWindow = window.open("http://dreamstream.reddust.org/welcome-to-gondwanaland.html","dreamStreamWindow","fullscreen=yes,width="+screen.availWidth+",height="+(screen.availHeight+12)+",top=0,left=0,resizable=yes,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,directories=no");
  }else{
    dreamStreamWindow.focus();
  }
}

function bannerExtensionHTML(inHTML){
  if(document.all){
    document.all.bannerExtension.innerHTML = '<nobr>'+inHTML+'</nobr>';
  }
}

function bannerExtensionLeft(inLeft){
  if(document.all){
    document.all.bannerExtension.style.left = inLeft + 'px';
  }
}

function XXshowMenuItem(mType){ return typeValue[mType] >= typeValue[getCookie('group')] }
function showMenuItem(mType){ return typeValue[mType] >= typeValue[top.userType] }
function returnUserType(){ return top.userType }

function getCookieVal (offset) {
         var endstr = document.cookie.indexOf (";", offset);
            if (endstr == -1)
            endstr = document.cookie.length;
         return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (name) {
         var arg = name + "=";
         var alen = arg.length;
         var clen = document.cookie.length;
         var i = 0;
         while (i < clen) {
             var j = i + alen;
             if (document.cookie.substring(i, j) == arg)
             return getCookieVal (j);
             i = document.cookie.indexOf(" ", i) + 1;
             if (i == 0) break;
        }

     return null;
}

    var sawsiWindow = null;
    function openSaw(url){
      var loc = (url != null) ? "/cgi-sawsi/modifypage.pl?url="+url : "/cgi-sawsi/openpage.pl?funk=frame";
      if(!sawsiWindow || sawsiWindow.closed){
        sawsiWindow = window.open(loc,"sawsiWindow","fullscreen=yes,width="+screen.availWidth+",height="+(screen.availHeight+12)+",top=0,left=0,resizable=yes,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,directories=no");
        sawsiWindow.focus();
      }else{
        if(url != null){ sawsiWindow.location = loc }
        sawsiWindow.focus();
      }
    }
