$(document).ready(function() {

    if (resumeState != undefined && resumeState.Available == true)
    {
        $('#organization-resume').attr('href',resumeState.ResumeUrl);
        $('#resume-location').text('At ' + resumeState.Section + ', ' + resumeState.TotalProgress + '% Complete');
        $('#resume-box-overlay').show();
        var progressBar = $('#resume-progress-container .progress');
        progressBar.width(0);
        setTimeout(function()
        {
            progressBar.animate({width:resumeState.TotalProgress+'%'}, 1000,'easeOutCirc');
        },500);
    }


    $('#rotating-content-area').cycle({
        fx:     'fade',
        pager:  '#rotating-content-nav ul',
        pagerAnchorBuilder: function(idx, slide) {
            return '<li><a href="#">&nbsp;</a></li>';
        },
        updateActivePagerLink: function(pager, currSlide, clsName) {
            $(pager).each(function() {
                $(this).children().removeClass(clsName + ' preActiveSlide');
                $(this).children(':eq(' + currSlide + ')').addClass(clsName);
                $(this).children(':lt(' + currSlide + ')').addClass('preActiveSlide');
            });
        },
        timeoutDuration: [12,8,8,8,16],
        timeoutFn: function(currElement, nextElement, opts, isForward) {
            return opts.timeoutDuration[opts.currSlide] * 1000;
        },
    });
    $('#testimonials').cycle({
        fx:     'fade',
        pager:  '#testimonialsNav #paging',
        timeout: 0,
    });
    $('#twitter-box').twitterSearch({
        term:  'meet_the_need',
        birdLink: 'http://twitter.com/meet_the_need',
        birdSrc: '/images/home/twitter.png',
        pause: true,
        timeout: 5000,
        title: false,
        css: {
            bird: {
                height: '65px',
                left: '15px',
                top: '-35px',
                width: '65px'
            },
            frame: { border: 'none' },
            img: {
                height: '25px',
                width: '25px'
            },
            container: { backgroundColor: 'transparent'},
            title: {
                color: 'white',
                backgroundColor: 'transparent',
                fontFamily: 'sans-serif',
                fontWeight: 'normal',
                height: '15px',
                padding: '5px 0 30px 0'
            },
            tweet: {
                borderBottom: '1px solid gray',
                margin: '2px'
            },
        }
    });
    $('#twitter-box .twitterSearchTitle a, .twitterSearchBird').attr('title','Follow Me');
    $('.twitterSearchBird').attr('target','_blank');
    
    // Pie chart popups
    $('#pie-chart-map area').each(function()
    {
            $(this).qtip(
            {
                    content: {
                            text: 'loading...',
                            ajax: {
                                    url: '/organizations/pie-content/'+$(this).attr('rel')
                            },
                            title: {
                                    text: 'MEET THE NEED' + $(this).text(),
                                    button: true
                            }
                    },
                    position: {
                            target: 'mouse',
                            adjust: { mouse: false },
                            effect: false
                    },
                    show: {
                            event: 'click',
                            solo: true
                    },
                    hide: 'unfocus',
                    style: {
                            classes: 'ui-tooltip-wiki ui-tooltip-light ui-tooltip-shadow'
                    }
            })
    }).click(function(event) { event.preventDefault(); });

});

function launchIntroVideo()
{
    var videoDialog = new Boxy('<div id="intro-video"><iframe src="http://player.vimeo.com/video/28070912?title=0&amp;byline=0&amp;color=ff9933&amp;autoplay=1" width="700" height="394" frameborder="0"></iframe></div>',{title:'Meet the Need',modal:true, unloadOnHide: true});
}
