// font replacement
Cufon.replace('h1');

jQuery(document).ready(function($) {

  // cycle (http://malsup.com/jquery/cycle/options.html)
  $.fn.cycle.transitions.peekABoo = function($cont, $slides, opts) { /* modified from turnUp */
    opts.before.push(function(curr, next, opts) {
      $.fn.cycle.commonReset(curr,next,opts,true,false);
      opts.cssBefore.top = next.cycleH;
      opts.animIn.height = next.cycleH;
    });
    opts.cssFirst  = { top: 0 };
    opts.cssBefore = { left: 0, height: 0 };
    opts.animIn	   = { top: 0 };
    opts.animOut   = { height: 0, top: $(opts.next).height() };
  };

  $("div#sidebar_pics").cycle({
    fx: 'peekABoo',
    speed: 2500,
    random: 1,
    sync: 0,
    pause: 1,
    autostop: 0,
    timeout: 8000,
    next: '#sidebar_pics'
  });

  // equalize blocks.
  $.fn.v_justify = function(block_sel) {
    var min_height = 100;
    $(this).find(block_sel).each(function() {
      var element = $(this);
      if (element.height() > min_height) {
        min_height = element.height();
      }
    });
    $(this).find(block_sel).css({height: min_height+"px"});
  }
  $("div#page").v_justify("div#sidebar, div#content");
  var sidebar_h = $("div#sidebar").height() - (132 - 36); 
  /* 132 = sidebar-inner -> margin-top */
  /* 36 = content-wrapper -> padding-top */
  $("div#sidebar-inner").css({height:sidebar_h+"px"});

  // click modal dialog
  $("div#click_modal").dialog({
      autoOpen: false,
      buttons: {
          "Continue to Registration":function() {
            window.location=$("a.register_now-link").eq(0).attr("href");
          },
          "Go back to site": function() {
            $(this).dialog("close");
          }
      },
      draggable: false,
      modal: true,
      resizable: false
  });
  $("a.register_now-link").bind('click', function(e) {
    $("div#click_modal").dialog('open');
    e.preventDefault();
  });

});
