// JavaScript Document
function setStyleSi(id) {
	document.getElementById(id).value = "SI";
	document.getElementById(id).style.background = "#090";
}

function setStyleNo(id) {
	document.getElementById(id).value = "NO";
	document.getElementById(id).style.background = "#900";
}


function checkValue(field) { 
	if(!isNumericValue(field.value)) { 
		giveWarningAndFixValue(field); 
	} 
	ganadoCalcula (field.id);
	//alert('eo');
}

function ganadoCalcula (nombreDelCampo) {

		var resultadoString = "";

		switch (nombreDelCampo){
		//########################################
		case "ganado0" :
			document.getElementById("ganado0Out").value = FormatNumber (document.getElementById("ganado0").value * 0.36, 2, true, false);
			break;
		case "ganado1" :
			document.getElementById("ganado1Out").value = FormatNumber (document.getElementById("ganado1").value * 0.73, 2, true, false);
			break;
		case "ganado2" :
			document.getElementById("ganado2Out").value = FormatNumber (document.getElementById("ganado2").value * 1, 2, true, false);
			break;
		//########################################
		}
		//VACAS
		tempValue = parseFloat(document.getElementById("ganado0Out").value) + parseFloat(document.getElementById("ganado1Out").value) + parseFloat(document.getElementById("ganado2Out").value);
		tempValue = FormatNumber (tempValue, 2, true, false);
		tempValue = tempValue + ''; //convierte a string
		document.getElementById("ganadoOutTotal").value = tempValue;
		document.getElementById("tamUGM").value = tempValue;
		
		tempValue = parseFloat(document.getElementById("ganado0").value) + parseFloat(document.getElementById("ganado1").value) + parseFloat(document.getElementById("ganado2").value);
		tempValue = FormatNumber (tempValue, 2, true, false);
		tempValue = tempValue + ''; //convierte a string
		document.getElementById("tamGanado").value = tempValue;
		
		//CULTIVOS
		tempValue = parseFloat(document.getElementById("maizHA").value) + parseFloat(document.getElementById("forrajeraHA").value) + parseFloat(document.getElementById("naturalHA").value);
		tempValue = FormatNumber (tempValue, 2, true, false);
		tempValue = tempValue + '';
		document.getElementById("tamHA").value = tempValue;
		
		//ESTIMACIONES
		tempValue = parseFloat(0.045 * 365 * parseFloat(document.getElementById("tamUGM").value));
		tempValue = FormatNumber (tempValue, 2, true, false);		
		tempValue = tempValue + '';
		document.getElementById("estPurines").value = tempValue;
		
		tempValue = parseFloat(0.045 * 90 * parseFloat(document.getElementById("tamUGM").value));
		tempValue = FormatNumber (tempValue, 2, true, false);		
		tempValue = tempValue + '';
		document.getElementById("estDeposito").value = tempValue;

		tempValue = ( parseFloat( document.getElementById("maizHA").value)*60) + ( parseFloat( document.getElementById("forrajeraHA").value)*40) + ( parseFloat( document.getElementById("naturalHA").value)*20);
		tempValue = FormatNumber (tempValue, 2, true, false);		
		document.getElementById("estCarga").value = tempValue;


}

function conclusiones () {
	if ((parseFloat(document.getElementById("depositoPurines").value) >  parseFloat(document.getElementById("estDeposito").value)) && (parseFloat(document.getElementById("tamUGM").value) > 0 )) {
		setStyleSi("con1");
	} else {
		setStyleNo("con1");
	}
	if ((parseFloat(document.getElementById("estCarga").value) > parseFloat(document.getElementById("estPurines").value)) && (parseFloat(document.getElementById("tamUGM").value) > 0 )) {
		setStyleSi("con2");
	} else {
		setStyleNo("con2");
	}
	if ((parseFloat(document.getElementById("depositoPurines").value) >=  parseFloat(document.getElementById("estDeposito").value)) && (parseFloat(document.getElementById("estCarga").value) >= parseFloat(document.getElementById("estPurines").value)) && (parseFloat(document.getElementById("tamUGM").value) > 0 )) {
		setStyleSi("con3");
	} else {
		setStyleNo("con3");
	}
}
