/**** Scripts für www.zupfinstrumente-emmerich.de ****/


function showImage(strImage, width, height, strTitle) {
  width +=20; height +=20;
  var availWidth  = screen.availWidth - 10;
  var availHeight = screen.availHeight - 32;
  var width  = Math.min(width, availWidth);
  var height = Math.min(height, availHeight);
  var left   = (availWidth - width) / 2;
  var top    = (availHeight - height) / 2;

  var strBig = (width == availWidth || height == availHeight) ? "yes" : "no";

  var strWndParams = "left=" + left + ",top=" + top + ",width=" + width + ",height=" + height +
                     ",resizable=" + strBig + ",scrollbars=" + strBig +
                     ",menubar=no,status=no,toolbar=no,directories=no";

  if (isOpera()) strParams = strParams.replace(/\//g, "%2F");

  checkCloseImage(); // neue Größe erzwingen
  wndImage = self.open(strImage, "_Image_Viewer_", strWndParams);

  if (wndImage != null) {
     wndImage.document.title=strTitle;
     wndImage.focus();
  }
}


function checkCloseImage() {
  if (!this.wndImage);
  else if (!(this.wndImage.closed))
    this.wndImage.close();
}


function onLoadIndex() {
  var strPage, posStrPage, wndPage;

  if (top != self)
    top.location.replace(self.location.href);

  top.status=document.title;

  wndPage = top.window["Page"];
  if (wndPage.location.href != "about:blank") return; // Refresh

  strPage = self.location.href;

  if ((posStrPage = strPage.lastIndexOf("?")) > 0)
    strPage = strPage.substring(posStrPage + 1);
  else
    strPage = "Home.htm";

  wndPage.location.href = strPage;
}


function playFlashVideo(strUrl) {
  var strWndParams = "width=400px,height=300px,scrollbars=no,menubar=no,status=no,toolbar=no,directories=no,dependent=no";

  var strTarget = "../FlashPlayer.htm?" + strUrl;

  wndImage = self.open(strTarget, "_Flash_Player_", strWndParams);
  if (wndImage != null) wndImage.focus();
}


function update()  {
  var wndNav, wndPage, wndHdr, strPage, strUrl, strImg;

  // Hot Links verhindern, Fenster ggfs. aus Aufrufer-Frame befreien:
  if (top == self || top.location.hostname != self.location.hostname) {
    strUrl = self.location.href;
    top.location.replace("index.htm?" + strUrl.substring(strUrl.lastIndexOf("/") + 1));
    return;
  }

  if (!(wndNav = top.window[0])) return;

 // Image der akt. Seite in der Nav-Bar hervorheben:

  if (wndPage = top.window[2]) {
    strPage = wndPage.location.href;
    strPage = strPage.substring(strPage.lastIndexOf("/") + 1, strPage.lastIndexOf("."));
  }
  else
    strPage = "Home";

  var Links = wndNav.document.links;
  if (!Links.length) return;  // Nav-Document noch nicht komplett geladen

  var Link, Img, length, i, bActive;

  for (i = 0, length =  Links.length; i < length; i++) {
    Link = Links[i];

    if (!Link.name) continue;

    if (bActive = (Link.name == strPage)) {
      strImg = "BulletSquareBkWt.gif";
    }
    else
      strImg = "BulletSquare.gif";

    if (Img = Link.getElementsByTagName("img")[0]) {
      Img.src = "../Images/" + strImg;
      Img.border = 0;
    }
   }
}


function updateHome()  {
  ///if (!isMSIE()) return;

  if (screen.availWidth < 900) {
    document.images[0].width=560;
    document.images[0].height=463;
  }
}


function checkMailUrl() {
  var strUrl = "mailto:info" + "@" + "zupfinstrumente" + "-emmerich.de";

  if (isMSIE())
    document.links("Mail").href = strUrl;
  else
    document.links.Mail.href = strUrl;
  
  document.Query.action=strUrl + "?subject=ContactForm&body=" + document.Query.name.value + ": " + document.Query.more.value;
}


function checkMail(Form) {
  Form.useragent.value = navigator.userAgent;
  Form.userlanguage.value = isMSIE() ? navigator.userLanguage : navigator.language;
  return true;
}


function isMSIE() {
  return (navigator.userAgent.indexOf("MSIE") >= 0);
}


function isNetscape() {
  return (navigator.userAgent.indexOf("Netscape") >= 0);
}


function isFirefox() {
  return (navigator.userAgent.indexOf("Firefox") >= 0);
}


function isOpera() {  // klappt bei Opera 8.5 und allen Fälschungsvarianten
  return (navigator.userAgent.indexOf("Opera") >= 0);
}