// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

var open_info = false;

var images_to_preload = ["metalle_active.jpg", "kunststoffe_active.jpg", "spritzteile_active.jpg"];

document.observe("dom:loaded", function() {
  images_to_preload.each(function(image) {
    (new Image()).src = "/_img/" + image;
  });

  $$("div.info").each(function(elem) {
    elem.style.display = "none";
  });

  $$("a.more_link").each(function(elem) {
    elem.style.display = "block";
    elem.innerHTML = "Mehr";
  });

  
  $$("a.pdflink").each(function(elem) {
    elem.observe("click", function() {
      openPDFWin(this.href);
      this.href = "#";
    });
  });

  $$("a.mt").each(function(elem) {
    elem.innerHTML = elem.innerHTML.replace("(at)", "@");
    elem.href = "mailto:" + elem.innerHTML;
  });
  
});

function toggle_info(id) {
  if (open_info !== false && open_info == id) {
    new Effect.BlindUp('info_' + id, { duration: 0.2 });
    open_info = false;
  } else {
    if (open_info !== false) {
      new Effect.BlindUp('info_' + open_info, { duration: 0.2 });
      open_info = false;
    }
    new Effect.BlindDown('info_' + id, { duration: 0.2 });
    open_info = id;
  }
}

function openPDFWin(url) {
  window.open(url, '', 'resizable');
}

