$(document).ready(function(){

	  $("a.video").fancybox({
	      transitionIn:'elastic',
	      transitionOut:'elastic',
	      easingIn:'easeOutBack',
	      easingOut:'easeInBack',
	      overlayOpacity:0.8,
	      overlayColor:'#000',
	      speedIn:400,
	      speedOut:400,
	      titleShow:false,
	      hideOnOverlayClick: true
	  });

	  $("a.play-btn").each(function(){

        var overlay = $('<div>')
            .width($(this).parent().width())
            .height($(this).parent().height())
            .css('position', 'absolute')
            .css('top', 0)
            .css('left', 0)
            .css('z-index', 10)
            .css('background-repeat', 'no-repeat')
            .css('background-image', 'url(/global/images/common/play.png)')
            .css('background-position', '50% 50%')
            .appendTo($(this));
    });


    /* TAGS */
    $('.more-tags').live('click', function(){
        var target = $(this).parent().parent();
        $.ajax({
            type: 'GET',
            url: $(this).attr('href') + '.json',
            data: '',
            dataType: 'json',
            success: function(results){
                target.html('');
                target.append(results.html);
            }
        });
        return false;
    });
    $('.less-tags').live('click', function(){
        var target = $(this).parent().parent();
        $.ajax({
            type: 'GET',
            url: $(this).attr('href') + '.json',
            data: 'n=64',
            dataType: 'json',
            success: function(results){
                target.html('');
                target.append(results.html);
            }
        });
        return false;
    });


    /* SEARCH */
    $('.global-search-kw').qtip({ 
        prerender: true,
        content: {text: $('#global-search-note').html() },
        position: { at: 'bottom center' },
        style: { classes: 'ui-tooltip-blue ui-tooltip-shadow ui-tooltip-tipped' }
    });
    if ($('.global-search-kw').val()) {
        $('.global-search-kw').css('backgroundPosition', '-650px -107px');
    }
    $('.global-search-kw').live('focus', function(){
        $(this).css('backgroundPosition', '-650px -107px');
    });
    $('.global-search-kw').live('blur', function(){
        if ($(this).val()) {
        } else {
            $(this).css('backgroundPosition', '-650px -27px');
        }
    });

});

