var NS = (document.layers) ? 1 : 0;
var IE = (document.all) ? 1: 0;
var IE5 = (IE && navigator.appVersion.indexOf("5")!=-1);
var IE4 = (IE && navigator.appVersion.indexOf("4")!=-1);
var step=3;

var menus=new Array(
    new Array('m1_i0','m1_i1','m1_i2'),
    new Array('m2_i0','m2_i1','m2_i2','m2_i3','m2_i4'),
    new Array('m3_i0','m3_i1'),
    new Array('m4_i0','m4_i1','m4_i2','m4_i3','m4_i4','m4_i5'),
    new Array('m5_i0','m5_i1','m5_i7','m5_i2','m5_i3','m5_i4','m5_i5','m5_i6'),
    new Array('m6_i0','m6_i1'),
    new Array('m7_i0','m7_i1','m7_i2','m7_i3','m7_i4')
);

var l_name = new Array("news","team","gallery","season","fun","sponsor","press");
var scroll=0;

function show_menu(n) {
    scroll=0;
    if (IE) {
        deselectall(n);
    var l = eval("document.all."+l_name[n]);
        if (l.clientHeight + l.style.pixelTop > document.body.scrollTop + document.body.clientHeight) {
            var t=l.clientHeight + l.style.pixelTop - document.body.clientHeight + 2;
            scroll=1;
        while (document.body.scrollTop+step < t) {
           document.body.scrollTop += step;
        }
            document.body.scrollTop=t;
        }
    }
    if (NS) {
        var bottom = screen.height - (screen.height-screen.availHeight) - (window.outerHeight-window.innerHeight) - 2*window.screenY;
        var l = document.layers[l_name[n]];
    if (l.clip.height + l.top > window.pageYOffset + bottom) {
            scroll=1;
        while (l.clip.height + l.top > window.pageYOffset + bottom) {
            window.scrollBy(0, step);
        }
            window.scrollTo(0, l.clip.height + l.top - bottom + 2);
    }
    }
}

function select(e,menu) {
    var m = menus[menu];
    for (var i=0;i<m.length;i++) {
    if (m[i] != e.id) deselect(eval("document.all."+m[i]))
    }
    e.className="select-cell";
}

function deselectall(menu) {
    var m = menus[menu];
    for (var i=0;i<m.length;i++) {
    deselect(eval("document.all."+m[i]))
    }
}

function deselect (e) {
    if (e.className!="normal-cell") e.className="normal-cell";
}


function setup () {
    for(var i=0;i<menus.length;i++) {
    if ((!IE5) && (!IE4)) eval('document.all.'+l_name[i]+'.style.pixelTop+=8');
    deselectall(i)
    };
}

if (IE) window.onload=new Function("setup()");

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow2(theURL,winName, height, width, bResize) { //v2.5
    features = 'resizable=1, scrollbars=1';
    if (bResize == 1)
        features = features + ',left=0, top=0, height=' + (screen.height-60) + ',width='+ (screen.width-10);
    else
    {
        if (height < screen.height)
        {
            if (width < screen.width)
                features = features + ', height=' + height + ',width='+ width;
            else
                features = features + ',left=0, top=0, height=' + height + ',width='+ (screen.width-10);
        }
        else
        {
            features = features + ',left=0, top=0, height=' + (screen.height-60) + ',width='+ (screen.width-10);
        }
    }
    penWin= open("",winName,features);
    penWin.document.open();
    penWin.document.write('<html><head><title>Picture</title>');
    penWin.document.write('</head><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onBlur="close()" onLoad="focus()">');
    penWin.document.write('<img src='+theURL+'>');
    penWin.document.write('</body></html>');
    penWin.document.close();
}
 

function MM_openBrWindow(theURL,winName,features) { //v2.0
 penWin=window.open(theURL,winName,features);
 penWin.document.open();
  penWin.document.write('<html><head><title>Wallpaper</title>');
  penWin.document.write('</head><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"  onBlur="close()"  onLoad="focus()">');
  penWin.document.write('<img src='+theURL+'>');
  penWin.document.write('</body></html>');
  penWin.document.close();
  }


