var active_action = false;

if( typeof XMLHttpRequest == "undefined" ) XMLHttpRequest = function() {
  try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
  try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
  try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
  try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
  throw new Error( "This browser does not support XMLHttpRequest." )
}


function ajaxGetContent(url) {
  http = new XMLHttpRequest();
  try {
    http.open("GET", url, true);
    //http.setRequestHeader("Connection", "close");
    http.onreadystatechange = targetDiv;
    http.send(null);
  } catch (e) {
    alert(e);
  }

}

function targetDiv() {
  if (http.readyState == 4) { // Complete
  if (http.status == 200) { // OK response
      document.getElementById("sectionContent").innerHTML = http.responseText;
    } else {
      alert("Problem: " + http.statusText);
    }
  }
} 


function showTitle(DirId) {
  switch(DirId) {
    case 1:
      document.getElementById('sectionTitle').innerHTML = "<img src='html.pics/title.bio.jpg' alt='' height='125' width='798' usemap='#title.newsc51276e2' border='0'>";
      break;
    case 2:
      document.getElementById('sectionTitle').innerHTML = "<img src='html.pics/title.news.jpg' alt='' height='125' width='798' usemap='#title.newsc51276e2' border='0'>";
      break;
    case 3:
      document.getElementById('sectionTitle').innerHTML = "<img src='html.pics/title.music.jpg' alt='' height='125' width='798' usemap='#title.newsc51276e2' border='0'>";
      break;
    case 4:
      document.getElementById('sectionTitle').innerHTML = "<img src='html.pics/title.image.gallery.jpg' alt='' height='125' width='798' usemap='#title.newsc51276e2' border='0'>";
      break;
    case 5:
      document.getElementById('sectionTitle').innerHTML = "<img src='html.pics/title.merchandise.jpg' alt='' height='125' width='798' usemap='#title.newsc51276e2' border='0'>";
      break;
    case 6:
      document.getElementById('sectionTitle').innerHTML = "<img src='html.pics/title.contact.jpg' alt='' height='125' width='798' usemap='#title.newsc51276e2' border='0'>";
      break;
  }
}


function goBio() {
  showTitle(1);
  ajaxGetContent("content_section.php?DirId=1");
}

function goNews() {
  showTitle(2);
  ajaxGetContent("content_section.php?DirId=2");
}

function goNewsFromArchive() {
  window.scrollTo(0,0);
  document.getElementById("sectionContent").innerHTML = "";
  showTitle(2);
  ajaxGetContent("content_section.php?DirId=2");
}

function goNewsArchive() {
  window.scrollTo(0,0);
  document.getElementById("sectionContent").innerHTML = "";
  showTitle(2);
  ajaxGetContent("content_section.php?DirId=2&archive=1");
}


function goArticle(articleId) {
  showTitle(2);
  ajaxGetContent("content_section.php?DirId=2&articleId=" + articleId);
}

function goMusic() {
  showTitle(3);
  ajaxGetContent("music.php");
}

function goImagegallery() {
  showTitle(4);
  ajaxGetContent("image_gallery.php");
}

function goMerchandise() {
  showTitle(5);
  ajaxGetContent("merchandise.php");
}

function goContact() {
  showTitle(6);
  ajaxGetContent("contact.php");
}

function showImageOnGallery(image, image_title) {
  document.getElementById('layerForImage').innerHTML = "<img src='../include/php/show_thumbnail.php?image=" + image +"&width=391&height=391' height='391' width='391' border='0'>";
  document.getElementById('layerForImageTitle').innerHTML = image_title;
}
