$(document).ready(function(){
    // Tooltips
    $(".location").not('#auckland, #wellington, #masterton').tooltip({
        effect: 'fade',
        offset: [-20,0],
        relative: true,
        opacity: 0.94,
        delay: 100
    });
    // Auckland and wellington tooltips position to the right
    $(".location#auckland").tooltip({
        effect: 'fade',
        position: 'center right',
        offset: [80,20],
        relative: true,
        opacity: 0.94,
        delay: 100
    });

    // Wellington tooltip position to the right
    $(".location#wellington, .location#masterton").tooltip({
        effect: 'fade',
        position: 'center right',
        offset: [-60,20],
        relative: true,
        opacity: 0.94,
        delay: 100
    });


    // Image slideshow using our locations as the pager, uses the alt attribute for the header
    $('#imageboxcontent').cycle({
        random: true
        /*before: function(){
            $('#imageboxhead p').html(this.alt);
        },
        pager: '#locations',
        pagerAnchorBuilder: function(idx, slide) {
            // return selector string for existing anchor
            return '#locations .location:eq('+idx+')';
        },
        pagerEvent: 'mouseover',
        //pauseOnPagerHover: true,
        fastOnEvent: 200*/
    });

    // toggle color of map red/grey
    $('#toggleButton').click(function(){

        if($('#map #locations div').is('.toolTipRed')){

            $('#map #locations div').removeClass('toolTipRed');
            $(this).val('Change to Red');           
        }
        else
        {
            $('#map #locations div').addClass('toolTipRed');
            $(this).val('Change to Grey');
        }

    });

    // preload image for menu roll over
    var image1 = $('<img />').attr('src', '../media/images/template/bg-mainmenu-hover.gif');
});
