﻿// JScript File
/*<script type="text/javascript" src="Scripts/LFUtil.js"></script>*/

function Alert(Mensaje, Question,yesurl,nourl)
{
    if (Question=='NO'||Question=='no')
    {
        alert(Mensaje);
        if (yesurl=='RELOAD' || yesurl=='reload')
        {
        window.location.reload();
        }
        else
        {
        window.location.href=yesurl;
        }
        return;
    }
    
    var sPath = window.location.pathname;
    if (Mensaje =='') {Mensaje = 'Registro Afectado.'}
    if (Question =='') Question = 'Desea permanecer en esta pantalla?'

    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    var mensaje=Mensaje + '\n\n\n'+ Question;

    if (confirm(mensaje))
    {
    if (yesurl==""){window.location.href=sPage;}else{window.location.href=yesurl;}
    }
    else
    {
    window.location.href=nourl;
    }

}

      function Anthem_PreCallBack() 
        {
			
			var loading = document.createElement("img");
		    loading.id = "loading";
			loading.style.backgroundColor = "transparent";
			loading.style.paddingLeft = "5px";
			loading.style.paddingRight = "5px";
			loading.style.position = "absolute";
			loading.style.zIndex = "9999";
			
			loading.src="Images/cargando12.gif";		
			
			document.body.appendChild(loading);
			center();
			//setOpacity(Main,75);
			//document.activeElement.disabled=true;			
          document.body.style.cursor="wait";  
		}
		
function Anthem_PostCallBack()
		 {		   
			var loading = document.getElementById("loading");
			var Main= document.getElementById("Contenido");
			document.body.removeChild(loading);
		  // setOpacity(Main,100);	
	        //document.getElementById("btnget").disabled=false;
	        
		     document.body.style.cursor="default";   	    
		}
		
		
		function getInnerWidth()
        {
	var x;	
	if (self.innerWidth) 
		x = self.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth)
		x = document.documentElement.clientWidth;
	else if (document.body) 
		x = document.body.clientWidth;
	return x;
        }

// viewport height
function getInnerHeight()
    {
	var y;	
	if (self.innerHeight) 
		y = self.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight)
		y = document.documentElement.clientHeight;
	else if (document.body) 
		y = document.body.clientHeight;
	
	return y;
    }

 function confirmCallBackFn(arg)
                        {
                            alert("Confirm returned the following result: " + arg);
                        }


function center()
        {		
		var box = document.getElementById("loading");
		var fullHeight = getInnerHeight();
		var fullWidth = getInnerWidth();
		var scTop = document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;
		var scrollTop = parseInt(scTop,10);
		var scLeft = document.documentElement.scrollLeft ? 
		document.documentElement.scrollLeft : document.body.scrollLeft;
		var scrollLeft = parseInt(scLeft,10);
		box.style.top = (scrollTop + ((fullHeight - box.offsetHeight) / 2)) + "px";
		box.style.left =  (scrollLeft + ((fullWidth - box.offsetWidth) / 2)) + "px";
	    }
	    
	


/*=====================================================================
* Nombre: AcceptNum *
* Descripción: Controla que solo se introducen números *
* en un textbox *
======== Agregar Atributos a Textos ========
txtMontoMaximo.Attributes.Add("OnKeyPress", "return AcceptNum(event)")
=====================================================================*/

function AcceptNum(evt)
{ 

var nav4 = window.Event ? true : false;

var key = nav4 ? evt.which : evt.keyCode; 

return (key <= 13 || (key >= 48 && key <= 57));

}



/*=====================================================================
* Nombre: AcceptText *
* Descripción: Controla que solo se introducen letras *
* en un textbox *
======== Agregar Atributos a Textos ========
txtMontoMaximo.Attributes.Add("OnKeyPress", "return AcceptNum(event)")
=====================================================================*/
function AcceptText(evt)
{ 
var nav4 = window.Event ? true : false;

var key = nav4 ? evt.which : evt.keyCode; 

return (key <= 13 || (key >= 65 && key <= 90) || (key >= 97 && key <= 122));

}


//function ValidarTextoCantidad(source, arguments)
//    {      
//        var maxlength = 10;      
//            if (arguments.Value.length==maxlength) 
//                {         
//                    arguments.IsValid=true      
//                }
//                else
//                {         
//                    arguments.IsValid=false      
//                }    
//   }

function ValidarCaracteres(textareaControl,maxlength)
    {
        if (textareaControl.value.length > maxlength)
            {
                textareaControl.value = textareaControl.value.substring(0,maxlength);            
                alert("Debe ingresar hasta un maximo de "+maxlength+" caracteres");        
            }    
    }

function HandleEndChanging(item)
    {

        __doPostBack(item.get_id(), ''); 
               
    }


function prueba(item)
{
        alert('entro');           
}


    
//hf : Id del del control HiddenField
//id : Id para identificar el control que fue clickeado
function ClientClick2(val){       
    var HF = $get(Idhf);
    
    //alert(Idhf);
    
    if(HF != null)
    {       
        HF.value = val;
        __doPostBack(HF.id,'');
    }   
}
function PaneExpanded(sender, eventArgs)
{          
    var pane = sender;
//    alert("Prueba");

//    eventArgs.set_cancel(true);

    var slidingZone = $find("SliZone");
    
//    slidingZone.collapsePane(pane.get_id());
      
    
    ClientClick2(pane.get_id());       
//    slidingZone.DockPane(pane.get_id());
    
    //slidingZone.expandPane(pane.get_id());    
}



 function mensaje(text)
    {
        radalert('Welcome to RadWindow!', 330, 100); return false;
    }



function url(ruta) {

hidden = open(ruta,'NewWindow','top=0,left=0,width=800,height=600,status=yes,resizable=yes,scrollbars=yes');

}


function GetRadWin()
			{
				var oWindow = null;
				if (window.radWindow) oWindow = window.radWindow;
				else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
				return oWindow;
			}	
			
			function CerrarRadWin(Text)
			{
				var oWindow = GetRadWin();			
				oWindow.close(Text);
			}				

function Custompopup(Url, NomVentana,Height,Width){
        ventana = window.open(Url, NomVentana,'height='+Height+',width='+Width+',left=100,top=100,status=yes,toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,directories=no');
        if(!ventana){
            alert('No se puede abrir esta pagina debido a que su Explorador(Browser) de Internet esta bloqueando los PopUp. Llamar a Mesa de Ayuda');
            ventana.close();
        }
        else if(window.focus) ventana.focus();
    }


