﻿$(document).ready(function(){
  function flash()
  {
    var flash_width = $(window).width();
    var flash_height = Math.ceil(flash_width / 1.783);
    if (flash_width >= 1000)
    {
      $('.flash').css('height',flash_height+'px');
    }
    else
    {
      var flash_height = Math.ceil(1000 / 1.783);
      $('.flash').css('width','1000px');
      $('.flash').css('height',flash_height+'px');
    }
  }
  flash();
  $(window).resize(function(){flash();})

  var menu_top = $(window).height() - $('#header').height() - $('#menu').outerHeight() - 100;
  var flash_width = $(window).width();
  var flash_height = Math.ceil(flash_width / 1.783);
  if (flash_width < 1000)
  {
    flash_height = Math.ceil(1000 / 1.783);
  }
  if (menu_top > flash_height - 100 || flash_width < 1000)
  {
    menu_top = flash_height - 100;
  }
  //$('.dop_menu').css('top',menu_top+'px');
  function scrollmenu()
  {
    menu_top_new = $(window).height() - $('#header').height() - $('#menu').outerHeight() - 100 + $(window).scrollTop();
    var flash_width = $(window).width();
    var flash_height = Math.ceil(flash_width / 1.783);
    if (flash_width < 1000)
    {
      flash_height = Math.ceil(1000 / 1.783);
    }

    if (menu_top_new > flash_height - 100)
    {
      $('.dop_menu').css('position','absolute');
      //menu_top_new = flash_height - 100;
      //$('.dop_menu').css('top',menu_top_new+'px')
    }
    else
    {
      $('.dop_menu').css('position','fixed');
      //$('.dop_menu').animate({top: menu_top_new}, {duration: 100, specialEasing: {top: 'linear'}, complete: function(){} });
    }


  }
  $(window).scroll(function(){ scrollmenu() })
  $(window).resize(function(){ scrollmenu() })
})
