/**
 * @author gonarch
 */

var aPrices = new Array;
 
/**
 * @param {Date} oDate
 */
function ShowPriceList(oDate){
	var iCurrentDate=Number(oDate.format('%Y%m%d'));
	var tPrices = document.getElementById("Prices");
	if (tPrices){
		var oTR = tPrices.getElementsByTagName("tr");
	
		var bFound=false;
		for(var i=0; i<aPrices.length; i++){
			if(aPrices[i].id <= iCurrentDate && !bFound){
				bFound=true;
				/* Показываем */
				for(var j=0; j<oTR.length; j++){
					if(oTR[j].className){
						if(aPrices[i][oTR[j].className]){
							oTR[j].getElementsByTagName("td")[1].innerHTML = aPrices[i][oTR[j].className];
						} else {
							oTR[j].getElementsByTagName("td")[1].innerHTML = "&#8212;";
						}
					}
				}
			}
		}
	}
}

/**
 * @param {Date} oDate
 */
function CalendarCallback(oDate){
	ShowPriceList(oDate);
	document.getElementById('cln-input').innerHTML=oDate.format('%j %f %Y');
}

function ToggleCalendar(evt){
	if((evt=checkEvent(evt))){
		if(matchClass(oCalendar.elemContainer, 'hidden'))
			ShowCalendar();
		else
			HideCalendar();
		CancelEvent(evt);
	}
}

function ShowCalendar(){
	oCalendar.Show();
	addClass(document.getElementById('calendar-href'), 'visible');
}

function HideCalendar(){
	oCalendar.Hide();
	removeClass(document.getElementById('calendar-href'), 'visible');
}