
#= require jquery
#= require ./shared/jquery-ui
#= require jquery_ujs
#= require ./shared/jquery.strings.js
#= require ./shared/jquery.utils.js
#= require_tree ./front
#= require ./shared/responsiveslides.js

$(document).ready ->

  if ( $("#top .menu").height() + 300 ) < $(window).height()
    $(".contact").css("position", "absolute")
    
  $(".rslides").responsiveSlides
    prevText: "<img src='/arrow-prev.png'/>"
    nextText: "<img src='/arrow-next.png'/>"
    auto: true
    timeout: 2500
    pager: false
    nav: true
    speed: 500
    namespace: "callbacks"
    before: ->
      $(".events").append "<li>before event fired.</li>"
      return

    after: ->
      $(".events").append "<li>after event fired.</li>"
      return
  
  
  $(".rslides").click ->
    $(this).closest(".rslides_container").toggleClass("big")
    
 

    
  prev_link = ""
  $("body").on "click", ".open", ->
    prev_link = $(this)
    
    $("body").append($("<div class='big'></div>"))
    $(".big").append $("<img class='img'/>").attr("src", $(this).attr("href"))
    if prev_link.closest(".gallery_images").length > 0
      $(".big").append("<a class='prev' href='#'><img src='/arrow-prev.png'></a><a class='next' href='#'><img src='/arrow-next.png'></a>")
    
   
    $(".big").click ->
      $(this).remove()
    
    $(".big .next").click ->
      if prev_link.next(".open").length > 0
        link = prev_link.next(".open")
      else
        link = prev_link.closest(".gallery_images").children(".open:first")
    
      
      $(".big img:first").attr("src", link.attr("href"))
    
      prev_link = link
      return false
    
    
    $(".big .prev").click ->
      if prev_link.prev(".open").length > 0
        link = prev_link.prev(".open")
      else
        link = prev_link.closest(".gallery_images").children(".open:last")
    
      
      $(".big img:first").attr("src", link.attr("href"))
    
      prev_link = link
      return false
      
    

        
      
    return false
  

  
    
