function switchClass(myElement, className1, className2) {
  if (myElement.className == className1) {
    myElement.className = className2;
  } else {
    myElement.className = className1;
  }
}
function CoordinateSelected(x, y) {
  // var arg = "@@@@@" + x + "#" + y ;
  // __doPostBack('',arg)
  // window.location.href = "~/stappenplan/2PlanType.aspx?x=" + x + "&y=" + y;
  window.location.href = "2PlanType.aspx?x=" + x + "&y=" + y;
}

function newPoint(drawObject) {
  // debugger;
  var x = drawObject.getWorldXArray()[0];
  var y = drawObject.getWorldYArray()[0];

  // Set the location in the current frame. For the blanco page, do nothing
  // alert(x + ", " + y);
  CoordinateSelected(x, y);
  // ifrmTable.setLocation(x,y);
}

// ///////////////////////////////////////////////////////////////////////////////////////////////

// Set Active Nav
function ActiveNav(Main, Sub) {
  document.getElementById(Main).className = 'active';

  if (Sub && Sub.length > 0) {
    // document.getElementById(Sub).style.display = 'block';
  }
}

// Flash Titel
function FlashTitel(TekstVar, TekstSizeVar, ColorVar, WidthVar, HeightVar) {
  document
      .write("<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' WIDTH='"
          + WidthVar + "' HEIGHT='" + HeightVar + "' id='FlashTitel'>");
  document.write("<PARAM NAME=movie VALUE='../Common/flash/Header.swf'>");
  document.write("<PARAM NAME=quality VALUE=high>");
  document.write("<PARAM NAME=wmode VALUE=transparent>");
  document.write("<PARAM NAME=FlashVars VALUE='TekstVar=" + TekstVar
      + "&TekstSizeVar=" + TekstSizeVar + "&ColorVar=" + ColorVar
      + "&WidthVar=" + WidthVar + "&HeightVar=" + HeightVar + "'>");
  document
      .write("<EMBED FlashVars='TekstVar="
          + TekstVar
          + "&TekstSizeVar="
          + TekstSizeVar
          + "&ColorVar="
          + ColorVar
          + "&WidthVar="
          + WidthVar
          + "&HeightVar="
          + HeightVar
          + "' src='../Common/flash/Header.swf' quality=high wmode=transparent WIDTH='"
          + WidthVar
          + "' HEIGHT='"
          + HeightVar
          + "' NAME='FlashTitel' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED>");
  document.write("</OBJECT>");
}

// Flash Detect
function FlashDetect(FlashCheck) {
  // if(FlashCheck=="FlashEnabled"){
  // clearTimeout(t);
  // Generate Flash
  var embed = document.createElement("embed");
  embed.setAttribute("type", "application/x-shockwave-flash");
  embed.setAttribute("pluginspage",
      "http://www.macromedia.com/go/getflashplayer");
  embed.setAttribute("src", "../Common/flash/Intro.swf");
  embed.setAttribute("quality", "high");
  embed.setAttribute("bgcolor", "#ffffff");
  embed.setAttribute("width", "590");
  embed.setAttribute("height", "190");
  document.getElementById("FlashBlok").appendChild(embed);
  // } else if (FlashCheck == "FlashDisabled") {
  // Show image
  // var img = document.createElement("img");
  // img.setAttribute("id", "FlashAlt");
  // img.setAttribute("src", "img/FlashAlt.jpg");
  // document.getElementById("FlashBlok").appendChild(img);
  // }
}

// Show / Hide Div
function ShowBlock(div, frame) {
  g_div = div;
  g_frame = frame;
  PauseBlock = setTimeout("PauseShowBlock()", 500);
}
function PauseShowBlock() {
  document.getElementById(g_div).style.display = 'block';
  document.getElementById(g_frame).style.display = 'block';
  // set iframe height
  document.getElementById(g_frame).style.height = document
      .getElementById(g_div).offsetHeight;
}
function HideBlock(div, frame) {
  clearTimeout(PauseBlock);
  document.getElementById(div).style.display = 'none';
  document.getElementById(frame).style.display = 'none';
}

// Random IMG
function RandomImg() {

  var Images = new Array()
  Images[0] = 'bruggen001_t.jpg'
  Images[1] = 'cultuurhistorie001_t.jpg'
  Images[2] = 'eb001_t.jpg'
  Images[3] = 'bruggen001_t.jpg'
  Images[4] = 'fonteinen001_t.jpg'
  Images[5] = 'golfslag001_t.jpg'
  Images[6] = 'goten001_t.jpg'
  Images[7] = 'harde oevers001_t.jpg'
  Images[8] = 'hoogteverschillen001_t.jpg'
  Images[9] = 'kunst001_t.jpg'
  Images[10] = 'meren001_t.jpg'
  Images[11] = 'rust001_t.jpg'
  Images[12] = 'spiegeling001_t.jpg'
  Images[13] = 'stromend001_t.jpg'
  Images[14] = 'varen001_t.jpg'
  Images[15] = 'vijvers001_t.jpg'

  var Start = '<a href="inspiratie.html"><img src="../Common/Image/fotos/';
  var End = '"></a>';

  var whichImg = Math.floor(Math.random() * (Images.length));
  document.write(Start + Images[whichImg] + End);

}

/**
 * Deze functie zet een popupaan of uit, afhankelijk van de huidige status. De
 * naam van het uitklapbare deel wordt als parameter meegegeven.
 *
 * @param pO
 *          naam van het uitklapbare deel dat getoggeld moet worden.
 * @return niets
 */
function togglePopup(pO) {
  var o = document.getElementById(pO);
  if (o == null) {
    return;
  }
  if (o.style.display != "block") {
    o.style.display = "block";
  } else {
    o.style.display = "none";
  }
}

function kiesElement(pElement, pStartWith, pLiElement) {
  console.group("kiesElement");
  console.group("parameters");
  console.log("pElement:", pElement);
  console.log("pStartWith", pStartWith);
  console.log("pLiElement", pLiElement);
  console.groupEnd();

  var divName = pStartWith + pElement;
  if (pLiElement == null) {
    var liName = "li" + pElement;
  } else {
    var liName = "li" + pLiElement;
  }
  var elements = document.getElementsByTagName("div");
  var divMin1 = null;
  var elementFound = false;
  for ( var n = 0; n < elements.length; n++) {
    var element = elements[n];
    if (element.id != null) {
      if (element.id.startsWith(pStartWith)) {
        element.style.display = "none";
        if (element.id == pElement) {
          elementFound = true;
        }
        if (elementFound == false) {
          divMin1 = element.id;
        }
      }
    }
  }
  var o = document.getElementById(divName);
  console.log("Div " + divName, o);
  if (o != null) {
    o.style.display = "block";
  }

  var elements = document.getElementsByTagName("li");
  for ( var n = 0; n < elements.length; n++) {
    var element = elements[n];
    if (element.id != null) {
      if (element.id.startsWith("li")) {
        element.style.backgroundColor = "";
      }
    }
  }
  var o = document.getElementById(liName);
  console.log("Li " + liName, o);
  if (o != null) {
    o.style.backgroundColor = "#77C3F4";
  }
  if (pElement.startsWith("Keuze")) {
    var ul = document.getElementById("ulKeuze");
    if (ul != null) {
      ul.style.display = "block";
    }
  }
  if (pElement.startsWith("Dossier")) {
    var ul = document.getElementById("ulDossier");
    if (ul != null) {
      ul.style.display = "block";
    }
  }

  console.groupEnd();
}

/**
 * Een element aanzetten en de bijbehorende elementen uitzetten.
 *
 * @param pElement
 *          id van het element wat aangezet moet worden
 * @param pStartWith
 *          begin van hey id van de elementen die uitgezet moeten worden
 * @return niets
 */
function toggleElement(pElement, pStartWith) {

  var elements = document.getElementsByTagName("div");
  for ( var n = 0; n < elements.length; n++) {
    var element = elements[n];
    if (element.id != null) {
      if (element.id != pElement && element.id.startsWith(pStartWith)) {
        element.style.display = "none";
      }
    }
  }
  togglePopup(pElement);
}


function toggelAfstemming(pCheckbox, pTrDatum, pTrVerslag) {
  if (pCheckbox == null) {
    return;
  }
  if (pCheckbox.checked) {
    var dtm = document.getElementById(pTrDatum);
    dtm.style.display = "";
    var verslag = document.getElementById(pTrVerslag);
    verslag.style.display = "";
  } else {
    var dtm = document.getElementById(pTrDatum);
    dtm.style.display = "none";
    var verslag = document.getElementById(pTrVerslag);
    verslag.style.display = "none";
  }
}

function showAskUser(pButton, pDivId) {
  console.group("showAskUser");
  console.group("parameters");
  console.log("pButton:", pButton);
  console.log("pDivId:", pDivId);
  console.groupEnd();
  
  pButton.style.display = "none";
  var div = document.getElementById(pDivId);
  div.style.display = "block";
  console.groupEnd();
}


function cancelAskUser(pButton) {
  var parent = pButton.parentNode;
  parent.style.display = "none";
  var parentId = parent.id;
  //window.alert(parentId);
  var akkoordButtonId = parentId.replace(/^divAskUser/, "btnAkkoord");
  //window.alert(akkoordButtonId);
  var akkoordButton = document.getElementById(akkoordButtonId);
  akkoordButton.style.display = "block";
}
