var where = {
  landestheater:  'neustrelitz', 
  schauspielhaus: 'neubrandenburg', 
  konzertkirche:  'neubrandenburg', 
  schlossgarten:  'neustrelitz', 
  unterwegs:      ''
};

for (o in where) {
  img1 = new Image(); img1.src="/img/orte/"+o+"_klein.gif";
  img3 = new Image(); img3.src="/img/orte/blink-"+o+".gif";
}

function mov1(who){
  $('#img_spielort').attr('src', "/img/orte/"+who+"_klein.gif");
  if (where[who]) $('#img_'+where[who]).attr('src', '/img/orte/blink-'+who+'.gif');
}

function mou1(who){
  $('#img_spielort').attr('src', "/img/1x1_trans.gif");
  if (where[who]) $('#img_'+where[who]).attr('src', "/img/1x1_trans.gif");
}

reswarning = function(){
  var windowHeight  = window.innerHeight || document.body.offsetHeight;
  var windowWidth   = window.innerWidth  || document.body.offsetWidth;
  $('#reswarning')[(parseInt(windowWidth)<800 || parseInt(windowHeight)<600) ? 'show' : 'hide']();
}

function flyPlane(){
  var p, plane;
  p = [
    ['#t_plane', -510, 1700],
    ['#o_plane', 1700, -510]
  ][ (Math.random()>0.5) ? 0 : 1 ];

  if ((plane = $(p[0])) && plane.size()) {
    plane.css({left: p[1], top: 100+Math.floor(Math.random()*600)}).animate({left: p[2]}, 35000, 'linear', flyPlane);
  } else {
    flyPlane();
  }
}

init = function(){
  var ort;
  Common.initRolloverImgs();

  for (ort in where){
    $('#a_'+ort).hover(
      function(o){ return function(){mov1(o);} }(ort),
      function(o){ return function(){mou1(o);} }(ort)
    );
  }

  setTimeout(function(){var button; if (button = $('#navi_service_heute')) button.click(); }, 2500);

  reswarning();

  $('#newsletter').click(function(){
    $('#newsletter_popup').toggle();
  });

  $('#nl_pop_close').click(function(){$('#newsletter_popup').hide()});
  
  $('#newsletter_form').submit(function (){  
    $.ajax({
      url:        'processNewsletterForm.php', 
      method:     "post",  
      data:       $("#newsletter_form").serializeArray(),  
      error:      function (oXHR) {  
        $('#feedback').html(oXHR.statusText);  
      },  
      beforeSend: function (oXHR) {  
        $('#feedback').html('Ihre Anmeldung wird versandt.');  
      },                            
      complete:   function(oXHR) {  
        $('#feedback').html(oXHR.responseText);
        setTimeout(function(){ $('#newsletter_popup').toggle(); }, 2000);
      }
    });
    return false;
  });

  flyPlane();

  function unclip(){
    $('#sk-banner').animate({clip: 'rect(0px, 385px, 200px, 0px)'});
  }

  function clip(){
    $('#sk-banner').animate({clip: 'rect(0px, 0px, 200px, 0px)'});
  }

  $('#sk-logo').hover(unclip, function(){});
  $('#sk-banner').hover(unclip, clip);
}                                                      


window.onresize = reswarning;

