// School Psychology Blog User interface
var SPS = {

    /**
     * Init functions
     */         
    init: function () {
        SPS.rollovers();
		SPS.blockquote();
        SPS.emulateHover($("#nav > li"));
        SPS.preloadImages(["images/buttons/leave-comment_over.gif"
                          ]);
        if($.browser.msie){
            SPS.fixIE6flicker(true);
			
        }                                 
    },
   
    /**
     * Emulate hover
     */
    emulateHover: function (items) {
        items.hover(
            function () {
                $(this).addClass('hover');
            },
            function () {
                $(this).removeClass('hover');
            }
        )
    },

    /**
     * Rollovers buttons
     */
    rollovers: function () {
        $('.rollover').hover(
            function () {
                $(this).attr('src', $(this).attr('src').replace(/.gif/, '_over.gif'));
            },
            function () {
                $(this).attr('src', $(this).attr('src').replace(/_over.gif/, '.gif')); 
            }
        );
     },
     
    /**
     * Fix background image flicker in IE6
     */         
    fixIE6flicker: function (fix) {
        try {
            document.execCommand("BackgroundImageCache", false, fix);
        } catch(err) { }
    },   
     
     
    /**
     * Preload images
     * @param {Array} images array with names of images   
     */               
    preloadImages: function (images) {
        for (var i = 0; i < images.length; i++) {
            var image = new Image();
            image.src = images[i];
        }
    },

    /**
     * Blockquote
     */
	blockquote: function () {
	$("blockquote").wrap("<div class='quote'></div>");
	}
}

$(document).ready(function () {
    SPS.init();
});
