﻿function ControlBotones() {
	window.history.forward(1); //Esto es para cuando le pulse al botón de Atrás
    window.history.back(1); //Esto para cuando le pulse al botón de Adelante
}

function Recargar() {
}


function SoloNumeros() {
	if (window.event.keyCode > 31 && (window.event.keyCode < 48 || window.event.keyCode > 57))
		window.event.keyCode = 0;
}

var gAutoPrint = true; 
function ImprimirRecibo(){
	if (document.getElementById != null)	{
		var html = "<HTML><BODY><TABLE align=center border=1 cellpadding=0 cellspacing=0 width=350px>";
			
		var printReadyElem = document.getElementById("TablaRecibo");
		
		if (printReadyElem != null){
				html += printReadyElem.innerHTML;
		}else{
			alert("No se encuentra el texto a imprimir en el codigo HTML");
			return;
		}
			
		html += "</TABLE></BODY></HTML>";
		
		var printWin = window.open("","ImprimirRecibo","width=380,height=500,scrollbars=NO,Resizable=NO,Directories=NO,Location=NO,Menubar=NO,Status=NO,Titlebar=NO,Toolbar=NO");

		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}else{
		alert("Lo sentimos, pero su navegador no soporta esta opción.");
	}
}

function getKey(keyStroke) 
{ 

    isNetscape=(document.layers); 
    eventChooser = (isNetscape) ? keyStroke.which : event.keyCode; 

if (eventChooser != 32)
{

    if (eventChooser==13 || eventChooser==60 || eventChooser==62 || eventChooser==91 || eventChooser==92 || eventChooser==93 || eventChooser==94 || eventChooser==95 || eventChooser==96) 
    { 
        return false; 
    } 
    if ((window.event.keyCode < 46 || window.event.keyCode > 122))
		    window.event.keyCode = 0;

}


} 


document.onkeypress = getKey; 

document.onkeydown = function(){
if(window.event && window.event.keyCode == 116)
{
window.event.keyCode = 505;
}
if(window.event && window.event.keyCode == 505)
{
return false;
}
}

function valEmail(valor){    // Cortesía de http://www.ejemplode.com
    re=/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/
    if(!re.exec(valor))    {
        return false;
    }else{
        return true;
    }
}

function RedirPpal(){
         if (confirm("Esta Ud. Seguro de Cerrar la Sesión?")){
            var url = '';
            url = 'http://' + window.location.host + '/';
            //url += window.location.pathname.toString().split('/')[1];
            url += 'CerrarSesion.aspx';
            parent.location = url;
         }
        return true;
    }


    function salida(){
    
            var param='';
         window.showModalDialog("\\salir.aspx",window,"status:no;dialogWidth:320px;dialogHeight:150px");
    }

window.history.forward(1);

function resetFind() {
            var btnEl = igtbl_getElementById("Find");
            btnEl.value="Buscar";
}
        
function FindValue(btnEl) {
        var oCell=null;
        var row=null;
            var eVal = igtbl_getElementById("FindVal");
            findValue = eVal.value;
            var re = new RegExp("^" + findValue, "gi");
            if(btnEl.value=="Buscar") {
                igtbl_clearSelectionAll(octl00xContentPlaceHolder1xuwgComercioElectronico.Id)
                
                oCell = octl00xContentPlaceHolder1xuwgComercioElectronico.find(re);
                if(oCell != null) {
                    btnEl.value="Siguiente";
                    row = oCell.Row.ParentRow;
                    while(row != null) {
                        row.setExpanded(true);
                        row = row.ParentRow;
                    }
                    oCell.setSelected(true);
                }else{
                btnEl.value="No hay resultados";
                }
            }
            else {
                oCell = octl00xContentPlaceHolder1xuwgComercioElectronico.findNext();
                if(oCell == null) {
                    btnEl.value="Buscar";
                }
                else {
                    row = oCell.Row.ParentRow;
                    while(row != null) {
                        row.setExpanded(true);
                        row = row.ParentRow;
                    }
                    oCell.setSelected(true);
                }
            }
        }
        
function FindValueContacto(btnEl) {
    var oCell=null;
    var row=null;
    var eVal = igtbl_getElementById("FindVal");
    var octl00xContentPlaceHolder1xuwgContactos = igtbl_getGridById("ctl00_ContentPlaceHolder1_uwgContactos");
    findValue = eVal.value;
    var re = new RegExp("^" + findValue, "gi");
    if(btnEl.value=="Buscar") {
        igtbl_clearSelectionAll(octl00xContentPlaceHolder1xuwgContactos.Id)
        oCell = octl00xContentPlaceHolder1xuwgContactos.find(re);
        if(oCell != null) {
            btnEl.value="Siguiente";
            row = oCell.Row.ParentRow;
            while(row != null) {
                row.setExpanded(true);
                row = row.ParentRow;
            }
            oCell.setSelected(true);
        }
        else{
            btnEl.value="No hay resultados";
        }
    }
    else {
        oCell = octl00xContentPlaceHolder1xuwgContactos.findNext();
        if(oCell == null) {
            btnEl.value="Buscar";
        }
        else {
            row = oCell.Row.ParentRow;
            while(row != null) {
                row.setExpanded(true);
                row = row.ParentRow;
            }
            oCell.setSelected(true);
        }
    }
}


function EncontrarGrillaContactos(btnEl) 
{
	var grid = igtbl_getGridById("ctl00xContentPlaceHolder1xuwgContactos");
	var eVal = igtbl_getElementById("FindVal");
	findValue = eVal.value;

	var re = new RegExp("^" + findValue, "gi");
	// Determine if this is an initial find or a find next.
	if(btnEl.value=="Buscar") 
	{
		igtbl_clearSelectionAll(grid.Id)
		var oCell = grid.find(re);

		if(oCell != null) 
		{
			btnEl.value="Sig.";
			var row = oCell.Row.ParentRow;
			while(row != null) 
			{
				row.setExpanded(true);
				row = row.ParentRow;
			}
			oCell.setSelected(true);
		}
	}
	else 
	{ // Otherwise it's a Find Next operation
		var oCell = grid.findNext();
		if(oCell == null) 
		{
			btnEl.value="Buscar";
		}
		else 
		{
			var row = oCell.Row.ParentRow;
			while(row != null)
			{
				row.setExpanded(true);
				row = row.ParentRow;
			}
			oCell.setSelected(true);
		}
	}
}
