

// Navibilder Preloaden
var PRELOAD_BILDER = new Array();

PRELOAD_BILDER[0] = new Image();
PRELOAD_BILDER[0].src = 'http://www.gastro-award.de/images/menu/home.png';
PRELOAD_BILDER[1] = new Image();
PRELOAD_BILDER[1].src = 'http://www.gastro-award.de/images/menu/menu_body.png';
PRELOAD_BILDER[2] = new Image();
PRELOAD_BILDER[2].src = 'http://www.gastro-award.de/images/menu/menu_left.png';
PRELOAD_BILDER[3] = new Image();
PRELOAD_BILDER[3].src = 'http://www.gastro-award.de/images/menu/menu_right.png';

var PRELOAD_IMAGES = new Array();

PRELOAD_IMAGES[0] = new Image();
PRELOAD_IMAGES[0].src = 'http://www.gastro-award.de/images/menu/award-hover.png';
PRELOAD_IMAGES[1] = new Image();
PRELOAD_IMAGES[1].src = 'http://www.gastro-award.de/images/menu/award.png';
PRELOAD_IMAGES[2] = new Image();
PRELOAD_IMAGES[2].src = 'http://www.gastro-award.de/images/menu/teilnahme-hover.png';
PRELOAD_IMAGES[3] = new Image();
PRELOAD_IMAGES[3].src = 'http://www.gastro-award.de/images/menu/teilnahme.png';
PRELOAD_IMAGES[4] = new Image();
PRELOAD_IMAGES[4].src = 'http://www.gastro-award.de/images/menu/magazin-hover.png';
PRELOAD_IMAGES[5] = new Image();
PRELOAD_IMAGES[5].src = 'http://www.gastro-award.de/images/menu/magazin.png';
PRELOAD_IMAGES[6] = new Image();
PRELOAD_IMAGES[6].src = 'http://www.gastro-award.de/images/menu/pressroom-hover.png';
PRELOAD_IMAGES[7] = new Image();
PRELOAD_IMAGES[7].src = 'http://www.gastro-award.de/images/menu/pressroom.png';
PRELOAD_IMAGES[8] = new Image();
PRELOAD_IMAGES[8].src = 'http://www.gastro-award.de/images/menu/ruckblick-hover.png';
PRELOAD_IMAGES[9] = new Image();
PRELOAD_IMAGES[9].src = 'http://www.gastro-award.de/images/menu/ruckblick.png';
PRELOAD_IMAGES[10] = new Image();
PRELOAD_IMAGES[10].src = 'http://www.gastro-award.de/images/menu/download-hover.png';
PRELOAD_IMAGES[11] = new Image();
PRELOAD_IMAGES[11].src = 'http://www.gastro-award.de/images/menu/download.png';

// Bildwechsel bei mouseover
function changebgpic(id,picnr)
{
  document.getElementById(id).style.background='url('+PRELOAD_IMAGES[picnr].src+') no-repeat';
}


/////////////////////////////////////////////////////////////////////////////////////////////////



// Forward wenn Unterframe angezeigt  wird
function forwardframe()
{	
	if (parent && parent.frames && parent.frames.length == 0)
	{
		window.location.href = "http://www.gastro-award.de/redirect.php?seite=" + window.location.href;
	}
}

// Forward wenn Unterframe angezeigt  wird
function forwardframess()
{	
	if (parent && parent.frames && parent.frames.length == 0)
	{
		window.location.href = "http://www.gastro-award.de";
	}
}


// Forward wenn Unterframe angezeigt  wird IFRAME
function forward()
{
	if (parent && parent.document.getElementById('iframemain') == null)
	{
		window.location.href = "http://www.gastro-award.de";
	}
}





// Popup Fenster für das Video
var newwin;
function flashworker_popup(url,name,eigenschaften) 
{
  newwin = window.open(url,name,eigenschaften); 
  setTimeout('newwin.focus();',200); 
  window.setTimeout("check_flashworker_popup()",2000);
} 

function check_flashworker_popup()
{
  if (newwin.closed == true) 
  {
    window.location.reload();
  }
  else
  {
    window.setTimeout("check_flashworker_popup()",500);
  }
}


// Popup window code
function newWindow(url) 
{
  popupWindow = window.open
  (
    url,
    'popUpWindow',
    'height=500,width=450,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes'
  )
}
function newWindow2(url,w,h) 
{
  popupWindow = window.open
  (
    url,
    'popUpWindow',
    'height='+h+',width='+w+',left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes'
  )
}

// Überprüfung des Topframes
function checkTopFrame()
{
  erg = window.location.href.search(/gastro-guide2.php/);
  if (erg != -1)
  {
    return;
  }
  if (parent.topFrame)
  {
    erg = parent.topFrame.location.href.search(/mediagalerie/);
    if (erg != -1)
    {
      parent.topFrame.location.href = 'http://www.gastro-award.de/page/frameset/topframeohneintro';
    }
  }
}

function scroll_bars()
{
  mainfra = document.body.offsetWidth;
  if (parent.topFrame.document.body)
  {
    topfra = parent.topFrame.document.body.offsetWidth;
  }
  else
  {
    mainfra = 0;
    topfra = 0;
  }
  
  if (mainfra != topfra)
  {
    return true;
  }

  return false;
}

//Iframe Größe anpassen
function iframesize()
{
  if (navigator.userAgent.indexOf("MSIE") != -1)
  {
    if (parent.document && parent.document.getElementById('mainFrame') && $('main'))
    {
      if (parent.document.getElementById('mainFrame').height != $('main').getHeight() + 130)
      {
        parent.document.getElementById('mainFrame').height = $('main').getHeight() + 130;
      }
    }
  }
  else
  {
    if (parent.document && parent.document.getElementById('mainFrame') && $('main'))
    {
      if (parent.document.getElementById('mainFrame').height != $('main').getHeight() + 200)
      {
        parent.document.getElementById('mainFrame').height = $('main').getHeight() + 200;
      }
    }
  }
  
  window.setTimeout("iframesize()", 1000);
}

// Fenstergröße überprüfen 
var BODYLASTWIDTH = 0;
function checkWidth()
{
  var bwidth = $(document.body).getWidth();
  if (BODYLASTWIDTH != 0 && bwidth != BODYLASTWIDTH)
  {
    parent.topFrame.updateMenu12();
  }
  
  BODYLASTWIDTH = bwidth;
}






// Error Handling
window.onerror=function(msg, url, linenumber)
{
  sendErrorMail(msg, url, linenumber);
}

function sendErrorMail(msg, url, linenumber)
{
  // Fehler im Magazinbereich
  if (url.search('gastro-award.de/page/magazin') != -1)
  {
    return;
  }  
  
  // Permission denied Fehler nicht beachten
  //if (msg.search('Permission denied') != -1)
  //  return;

    
  if (!Ajax)
    return;

  var myAjax = new Ajax.Request(
    "/mediagalerie/sendErrorEmail.php", { 
    method: 'post', 
    parameters: {msg: msg, url: url, linenumber: linenumber},
    onComplete: function(originalRequest) {},
    onFailure: function() {}
  });
}


