String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
//**************************************************************************
function fFiltrar(){
	document.getElementById("TxtAc").value="F";
	document.getElementById("Frm").submit();
}
//**************************************************************************
function fCancelar(){
	document.getElementById("TxtCod").value="";
	document.getElementById("CboLin").value="";
	document.getElementById("TxtDes").value="";
	document.getElementById("CboMar").value="";
	document.getElementById("CboUni").value="";
	document.getElementById("TxtPcS").value="";
	document.getElementById("TxtPcD").value="";
	document.getElementById("TxtPvMin").value="";
	document.getElementById("TxtPvMax").value="";
	document.getElementById("DivSTOCK").innerHTML="";
	document.getElementById("DivSTOCKm").innerHTML="";
	document.getElementById("DivPRECIOS").innerHTML="";
	document.getElementById("CmdE").disabled =true;
	document.getElementById("CmdG").value="Guardar";
	document.getElementById("TxtId").value="";
	document.getElementById("TxtAc").value="";
	document.getElementById("TxtCod").focus();
}
//**************************************************************************
function CalcularDOL(){
	var PcS=document.getElementById("TxtPcS").value;
	var Tc=document.getElementById("TxtTC").value;
	var PcD=parseFloat("0");
	if(PcS.trim().length==0)PsC="0";
	if(Tc.trim().length==0)Tc="0";
	PcS=parseFloat(PcS);
	Tc=parseFloat(Tc);
	PcD=PcS / Tc;
	PcD=PcD.toFixed(2);	
	if(PcD=="NaN"){
		document.getElementById("TxtPcD").value="0";
	}else{
		document.getElementById("TxtPcD").value=PcD;
	}

}
//**************************************************************************
function fGuardar(){
	var Cod=document.getElementById("TxtCod").value;
	var Lin=document.getElementById("CboLin").value;
	var Des=document.getElementById("TxtDes").value;
	var Mar=document.getElementById("CboMar").value;
	var Uni=document.getElementById("CboUni").value;
	var PcS=document.getElementById("TxtPcS").value;
	var PcD=document.getElementById("TxtPcD").value;
	var PMin=document.getElementById("TxtPvMin").value;
	var PMax=document.getElementById("TxtPvMax").value;
	var StrF=gv("Foto");
	//
	if(Des.trim().length==0){
		alert("Ingrese la descripcion o nombre del producto");
		document.getElementById("TxtDes").focus();
		return;
	}
	//
	if(jLen(StrF)>0){
		StrF=StrF.toUpperCase();
		var png=StrF.indexOf(".PNG");
		var bmp=StrF.indexOf(".BMP");
		var jpg=StrF.indexOf(".JPG");
		if(png==-1 && bmp==-1 && jpg==-1){
			return AF("Solo se permite imagenes de los siguientes formatos .png , .bmp , .jpg","Foto");
		}
		var F11=document.getElementById("Foto");
		var StrFile = F11.files[0];
		if(StrFile.size>80*1024){
			alert("El tamaño del archivo no debe ser superior a 2MB");
			jF("Foto");
			return;
		}
	}
	//
	if(document.getElementById("CmdG").value=="Guardar"){
		document.getElementById("TxtAc").value="G";
	}else{
		document.getElementById("TxtAc").value="M";
	}
	document.getElementById("Frm").submit();
}
/**************************************************************************
	onkeypress="return pulsar(event);"
**************************************************************************/
function pulsar(e) { 	
	var tecla = (document.all) ? e.keyCode :e.which; 
	var Obj=event.srcElement.name;	
	if(Obj=="TxtNom"){
		if(tecla==13){			
			document.getElementById('CmdG').click();			
		}
	}	
	return (tecla!=13); 
} 
//**************************************************************************
