var DHTML = (document.getElementById || document.all || document.layers);

var pad;
var rubriek  = new Array();
var link     = new Array();
var optie_nl = new Array();
var optie_en = new Array();
var i;

//functions

function menu( this_rubriek, taal, diepte, afb_pad )
{
  pad = bepaal_pad( diepte );

  var img;
  var tekst;
  var optie;
  var linkto;
  var blnk;
  var thislink;

  i = 0;
  vul_lijst( "home"      , "index.htm?id=home",      "Oddlings home", "" ); 
  vul_lijst( "alienzz"   , "index.htm?id=alienzz",   "Alienzz"      , "" ); 
//vul_lijst( "marvinmoon", "index.htm?id=m&m",       "Marvin & Moon", "" );
  vul_lijst( "mannekino" , "index.htm?id=mannekino", "Mannekino"    , "" ); 
  vul_lijst( "16feet"    , "index.htm?id=16feet",    "16feet"       , "" ); 
  vul_lijst( "workshop"  , "index.htm?id=workshop",  "acro workshop", "" ); 
  vul_lijst( "speellijst", "speellijst.htm",         "speellijst"   , "playing list" );
//vul_lijst( "pers"      , "", "in de pers"   , "in press" );
  vul_lijst( "foto"      , "", "foto"         , "photos" ); 
  vul_lijst( "video"     , "video.htm",              "video"        , "" ); 
  vul_lijst( "nieuws"    , "nieuws.htm",             "nieuws"       , "news" ); 
  vul_lijst( "downloads" , "downloads.htm",          "downloads"    , "" ); 
  vul_lijst( "games"     , "", "OddGames"     , "" ); 
//  vul_lijst( "oddcard" , "", "OddCards"     , "" ); 
  vul_lijst( "guestbook" , "", "gastenboek"   , "guestbook" ); 
  vul_lijst( "contact"   , "index.htm?id=contact",   "contact"      , "" ); 

  if ( afb_pad == "" || afb_pad == null )
  {
    afb_pad = pad;
  }

  blnk = 430 - (25 * rubriek.length);

  document.write(
    "<table width=100% cellspacing=0 cellpadding=0 border=0>" +
    "  <tr>" +
    "    <td valign=bottom height=" + blnk + ">" +
    "      <img src=" + pad + "/gfx/kop_tekst.gif class=kop>" +
    "     </td>" +
    "" );

  for( idx = 0; idx < rubriek.length; idx++)
  {
    document.write(
      "  </tr>" +
      "  <tr valign=top align=right>" +
      "" );

    if ( rubriek[idx] != null && rubriek[idx] != "" )
    {
      linkto = rubriek[idx] + "/index.htm";
      if ( link[idx] != "" )
      {
        linkto = link[idx];
      }

      if ( linkto.indexOf( "?") > -1 )
      {
	linkto += ",";
      }
      else
      {
	linkto += "?";
      }

      img = "gfx/menu/" + rubriek[idx];

      optie = optie_nl[idx];
      if ( taal == "en" && optie_en[idx] != "" )
      {
        img = img + "_en";
	optie = optie_en[idx];
      }

      if ( rubriek[idx] == this_rubriek )
      {
	img = img + "_aan";
	thislink = linkto;
      }
      else
      {
	img = img + "_uit";
      }

      linkto += "lang=" + taal;

      tekst =
        "<a href=" + pad + linkto + ">" +
	"<img id='" + rubriek[idx] + "' src='" + pad + img + ".gif' alt='" + optie + "' " +
	" onMouseOver=\"zetStatus(this,'over','" + img + "');self.status='" + optie + "';return true\" " +
	" onMouseOut=\"zetStatus(this,'out','" + img + "');self.status='';return true\" " + 
	"width=110 height=20 border=0>" +
	"</a>";

      document.write(
	"    <td>" + tekst + "</td>" +
	"" );
    }
  }

  document.write(
    "  </tr>" +
    "  <tr valign=bottom>" +
    "    <td align=right height=50>" +
    "      <a href='" + pad + thislink + "lang=nl' onMouseOver=\"self.status='Nederlands';return true\" onMouseOut=\"self.status='';return true\"><img src=" + pad + "gfx/vlag_nl_anim.gif alt=\"Nederlands\" width=40 height=30 border=0></a>" +
    "      <a href='" + pad + thislink + "lang=en' onMouseOver=\"self.status='English';return true\"    onMouseOut=\"self.status='';return true\"><img src=" + pad + "gfx/vlag_en_anim.gif alt=\"English\" width=40 height=30 border=0></a>" +
    "    </td>" +
    "  </tr>" +
    "  <tr valign=bottom>" +
    "    <td align=right height=50>" +
    "	   <a href='http://www.facebook.com/Oddlings' target='_blank'><img src='" + pad + "gfx/facebook.png' alt='follow Oddlings on facebook' border=0></a>" +
    "    </td>" +
    "  </tr>" +
    "</table>" +
    "" );

}

function vul_lijst( rubr, lnk, opt_nl, opt_en )
{
  rubriek[i]  = rubr;
  link[i]     = lnk;
  optie_nl[i] = opt_nl;
  optie_en[i] = opt_en;
  i++;
}

function disp_img( naam, tekst, breed, hoog, dik, diepte, link )
{
  var pad = bepaal_pad( diepte );
  var schaduw_breed = breed - dik;
  var schaduw_hoog  = hoog  - dik;

  document.write(
    "<table cellspacing=0 cellpadding=0 border=1>" +
    "  <tr>" +
    "    <td colspan=2 rowspan=2>" +
    "" );

  if ( link != null && link != "" )
  {
    document.write(
      "<a href=\"" + link + "\" target=_parent>" +
      "" );
  }

  document.write(
    "<img src=" + naam + " width=" + breed + " height=" + hoog + " alt=\"" + tekst + "\" border=0>" +
    "" );

  if ( link != null && link != "" )
  {
    document.write(
      "</a>" +
      "" );
  }

  document.write(
    "</td>" +
    "    <td><img src=" + pad + "leeg.gif width=" + dik + " height=" + dik + " border=0></td>" +
    "  </tr>" +
    "  <tr>" +
    "    <td><img src=" + pad + "schaduw_rechts.jpg width=" + dik + " height=" + schaduw_hoog + " border=0></td>" +
    "  </tr>" +
    "  <tr>" +
    "    <td><img src=" + pad + "leeg.gif width=" + dik + " height=" + dik + " border=0></td>" +
    "    <td><img src=" + pad + "schaduw_onder.jpg width=" + schaduw_breed + " height=" + dik + " border=0></td>" +
    "    <td><img src=" + pad + "schaduw_hoek.jpg width=" + dik + " height=" + dik + " border=0></td>" +
    "  </tr>" +
    "</table>" +
    "" );
}

function bepaal_pad( diepte )
{
  var pad = "";
  for( i = 1; i < diepte; i++)
  {
    pad = pad + "../";
  }
  if ( pad == "" )
  {
    pad = "./";
  }
  return( pad );
}

function zetStatus(objImg, strState, img)
{
  var strSrc = pad;

  switch(strState.toLowerCase())
  {
    case "over":
      objImg.style.cursor = 'hand';
      strSrc += img.substring(0, img.length-3) + "aan";
      break;
    case "out":
      objImg.style.cursor = 'pointer';
      strSrc += img;
      break;
    default:
      break;
  }
	
  strSrc += ".gif";

//alert( strSrc );

  objImg.src = strSrc;
}

function zet_map( loc )
{
  var locationstring = "a"+loc;
  var pos, str, map_pos;
  var mapnaam  = "";

  pos = locationstring.indexOf('?');
  if ( pos != -1 )
  {
    str = locationstring.substr(pos+1);
    map_pos  = str.indexOf("map=");
    if ( map_pos != -1 )
    {
      mapnaam = str.substring(map_pos+4)
      pos = mapnaam.indexOf(',');
      if ( pos != -1 )
      {
        mapnaam = mapnaam.substring(0, pos);
      }
    }
  }
  return( mapnaam );
}

function zet_taal( loc )
{
  var locationstring = "a"+loc;
  var pos, str, taal_pos;
  var taal = "nl";

  pos = locationstring.indexOf('?');
  if ( pos != -1 )
  {
    str = locationstring.substr(pos+1);
    taal_pos  = str.indexOf("lang=");
    if ( taal_pos != -1 )
    {
      taal = str.substring(taal_pos+5)
      pos = taal.indexOf(',');
      if ( pos != -1 )
      {
        taal = taal.substring(0, pos);
      }
    }
  }

  return( taal );
}

var winWidth = 0, winHeight = 0;
var mainWidth = 0, mainHeight = 0;

function windowSize()
{
  return;

  if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
  {
    //IE 4 compatible
    //alert( "IE 4");
    winWidth = document.body.clientWidth;
    winHeight = document.body.clientHeight;
  }
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
  {
    //IE 6+ in 'standards compliant mode'
    //alert( "IE 6+");
    winWidth = document.documentElement.clientWidth;
    winHeight = document.documentElement.clientHeight;
  }
  else if( typeof( window.innerWidth ) == 'number' )
  {
    //Non-IE
    //alert( "Non-IE");
    winWidth = window.innerWidth;
    winHeight = window.innerHeight;
  }
  //window.alert( 'Width = ' + winWidth );
  //window.alert( 'Height = ' + winHeight );

  mainWidth  = winWidth  - 280;
  mainHeight = winHeight;
}

function zet_param( loc, param, def )
{
  var locationstring = "a"+loc;
  var pos, str, param_pos;
  var val = def;
  param += "=";

  pos = locationstring.indexOf('?');
  if ( pos != -1 )
  {
    str = locationstring.substr(pos);
    param_pos  = str.indexOf( param );

    if ( param_pos != -1 )
    {
      val = str.substring(param_pos+param.length)
      pos = val.indexOf(',');
      if ( pos != -1 )
      {
        val = val.substring(0, pos);
      }
    }
  }

  return( val );
}

