function addProdutoArmazenado(){
	
	var vc_erro		= new String();

	if (document.getElementById("vc_produto_armazenado").value.length == 0){
		vc_erro	+= '- Digite O PRODUTO A SER ARMAZENADO .\n';
	}
	
	if (document.getElementById("vc_densidade").value.length == 0){
		vc_erro	+= '- Digite a DENSIDADE.\n';
	}
	
	if (document.getElementById("vc_viscosidade").value.length == 0){
		vc_erro	+= '- Digite a viscosidade.\n';
	}
	
	if (document.getElementById("vc_temperatura").value.length == 0){
		vc_erro	+= '- Digite a TEMPERATURA.\n';
	}
	
	
	if (vc_erro.length == 0) {
		if (document.frm_cotacao.vc_produto_armazenado.length){ 
			var vc_produto_armazenado 	= document.frm_cotacao.vc_produto_armazenado[0].value;
			var vc_densidade 			= document.frm_cotacao.vc_densidade[0].value;
			var vc_viscosidade 			= document.frm_cotacao.vc_viscosidade[0].value;
			var vc_temperatura 			= document.frm_cotacao.vc_temperatura[0].value;
		}else{
			var vc_produto_armazenado 	= document.frm_cotacao.vc_produto_armazenado.value;
			var vc_densidade 			= document.frm_cotacao.vc_densidade.value;
			var vc_viscosidade 			= document.frm_cotacao.vc_viscosidade.value;
			var vc_temperatura 			= document.frm_cotacao.vc_temperatura.value;	
		}
		html = 	"	 	<table>												"
		html += "	   <tr>																				"
		html += "        <td><input class='bx_01' readonly type='text' name='vc_produto_armazenado' value='"+vc_produto_armazenado+"' id='textfield11'></td>				"
		html += "        <td><input class='bx_01' readonly name='vc_densidade' type='text' value='"+vc_densidade+"' id='textfield12' size='10'></td>		"
		html += "        <td><input class='bx_01' readonly name='vc_viscosidade' type='text' value='"+vc_viscosidade+"' id='textfield13' size='10'></td>		"
		html += "        <td><input class='bx_01' readonly type='text' name='vc_temperatura' value='"+vc_temperatura+"' id='textfield14'></td>				"
		html += "        <td><label>																	"
		html += "          <input type='button' onClick='removeProdutoArmazenado(this)'  value='Excluir' >	"
		html += "        </label></td>																	"
		html += "      </tr>																			"
		html += "   </table> 																			"
	
		document.getElementById('produto_armazenado').innerHTML += html;
		
		// verifico se já foi adicionado algum campo para recuperar as informações sempre da primeira linha
		if (document.frm_cotacao.vc_produto_armazenado.length){ 
			document.frm_cotacao.vc_produto_armazenado[0].value = "";
			document.frm_cotacao.vc_densidade[0].value = "";
			document.frm_cotacao.vc_viscosidade[0].value = "";
			document.frm_cotacao.vc_temperatura[0].value = "";
		}	
	}else{
		alert('ATENÇÃO!\n\n' + vc_erro);
		return false;
	}
}

function removeProdutoArmazenado(obj){
	pai   = 	filho = obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
	filho = obj.parentNode.parentNode.parentNode.parentNode.parentNode;
	pai.removeChild(filho);
}

function addProdutoModelo(){
	var vc_erro		= new String();

	if (document.getElementById("vc_produto_modelo").value == 0){
		vc_erro	+= '- Informe o MODELO.\n';
	}
	
	if (document.getElementById("vc_produto_capacidade").value.length == 0){
		vc_erro	+= '- Digite a CAPACIDADE DO PRODUTO A SER ARMAZENADO.\n';
	}
	
	if (vc_erro.length == 0) 
	{
		if (document.frm_cotacao.vc_produto_capacidade.length){ 
			var vc_produto_modelo 		= document.frm_cotacao.vc_produto_modelo[0].value;
			var vc_produto_capacidade	= document.frm_cotacao.vc_produto_capacidade[0].value;
		}else{
			var vc_produto_modelo 		= document.frm_cotacao.vc_produto_modelo.value;
			var vc_produto_capacidade	= document.frm_cotacao.vc_produto_capacidade.value;	
		}
	
	
	html = 	"	 	<table>												"
	html += "	   <tr>																				"
	html += "        <td><input class='bx_01' readonly type='text' name='vc_produto_modeloA' value='"+vc_produto_modelo+"' ></td>				"
	html += "        <td><input class='bx_01' readonly name='vc_produto_capacidadeA' type='text' value='"+vc_produto_capacidade+"' size='10'></td>		"
	html += "        <td><label>																	"
	html += "          <input type='button' onClick='removeProdutoModelo(this)'  value='Excluir' >	"
	html += "        </label></td>																	"
	html += "      </tr>																			"
	html += "   </table> 																			"

	document.getElementById('cotacao_produto').innerHTML += html;
	
	// verifico se já foi adicionado algum campo para recuperar as informações sempre da primeira linha

	//document.frm_cotacao.vc_produto_modelo[0].value = "";
	document.frm_cotacao.vc_produto_capacidade.value = "";
		return true;
	} 
	else 
	{
		alert('ATENÇÃO!\n\n' + vc_erro);
		return false;
	}

	

}

function removeProdutoModelo(obj){
	filho = obj.parentNode.parentNode.parentNode.parentNode.parentNode;
	pai	= filho.parentNode;
	pai.removeChild(filho);
}

function verificaCotacao()
{
	var vc_erro		= new String();
	
	if (document.getElementById("vc_empresa").value.length == 0) 
	{
	 	vc_erro		+= '- Digite a EMPRESA.\n';
	}
	
	if (document.getElementById("vc_contato").value.length == 0) 
	{
	 	vc_erro		+= '- Digite o CONTATO.\n';
	}
	
	if (document.getElementById("vc_departamento").value.length == 0) 
	{
	 	vc_erro		+= '- Digite o DEPARTAMENTO.\n';
	}

	if (document.getElementById("vc_telefone").value.length == 0) 
	{
	 	vc_erro		+= '- Digite o TELEFONE.\n';
	}

	if (document.getElementById("vc_email").value.length != 0){
		vc_erro	+= verficaEmail(document.getElementById("vc_email").value);
	}else{
		vc_erro	+= '- Digite o E-MAIL.\n';
	}
	
	if (vc_erro.length == 0) 
	{
		//Faz tratamento nas virgulas;		
		objs  = document.getElementsByName('vc_produto_armazenado')
		objs1 = document.getElementsByName('vc_densidade')
		objs2 = document.getElementsByName('vc_viscosidade')
		objs3 = document.getElementsByName('vc_temperatura');
		for(i=0;i<objs.length;i++){
			objs[i].value = objs[i].value.replace(/,/g,"'");
			objs1[i].value = objs1[i].value.replace(/,/g,"'");
			objs2[i].value = objs2[i].value.replace(/,/g,"'");
			objs3[i].value = objs3[i].value.replace(/,/g,"'");
		}
		/* ---------------------------------------- */
		
		
		objs4 = document.getElementsByName('vc_produto_modelo');
		objs5 = document.getElementsByName('vc_produto_capacidade');
		
		for(i=0;i<objs4.length;i++){
			objs4[i].value = objs4[i].value.replace(/,/g,"'");
			objs5[i].value = objs5[i].value.replace(/,/g,"'");
		}
		
		document.getElementById("button2").value	= 'processando...';
		document.getElementById("button2").disabled	= true;
		
		
		return true;
	} 
	else 
	{
		alert('ATENÇÃO!\n\n' + vc_erro);
		return false;
	}	
}


