// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$.ajaxSetup({ 
  'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
})

$(document).ready(function(){
  $(document).ajaxSend(function(event, request, settings) {
      // do nothing if this is a GET request. Rails doesn't need
      // the authenticity token, and IE converts the request method
      // to POST, just because - with love from redmond.
      if (settings.type == 'GET') return;
      if (typeof(AUTH_TOKEN) == "undefined") return;
      settings.data = settings.data || "";
      settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
    });
  
  // Reset Font Size
  var originalFontSize = $('html').css('font-size');
    $(".resetFont").click(function(){
    $('html').css('font-size', originalFontSize);
  });
  // Increase Font Size
  $(".increaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*1.1;
    if (newFontSize<28) {
      $('html').css('font-size', newFontSize);}
    return false;
  });
  // Decrease Font Size
  $(".decreaseFont").click(function(){
    var currentFontSize = $('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*0.9;
    if (newFontSize>10) {
      $('html').css('font-size', newFontSize);
    }
    return false;
  });
  

	// assign a click event to the exposed element, using normal jQuery coding
	$("#expose").click(function() {

		// perform exposing for the clicked element
		$(this).expose({api: true}).load();

	});
	
	// expose the form when it's clicked or cursor is focused 
  $("form.expose").bind("click keydown", function() { 

      $(this).expose({ 

          // custom mask settings with CSS 
          maskId: 'mask', 

          // when exposing is done, change form's background color 
          onLoad: function() { 
              this.getExposed().css({backgroundColor: '#c7f8ff'}); 
          }, 

          // when "unexposed", return to original background color 
          onClose: function() { 
              this.getExposed().css({backgroundColor: null}); 
          }, 

          api: true 

      }).load(); 
  });
  
  // image overlay
  $("a[rel]").each(function(i) {
    $(this).overlay({ 
                expose: '#6096D4',
                // common configuration for each overlay 
                oneInstance: true,  
                closeOnClick: true
                } 
            ); 
  });
  // $("#trigger1").tooltip({
  //    tip: '#tooltip1',
  //    // custom positioning 
  //    position: ['top', 'center'], 
  // 
  //    // move tooltip a little bit to the right 
  //    offset: [0, 15], 
  // 
  //    // use a simple show/hide effect 
  //    effect: 'toggle', 
  // 
  //    // there is no delay when the mouse is moved out of the trigger 
  //    delay: 0
  // });
  // $("#trigger2").tooltip({
  //   tip: '#tooltip2',
  //   // custom positioning 
  //   position: ['top', 'center'], 
  // 
  //   // move tooltip a little bit to the right 
  //   offset: [270, 0], 
  // 
  //   // use a simple show/hide effect 
  //   effect: 'toggle', 
  // 
  //   // there is no delay when the mouse is moved out of the trigger 
  //   delay: 10
  //   
  // });
  
  // <%=@gallery.id-%>

    
});
