/******************************************************************
 -- START -- OnDocumentReady
******************************************************************/
$(document).ready(function(){

	$("#nota_ano").change(onYearNote);
	$("#nota_mes").change(onMonthNote);
	$("#nota_dia").change(onDayNote);

	// -- START Carga imagenes de de personalidades mientras se vaya "escroleando" la pagina --
	$(function(){
		$("#listados-programas-grid img.preload").lazyload({
			placeholder : "images/grey.gif",
			effect: "fadeIn",
			effectspeed: "slow"
		});
	});
	// -- END --


});
/******************************************************************
 -- END -- OnDocumentReady
******************************************************************/

/**********************************************
 -- onYearNote
**********************************************/
function onYearNote(){

	var comboMonthScope = $("#comboMonths");
	$.post("classes/getMonthOfTheYear.php",{year:$(this).attr("value")},function($data)	{
		comboMonthScope.html($data);
		$("#nota_mes").change(onMonthNote);
	});

}

/**********************************************
 -- onMonthNote
**********************************************/
function onMonthNote(){

	var comboDayScope = $("#comboDay");
	$.post("classes/getValidDayOfTheMonth.php",{year:$("#nota_ano").attr("value"),month:$(this).attr("value")},function($data)	{
		comboDayScope.html($data);
		$("#nota_dia").change(onDayNote);
	});

}

/**********************************************
 -- onDayNote
**********************************************/
function onDayNote(){

	var baseDir = $('base').attr('href');
	var year = $("#nota_ano").attr("value");
	var month = $("#nota_mes").attr("value");
	var days = $("#nota_dia").attr("value");
	
	window.location = baseDir+"inicio/buscador/?ano="+year+"&mes="+month+"&dia="+days;

}

/**********************************************
 -- onSearch
**********************************************/
function onSearch(){

	var baseDir = $('base').attr('href');
	var querySearch = $("#search_field").attr("value");
	
	window.location = baseDir+"inicio/buscador/?search="+querySearch;

}