﻿function addNewsListeners() {
    $('#AllStories > div').click(function() {
        var clickedStory = $(this);
        var mainStory = $('#MainStory');
        if (clickedStory.html() != mainStory.html()) {
            mainStory.slideUp(200, function() {
            $('#AllStories > div').removeClass('activeStory');
                clickedStory.addClass('activeStory');
                mainStory.html(clickedStory.html());
                mainStory.slideDown(200);
            });
        }
    }).hover(function() {
        var hoveredStory = $(this);
        if (!hoveredStory.hasClass('activeStory') && hoveredStory.get(0).id.toLowerCase() != 'mainstory') {
            $(this).addClass('newshover');
        }
    }, function() {
        $(this).removeClass('newshover');
    });
    var firstStory = $('#AllStories div:first');
    $('#MainStory').html(firstStory.html());
    firstStory.addClass('activeStory');
}
function cyclePartners(partners, imagePath) {
    var path = "";
    if (typeof (imagePath) == 'undefined') {
        path = 'UserImages/Sponsors/';
    } else {
        path = imagePath + '/Sponsors/';
    }
    jQuery.each(partners, function(i, partnerDetails) {
        var link = $('<a/>').attr('href', unescape(partnerDetails.url))
                 .appendTo('#Partners');
        $('<img/>').attr({
        alt: unescape(partnerDetails.alt),
            src: path + unescape(partnerDetails.filename) + "_thumb.jpg"
        }).appendTo(link);
    });
    $('#Partners').cycle({ fx: 'scrollLeft', timeout: 6000, random: 1, fit: 1, containerResize: 0 });
}
function cycleGalleryPics(galleryImages) {
    var galleryDiv = $('#Gallery');
    galleryDiv.html('');
    var path = "";
    if (typeof (imagePath) == 'undefined') {
        path = 'UserImages/Gallery/';
    } else {
        path = imagePath + '/Gallery/';
    }
    jQuery.each(galleryImages, function() {
        $('<img/>').attr({
            width: 360, height: 362,
            alt: unescape(this.alt),
            src: path + unescape(this.filename) + '.jpg'
        }).appendTo('#Gallery');
    });
    galleryDiv.cycle({ fx: 'fade', timeout: 3000, random: 1, fit: 1, containerResize: 0 });
}