$(document).ready(function(){

    $('.video-thumb').append('<span class="video-icon" />');

    $('.video-thumb').click(function(){

        var clicked = $(this);

        //store link

        var link = $(this).attr('href');

        //check if it's an apple handheld and don't do anything

        if (!$('body').hasClass('apple-handheld')) {

            //link id keeps the fancybox width and height as video-widthxheight

            thumbid = $(this).attr('id');

            //get widthxheight

            size = thumbid.split('-');

            //split into width and height

            size = size[1].split('x');

            width = size[0];

            height = size[1];

            $.fancybox({

                autoDimensions:     false,

                autoScale:          false,

                width:              parseInt(width),

                height:             parseInt(height),

                padding:            0,

                href:               MyAjax.ajaxurl + '?action=vetta_video_load&url=' + link + '&width=' + size[0] + '&height=' + size[1]

            });

            //

            return false;

        }

    });

    $('.mapit').click(function(){

        $.fancybox({

            'padding'       : 0,

            'autoScale'     : false,

            'transitionIn'  : 'none',

            'transitionOut' : 'none',

            'width'     : 655,

            'height'        : 500,

            'href'      : this.href + '&amp;output=embed',

            'type'              : 'iframe'

        });

        return false;

    });

    $('#slides').cycle({ 

        fx:     'scrollHorz', 

        speed:  'slow', 

        timeout: 8500, 

        next:   '#slide-next',

        prev:   '#slide-prev'

    });

    getTwitters('load-twitter', { 

                id: twitter['user'],

                count: twitter['number'], 

                enableLinks: true,

                newwindow: true, 

                clearContents: true,

                timeout: 10,

                onTimeoutCancel: true,

                template: '<p class="twitter-line">\%text%\ <a href="http://twitter.com/%user_screen_name%/status/%id_str%">%time%</a></p>'

        });

});
