/* ---------------------------------------
 * Filename: engine.js
 * Version: 1.5.0 (2009-8-05) yyyy-mm-dd
 * Description: script configurations and document onload functions - multiple dependencies
 * Website:
 * Author: Anthony Eggert - http://www.stylephreak.com
 ----------------------------------------- */
var Stylephreak = { 

	showAll : function () {
		$('#page,#toppanel').show();		
	},

	// Link Treatments
    treatLinks: function() { 
		// Link Treatment - Find all links with external designations and open them in a new window (validates Strict)
        $('a[rel="external"]').click(function() {
            window.open($(this).attr('href'));
            return false;
        }); 
    },
    // Cufon Font Replacements (http://cufon.shoqolate.com)
    cufonFonts: function() {
        $.getScript("/wp-content/themes/savingpoint/library/media/js/ext/Bell_Centennial.font.js",
        function() {
		
			Cufon.replace('#content blockquote.hilite', {
				textShadow: '#555 1px 1px 1px'
			});
        });		
    },
    // Rounded Corners (http://malsup.com/corner/)
    roundedCorners: function() {
        $.getScript("/wp-content/themes/savingpoint/library/media/js/ext/jquery.corners.js",
        function() {
            $('.rounded,.comment-list li').corner();
            $('.widget').corner();
        });
    },
	
    dropDownMenu: function() {
        $("#nav-container ul.nav").superfish(); 
    },
	
    slideshow: function() {
        $('head').append('<link>');
        css = $('head').children(':last');
        css.attr({
            rel: 'stylesheet',
            type: 'text/css',
            href: '/wp-content/themes/savingpoint/library/media/js/ext/dotSlider/css/slideshow.css'
        });
        $.getScript("/wp-content/themes/savingpoint/library/media/js/ext/dotSlider/jquery.tools.min.js",
        function() {
			/*$("#slides-window").scrollable()*/
            $("#slides-window").scrollable({
                easing: 'linear',
                size: '1',
                items: '#slides-wrap',
                loop: true,
                keyboard: false,
                next: '.advanceButton' ,
                speed: '2600'
            }).navigator().autoscroll(7000);
        });
    },
    loginPanel: function() {
        $('head').append('<link>');
        css = $('head').children(':last');
        css.attr({
            rel: 'stylesheet',
            type: 'text/css',
            href: '/wp-content/themes/savingpoint/library/media/js/ext/loginPanel/css/loginPanel.css'
        });
		// Expand Panel
	$("#open,.open").click(function(){
		$("div#panel").slideDown("slow");
	
	});	
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");	
	});		
	$("#toggle a,.open").click(function () {
		$("#toggle a").toggle();
	});		

    }	
}

// functions to run when the DOM is ready
$(document).ready(function() {		   
	Stylephreak.loginPanel();				   
	Stylephreak.cufonFonts();	
	Stylephreak.slideshow();	
	Stylephreak.dropDownMenu();			
});
// functions to run after page is fully loaded
$(window).load(function() {	
	Stylephreak.roundedCorners();							
    Stylephreak.treatLinks();	
	Stylephreak.showAll();
});