
/**
* Dataobject. Stores the User input
**/
var performance = new Object();
var month = "03";
var year="2002";
var amount="monatlich";

/**
* toggles the dropdown list in expanded/collpsed view
**/
function toggleMenue(menue_id, bg, w)
{
	var menue = document.getElementById(menue_id);
	var buttonBg = document.getElementById(bg);
	if(menue)
		toggleBlockElement(menue, buttonBg, String(w));
}
/**
* helper func for toggleMenue
**/
function toggleBlockElement(block,buttonBg, w)
{
	if(!block.style.display || block.style.display=="none")
	{
		block.style.display="block";
		buttonBg.style.backgroundPosition="0px 0px";
	}
	else
	{
		block.style.display="none";
		var pos = "-"+w+"px 0px";
		buttonBg.style.backgroundPosition=pos;
	}
}

/**
* set the month of the performance
**/
function setMonth(m)
{
	if(m<10)
		m="0"+m;
	
	month=m;
	updateSelection();
}
/**
* set the year of the performance
**/ 
function setYear(y)
{
	year=y;
	updateSelection();
}
/**
* set the amount of the performance
**/
function setAmount(a)
{
	amount=a;
	updateSelection();
}
/**
* update the selected items in the drop down list
**/
function updateSelection()
{
	var monthElement = document.getElementById("monthValue");
	var yearElement = document.getElementById("yearValue");
	var amountElement = document.getElementById("amountValue");
	
	// fill the aquabuttons
	monthElement.innerHTML=String(month);
	yearElement.innerHTML=String(year);
	amountElement.innerHTML=amount;
	
	//set the values to the hidden input fields
	var f = document.forms["calculator"];
	var startDateInput = f.elements["startdate"];  
	var amountInput = f.elements["input_betrag"];
	
	startDateInput.value=month+"-"+year;
	amountInput.value=amount;
}
/**
* sumbit the data to the server script by executing the form-tag action
**/
function submitPerformance()
{
	document.forms["calculator"].submit();
}
