// _______________________________________________________________________
// FUNCTION preload: preload images
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
function preload(imgObj,imgSrc)
{
	if (document.images) {
		eval(imgObj+' = new Image()');
		eval(imgObj+'.src = "'+imgSrc+'"');
	}
}

preload("img0", "images/nav_titel_over.gif");
preload("img1", "images/nav_sprecher_over.gif");
preload("img2", "images/nav_autor_over.gif");
preload("img3", "images/nav_regie_over.gif");
preload("img4", "images/nav_musik_over.gif");
preload("img5", "images/nav_team_over.gif");
preload("img6", "images/nav_grafik_over.gif");
preload("img7", "images/nav_aktuell_over.gif");
preload("img8", "images/nav_hoerspielpark_over.gif");
preload("img9", "images/nav_links_over.gif");
preload("img10", "images/nav_newsletter_over.gif");
preload("img11", "images/nav_kontakt_over.gif");
preload("img11", "images/nav_warenkorb_over.gif");
preload("img11", "images/nav_suche_over.gif");
preload("img12", "images/t_hoerspielpark_over.gif");
preload("img13", "images/detnav_bestellung_over.gif");
preload("img14", "images/detnav_download_over.gif");
preload("img15", "images/detnav_material_over.gif");
preload("img16", "images/detnav_vorhoeren_over.gif");

// _______________________________________________________________________
// FUNCTION toggleContent: show and hide content
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
function toggleContent(content1, content2)
{
  for (var i=0; i<arguments.length; i++)
  {
    if (document.getElementById(arguments[i]))
    {
      if (document.getElementById(arguments[i]).style.display == "block")
        document.getElementById(arguments[i]).style.display = "none";
      else
        document.getElementById(arguments[i]).style.display = "block";
    }
  }
}

// _______________________________________________________________________
// FUNCTION showAudioPlayer: shows the audio player for prelistening
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
function showAudioPlayer()
{
  document.getElementById("audioPlayer").style.display = "block";
  document.getElementById("l_vorhoeren").style.display = "none";
}

// _______________________________________________________________________
// FUNCTION openDetail: open detail window with image
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
function openDetail(src)
{
  var winProperties = "toolbar=no,location=no,directories=no,status=no,copyhistory=no,width=200,height=100,resizable=yes,scrollbars=yes";
  var url_neu = "detail_img.html";
  var myWin = open(url_neu, src, winProperties);
}

// _______________________________________________________________________
// FUNCTION openShop: open the shop popup
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
function popitup(url) {
	newwindow=window.open(url,'name','height=100,width=100');
	if (window.focus) {newwindow.focus()}
	return false;
}


// _______________________________________________________________________
// FUNCTION checkform: checks required fields for newsletter subscription
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
function checkform() {
  for (i=0;i<fieldstocheck.length;i++) {
    if (eval("document.forms[0].elements['"+fieldstocheck[i]+"'].value") == "") {
      alert("Bitte gib eine "+fieldnames[i]+" an.");
      eval("document.forms[0].elements['"+fieldstocheck[i]+"'].focus()");
      return false;
    }
  }
  return true;
}

var fieldstocheck = new Array();
var fieldnames = new Array();
function addFieldToCheck(value,name) {
  fieldstocheck[fieldstocheck.length] = value;
  fieldnames[fieldnames.length] = name;
}

/*
 * Tooltip script
 * powered by jQuery (http://www.jquery.com)
 *
 * written by Alen Grakalic (http://cssglobe.com)
 *
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */

this.tooltip = function()
{
  /* CONFIG */
  xOffset = 10;
  yOffset = 20;
  // these 2 variable determine popup's distance from the cursor
  // you might want to adjust to get the right result
  /* END CONFIG */
  $("a.tooltip").hover(function(e)
  {
    this.t = this.title;
    this.title = "";
    $("body").append("<p id='tooltip'>"+ this.t +"</p>");
    $("#tooltip")
    .css("top",(e.pageY - xOffset) + "px")
    .css("left",(e.pageX + yOffset) + "px")
    .fadeIn("fast");
  },
  function()
  {
    this.title = this.t;
    $("#tooltip").remove();
  });

  $("a.tooltip").mousemove(function(e)
  {
    $("#tooltip")
    .css("top",(e.pageY - xOffset) + "px")
    .css("left",(e.pageX + yOffset) + "px");
  });
};

// _______________________________________________________________________
// FUNCTION showSearchBox: shows the search box
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
function showSearchBox()
{
  document.getElementById("searchform").style.display = "block";
  document.getElementById("marginalNav7").style.display = "none";
  document.getElementById("query").value = "Titel oder Person";
}

/*
 * Init search box autocomplete
 *
 * for more info visit http://www.devbridge.com/projects/autocomplete/jquery/
 *
 */
var options, a;
jQuery(function()
{
  options = {
    serviceUrl: '_index.php?usr_action=suggest',
    minChars: 1,
    delimiter: /(,|;| )\s*/, // regex or character - add space as devider between first and lastname
    maxHeight: 400,
    width: 170,
    zIndex: 9999,
    deferRequestBy: 0, //miliseconds
    // callback function:
    onSelect: function(value, data) {
      // retrieve id from oid
      var id = data.substring(data.indexOf(':') + 1, data.length);
      // get context: person or produktion and compile params
      if (data.indexOf('Person') != -1) {
        var params = "context=person&peid=" + id;
      }
      else {
        var params = "context=produktion&prid=" + id;
      }
      // open url
      location.href = "_index.php?" + params; }
  };
  a = $('#query').autocomplete(options);
});

