/* -------------------------------------------------------------------------------------------------- */
function limpiarCombo(objCombo, objRadAnterior, objRadNuevo)
{
    if (objRadAnterior.value != objRadNuevo)
    {
        objCombo.options.length = 0;
        objRadAnterior.value = objRadNuevo;
    }
}


/* -------------------------------------------------------------------------------------------------- */
function InsertarFila()
{
    var tabla = document.getElementById('grvCotizacion2');
    var fila =tabla.tBodies[0].insertRow(0);
    
    fila.setAttribute('className', 'cabecera_grilla'); 
    fila.setAttribute('class', 'cabecera_grilla'); 
    
    try 
    {
        var columna = document.createElement('<TH colspan=3/>');
    }
    catch (err) 
    {
        var columna = document.createElement('TH');
        columna.setAttribute('colspan', '3');
    }
    
    columna.setAttribute('scope', 'col'); 
    columna.setAttribute('className', 'ServAdicTrans');
    columna.setAttribute('class', 'ServAdicTrans');
    columna.innerHTML = '&nbsp;'
    fila.appendChild(columna);
    
    try 
    {
        columna = document.createElement('<TH colspan=5/>');
    }
    catch (err) 
    {
        columna = document.createElement('TH');
        columna.setAttribute('colspan', '5');
    }
    columna.setAttribute('scope', 'col'); 
    columna.setAttribute('className', 'ServAdicOpaco');
    columna.setAttribute('class', 'ServAdicOpaco');
    columna.setAttribute('vAlign', 'center'); 
    columna.setAttribute('align', 'middle'); 
    columna.innerHTML = 'Plazos de Entrega'
    fila.appendChild(columna);
}


/* -------------------------------------------------------------------------------------------------- */
function AgregarServiciosDisponibles()
{
    var myGrv = document.getElementById('grvCotizacion2');
    if (myGrv != undefined && myGrv != null)
    {   
        var sMyGrv = myGrv.outerHTML;
        InsertarFila();
    }
}


/* -------------------------------------------------------------------------------------------------- */
function setearFormaPago()
{
    if (document.form1.radConRetiro.checked)
        document.form1.hdfFormaPago.value = "1";
    else if (document.form1.radSinRetiro.checked)
        document.form1.hdfFormaPago.value = "2";
    else if (document.form1.radSinRetiro2.checked)
        document.form1.hdfFormaPago.value = "3";
}


/* -------------------------------------------------------------------------------------------------- */
function habilitarPanRetiro(opcion, formaPago)
{
    if(opcion)
        document.form1.hdfOpcionEncabezado.value = "tr_con_retiro"
    else
        document.form1.hdfOpcionEncabezado.value = "tr_sin_retiro"

    if (document.form1.txtValPagar != undefined && document.getElementById('panRetiro') != undefined)
    {
        if (opcion)
        {
        document.form1.txtValPagar.value = document.form1.hdfMontoConRetiro.value
        document.getElementById('panRetiro').style.display = '';
        document.form1.hdfOpcionEncabezado.value = "tr_con_retiro"
        }
        else
        {
        document.form1.txtValPagar.value = document.form1.hdfMontoSinRetiro.value
        document.getElementById('panRetiro').style.display = 'none';
        document.form1.hdfOpcionEncabezado.value = "tr_sin_retiro"
        }
    }
}


/* -------------------------------------------------------------------------------------------------- */
function setearOnLoad()
{   
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_pageLoaded(mostrar_alerta);
    //prm.add_pageLoaded(AgregarServiciosDisponibles);
}


/* -------------------------------------------------------------------------------------------------- */
function mostrar_alerta()
{
    if (document.form1.hdfMensaje.value != "")
    {
        alert(document.form1.hdfMensaje.value);
        document.form1.hdfMensaje.value = "";
    }
    if (document.form1.hdfFoco.value != "")
    {
        try
        {
            eval("document.form1." + document.form1.hdfFoco.value).select();
        }
        catch(err)
        {
            eval("document.form1." + document.form1.hdfFoco.value).focus();
        }
        document.form1.hdfFoco.value = "";
    }
}


/* -------------------------------------------------------------------------------------------------- */
function validarEliminacion(posicion)
{
    document.form1.hdfItem.value= posicion; 
    if (document.form1.hdfContItem.value> 1)
        return true;
    else
        alert("No puede eliminar el único ítem para ingreso del envío.")
    return false;
}


/* -------------------------------------------------------------------------------------------------- */
function txtdim1_onkeypress() {
	if (esnumerico() == false){ 
		event.keyCode = 0
	}
	else{
		if (event.keyCode == 13){
			formulario.txtdim2.focus ();
		}
	}
}


/* -------------------------------------------------------------------------------------------------- */
function txtdim2_onkeypress(){
	if (esnumerico() == false){ 
		event.keyCode = 0
	}
	else{
		 if (event.keyCode == 13){
			formulario.txtdim3.focus ();
		 }
	}
}


/* -------------------------------------------------------------------------------------------------- */
function txtdim3_onkeypress(){
	if (esnumerico() == false){ 
		event.keyCode = 0
	}
}


/* -------------------------------------------------------------------------------------------------- */
function esnumerico()
{
    var valorascii;
    valorascii = event.keyCode; 	
    var valret = true;
	if (valorascii < 48 || valorascii > 57)
		{
		if (valorascii != 8 && valorascii != 13 && valorascii != 27 && valorascii != 46)
			{
			valret = false;
			}
		}
		return valret;
}		

