jQuery.noConflict();
jQuery(document).ready(function($){
//$(document).ready(function() {
//--------------------------
    $(".sections").hide();
    $(".pages").hide();
    setInterval("checkAnchor()", 300);

    //$("#page-0-1").show();
    $(".pager span").click(function(event) {
        event.preventDefault();
        $(".pages").hide();
        $(".pager span").removeClass("on");
        $(this).addClass("on");
        $("#page-"+$(this).attr("title")).fadeIn();
    });
    
    $(".openSectionPages").click(function(event) {
        event.preventDefault();
        var section=$(this).attr("title");
        $(".pages").hide();
        $(".pager span").removeClass("on");
        $("#pager"+section+" span:first").addClass("on");
        $("#page-"+section+"-1").fadeIn();
        $("#pager"+section).show();
    });
    
    //ensures that we can get back to default page when the anchor hasn't changed
    $("#leftcol a").click(function(event) {
        var section = $(this).attr("href");
        $(".pages").hide();
        $(section+ " .pages:first").fadeIn();
    });

    //___________________________________________

    /*
    $('a.zoom').fancyZoom({
        directory: '/resources/images/interface/fancyzoom'
    });
    */

    $.fn.nyroModal.settings.css = {
                bg: {
                        zIndex: 100,
                        position: 'fixed',
                        top: 0,
                        left: 0,
                        height: '100%',
                        width: '100%'
                },
                wrapper: {
                        zIndex: 101,
                        position: 'fixed',
                        top: '50%',
                        left: '50%',
                        paddingBottom: '15px'
                },
                wrapper2: {
                },
                content: {
                        overflow: 'hidden',
                        paddingBottom: '0px'
                },
                loading: {
                        zIndex: 102,
                        position: 'fixed',
                        top: '50%',
                        left: '50%',
                        marginTop: '-50px',
                        marginLeft: '-50px'
                }
    }

    $.fn.nyroModal.settings.showBackground = function(elts, settings, callback) {
        elts.bg.css({opacity:0}).fadeTo(500, 0.3, callback);
    };

    $.fn.nyroModal.settings.hideContent = function(elts, settings, callback) {
        elts.contentWrapper
            .animate({
                opacity: 0

            }, {duration: 350, complete: function() {
                elts.contentWrapper.hide();
                callback();
            }});

    }
    
    //_________________________________________

//--------------------------
});

var currentAnchor = null;
function checkAnchor(){
    var hash = document.location.hash;
    if(currentAnchor != hash){
        currentAnchor = hash;
        jQuery(".sections").hide();
        jQuery(".pages").hide();
        jQuery("#leftcol li, #leftcol a").removeClass("on");
        jQuery(".pager span").removeClass("on");
        if(!currentAnchor) {
            //highlight 1st section links in left
            jQuery("#leftcol li a:first").addClass("on");
            jQuery("#leftcol li:first").addClass("on");
            //show first section
            jQuery(".sections:first").show();
            //show 1st page of 1st section
            jQuery(".sections:first .pages:first").show();
            //highlight first pager link
            jQuery(".sections:first .pager span:first").addClass("on");
            //but hide the pager - only visible after past intro page
            jQuery(".pager").hide();
        } else {
            //show first page of selected section
            jQuery(currentAnchor+' .pages:first').show();
            //highlight pager 1 of this section
            jQuery(currentAnchor+' .pager span:first').addClass("on");
            //fade in the section
            jQuery(currentAnchor).fadeIn();
            //highlight section links in left
            jQuery("#leftcol a[href='"+currentAnchor+"']").addClass("on");
            var parent = jQuery("#leftcol a[href='"+currentAnchor+"']").parent();
            jQuery(parent).addClass("on");
            //but hide the pager - only visible after past intro page
            jQuery(".pager").hide();
        }
    }
}

