var cadena=window.location.href;
cadena=cadena.substr((cadena.indexOf("presupuesto.html?")+"presupuesto.html?".length),cadena.length);

var i;
var j;
var k;
var m;

var campos=new Array();

campos[0]="hmueble";
campos[1]="halto";
campos[2]="hlargo";
campos[3]="hfondo";
campos[4]="hmadera";
campos[5]="cint1";
campos[6]="cint2";
campos[7]="cint3";
campos[8]="cint4";
campos[9]="cint5";
campos[10]="cint6";
campos[11]="cint7";
campos[12]="cint8";
campos[13]="cint9";
campos[14]="cint10";
campos[15]="hserie";
campos[16]="cext2";
campos[17]="cext3";
campos[18]="cext4";
campos[19]="cext5";
campos[20]="cext6";
campos[21]="hcext7";
campos[22]="hcext8";
campos[23]="cext9";
campos[24]="cext10";
campos[25]="cext11";
campos[26]="hcext12";
campos[27]="hapertura";
campos[28]="ccomp1";
campos[29]="ccomp2";
campos[30]="ccomp3";
campos[31]="hcomp4";
campos[32]="hcomp5";
campos[33]="hcomp6";
campos[34]="hcomp7";
campos[35]="hcomp8";
campos[36]="ccomp10";
campos[37]="pAbatibles";
campos[38]="pPlegables";
campos[39]="pCorrederas";
campos[40]="habatibles";
campos[41]="hplegables";
campos[42]="hcorrederas";
campos[43]="hlacado";
campos[44]="final";

var valores=new Array();

for(i=0;i<(campos.length);i++){
	//document.write(i +"__" + campos[i] + " ==== " + cadena.indexOf("&" + campos[i] + "=") + "<BR>");
	//document.write(campos[i] + " = ");
	//document.write(cadena.substr((cadena.indexOf("&" + campos[i] + "=") + (campos[i].length+2)),cadena.substr((cadena.indexOf("&" + campos[i] + "=") + (campos[i].length+2)),cadena.length).indexOf("&")) + "<BR>");
	valores[i]=cadena.substr((cadena.indexOf("&" + campos[i] + "=") + (campos[i].length+2)),cadena.substr((cadena.indexOf("&" + campos[i] + "=") + (campos[i].length+2)),cadena.length).indexOf("&"));
}

if (valores[40]=="") valores[40]=0;
if (valores[41]=="") valores[41]=0;
if (valores[42]=="") valores[42]=0;

var camposUnescape=new Array();

camposUnescape[0]="hnombre";
camposUnescape[1]="hdni";
camposUnescape[2]="hdireccion";
camposUnescape[3]="hpoblacion";
camposUnescape[4]="hprovincia";
camposUnescape[5]="htelefono";
camposUnescape[6]="hmovil";
camposUnescape[7]="hemail";

i=i-1;

for(j=0;j<(camposUnescape.length);j++){
	//document.write(camposUnescape[j] + " = ");
	//document.write(unescape(unescape(cadena.substr((cadena.indexOf("&" + camposUnescape[j] + "=") + (camposUnescape[j].length+2)),cadena.substr((cadena.indexOf("&" + camposUnescape[j] + "=") + (camposUnescape[j].length+2)),cadena.length).indexOf("&")))) + "<BR>");
	valores[i]=fTrim(unescape(unescape(cadena.substr((cadena.indexOf("&" + camposUnescape[j] + "=") + (camposUnescape[j].length+2)),cadena.substr((cadena.indexOf("&" + camposUnescape[j] + "=") + (camposUnescape[j].length+2)),cadena.length).indexOf("&")))));
	i=i+1;
}

var total=0;
var totalTexto;
var indice;
var indiceNum=0;

//DATOS
for(i=campos.length;i<(campos.length+8);i++){
	//document.write( camposUnescape[(i-campos.length)] + ":" + valores[(i-1)] + "<BR>");
}

function fTrim(trimCadena){
	if(trimCadena.length < 1){
		return"";
	}
	trimCadena = rfTrim(trimCadena);
	trimCadena = lfTrim(trimCadena);
	if(trimCadena==""){
		return "";
	}
	else{
		return trimCadena;
	}
}

function rfTrim(cadenaAux){
	var espacio = String.fromCharCode(32);
	var longitud = cadenaAux.length;
	var strAux = "";
	
	if(longitud < 0){
		return"";
	}
	
	var posAux = longitud -1;

	while(posAux > -1){
		if(cadenaAux.charAt(posAux) == espacio){
		}
		else{
			strAux = cadenaAux.substring(0,posAux +1);
			break;
		}
		posAux = posAux-1;

	} //End While
	return strAux;

} //End Function

function lfTrim(cadenaAux){
	var espacio = String.fromCharCode(32);
	
	if(longitud < 1){
		return"";
	}
	
	var longitud = cadenaAux.length;
	var strAux = "";
	var posAux = 0;

	while(posAux < longitud){
		if(cadenaAux.charAt(posAux) == espacio){
		}
		else{
		strAux = cadenaAux.substring(posAux,longitud);
		break;
		}
		posAux = posAux + 1;
	} //End While
	
	return strAux;

} //End Function



function armario(){
	if (valores[15]!="" && valores[15]!="0"){
		if (valores[15]=="1") document.write("Gorbea");
		else if (valores[15]=="2") document.write("Serantes");
		else if (valores[15]=="3") document.write("Argalario");
		else if (valores[15]=="4") document.write("Cenefas");
		else if (valores[15]=="5") document.write("Aneto");

		if (valores[4]!=""){
			if (valores[4]=="1") document.write("&nbsp;Sapelly");
			else if (valores[4]=="2") document.write("&nbsp;Haya");
			else if (valores[4]=="3") document.write("&nbsp;Cerezo");
			else if (valores[4]=="4") {
				if (valores[43]=="1") document.write("&nbsp;Lacado Laca blanca");
				else if (valores[43]=="2") document.write("&nbsp;Lacado Laca color");
				else if (valores[43]=="3") document.write("&nbsp;Lacado Dos colores");
				else if (valores[43]=="4") document.write("&nbsp;Lacado Dkp");
			}
		}
	}
}

function cantidadPuertas(){
	var divisor=0;

	for (j=40;j<43;j++){
		if (!isNaN(parseInt(valores[j]))){
			divisor = divisor + parseInt(valores[j]);
		}
	}

	if (divisor!=0) document.write(divisor);
}

function mueble(){
	var ponerX=false;
	if (valores[0]!=""){
		if (valores[0]=="1") document.write("Interior m&aacute;s Frente ");
		if (valores[0]=="2") document.write("S&oacute;lo Interior ");
		if (valores[0]=="3") document.write("S&oacute;lo Frente ");
	}

}

function medidas(){
	var ponerX=false;
	if (valores[1]!=""){ 
		document.write(valores[1]);
		ponerX=true;
	}
	if (valores[2]!=""){
		if (ponerX) document.write("x");
		document.write(valores[2]);
		ponerX=true;
	}
	if (valores[3]!=""){
		if (ponerX) document.write("x");
		document.write(valores[3]);
		ponerX=true;
	}
}

var armarioMontaje=false;
var contadorConceptos=0;

function componentes(){

	var apertura="";
	var continuar = true;
	var menor = true;

	var totalsoloint=0;


	// PUERTAS
	for(k=37;k<40;k++){
		if (valores[k]!=""){
			//document.write(valores[k] + "<BR>");
			var datos = valores[k].split("-");
			var cte=0;
			var unidades = 0;
			for(m=0;m<(datos.length-1);m++){

				
				//alert(datos[m].substr((datos[m].indexOf("puerta")+"puerta".length),(datos[m].indexOf("_")-(datos[m].indexOf("puerta")+"puerta".length))));
				//alert(datos[m].substr((datos[m].indexOf("_")+1),datos[m].length));
				
				i = parseInt(datos[m].substr((datos[m].indexOf("puerta")+"puerta".length),(datos[m].indexOf("_")-(datos[m].indexOf("puerta")+"puerta".length))))
			
				// Serie
				if (i<11){
					//Gorbea
					indice = "G";			
				} else if (i<22) {
					//Serantes
					indice = "S";
				} else if (i<75) {
					//Argalario
					indice = "A";
				}  else if (i<80) {
					//Cenefas
					indice = "C";			
				}  else {
					//Aneto
					indice = "X";
				}

				// Madera
				if (valores[4]==1){
					// Sapelly
					indice = indice + "S";
				} else if (valores[4]==2){
					// Haya
					indice = indice + "H";
				} else if (valores[4]==3){
					// Cerezo
					indice = indice + "C";
				} else if (valores[4]==4) {
					indice = indice + "H";
				}
				
				//Apertura
				if (k==37){
					// Abatibles
					indice = indice + "A";
					apertura = "Abatible"
				} else if (k==38){
					// Plegables
					indice = indice + "P";
					apertura = "Plegable"
				} else if (k==39){
					// Correderas
					indice = indice + "C";
					apertura = "Corredera"
				}

				//alert("indice " + indice);

				//Tamaño
				var divisor=0;

				for (j=40;j<43;j++){
					if (!isNaN(parseInt(valores[j]))){
						divisor = divisor + parseInt(valores[j]);
					}
				}
				
				if (divisor>0){
				
					if ((k==37) || (k==38)){
						if (parseInt(valores[2]/parseInt(divisor))<28){
							continuar=false;
							menor=true;
						}else{
							if ((parseInt(valores[2]/parseInt(divisor))<31)) indice = indice + "30"; 
							else if (parseInt(valores[2]/parseInt(divisor))<36) indice = indice + "35";
							else if (parseInt(valores[2]/parseInt(divisor))<41) indice = indice + "40";
							else if (parseInt(valores[2]/parseInt(divisor))<46) indice = indice + "45";
							else if (parseInt(valores[2]/parseInt(divisor))<53) indice = indice + "50";
							else {
								continuar=false;
								menor=false;
							}
						}
					} else if (k==39) {
						if (parseInt(valores[2]/parseInt(divisor))<58){
							continuar=false;
							menor=true;
						}else{
							if (parseInt(valores[2]/parseInt(divisor))<61) indice = indice + "30"; 
							else if (parseInt(valores[2]/parseInt(divisor))<71) indice = indice + "35";
							else if (parseInt(valores[2]/parseInt(divisor))<81) indice = indice + "40";
							else if (parseInt(valores[2]/parseInt(divisor))<91) indice = indice + "45";
							else if (parseInt(valores[2]/parseInt(divisor))<106) indice = indice + "50";
							else {
								continuar=false;
								menor=true;
							}
						}
					}

					if (continuar) {
						i = i + 28;

						//document.write("Indice:" + indice + "<BR>");
						
						//alert("I " + i);

						unidades = parseInt(datos[m].substr((datos[m].indexOf("_")+1),datos[m].length));

						//document.write("Precio:" + Puertas[indice + "_" + i] + "<BR>");
						//document.write("Puerta:" + Puertas[i] + "<BR>");
						//document.write("Unidades:" + unidades + "<BR>");
						
						if (valores[43]=="1") {
							totalTexto = (parseInt( (unidades * Puertas[indice + "_" + i] * (Otros[8]/10)) * Otros[18])).toString();
							total = total + parseInt( (unidades * Puertas[indice + "_" + i] * (Otros[8]/10)) * Otros[18]);
						} else if (valores[43]=="2") {
							totalTexto = (parseInt( (unidades * Puertas[indice + "_" + i] * (Otros[8]/10)) * Otros[19])).toString();
							total = total + parseInt( (unidades * Puertas[indice + "_" + i] * (Otros[8]/10)) * Otros[19]);
						} else if (valores[43]=="3") {
							totalTexto = (parseInt( (unidades * Puertas[indice + "_" + i] * (Otros[8]/10)) * Otros[20])).toString();
							total = total + parseInt( (unidades * Puertas[indice + "_" + i] * (Otros[8]/10)) * Otros[20]);
						} else if (valores[43]=="4") {
							totalTexto = (parseInt( (unidades * Puertas[indice + "_" + i] * (Otros[8]/10)) * Otros[21])).toString();
							total = total + parseInt( (unidades * Puertas[indice + "_" + i] * (Otros[8]/10)) * Otros[21]);
						} else {
							totalTexto = (parseInt( (unidades * Puertas[indice + "_" + i] * (Otros[8]/10)) *100)).toString();
							total = total + parseInt( (unidades * Puertas[indice + "_" + i] * (Otros[8]/10)) *100);
						}
						document.write('<tr class="v10negra">');
						document.write('<td bgcolor="#B4D8CD">' + unidades + '</td>');
						document.write('<td bgcolor="#CCDAC5">' + Puertas[i] + '&nbsp;' + apertura + '</td>');
						document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
						document.write("</tr>");
						contadorConceptos = contadorConceptos + 1;
						
					} else {
						i = i + 28;

						unidades = parseInt(datos[m].substr((datos[m].indexOf("_")+1),datos[m].length));

						document.write('<tr class="v10negra">');
						document.write('<td bgcolor="#B4D8CD">' + unidades + '</td>');
						if ((k==37) || (k==38)){
							if (menor) document.write('<td bgcolor="#CCDAC5">' + Puertas[i] + '&nbsp;' + apertura + ' no standard menor 30 cm.</td>');
							else document.write('<td bgcolor="#CCDAC5">' + Puertas[i] + '&nbsp;' + apertura + ' standard excede 50 cm.</td>');
						} else if (k==39){
							if (menor) document.write('<td bgcolor="#CCDAC5">' + Puertas[i] + '&nbsp;' + apertura + ' no standard menor 60 cm.</td>');
							else document.write('<td bgcolor="#CCDAC5">' + Puertas[i] + '&nbsp;' + apertura + ' no standard excede 100 cm.</td>');
						}
						document.write('<td bgcolor="#B4D8CD" align="right">CONSULTAR</td>');
						document.write("</tr>");
						contadorConceptos = contadorConceptos + 1;
					}
				}
			}
		}
	}

	//DESCUENTO POR FRONTAL
	armarioMontaje = false;
	if (parseInt(total) > 0){
		armarioMontaje = true;
		if (valores[0]=="3"){
			total = total - parseInt( Otros[0] * (valores[2]/100) * (Otros[8]/10) * 100);
			totalTexto = (parseInt( Otros[0] * (valores[2]/100) * (Otros[8]/10) * 100)).toString();
			document.write('<tr class="v10negra">');
			document.write('<td bgcolor="#B4D8CD">-</td>');
			document.write('<td bgcolor="#CCDAC5">Descuento por sólo Frontal</td>');
			document.write('<td bgcolor="#B4D8CD" align="right">-' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) +  '</td>');
			document.write("</tr>");
			contadorConceptos = contadorConceptos + 1;
		}
	}


	//document.write("total puertas:" + total + "<BR>");
	//EXTERIOR
	if (armarioMontaje){
		if (valores[4]==1) {
			total = total + parseInt(ES[0] * (Otros[8]/10) * 100);
			totalTexto = (parseInt(ES[0] * (Otros[8]/10) * 100)).toString();
		} else if (valores[4]==2) {
			total = total + parseInt(ES[0] * (Otros[8]/10) * 100);
			totalTexto = (parseInt(ES[0] * (Otros[8]/10) * 100)).toString();
		} else if (valores[4]==3) {
			total = total + parseInt(ES[0] * (Otros[8]/10) * 100);
			totalTexto = (parseInt(ES[0] * (Otros[8]/10) * 100)).toString();
		} else if (valores[4]==4) {
			if (valores[43]=="1") {							
				total = total + parseInt(EH[0] * (Otros[8]/10) * Otros[18]);				
				totalTexto =  (parseInt(EH[0] * (Otros[8]/10) * Otros[18])).toString();
			} else if (valores[43]=="2") {
				total = total + parseInt(EH[0] * (Otros[8]/10) * Otros[19]);				
				totalTexto =  (parseInt(EH[0] * (Otros[8]/10) * Otros[19])).toString();				
			} else if (valores[43]=="3") {
				total = total + parseInt(EH[0] * (Otros[8]/10) * Otros[20]);				
				totalTexto =  (parseInt(EH[0] * (Otros[8]/10) * Otros[20])).toString();				
			} else if (valores[43]=="4") {
				total = total + parseInt(EH[0] * (Otros[8]/10) * Otros[21]);				
				totalTexto =  (parseInt(EH[0] * (Otros[8]/10) * Otros[21])).toString();
			}
		}
		//document.write("Exterior:" + Ext[0] + "<BR>");
		//document.write("Precio:" + ES[0] + "<BR>");

		//JAMBAS
		document.write('<tr class="v10negra">');
		document.write('<td bgcolor="#B4D8CD">1</td>');
		document.write('<td bgcolor="#CCDAC5">' + Ext[0] + '</td>');
		document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) +  '</td>');
		document.write("</tr>");
		contadorConceptos = contadorConceptos + 1;

	

		for(i=16;i<27;i++){

			if (valores[i]!=""){
				indiceNum = i - 15;
				// Madera
				if (valores[4]==1){
					// Sapelly
					//document.write("Exterior:" + Ext[indiceNum] + "<BR>");
					//document.write("Cantidad:" + valores[i] + "<BR>");
					//document.write("Precio:" + (valores[i] * ES[indiceNum]) + "<BR>");

					document.write('<tr class="v10negra">');
					if ((i==21) || (i==22) || (i==23) || (i==24) || (i==25)){
						total = total + parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * ES[indiceNum] * (Otros[8]/10) * 100);
						totalTexto = (parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * ES[indiceNum] * (Otros[8]/10) * 100)).toString();
						document.write('<td bgcolor="#B4D8CD">1</td>');
						document.write('<td bgcolor="#CCDAC5">' + Ext[indiceNum]+ '</td>');
						document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
					}
					else {
						total = total + parseInt(valores[i] * ES[indiceNum] * (Otros[8]/10) * 100);
						totalTexto = (parseInt(valores[i] * ES[indiceNum] * (Otros[8]/10)) * 100).toString();
						document.write('<td bgcolor="#B4D8CD">' + valores[i] + '</td>');
						document.write('<td bgcolor="#CCDAC5">' + Ext[indiceNum]+ '</td>');
						document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
					}
					
					document.write("</tr>");
					contadorConceptos = contadorConceptos + 1;

				} else if (valores[4]==2){
					// Haya
					
					//document.write("Exterior:" + Ext[indiceNum] + "<BR>");
					//document.write("Cantidad:" + valores[i] + "<BR>");
					//document.write("Precio:" + ( valores[i] * EH[indiceNum] ) + "<BR>");

					document.write('<tr class="v10negra">');
					if ((i==21) || (i==22) || (i==23) || (i==24) || (i==25)){
						total = total + parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * EH[indiceNum] * (Otros[8]/10) * 100);
						totalTexto = (parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * EH[indiceNum] * (Otros[8]/10) * 100)).toString();
						document.write('<td bgcolor="#B4D8CD">1</td>');
						document.write('<td bgcolor="#CCDAC5">' + Ext[indiceNum]+ '</td>');
						document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
					}
					else {
						total = total + parseInt(valores[i] * EH[indiceNum] * (Otros[8]/10) * 100);
						totalTexto = (parseInt(valores[i] * EH[indiceNum] * (Otros[8]/10) * 100)).toString();
						document.write('<td bgcolor="#B4D8CD">' + valores[i] + '</td>');
						document.write('<td bgcolor="#CCDAC5">' + Ext[indiceNum]+ '</td>');
						document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
					}
					document.write("</tr>");
					contadorConceptos = contadorConceptos + 1;

				} else if (valores[4]==3){
					// Correderas
					//document.write("Exterior:" + Ext[indiceNum] + "<BR>");
					//document.write("Cantidad:" + valores[i] + "<BR>");
					//document.write("Precio:" + ( valores[i] * EC[indiceNum] ) + "<BR>");

					document.write('<tr class="v10negra">');
					if ((i==21) || (i==22) || (i==23) || (i==24) || (i==25)){					
						total = total + parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * EC[indiceNum] * (Otros[8]/10) * 100);
						totalTexto = (parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * EC[indiceNum] * (Otros[8]/10) * 100)).toString();
						document.write('<td bgcolor="#B4D8CD">1</td>');
						document.write('<td bgcolor="#CCDAC5">' + Ext[indiceNum]+ '</td>');
						document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
					}
					else {
						total = total + parseInt(valores[i] * EC[indiceNum] * (Otros[8]/10) * 100);
						totalTexto = (parseInt(valores[i] * EC[indiceNum] * (Otros[8]/10) * 100)).toString();
						document.write('<td bgcolor="#B4D8CD">' + valores[i] + '</td>');
						document.write('<td bgcolor="#CCDAC5">' + Ext[indiceNum]+ '</td>');
						document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
					}
					document.write("</tr>");
					contadorConceptos = contadorConceptos + 1;
				} else if (valores[4]==4){
					// Haya
					
					//document.write("Exterior:" + Ext[indiceNum] + "<BR>");
					//document.write("Cantidad:" + valores[i] + "<BR>");
					//document.write("Precio:" + ( valores[i] * EH[indiceNum] ) + "<BR>");

					document.write('<tr class="v10negra">');
					if ((i==21) || (i==22) || (i==23) || (i==24) || (i==25)){
						if (valores[43]=="1") {							
							total = total + parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * EH[indiceNum] * (Otros[8]/10) * Otros[18]);				
							totalTexto =  ( parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * EH[indiceNum] * (Otros[8]/10) * Otros[18])).toString();
						} else if (valores[43]=="2") {
							total = total + parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * EH[indiceNum] * (Otros[8]/10) * Otros[19]);				
							totalTexto =  ( parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * EH[indiceNum] * (Otros[8]/10) * Otros[19])).toString();
						} else if (valores[43]=="3") {
							total = total + parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * EH[indiceNum] * (Otros[8]/10) * Otros[20]);				
							totalTexto =  ( parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * EH[indiceNum] * (Otros[8]/10) * Otros[20])).toString();
						} else if (valores[43]=="4") {
							total = total + parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * EH[indiceNum] * (Otros[8]/10) * Otros[21]);				
							totalTexto =  ( parseInt((parseInt(valores[40]) + parseInt(valores[41]) + parseInt(valores[42])) * EH[indiceNum] * (Otros[8]/10) * Otros[21])).toString();
						}
						document.write('<td bgcolor="#B4D8CD">1</td>');
						document.write('<td bgcolor="#CCDAC5">' + Ext[indiceNum]+ '</td>');
						document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
					}
					else {
						if (valores[43]=="1") {							
							total = total + parseInt(valores[i] * EH[indiceNum] * (Otros[8]/10) * Otros[18]);				
							totalTexto =  ( parseInt(valores[i] * EH[indiceNum] * (Otros[8]/10) * Otros[18])).toString();
						} else if (valores[43]=="2") {
							total = total + parseInt(valores[i] * EH[indiceNum] * (Otros[8]/10) * Otros[19]);				
							totalTexto =  ( parseInt(valores[i] * EH[indiceNum] * (Otros[8]/10) * Otros[19])).toString();				
						} else if (valores[43]=="3") {
							total = total + parseInt(valores[i] * EH[indiceNum] * (Otros[8]/10) * Otros[20]);				
							totalTexto =  ( parseInt(valores[i] * EH[indiceNum] * (Otros[8]/10) * Otros[20])).toString();			
						} else if (valores[43]=="4") {
							total = total + parseInt(valores[i] * EH[indiceNum] * (Otros[8]/10) * Otros[21]);				
							totalTexto =  ( parseInt(valores[i] * EH[indiceNum] * (Otros[8]/10) * Otros[21])).toString();
						}
						document.write('<td bgcolor="#B4D8CD">' + valores[i] + '</td>');
						document.write('<td bgcolor="#CCDAC5">' + Ext[indiceNum]+ '</td>');
						document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
					}
					document.write("</tr>");
					contadorConceptos = contadorConceptos + 1;

				}
				
			}
		}
	}

	//SOLO INTERIOR
	if (valores[0]!="3"){	
		if ((valores[1]>260) && (valores[3]>70)){				
			totalsoloint = totalsoloint + parseInt(Otros[17] * (valores[2]/100) * (Otros[8]/10) * 100);
			if (valores[0]=="2"){
				totalTexto = (parseInt( Otros[17] * (valores[2]/100) * (Otros[8]/10) * 100)).toString();
				document.write('<tr class="v10negra">');
				document.write('<td bgcolor="#B4D8CD">' + (valores[2]/100) + '</td>');
				document.write('<td bgcolor="#CCDAC5">' + OtrosDesc[8] + '</td>');
				document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
				document.write("</tr>");
				contadorConceptos = contadorConceptos + 1;
			}
		} else if (valores[1]>260){
			totalsoloint = totalsoloint + parseInt( Otros[2] * (valores[2]/100) * (Otros[8]/10) * 100);
			if (valores[0]=="2"){
				totalTexto = (parseInt( Otros[2] * (valores[2]/100) * (Otros[8]/10) * 100)).toString();
				document.write('<tr class="v10negra">');
				document.write('<td bgcolor="#B4D8CD">' + (valores[2]/100) + '</td>');
				document.write('<td bgcolor="#CCDAC5">' + OtrosDesc[2] + '</td>');
				document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
				document.write("</tr>");
				contadorConceptos = contadorConceptos + 1;
			}
		} else if (valores[3]>70){
			totalsoloint = totalsoloint +  parseInt( Otros[1] * (valores[2]/100) * (Otros[8]/10) * 100);
			if (valores[0]=="2"){
				totalTexto = (parseInt( Otros[1] * (valores[2]/100) * (Otros[8]/10) * 100)).toString();
				document.write('<tr class="v10negra">');
				document.write('<td bgcolor="#B4D8CD">' + (valores[2]/100) + '</td>');
				document.write('<td bgcolor="#CCDAC5">' + OtrosDesc[1] + '</td>');
				document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
				document.write("</tr>");
				contadorConceptos = contadorConceptos + 1;
			}
		} else{
			if (valores[0]=="2"){
				totalsoloint = totalsoloint + parseInt( Otros[0] * (valores[2]/100) * (Otros[8]/10) * 100);
				totalTexto = (parseInt( Otros[0] * (valores[2]/100) * (Otros[8]/10) * 100)).toString();
				document.write('<tr class="v10negra">');
				document.write('<td bgcolor="#B4D8CD">' + (valores[2]/100) + '</td>');
				document.write('<td bgcolor="#CCDAC5">' + OtrosDesc[0] + '</td>');
				document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
				document.write("</tr>");
				contadorConceptos = contadorConceptos + 1;
			}
		}
 		
		if (valores[34]=="1" && valores[0]=="2"){
			// abuardillado
			totalsoloint = totalsoloint + parseInt( Otros[3] * (valores[2]/100) * (Otros[8]/10) * 100);
			totalTexto = (parseInt( Otros[3] * (valores[2]/100) * (Otros[8]/10) * 100)).toString();
			document.write('<tr class="v10negra">');
			document.write('<td bgcolor="#B4D8CD">' + (valores[2]/100) + '</td>');
			document.write('<td bgcolor="#CCDAC5">' + OtrosDesc[3] + '</td>');
			document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
			document.write("</tr>");
			contadorConceptos = contadorConceptos + 1;
		}
	}
	
	//INTERIOR

	for(i=5;i<15;i++){
		if (valores[i]!=""){
			indiceNum = i - 5;
			/*
			// Madera
			if (valores[4]==1){
				// Sapelly
				total = total + (valores[i] * IS[indiceNum]);
				//document.write("Interior:" + Itr[indiceNum] + "<BR>");
				//document.write("Cantidad:" + valores[i] + "<BR>");
				//document.write("Precio:" + (valores[i] * IS[indiceNum]) + "<BR>");

				document.write('<tr class="v10negra">');
				document.write('<td bgcolor="#B4D8CD">' + valores[i] + '</td>');
				document.write('<td bgcolor="#CCDAC5">' + Itr[indiceNum]+ '</td>');
				document.write('<td bgcolor="#B4D8CD" align="right">' + parseInt(valores[i] * IS[indiceNum] * (Otros[8]/10))  + '</td>');
				document.write("</tr>");
				contadorConceptos = contadorConceptos + 1;

			} else if (valores[4]==2){
				// Haya
				total = total + parseInt(IH[indiceNum]);
				//document.write("Interior:" + Itr[indiceNum] + "<BR>");
				//document.write("Cantidad:" + valores[i] + "<BR>");
				//document.write("Precio:" + ( valores[i] * IH[indiceNum] ) + "<BR>");

				document.write('<tr class="v10negra">');
				document.write('<td bgcolor="#B4D8CD">' + valores[i] + '</td>');
				document.write('<td bgcolor="#CCDAC5">' + Itr[indiceNum]+ '</td>');
				document.write('<td bgcolor="#B4D8CD" align="right">' + parseInt(valores[i] * IH[indiceNum] * (Otros[8]/10))  + '</td>');
				document.write("</tr>");
				contadorConceptos = contadorConceptos + 1;

			} else if (valores[4]==3){
				// Correderas
				total = total + parseInt(IC[indiceNum]);
				//document.write("Interior:" + Itr[indiceNum] + "<BR>");
				//document.write("Cantidad:" + valores[i] + "<BR>");
				//document.write("Precio:" + ( valores[i] * IC[indiceNum] ) + "<BR>");

				document.write('<tr class="v10negra">');
				document.write('<td bgcolor="#B4D8CD">' + valores[i] + '</td>');
				document.write('<td bgcolor="#CCDAC5">' + Itr[indiceNum]+ '</td>');
				document.write('<td bgcolor="#B4D8CD" align="right">' + parseInt(valores[i] * IC[indiceNum] * (Otros[8]/10))  + '</td>');
				document.write("</tr>");
				contadorConceptos = contadorConceptos + 1;
			
			}
			*/

			//NUEVO NO DEPENDE DE LA MADERA
			if (valores[4]==4){
				if (valores[43]=="1") {							
					total = total + parseInt(valores[i] * IS[indiceNum] * (Otros[8]/10) * Otros[18]);				
					totalTexto =  (parseInt(valores[i] * IS[indiceNum] * (Otros[8]/10) * Otros[18])).toString();
				} else if (valores[43]=="2") {
					total = total + parseInt(valores[i] * IS[indiceNum] * (Otros[8]/10) * Otros[19]);				
					totalTexto =  (parseInt(valores[i] * IS[indiceNum] * (Otros[8]/10) * Otros[19])).toString();
				} else if (valores[43]=="3") {
					total = total + parseInt(valores[i] * IS[indiceNum] * (Otros[8]/10) * Otros[20]);				
					totalTexto =  (parseInt(valores[i] * IS[indiceNum] * (Otros[8]/10) * Otros[20])).toString();
				} else if (valores[43]=="4") {
					total = total + parseInt(valores[i] * IS[indiceNum] * (Otros[8]/10) * Otros[21]);				
					totalTexto =  (parseInt(valores[i] * IS[indiceNum] * (Otros[8]/10) * Otros[21])).toString();
				}
			} else {
				total = total + parseInt(valores[i] * IS[indiceNum] * (Otros[8]/10) * 100);
				totalTexto = (parseInt(valores[i] * IS[indiceNum] * (Otros[8]/10) * 100)).toString();
			}
			document.write('<tr class="v10negra">');
			document.write('<td bgcolor="#B4D8CD">' + valores[i] + '</td>');
			document.write('<td bgcolor="#CCDAC5">' + Itr[indiceNum]+ '</td>');
			document.write('<td bgcolor="#B4D8CD" align="right">' + totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length) + '</td>');
			document.write("</tr>");
			contadorConceptos = contadorConceptos + 1;
		}
	}

	//OTROS
	/*for(i=118;i<127;i++){
		if (valores[i]!=""){
			//OTROS
		}
	}*/

	//TOTAL
	//total = parseInt( total * (Otros[8]/10));
	//if (armarioMontaje && valores[0]=="1") total = total + totalsoloint;
	if (valores[0]=="2") total = total + totalsoloint;
	//if (valores[0]=="3") total = total - totalsoloint;
	return total;

	//document.write("Total:" + total + "<BR>");
}
function escribir(valorDato){
	totalTexto = (valorDato).toString();
	document.write(totalTexto.substr(0,(totalTexto.length-2))+ "." +  totalTexto.substr((totalTexto.length-2),totalTexto.length));
}

function armMontaje(){
	var totalmontador=0;
	//Otros
	if (valores[29]!="")
		totalmontador = totalmontador + parseInt(valores[29] * Otros[6] * 100);
	if (valores[30]!="")
		totalmontador = totalmontador + parseInt(valores[30] * Otros[7] * 100);

	//Montaje de interior para Solo Interior
	if (valores[2]!="" && (valores[0]=="2")){
		totalmontador = totalmontador + parseInt(Otros[4] * (valores[2]/100) * 100);	
	}

	//Montaje de exterior
	if (armarioMontaje && valores[2]!="" && ((valores[0]=="1") || (valores[0]=="3"))){
		totalmontador = totalmontador + parseInt(Otros[5] * (valores[2]/100) * 100);	
	}

	//Salidas de Salidas y Mediciones
	if (valores[36]!=""){
		if (valores[36]=="1")
			totalmontador = totalmontador + parseInt(Otros[12] * 100);
		else if (valores[36]=="2")
			totalmontador = totalmontador + parseInt(Otros[14] * 100);
		else if (valores[36]=="3")
			totalmontador = totalmontador + parseInt(Otros[16] * 100);
	}
	return totalmontador;
}

function armMedicion(){
	var totalmedicion=0;
	if (valores[36]!=""){
		if (valores[36]=="1")
			totalmedicion = totalmedicion + parseInt(Otros[11] * 100);
		else if (valores[36]=="2")
			totalmedicion = totalmedicion + parseInt(Otros[13] * 100);
		else if (valores[36]=="3")
			totalmedicion = totalmedicion + parseInt(Otros[15] * 100);
	}
	//Otros
	if (valores[29]!="")
		totalmedicion = totalmedicion + parseInt( valores[29] * Otros[9] * 100);
	if (valores[30]!="")
		totalmedicion = totalmedicion + parseInt( valores[30] * Otros[10] * 100);
	return totalmedicion;
}

function agregarConceptos(){
var indiceFor;
	if (contadorConceptos<11){
		for(indiceFor=0;indiceFor<(11-contadorConceptos);indiceFor++){
			document.write('<tr class="v10negra">');
			document.write('<td bgcolor="#B4D8CD">&nbsp;</td>');
			document.write('<td bgcolor="#CCDAC5">&nbsp;</td>');
			document.write('<td bgcolor="#B4D8CD">&nbsp;</td>');
			document.write("</tr>");
		}
	}
}
