$(document).ready(function(){
	
	hovertips();
	
	function do_search(q) {
	    $.post('/search/', {'q': [q]}, function(data) {
			$('#search_results').html(data);
		});
	}
	
	$('#q').click(function() {
		if ($(this).val() == 'Search by Presenter or Topic...') {
			$(this).attr('value', '');
		}
	});
		
	$('#q').keyup(function() {
		q = $(this).val();
		if ($(this).val() == 'Search by Presenter or Topic...') {
            $(this).attr('value', '');
			return false;
		}
		if (q.length > 2) {
			do_search(q);
		}
	});
	
	$('#reset').click(function() {
	    $('#q').attr('value', '');
	    do_search('');
	})

});

function hovertips() {
	$('.list .c_Video a')
	.mouseover(function() {
        $(this).after("<span class='boogeeba'> <sup>Watch Now!</sup></span>")
    }).mouseout(function() {
        $(".boogeeba").remove()
    })
	
	$('.list .c_Article a')
	.mouseover(function() {
        $(this).after("<span class='boogeeba'> <sup>Read Now!</sup></span>")
    }).mouseout(function() {
        $(".boogeeba").remove()
    })
	
	$('.list .c_Audio a')
	.mouseover(function() {
        $(this).after("<span class='boogeeba'> <sup>Listen Now!</sup></span>")
    }).mouseout(function() {
        $(".boogeeba").remove()
    })
	
	$('.list .c_Download a')
	.mouseover(function() {
        $(this).after("<span class='boogeeba'> <sup>Access File!</sup></span>")
    }).mouseout(function() {
        $(".boogeeba").remove()
    })
}
