//javascript 
function getFechasCalendar(idCalendar,month,year) {
	var params = "module=getCalendar&function=catalogos&idCalendar="+idCalendar+"&month="+month+"&year="+year;
	document.getElementById("calendarDiv").innerHTML = "<img src='../images/wait.gif' /> Espere...";
	userAjax.getNewResponse("../php/ajaxControl.php","get",params,"calendarDiv","");
}
var existsMonthDiv = false;
var existsYearDiv = false;
function showSpacesMonths(idCalendar,month,year) {
		existsYearDiv = false;
	
	try {
		document.getElementById(idCalendar+"-monthName").removeChild(monthDiv);
	} catch (e) { }
	
	try {
		document.getElementById(idCalendar+"-yearFull").removeChild(yearDiv); 
	} catch (e) { }
	if(existsMonthDiv)
	{
		existsMonthDiv = false;	
	}
	else	
	{
		var output = "<div id='"+idCalendar+"-monthSel' style='position:absolute;z-index:1'><table border='0' width='105'><tr><td align='left'><table bgcolor='#f7941d' style='border:1px solid #efb36a; ' width='105' align='right'><tr><td >";
		var selected = "";
		for(var i=1;i<=12;i++) {
			if(i==month)
				output += "<div style='width:100%;background-color:#f9A43d;color:#FFFFFF; cursor: pointer' onclick='existsMonthDiv = false;document.getElementById(\""+idCalendar+"-monthName\").removeChild(monthDiv); ' >"+monthArray[i]+"</div>";
			else
				output += "<div style='width:100%; cursor:pointer' id='fechama_"+i+"' onmouseout='getObj(\"fechama_"+i+"\").style.backgroundColor = \"\"' onmouseover='getObj(\"fechama_"+i+"\").style.backgroundColor = \"#f9A43d\"' onclick='existsMonthDiv=false;getFechasCalendar(\""+idCalendar+"\","+i+","+year+")'><a href='javascript:;'  style='color:#FFFFFF;  ' onclick='getFechasCalendar(\""+idCalendar+"\","+i+","+year+")' >"+monthArray[i]+"</a></div>";
		}
		output += "</td></tr></table></td></tr></table></div>";
		monthDiv = document.createElement("div");
		monthDiv.innerHTML = output;
		document.getElementById(idCalendar+"-monthName").appendChild(monthDiv); 
		existsMonthDiv = true;
	}
}

function showSpacesYears(idCalendar,month,year) {
	existsMonthDiv = false;
	try {
		document.getElementById(idCalendar+"-monthName").removeChild(monthDiv);
	} catch (e) { }
	
	try {
		document.getElementById(idCalendar+"-yearFull").removeChild(yearDiv); 
	} catch (e) { }
	if(existsYearDiv)
	{
		existsYearDiv = false;
	}
	else{
		var output = "<div id='"+idCalendar+"-yearSel' style='position:absolute;'><table cellspacing='2' cellpadding='2'><tr><td style='border:1px solid #efb36a; background-color:#f7941d;' align='left'>";
		var selected = "";
		var date = new Date();
		var nowYear = date.getFullYear();
		var yearEnd = year+5;
		for(var i=year-5;i<=yearEnd;i++) {
			selected = i == year ? " onclick='existsYearDiv = false;document.getElementById(\""+idCalendar+"-yearFull\").removeChild(yearDiv); ' ":"";
			if(i == year)
				output += "<div "+selected+" style='color:#FFFFFF;cursor:pointer' >"+i+"&nbsp;&nbsp;&nbsp;</div>";
			else
			output += "<div style='width:100%; cursor:pointer' id='fechamy_"+i+"' onmouseout='getObj(\"fechamy_"+i+"\").style.backgroundColor = \"\"' onmouseover='getObj(\"fechamy_"+i+"\").style.backgroundColor = \"#f9A43d\"' onclick='existsYearDiv=false;getFechasCalendar(\""+idCalendar+"\","+i+","+year+")'><a href='javascript:;' onclick='getFechasCalendar(\""+idCalendar+"\","+month+","+i+")' style='color:#FFFFFF;' ><span "+selected+" >"+i+"</span></a></div>";
		}
		output += "</td></tr></table></div>";
		yearDiv = document.createElement("div");
		yearDiv.innerHTML = output;
		document.getElementById(idCalendar+"-yearFull").appendChild(yearDiv); 
		existsYearDiv = true;
	}
}

