/* ---------------------------------------
 * 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 = { 

	// 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;
        }); 
		// Link Treatment - Append the appropriate class name to each document link (e.g. class="doc")		
        $('a[href]').each(function() {
            if ((C = $(this).attr('href').match(/[.](doc|xls|pdf|zip|txt)$/))) {
                $(this).addClass(C[1]);
            }
        });
        // Link Treatment -  Iconize Links (jQuery UI)
        $('a.doc').prepend('<span class="ui-icon ui-icon-document"></span>');
        // Link Treatment - Appends the class 'ui-state-active' to the current navigation link's parent.	
        $("#nav a").each(function() {
            var hreflink = $(this).attr("href");
            if (hreflink.toLowerCase() == location.href.toLowerCase()) {
                $(this).parent("li").addClass("ui-state-active");
            }
        });
    },
	// UI Accordion
    uiAccordion: function() {
        $("#accordion").accordion({ });
    },
	
    // Rounded Corners (http://malsup.com/corner/)
    tableSorter: function() {
        $.getScript("/wp-content/themes/saunders-music/library/media/js/ext/jquery.tablesorter.min.js",
        function() {
			$.tablesorter.defaults.widgets = ['zebra']; 
    		 $("#tracks").tablesorter({ 
        // pass the headers argument and assing a object 
        headers: { 
            3: {   sorter: false  } 
        } ,
        headers: { 
		    0: {   sorter: false  } 	
        } 
    });  
			 
        });
    },

    // Rounded Corners (http://malsup.com/corner/)
    roundedCorners: function() {
        $.getScript("/wp-content/themes/saunders-music/library/media/js/ext/jquery.corners.js",
        function() {
            $('.rounded').corner();
			$('.entry-meta').corner();

        });
    }
}

// functions to run when the DOM is ready
$(document).ready(function() {
    Stylephreak.treatLinks();	
	Stylephreak.roundedCorners();
	Stylephreak.uiAccordion();
	Stylephreak.tableSorter();
});
// functions to run after page is fully loaded
$(window).load(function() {	

	
});