jQuery.preloadImages = function()
{
    jQuery.each (arguments,function (e) {
        jQuery ('<img src="' + this + '" />');
    });
}

$.preloadImages('wp-content/themes/oforo-2009/images/bg-about-us-vision.png', 'wp-content/themes/oforo-2009/images/bg-about-us-mission.png');

$(document).ready(function() {
   var pageMark = $('div#wrapper div#middle div#flipthru h2.page-mark');
   var page = $('div#wrapper div#middle div#flipthru div.page');
   var background = $('div#wrapper div#middle div#flipthru');

   pageMark.click(function(event) {
       event.preventDefault();

       var pageKey = $(this).attr('title');
       
       if ($(this).attr('title') == 'Why Ornaments 4 Orphans') {
           background.css('background-image', 'url(wp-content/themes/oforo-2009/images/bg-about-us-why.png)')
       } else if ($(this).attr('title') == 'Our Vision') {
           background.css('background-image', 'url(wp-content/themes/oforo-2009/images/bg-about-us-vision.png)');
       } else if ($(this).attr('title') == 'Our Mission') {
           background.css('background-image', 'url(wp-content/themes/oforo-2009/images/bg-about-us-mission.png)');
       }

       $('div#flipthru h2.page-mark').each(function() {
           if ($(this).hasClass('active')) {
               $(this).removeClass('active');
           }
       });

       $('div#flipthru div.page').each(function() {
           if($(this).hasClass('active')) {
               $(this).removeClass('active');
           }
       });

       $(this).addClass('active');
       $('div#flipthru div.page[title="' + pageKey + '"]').addClass('active');
   });
});
