// For IE hover flicker bug
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

// Hello jQuery!
$(document).ready(function(){
// Add class to body to tell the stylesheet that JavaScript is turned on
	$('body').addClass('jsOn');

	//	Add pipes to all links in the navigation, except the last link
	$('#navWork li:not(:last)').append(' |');
	$('#navAbout li:not(:last)').append(' |');

//	Get the current year and put it in the footer the footer
	var currentYear = (new Date).getFullYear();
	$('#copyrightYear').html('&copy;&nbsp;' + currentYear);



$("#container:not(.pageHome)").randombg({
    directory: "/wp-content/themes/chardiet/images/structure/pageBG/", //directory to image folder
    howmany: 4 //how many images are in this folder
});

}); // Bye-bye jQuery!



(function($) {

	$.randombg = {
		defaults: {
			directory: "/wp-content/themes/chardiet/images/structure/pageBG/",
			howmany: 4

		}
	}
    $.fn.extend({
        randombg:function(config) {
            var config = $.extend({}, $.randombg.defaults, config);
			return this.each(function() {
		
				var directory = config.directory, howmany = config.howmany;

				var which = Math.floor(Math.random()*howmany)+1;
				$(this).css({"background-image" : "url(" +directory + which + ".jpg)"});
			  
            })
        }
    })
})(jQuery);
