function init(){

  // Recreate $.post with 'error' callback
  $.post = function( url, data, callback, type ) {
		if ( jQuery.isFunction( data ) ) {
			callback = data;
			data = {};
		}
    settings = {
			type: "POST",
			url: url,
			data: data,
			dataType: type
		};
    if ( jQuery.isFunction( callback ) ) {
      settings.success = callback;
    } else {
      if ( jQuery.isFunction( callback.success ) ) {
        settings.success = callback.success;
      }
      if ( jQuery.isFunction( callback.error ) ) {
        settings.error = callback.error;
      }
    }

		return jQuery.ajax(settings);
	}
  // Create missing function
  $.postJSON = function(url, data, callback) {

    // Force disable jQuery cache setting
    var cache = jQuery.ajaxSettings.cache; jQuery.ajaxSettings.cache = false;

    $.post(url, data, callback, "json");

    // Restore jQuery caching setting
    jQuery.ajaxSettings.cache = cache;
  };


  // Replace subheader with sifrtxt
  $('#display-header').sifrtxt({ src: '/swf/header.swf', flashVars: {textcolor: 'ffffff', txt: $('h3.pg-title').text(), img: $('#display-header').css('background-image') }});
  // Replace footerpics with swf pics
  $('#display-home').sifrtxt({ src: '/swf/homepage.swf', width:'800', height:'365', flashVars: { xmlFile: '/public/images/home_images/homepage_images.xml'}}).css('margin-left:-20px');
  $('#display-footer').sifrtxt({ src: '/swf/imgbar.swf', flashVars: { xmlFile: '/public/imgbar.xml'}});
  //$('#display-footer').sifrtxt({flashVars: { img: $('#subheader').css('background-image')}});

  $('#FLVconstruction').sifrtxt({mode:'replace',  src: '/swf/FLVPlayer_Progressive.swf', width:'380', height:'300', flashVars: { skinName:"/swf/Halo_Skin_3" , streamName:"/public/timelapse/FCPC2Full091608_2min_F8_FastStart_400K" , autoPlay:"false" , autoRewind:"false" }});

  $('h1.sans').sifrtxt();
  $('h2.serif').sifrtxt( { src: '/includes/sIFR/swanerquote.swf' });


  // Replaced with call within sifrtxt - $('.sifr-replaced').css('visibility','visible');

  $('.quote').sifrtxt({src: '/includes/sIFR/swanerquote.swf' , flashVars: { textcolor: '#4d714d', linkcolor: '#4d714d', hovercolor: '#003300' }});
  // Replaced with call within sifrtxt - $('.sifr-replaced').css('visibility','visible');


  // Create superfish menus
  var nav = '';
  $('#main-navigation ul').superfish({
    hoverClass:    'sfHover',             // the class applied to hovered list items
    pathClass:     'overideThisToUse',    // the class you have applied to list items that lead to the current page
    pathLevels:    1,                     // the number of levels of submenus that remain open or are restored using pathClass
    delay:         800,                   // the delay in milliseconds that the mouse can remain outside a submenu without it closing
    animation:     {height:'show'},       // an object equivalent to first parameter of jQuery’s .animate() method
    speed:         'normal',              // speed of the animation. Equivalent to second parameter of jQuery’s .animate() method
    autoArrows:    false,                 // if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance
    dropShadows:   false,                 // completely disable drop shadows by setting this to false
    disableHI:     true
  });

  $('#subnav ul').superfish({
    animation: {height:'show'},           // slide-down effect without fade-in
    autoArrows:    false,                 // if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance
    dropShadows:   false,                 // completely disable drop shadows by setting this to false
    delay:     1200                       // 1.2 second delay on mouseout
  });

  // Attach safari-specific stylesheet
  if ($.browser.safari) {
    $('head').append('<link rel="stylesheet" href="/css/safari.css" type="text/css" media="all" />');
  }

  // Add rounded corners (where req'd) for all but IE6
  if (!($.browser.msie && $.browser.version < '7.0')) {
    $(".bubble").append('<div class="crn ur">&nbsp;</div><div class="crn ul">&nbsp;</div><div class="crn lr">&nbsp;</div><div class="crn ll">&nbsp;</div>');
  }

  if ($('body').is('.docent')) {
    $('form.signupform button').livequery('click',function(e){
      // Handle cancel
      if ($(this).is('.cancel')) {
        Shadowbox.close();
      }
      // Handle submit
      if ($(this).is('.submit')) {
        e.preventDefault();
        // Identify which volunteer link created this form
        var frm = $(this).parents('form'),
            day = frm.find('input[name=day]').val(),
            vol = frm.find('input[name=vol]').val(),
            voltgt = $('table.calendar #'+day+' td:eq('+(vol.replace(/\D/g,''))+') li:eq('+(vol.slice(-1)=='a'?0:1)+')');
        // Create callback functions for ajax reponse
        var pass = function(data){
          Shadowbox.close();
          voltgt.replaceWith('<li class="filled"><span>'+data.name+'</span></li>');
        };
        var fail = function(data) {
          msg = $('#sb-content form div.msg');
          if (msg.length > 0) { msg.remove(); }
          $('#sb-content form').prepend('<div class="msg">'+data.msg+'</div>').find('.msg').fadeTo(3000,1).slideUp();
        };
        // Submit information and process response
        $.postJSON(
          /* url */       $(this).parents('form').attr('action'),
          /* form data*/  $(this).parents('form').serialize(),
          /* callbacks*/  { success: function(data){ if (data.status == 'pass') { pass(data); } else { fail(data); } },
                            error: function() { fail({msg:'There was an error submitting your information. Please call us to volunteer.'}); }
                          }
        );
      }
    });

    // Assign shadowbox actions to each shift link
    var frmtpl = $('#signupform').remove();
    $('table.calendar a').each(function(e){
      // Create a clone of the form template
      var frm = frmtpl.clone();

      // Extract info from table
      var dat = {
        date: $(this).parents('tr').children('td:first-child').text(),
        shift: $('table.calendar th#'+$(this).attr('class')).text(),
        day: $(this).parents('tr').attr('id'),
        vol: $(this).attr('class').replace('shift','vol')+($(this).parents('ul').find('li').index($(this).parent('li')) == 0 ? 'a' : 'b')
      };

      // Modify form fields to contain appropriate values
      frm.find('#datetxt').html(dat.date+' &mdash; '+dat.shift);
      // jQuery's .val() function doesn't change the actual HTML of form fields, so
      // the form fields are removed from the template, rewritten, and appended back
      // into the template
      var tmpday = $('<div/>').append(frm.find("input[name=day]").remove()).html(),
          tmpvol = $('<div/>').append(frm.find("input[name=vol]").remove()).html();
          if (tmpday.match(/value=/i) === null) { tmpday = tmpday.replace(/input/i,'input value=""'); }
          if (tmpvol.match(/value=/i) === null) { tmpvol = tmpvol.replace(/input/i,'input value=""'); }
      $('form',frm).append($(tmpday.replace(/value="*.*?"* /,'value="'+dat.day+'"')),$(tmpvol.replace(/value="*.*?"* /,'value="'+dat.vol+'"')));

      // Genearte HTML for shadowbox
      var frmhtml = frm.html();

      // Open shadowbox on click
      $(this).click(function(e){
        e.stopPropagation(); e.preventDefault();
        //alert(dat.date+":"+dat.shift+":"+dat.day+":"+dat.vol);
        Shadowbox.open({
          content:    frmhtml,
          player:     "html",
          title:      "",
          height:     340,
          width:      680
        });
      });
    });
  }
}

// Function to replace text with sifr/flash
$.fn.sifrtxt = function(newattr){
  return this.each(function(){
    // Set up default values
    var defaults = {
      //width:        '100%',
      //height:       '100%',
      bgcolor:      'none',
      wmode:        'transparent',
      flashVersion: '8.0.0',       // required flash version
      mode:         'sifr',

      src:          '/includes/sIFR/sans.swf',
      flashVars:    { img: 'none', textcolor: '#000000', linkcolor: '#61361d',
                      css: [
                          '* { color: #000000; text-align: left; }',
                          'a { color: #61361d; text-decoration: none; }',
                          'a:hover { text-decoration: underline; }'
                      ].join(' ')

      }
    };
    if (typeof newattr == 'undefined') { newattr = defaults; }

    // Define attributes using defaults and any new attributes
    var attr = $.extend({},defaults,newattr);
    attr.flashVars = $.extend({},defaults.flashVars,newattr.flashVars);

    // Retrieve contents of element to be replaced by flash, and assign
    // flashvars as req'd
    attr.flashVars.img = typeof(attr.flashVars.img)=='undefined'?'none':attr.flashVars.img.replace(/(url\(([\"\'])*)(.*?)([\"\']*\))/,"$3");

    var newobj = $(this).jmedia(
        {version:attr.flashVersion,flashXI:true,flashXIsrc: "/includes/XI.swf",mode:attr.mode},
        attr
    );
    newobj.css('visibility','visible');
  });
}

// Prep Shadowbox
Shadowbox.path = '/includes/shadowbox/';
Shadowbox.options = $.extend(Shadowbox.options,{
  players:['img','html'],
  enableKeys:false
});
Shadowbox.init();