/**
 * JS
 * @author Darío Ruellan <druellan@ecimtech.com>
 * @author Gustavo Salvini <gsalvini@ecimtech.com>
 * @copyright ecimTech 2009
 * @import: jquery/jquery.quicksearch.js
 */

$(function()
{
	// Quicksearch
	$("#program .row").quicksearch(
	{
		attached: 'div.searchbox',
		labelText: '&nbsp;',
		inputText: 'Búsqueda rápida',
		loaderText: ' <span class="spinner"></span>',
		onBefore: function()
		{
			if ($("div.searchbox input.qs_input").val() ) {
				$("#program .letters").slideUp("fast");
			} else {
				$("#program .letters, #program h3").slideDown("fast");
			}
		},
		onAfter: function()
		{
			setTimeout("updateQS()", 400);
			setTimeout("updateQS()", 1000);			
		}
	});

})

function updateQS()
{
//	console.log("QuickSearch H3 Check");
	$("#program .group").each(function()
	{
		var l = $(".row:visible",this).size();
		if ( l == 0)
			$("h3", this).slideUp("fast");
		else
			$("h3", this).slideDown("fast");
	});
}


