//<script language="javascript">
	//document.onmousedown=noRightClick;
	
	//Función para maximizar la pantalla actual
	function fnMaximizar(){
	    window.moveTo(0,0);
        window.resizeTo(screen.availWidth,screen.availHeight);
        window.focus();
	}
	//Función que sirve para hayar el historial de las llamadas por el cliente
	function fnHistorialLlamadas(Op){
	    //alert(document.getElementById("txtidINOR").value);
	    if( Op =='CLIENTE'){
		    document.all.frm_Historia.src="CONT_Historial.aspx?idCliente="+document.getElementById("txtIdCliente").value+"&idInmueble="+document.getElementById("txtidInmueble").value+"&idINOR=" + document.getElementById("txtidINOR").value + "&Opcion="+Op+"&Dummy="+Date();
		}else{
		    document.all.frm_HistoriaCodigo.src="CONT_Historial.aspx?idCliente="+document.getElementById("txtIdCliente").value+"&idInmueble="+document.getElementById("txtidInmueble").value+"&idINOR=" + document.getElementById("txtidINOR").value + "&Opcion="+Op+"&Dummy="+Date();
		}
	}
	
	//Función que calcula la cantidad de caracteres faltantes por ingresar en un textarea
	function fnCantidadCaracteres(Objeto, MaxCaracteres, Label){
		var strPalabra;
		MaxCaracteres = parseInt(MaxCaracteres);		
		strPalabra = Objeto.value;
		if (strPalabra.length > MaxCaracteres){
		    alert('Ha sobrepasado el limite de caracteres permitidos, por favor verifique la informacion');
			strPalabra = strPalabra.substring(0,MaxCaracteres);
			Objeto.value = strPalabra;
		}
		var intCantidad = parseInt(strPalabra.length);
		intCantidad = MaxCaracteres - intCantidad;
		//document.all.item(Label).innerText = intCantidad;
		document.getElementById(Label).innerText = intCantidad + " / " + MaxCaracteres; 
	}

    //Funcion para abrir ventanas si se pasa para pantalla completa pasar alto = 0 y ancho = 0
    function fnAbreVentana(URL, alto, ancho){
        if (alto == 0){
            alto = screen.availHeight * .92;
        }
        if (ancho == 0){
            ancho = screen.availWidth * .98;
        }
        var top = (screen.availHeight * .92 - alto) / 2;
        var left = (screen.availWidth - ancho) / 2;
        window.open(URL,"","height=" + alto + ",width=" + ancho + ",status=yes,toolbar=no,resizable=yes,scrollbars=yes,menubar=no,location=no, top=" + top + ", left=" + left)
    }
    
    function fnAbreVentanaModal(URL, alto, ancho){
        var RTA;
        var strParametros;
        if (alto == 0){
            alto = screen.availHeight * .92;
        }
        if (ancho == 0){
            ancho = screen.availWidth * .98;
        }
        strParametros = "dialogHeight:" + alto + " px;dialogWidth:" + ancho + " px;status:Yes;resizable:Yes;center:Yes";
        //alert(strParametros);
        RTA = showModalDialog(URL,"",strParametros);
        return RTA;
    }

	String.prototype.trim = function() {
	 // skip leading and trailing whitespace
	 // and return everything in between
	  return this.replace(/^\s*(\b.*\b|)\s*$/, "$1");
	}
	function fnTeleclienteXMLHTTP(strURL){
		//alert(strURL);
		var oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
		oXMLHTTP.open("POST", strURL, false);
		oXMLHTTP.send();
		//alert(oXMLHTTP.responseText);
		//alert(oXMLHTTP.responseBody);
		//return 1;
		return oXMLHTTP.responseText;
		//return oXMLHTTP.responseBody; 
	}
	
 //Función de fechas para futuras
    function fnAbrirFechaFuturo(url, strFecha){
		var Fecha = document.getElementById(strFecha);
		intTop = Fecha.offsetTop  + Fecha.offsetHeight;
		FechaSeleccionada = Fecha.value;
		strParametros="dialogWidth:185px;dialogHeight:230px;status:0;scroll:0;dialogTop:"+ intTop + ";dialogLeft:500"
		var cSearchValue=showModalDialog(url,FechaSeleccionada,strParametros);
		if (cSearchValue == -1 || cSearchValue == null){}
		else{
    		 var dtmFechaAhora = new Date();
    		 var dtmFechaAhora1 = new Date( dtmFechaAhora.getFullYear(), dtmFechaAhora.getMonth(), dtmFechaAhora.getDate() );
    		 var dtmFechaSel = new Date(cSearchValue);
             if( dtmFechaSel < dtmFechaAhora1 ){
	   		    alert("Debe Seleccionar un fecha futura");
                return;
	    	 }
	        Fecha.value=cSearchValue;
		}
	}

	function fnAbrirFecha(url, strFecha){
		//alert(strFecha);
		var Fecha = document.all.item(strFecha);

		FechaSeleccionada = Fecha.value;
		strParametros="dialogWidth:185px;dialogHeight:265px;status:0;scroll:0";
		var cSearchValue=showModalDialog(url,FechaSeleccionada,strParametros);
			
		if (cSearchValue == -1 || cSearchValue == null)
		      {
		   //alert('Canceló o cerró la ventana');	
		}
		else if (cSearchValue=="")
		      {
		   alert('No ingreso ninguna fecha');
		}
		else
		{
		   //alert('Fecha: ' + cSearchValue);
		         Fecha.value=cSearchValue;
		}
	}
	//Función para validar si hacen clic con el botón derecho del mouse
	function noRightClick(){
		if (event.button==2){
			alert('Boton derecho deshabilitado.')
		}
	}
	//Función para verificar si presionaron la tecla enter
	function disableEnterKey(){ 
     	if (window.event.keyCode == 13) window.event.keyCode = 0; 
	}
	
	//Funciones Cliente (Milton)
	
	//Función para permitir entrar solo valores numéricos en un cuadro
	//de texto
	//Forma de utilizarlo:
	//	onkeypress=javascript:fnVldarNmros(); onblur=javascript:this.value=this.value.toUpperCase();
	function fnVldarNmros(){
		if (event.keyCode > 45 && event.keyCode < 58){
			event.returnValue = true;
		} 
		else{
			event.returnValue = false;
		}
	}
	//TRIM
	String.prototype.trim = function(){
		return this.replace(/^\s*(\b.*\b|)\s*$/, "$1");
	}
	//REPLACE
	function replace(strOrig, strFrom, strTo) {
		var strNew;
		var i;
		var iFromLen;
		strNew = "";
		iFromLen = strFrom.length;
		i = strOrig.indexOf(strFrom)
		j = 0;
		while (i>=0) {
			strNew = strNew + strOrig.substring(j, i) + strTo;
			j = i + iFromLen
			i = strOrig.indexOf(strFrom, j)
		}
		i = strOrig.length;
		strNew = strNew + strOrig.substring(j, i);
		return strNew;
	}
	//Función para validar que un correo electrónico este bien escrito
	function fnValidarEmail(strCorreo){
		/*if(strCorreo.trim() == ""){
			alert("La cuenta de correo no puede estar en blanco.");
			return false;
		}*/
		//Validar la cuenta de correo usando una expresión regular (RegExp)
		if(strCorreo.search(/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/ig)){
			return false;
		}
		return true;
	}
	//Función que permite seleccionar el valor de un combo
	function fnSeleccionaValorCombo(objCombo,strValor){
	    var intI;
	    for (intI=0; intI <= parseInt(objCombo.length) -1; intI++){
	        if (objCombo.options[intI].value == strValor){
	            objCombo.selectedIndex = intI;
	        }
	    }
	}
	
	//FUNCIONES DE ORDENAMIENTO DE VECTORES
	Array.prototype.swap=function(a, b){
	    var tmp=this[a];
	    this[a]=this[b];
	    this[b]=tmp;
    }

    function partition(array, begin, end, pivot){
	    var piv=array[pivot];
	    array.swap(pivot, end-1);
	    var store=begin;
	    var ix;
	    for(ix=begin; ix<end-1; ++ix) {
		    if(array[ix]<=piv) {
			    array.swap(store, ix);
			    ++store;
		    }
	    }
	    array.swap(end-1, store);
	    return store;
    }

    function qsort(array, begin, end){
	    if(end-1>begin) {
		    var pivot=begin+Math.floor(Math.random()*(end-begin));
		    pivot=partition(array, begin, end, pivot);
		    qsort(array, begin, pivot);
		    qsort(array, pivot+1, end);
	    }
    }

    function quick_sort(array){
	    qsort(array, 0, array.length);
    }

    function dosort(form){
	    var array=form.unsorted.value.split(/ +/);
	    quick_sort(array);
	    form.sorted.value=array.join(' ');
    }

    /**************************************************************
     Mid: Returns a String containing a specified number of 
          characters from a string

     Parameters:
          String = String expression from which characters are 
                   returned. If string contains null, false is 
                   returned.
          Start  = Number. Character position in string at which 
                   the part to be taken begins. If Start is 
                   greater than the number of characters in 
                   string, Mid returns a zero-length string ("").
          Length = Number of characters to return. If omitted 
                   false is returned. 

     Returns: String
    ***************************************************************/

    function Mid(String, Start, Length){
        if (String == null)
	        return (false);

        if (Start > String.length)
	        return '';

        if (Length == null || Length.length == 0)
	        return (false);

        return String.substr((Start - 1), Length);
    } 
    	
	/*
	function validarEmail(){
		var hayAlgo = true;
		if(fEnvioCorreo.sender.value==""){
			hayAlgo = false;
			alert("La cuenta de correo no puede estar en blanco.");
			fEnvioCorreo.sender.focus();
			return false;
		}
		// validar la cuenta de correo usando una expresión regular (RegExp)
		if(fEnvioCorreo.sender.value.search(/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/ig)){
			hayAlgo = false;
			alert("La cuenta no es válida, debes escribirla de forma: nombre@servidor.dominio");
			fEnvioCorreo.sender.select();
			fEnvioCorreo.sender.focus();
			return false;
		}
	}
	*/

    function fnQuitarTildes(keyCode){
    if (keyCode == 225) //a
        window.event.keyCode = 97;
    if (keyCode == 193) //A
        window.event.keyCode = 65;
    if (keyCode == 233) //e
        window.event.keyCode = 101;
    if (keyCode == 201) //E
        window.event.keyCode = 69;
    if (keyCode == 237) //i
        window.event.keyCode = 105;
    if (keyCode == 205) //I
        window.event.keyCode = 73;
    if (keyCode == 243) //o
        window.event.keyCode = 111;
    if (keyCode == 211) //O
        window.event.keyCode = 79;
    if (keyCode == 250) //u
        window.event.keyCode = 117;
    if (keyCode == 218) //U
        window.event.keyCode = 85;
    if (keyCode == 241) //ñ
        window.event.keyCode = 110;
    if (keyCode == 209) //Ñ
        window.event.keyCode = 78;
    }

/**************************************************************
 InStr: Returns a Long specifying the position of the first 
        occurrence of one string within another. Is String1
        or String2 are null, false is returned.

 Parameters:
      String1 = String expression being searched.
      String2 = String expression sought

 Returns: Integer
***************************************************************/
function InStr(String1, String2)
{
	var a = 0;

	if (String1 == null || String2 == null)
		return (false);

	String1 = String1.toLowerCase();
	String2 = String2.toLowerCase();

	a = String1.indexOf(String2);
	if (a == -1)
		return 0;
	else
		return a + 1;
}

function fnTecla(e) {
    var keyPressed;
    if (window.event)
        keyPressed = window.event.keyCode; // IE
    else
        keyPressed = e.which; // Firefox

    return keyPressed;
}

function fnSelecionarTodo(strCheck, check) {
    var objCheckbox = '';
    for (var i = 0; i < theForm.elements.length; i++) {
        objCheckbox = theForm.elements[i];
        if (objCheckbox.type == 'checkbox') {
            if (InStr(objCheckbox.id, strCheck) > 0) {
                objCheckbox.checked = check.checked;
            }
        }
    }
}

//</script>