﻿$('html').addClass('js');
$(document).ready(function () {
    var strplayimg = '/graphics/home/survey/flash_play.png';
    var strplauseimg = '/graphics/home/survey/flash_pause.png';
    $('#flashcontent').cycle({ fx: 'fade', timeout: 8500, speed: 1000, slideExpr: 'a.sl' });
    $('#flash_nav_last').click(function () { $('#flashcontent').cycle('prev'); return false; });
    $('#flash_nav_next').click(function () { $('#flashcontent').cycle('next'); return false; });
    $('#flash_nav_p').click(function () {
        $('#flashcontent').cycle('toggle'); if ($('#flash_nav_p:first-child').attr('src').search('play') > 0) { $('#flash_nav_p:first-child').attr('src', strplauseimg); } else { $('#flash_nav_p:first-child').attr('src', strplayimg); return false; }
    });

    $('#socialupdatefeed').cycle({ fx: 'none', timeout: 5000, speed: 1000, slideExpr: 'div.sd' });
    $('#socialupdatefeed').cycle('pause');
    $('html').removeClass('js');

    $('.hFeed').click(function () {
        $('#socialupdatefeed').cycle(parseInt($(this).attr('id').replace('hFeed', '')));
        $('.imgFeed').attr('src', '/graphics/home/newContent/FeedOff.jpg');
        $(this).children('img').attr('src', '/graphics/home/newContent/FeedOn.jpg');
        ajLog($(this).attr('id'));
        return false;
    });
    $('.hFeat').click(function () {
        var w = $(this).attr('id').replace('hFeat', '');
        ajFeat('math', w, 'feat_math_drop');
        ajFeat('science', w, 'feat_science_drop');
        ajFeat('reading', w, 'feat_ela_drop');
        $('.imgFeat').attr('src', '/graphics/home/newContent/FeedOff.jpg');
        $(this).children('img').attr('src', '/graphics/home/newContent/FeedOn.jpg');
        return false;
    });
    $("#aTwitter").contextMenu({ menu: 'twitterMenu' }, function (action, el, pos) { location.href = action; });
    $("#aTwitter").click(function () {
        return false;
    });
});
function ajFeat(s,w,i) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/webServices/Featured.asmx/Resources",
        data: "{subj:'"+s+"',WeeksBack:'"+w+"'}",
        dataType: "json",
        success: function(msg) {
            if (msg.d.Id != '0') {
                $('#'+i).html('<a href="\/record\/'+msg.d.Id+'.aspx">'+msg.d.Title+'<\/a><br\/>'+msg.d.Grades);
            }
        }
    })
};
function ajLog(s) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "/webServices/Social.asmx/ClickLog",
        data: "{s:'" + s + "'}",
        dataType: "json"
    })
};
