﻿var SectionManager = {
    currentSection: 'familyBG',
    fadeTime: 1000,
    GotoSection: function(sectionID) {
        var curObj = $('#' + this.currentSection);
        //curObj.attr({ newImage: sectionID, fadeTime: this.fadeTime });

        curObj.fadeOut(this.fadeTime);
        $('#' + sectionID).fadeIn(this.fadeTime);

        this.currentSection = sectionID;
    }
};

function Change(baseID) {

    $('div.desc-text').hide();
    $('#' + baseID + 'Text').fadeIn('fast');

    // clear all clicks
    //$('a[rel="' + baseID + '"]').click();

    SectionManager.GotoSection(baseID + 'BG');
    return false;
};

$(document).ready(function() {
    // Make sure the bar has always the correct width
    $(window).bind('resize', function() {
        $('#infoBar').width($(this).width());
    });

    // Set the initial bar width
    $(window).trigger('resize');

    $('#infoBar').ie6warning();

    $('#imageFamily').attr('base', 'family');
    $('#imageGirl').attr('base', 'victim');
    $('#imageMan').attr('base', 'addiction');

    var fn_click = function() {
        var $this = $(this);

        $('.mainTextImage.selected').click(fn_click).removeClass('selected');

        $this.addClass('selected');
        $this.unbind('click');
        Change($this.attr('base'));
    };

    // set all link attributes
    $('.mainTextImage').click(fn_click);

    $('.mainTextImage:first').click();
});
        

