var weekOfYear = 4.345;

function openClose(lk){
	if(document.getElementById(lk).className == 'show')
		document.getElementById(lk).className = 'hidden';
	else
		document.getElementById(lk).className = 'show';
}

function changeOption(objValue1,objLabel){
	var tmp = parseFloat(objValue1);
	tmp = tmp.toFixed(2)
	document.getElementById(objLabel).value = tmp.toString() + " EUR";
	calculateSum('LabelSumText','LabelServiceText','LabelDifText');
}

function calculateOptions(LabelValue,SelectValue1,SelectValue2,LabelText){
	var tmp_LabelValue = 1.0;
	var tmp_SelectValue1_0 = 1.0;
	var tmp_SelectValue1_1 = 1.0;
	var result = 0.0;
	
	if(LabelValue != null){
		tmp_LabelValue = parseFloat(document.getElementById(LabelValue).value);
	}
	if(SelectValue1 != null){
		tmp_SelectValue1_0 = parseFloat(SelectValue1.substring(0,SelectValue1.indexOf('/')));
	}
	if(SelectValue1 != null){
		tmp_SelectValue1_1 = parseFloat(SelectValue1.substring(SelectValue1.indexOf('/')+1));
	}
	if(SelectValue2 != null){
		tmp_SelectValue1_1 = parseFloat(SelectValue2);
	}
	
	result = weekOfYear * tmp_LabelValue * tmp_SelectValue1_0 * tmp_SelectValue1_1;
	result = result.toFixed(2);
	
	document.getElementById(LabelText).value = result.toString() + " EUR";
	calculateSum('LabelSumText','LabelServiceText','LabelDifText');
}

function calculateSum(LabelText1,LabelText2,LabelText3){
	var sum = 0.0;
	var ser = 0.0;
	var dif = 0.0;
	
	for(i = 2; document.getElementById('LabelText_' + i.toString()); i++){
		sum += parseFloat(document.getElementById('LabelText_' + i.toString()).value);
	}
	
	ser = parseFloat(document.getElementById('LabelText_1').value);
	dif = sum - ser;
	
	sum = sum.toFixed(2);
	ser = ser.toFixed(2);
	dif = dif.toFixed(2);
	
	document.getElementById(LabelText1).value = sum.toString() + " EUR";
	document.getElementById(LabelText2).value = ser.toString() + " EUR";
	document.getElementById(LabelText3).value = dif.toString() + " EUR";
}
