
#= require jquery
#= require jquery_ujs
#= require public/color-thief.min.js


#= require jquery.bxslider
#= require jquery.easing.1.3
#= require vendor/jquery.ui.widget
#= require vendor/tmpl.min
#= require vendor/jquery.iframe-transport
#= require vendor/jquery.fileupload
#= require vendor/jquery.fileupload-ui
#= require vendor/jquery.fileupload-process
#= require vendor/flipclock.js

#= require public/prettify.js
#= require public/jquery.jOrgChart.js
#= require public/jquery.magnific-popup.min

#= require bootstrap-p




@resize = ->

  $("#document_cart").css('margin-top': (($(window).height()-($("#document_cart").outerHeight()+0))/ 2-30)+'px')
  
  $(".with_ratio").each ->
    ratio = parseFloat($(this).data("ratio"))
    height = $(this).width()*ratio
  
    $(this).css("height",height+"px")
  
  
  $(".customer_message_list .height_frame").css
    "height" : $(".customer_message_show").height()+"px"
  min_height = 0
  
  min_height = $(window).height() - $(".top").height() - $(".top_home").height() - $(".bottom").height() - 0

  $("#main").css("min-height", min_height+"px")

  $("iframe").each ->
    $(this).css
      "height" : Math.round($(this).width()/ 1.77)+"px"

  if $(window).width() > 1250
    $(".infos .main").css
      "position" : "static"
    $(".bottom_image").css
      "left" : "0px"

  else
    $(".infos .main").css
      "position" : "relative"
    $(".bottom_image").css
      "left" : "-120px"




  $("#large").css "min-height", ($(window).height()-30)+"px"

  $(".bxslider").each ->


    height = ($(window).height())
    optimal_height = Math.round($(this).width()/ $(this).data("ratio"))
    if optimal_height < height
      height = optimal_height

    $(this).find("li").css("max-height", height+"px")


  
@flash_delay = ->
  $("#flashs").find(".alert").each ->

    if !$(this).hasClass("delay")
      $(this).addClass("delay")
      $(this).delay(3000).fadeOut();

@scrollToAnchor = (aid) ->
  aTag = $("#" + aid )
  $("html,body").animate({scrollTop: aTag.offset().top}, 1000)
  return



bottom = 0
prev_link = ""


$("document").ready ->

  flash_delay();
  resize()
  
    
$(window).on "resize", ->
  resize()