var popUp; 

function Popup(id, ti) 
{
    window.open('renglones.aspx?id=' + id + '&tipo=' + ti,'Renglones','toolbars=0,scrollbars=1,location=0, statusbars=0, menubars=0, resizable=0, top=50, left=95,width=600,height=400,screenX=300,screenY=200');
}

function OpenCalendar(idname, postBack)
{
	popUp = window.open('Calendar.aspx?formname=' + document.forms[0].name + 
		'&id=' + idname + '&selected=' + document.forms[0].elements[idname].value + '&postBack=' + postBack, 
		'popupcal', 
		'width=179,height=230,left=200,top=250');
}

function OpenFoto(url)
{
    window.open(url, null, 'toolbars=0,scrollbars=0,location=0,statusbars=0,menubars=0,resizable=1,width=500,height=500');
}

function SetDate(formName, id, newDate, postBack)
{
	eval('var theform = document.' + formName + ';');
	popUp.close();
	theform.elements[id].value = newDate;
	if (postBack)
		__doPostBack(id,'');
}	

var estado_busquedaavanzada_vacio = false;
    
function OnEstadoBusquedaAvanzadaVacio(pthis)
{
    if(estado_busquedaavanzada_vacio == false)
    {
        pthis.value = ''; 
        pthis.style.background = '#FFFFFF'; 
        estado_busquedaavanzada_vacio = true;
    }
}

function OnEstadoBusquedaAvanzadaRellenar(pthis)
{
    if(pthis.value == '')
    {
        /////////pthis.value = "            B\u00fasqueda r\u00e1pida..."; 
        pthis.style.background = '#FFFFFF url(http://www.panamacompra.gob.pa/panamacompra/Images/google_custom_search_watermark.gif) left no-repeat'; 
        estado_busquedaavanzada_vacio = false;
    }
}

var estado_busquedainstituciones_vacio = false;
    
function OnEstadoBusquedaInstitucionesVacio(pthis)
{
    if(estado_busquedainstituciones_vacio == false)
    {
        pthis.value = ''; 
        estado_busquedainstituciones_vacio = true;
    }
}

function OnEstadoBusquedaInstitucionesRellenar(pthis)
{
    if(pthis.value == '')
    {
        pthis.value = 'Ingrese la Institucion...'; 
        estado_busquedainstituciones_vacio = false;
    }
}	

function IsACMenor(length, limit)
{
    if(length <= limit)
    {
        return true;
    }
    
    return false;
}

function OnACScriptAction(name)
{
    var behavior = $find(name);
    if (!behavior._height) 
    {
        var target = behavior.get_completionList();
        behavior._height = target.offsetHeight - 2;
        target.style.height = '0px';
        
    } 
//  ajusta el div al tamaņo de la lista
//  var length = behavior.get_completionList().childNodes.length;
//  if(IsACMenor(length, 16))
//  {
//      var new_height = length * 19;
//      behavior._height = new_height;
//  }
}

function OnBuscarVerificar(pcontrol)
{
    var control = document.getElementById(pcontrol); 
    if('' == control.value) return false;    
}

var mesName = new Array();
mesName.push('Enero');
mesName.push('Febrero');
mesName.push('Marzo');
mesName.push('Abril');
mesName.push('Mayo');
mesName.push('Junio');
mesName.push('Julio');
mesName.push('Agosto');
mesName.push('Septiembre');
mesName.push('Octubre');
mesName.push('Noviembre');
mesName.push('Diciembre');
    
function colocarCero(digitos)
{
    var digitos_str = '';
    
    if(digitos < 10) 
        digitos_str = '0' + digitos.toString();
    else
        digitos_str = digitos.toString();
        
    return digitos_str;
}

/*
function ObtenerHora()
{
    var hoy = new Date();
    var dia = hoy.getDate();
    var mes = hoy.getMonth();
    var anio = hoy.getFullYear();
    var hora = '<%=DateTime%>';///.ToString("hh:mm:ss tt")%>';
    alert(hora);
    var returnValue = dia.toString() + '&nbsp;de&nbsp;' + mesName[mes].toString() + '&nbsp;de&nbsp;' + anio.toString()+ "&nbsp;&nbsp;" + hora; 
    
    return returnValue;  
    
    ////////////////var hora = hoy.getHours();
    ////////////////var minutos = hoy.getMinutes();
    ////////////////var segundos = hoy.getSeconds();
    
    ////////////////var ampm = '';
    
    ////////////////if(hora > 12)
    ////////////////{
    ////////////////    hora = hora - 12;
    ////////////////    ampm = 'pm';
    ////////////////} 
    ////////////////else
    ////////////////{
    ////////////////    ampm = 'am';
    ////////////////}
   
    ////////////////var horastr = colocarCero(hora);
    ////////////////var minutosstr = colocarCero(minutos);
    //////////////// var segundosstr = colocarCero(segundos);  
    
}


function MostrarHora()
{   ///alert(hora);
    var capa = document.getElementById('mostrar_hora');
    capa.innerHTML = ObtenerHora();
}

function EjecutarHora()
{   setInterval('MostrarHora()', 500);
}
*/

function stopRKey(evt) 
{
    var evt = (evt) ? evt : ((event) ? event : null);
    var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
    if ((evt.keyCode == 13) && (node.type == 'text')) 
    {
        return false; 
    } 
    else 
    {
        return true
    }
}

function moverDerecha(nombre)
{
    var capa = document.getElementById(nombre);
    var pos = parseInt(capa.style.right);
    if(pos < 296)
    {
        capa.style.right = (pos + 296);
    }
}

function moverIzquierda(nombre)
{
    var capa = document.getElementById(nombre);
    var pos = parseInt(capa.style.right);
    if(pos >= 296)
    {
        capa.style.right = (pos - 296);
    }
}

function showCargando()
{
    if($("div#cargandoFondo").length > 0 && $("div#cargandoIcono").length > 0)
    {
        $("div#cargandoFondo").css("visibility", "visible");
        $("div#cargandoIcono").css("visibility", "visible");
    }
}