﻿

jQuery.noConflict(); //changes $ to jQuery(prevents conflicting '$' naming between libraries)
jQuery(document).ready(function($) { // Do jQuery stuff using $



    // Image replacement for headings - better to use flash ?

    $('h1').each(function() {
        var headingText = $(this).html();

        if (headingText.lastIndexOf(' ') > 0) {

            //make last word orange

            var firstWords = headingText.substring(0, headingText.lastIndexOf(' '));
            var lastWord = headingText.substring(headingText.lastIndexOf(' ') + 1);

            $(this).html(
            '<img src="/umbraco/ImageGen.ashx?text=' + firstWords + '&amp;FontSize=26&amp;Font=/fonts/Cheryl.ttf&amp;FontColor=black&amp;BgColor=557895" alt="' + headingText + '" />'
            + '<img src="/umbraco/ImageGen.ashx?text=' + lastWord + '&amp;FontSize=26&amp;Font=/fonts/Cheryl.ttf&amp;FontColor=FF9933&amp;BgColor=557895" />');
        }
        else {
            $(this).html('<img src="/umbraco/ImageGen.ashx?text=' + headingText + '&amp;FontSize=26&amp;Font=/fonts/Cheryl.ttf&amp;FontColor=black&amp;BgColor=557895" alt="' + headingText + '" />');
        }

    });

    $('div#sidebar div.widget > span.heading').each(function() {
        var headingText = $(this).html();
        $(this).html('<img src="/umbraco/ImageGen.ashx?text=' + headingText + '&amp;FontSize=20&amp;Font=/fonts/Cheryl.ttf&amp;FontColor=white&amp;BgColor=6285a2" alt="' + headingText + '" />');
    });




    /*
    //superfish    
    $('ul.sf-menu').superfish();
    */

    $("ul.sf-menu").supersubs({
        minWidth: 12,   // minimum width of sub-menus in em units 
        maxWidth: 27,   // maximum width of sub-menus in em units 
        extraWidth: 1     // extra width can ensure lines don't sometimes turn over 
        // due to slight rounding differences and font-family
    }).superfish();  // call supersubs first, then superfish, so that subs are 
    // not display:none when measuring. Call before initialising 
    // containing tabs for same reason. 



    $('.tagcloud a').tagcloud({
        size: { start: 8, end: 16, unit: "pt" },
        color: { start: '#cde', end: '#ffffff' }
    });



    $('a[rel*=lightbox]').lightBox({
        overlayBgColor: '#FFF',
        overlayOpacity: 0.6,
        imageBlank: '/Images/jquery.lightbox-0.5/lightbox-blank.gif',
        imageLoading: '/Images/jquery.lightbox-0.5/lightbox-ico-loading.gif',
        imageBtnClose: '/Images/jquery.lightbox-0.5/lightbox-btn-close.gif',
        imageBtnPrev: '/Images/jquery.lightbox-0.5/lightbox-btn-prev.gif',
        imageBtnNext: '/Images/jquery.lightbox-0.5/lightbox-btn-next.gif',
        containerBorderSize: 10,
        containerResizeSpeed: 200,
        keyToClose: 'x',
        keyToPrev: 'p',
        keyToNext: 'n',
        fixedNavigation: true
    });


}); 
