// front-end javascripts go here

jQuery(function($) {
	//put your init junk here
  Cufon.replace('#nav a, h1, h2'); 
  
  if ($('#header').length > 0) setInterval(function() { replaceSlide() }, 3000);
  if ($('#flash-header').length > 0) swfobject.embedSWF('http://hojocentral.factore.ca/flash/hojoheader.swf', 'flash-header', 960, 180, '8.0.0', null, {}, {wmode: 'transparent'});
  
});

function replaceSlide() { 
  newImage = $('.on-deck img:first')
  oldSlide = $('.on-display:random');
  //console.log(newImage);
  //console.log(newImage);
  newImage.prependTo(oldSlide);
  $('img:last', oldSlide).fadeOut("slow", function() { $(this).appendTo('.on-deck').show(); });
}

jQuery.jQueryRandom = 0;
jQuery.extend(jQuery.expr[":"],
{
    random: function(a, i, m, r) {
        if (i == 0) {
            jQuery.jQueryRandom = Math.floor(Math.random() * r.length);
        };
        return i == jQuery.jQueryRandom;
    }
});

$(window).load(function() {
  $('#nav, #content').equalHeights();
})
