//ASSUMES that SLA_metrics.js was loaded
var year_last = new Date().getFullYear() - 1;
var year_current = new Date().getFullYear();
var month_last = 11;
var month_current = new Date().getMonth();

//ADJUST available months for viewing
function adjustCurrentAvailMetrics(){
	var month_id = null;
	var good_month = false;
	var metrics_count = SLA.getMetricsCount();
	var metrics_iterated = 0;
						
	while (! good_month){
		month_id = SLA.getMonthID(year_current, month_current);
		
		if (month_id != -1){ good_month = true; }
		else {
			month_current--;
			metrics_iterated++;
			if (month_current < 0){ 
				year_last--;
				year_current--; 
				
				month_current = 11;
				month_last = 11;									
			}
		}
		
		if (metrics_iterated >= metrics_count){
			good_month = true;
			alert("ERROR:SLA Metrics information not available for current year");
			return;
		}
	}					
}

function adjustLastAvailMetrics(){
	var month_id = null;
	var good_month = false;
	var metrics_count = SLA.getMetricsCount();
	var metrics_iterated = 0;
						
	while (! good_month){
		month_id = SLA.getMonthID(year_last, month_last);
									
		if (month_id != -1){ good_month = true; }
		else {
			month_current--;
			metrics_iterated++;
			if (month_current < 0){ 
				year_last--;
				month_last = 11;									
			}
		}
		
		if (metrics_iterated >= metrics_count){
			good_month = true;
			alert("ERROR:SLA Metrics information not available for last year");
			return;
		}
	}
}
					
//SHOW METRICS
function drawMetricsGraph (divName){
	SLA.setObjectName("SLA");
	SLA.setTargetDivId(divName);
	SLA.getYearsList();
							
	SLA.writeDiv(month_current, year_current);
}
function showLastYear (){
	SLA.writeDiv(month_last, year_last);	
}
function showCurrentYear (){
	SLA.writeDiv(month_current, year_current);						
}


