/* Sheep's Journey */

$(document).ready(function(){
  
  // Forms
  // binding to the load field settings event to initialize the checkbox
  $(document).bind("gform_load_field_settings", function(event, field, form){
          $("#field_placeholder").val(field["placeholder"]);
  });

  // Set the placeholder copy
  if(typeof placeholder !== 'undefined') {
	var values = $.parseJSON(placeholder);
	
	$.each(values, function(key, value) {
		$(value.field).attr('placeholder', value.value);
	});
  }

  // Request workshop form - selected checkbox/radio
  $("label.radio, label.checkbox").bind("click", function(e){
    e.preventDefault();
    var $el = $(this), 
        $parent = $el.parent();
    if ($el.hasClass("checkbox")) {
      $el.toggleClass("selected");
    } else {
      $parent.find("label").removeClass("selected");
      $el.addClass("selected");
    }
  });
  
  
  // Tooltips
  // uses jquery tools tooltip
  // http://flowplayer.org/tools/tooltip/index.html
  $(".media-icon a[title]").tooltip({
    effect:"fade",
    layout:'<div class="tooltip-right"><div class="tooltip-left"></div><div class="tooltip-arrow"></div>',
    offset:[-5,0]
  });

  // Header carousel
  $(".scrollable").scrollable({ circular: true });
  
  $(".media-icon a").click(function(event) {
    event.preventDefault();
    
    var index = $(this).attr('href');
    
    if (index) {
      index = Number(index.split('-').pop());
      $(".scrollable").data("scrollable").seekTo(index);
    }
    
  });
  
});
