// Desahabilita la seleccion
//if(isIE()) document.onselectstart=new Function ("return false");  
	
//document.oncontextmenu = function(){return false}  //Bloquea boton secundario

if( typeof(isIE)=="undefined" ){
	function isIE(){	
		if(navigator.appName.indexOf("Microsoft")>-1) return true;
		else return false;
	}
}

/*if( typeof($)=="undefined" ){
	function $(id){
		return document.getElementById(id);
	}
}*/

if( typeof(key)=="undefined" ){
	function key(e,tipo){
	//	alert(tecla(e));
	
		if(isIE()) { //IE
			if(tipo=='numeric'){
				if(tecla(e)!=8 && tecla(e)!=13 && (tecla(e)<48 || tecla(e)>57)) event.returnValue=false;
			}
			else if(tipo=='string'){
				if(tecla(e)>=48 && tecla(e)<=57) event.returnValue=false;		
			}
		}
		else {		 //otros navegadores
			if(tipo=='numeric'){
				if(tecla(e)!=8 && tecla(e)!=13 && tecla(e)!=0 && (tecla(e)<48 || tecla(e)>57)) {
					e.preventDefault();
					return false;	
				}
			}
			else if(tipo=='string'){
				if(tecla(e)>=48 && tecla(e)<=57) {
					e.preventDefault();
					return false;	
				}						
			}		
			else if(tipo=='cuit'){
				if(tecla(e)!=8 && tecla(e)!=13 && tecla(e)!=45 && tecla(e)!=0 && (tecla(e)<48 || tecla(e)>57)) {
					e.preventDefault();
					return false;	
				}						
			}		
		}
	}
}

if( typeof(tecla)=="undefined" ){
	function tecla(e){
		if(isIE()) //IE
			return event.keyCode;
		else
			return e.which;	
	}
}

// FUNCION PARA INSTANCIAR EL OBJECTO XMLHttpRequest  (A J A X)
var $Ajax={
	XMLHttp: false,
	on_finalizer: function(){},
	resultText: '',
	
	create_instance_ajax: function(){
		this.XMLHttp=false;
		
		if( window.XMLHttpRequest ){
			return new XMLHttpRequest();
		}
		else if( window.ActiveXObject ){
			var versiones = ["Msxml2.XMLHTTP.7.0","Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
			
			for(var i=0;i<versiones.length;i++){
				try {
					XMLHttp = new ActiveXObject(versiones[i]);
					if( XMLHttp ){
						return XMLHttp;
						break;
					}
				} catch(e){}
			}
		}
	},
	
	changing_state_ajax: function(){
		//if( $Ajax.XMLHttp.readyState==1 ){
			try{
				$Ajax.XMLHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			}
			catch(e){}
		//}
		
		if( $Ajax.XMLHttp.readyState==4 ){
			if( $Ajax.XMLHttp.status==200 ){
				$Ajax.resultText = $Ajax.XMLHttp.responseText;
				$Ajax.on_finalizer();
				
			}else{
				alert("Error al recibir respuesta "+$Ajax.XMLHttp.statusText);
			}
		}
	},
	
	execute: function(method, link, send){
		this.XMLHttp = this.create_instance_ajax();
		if( this.XMLHttp ){
			if( typeof(send)=="undefined" ) send=null;
			this.XMLHttp.onreadystatechange = $Ajax.changing_state_ajax;
			this.XMLHttp.open(method, link, true);
			this.XMLHttp.send(send);
			return;
		}		
	}
}

if( typeof(openWindow)=="undefined" ){
	function openWindow(link, width, height,opt){
		var left=0;
		var top=0;
	
		if(typeof(width)!="undefined" && opt!="") left=(screen.width/2)-(width/2);
		else width=screen.availWidth;
		if(typeof(height)!="undefined" && opt!="") top=(screen.height/2)-(height/2)-35;
		else height=screen.availHeight;
		
		if(document.all){
			return window.showModalDialog(link,'','scroll:no;status:no;dialogWidth:'+width+'px;dialogHeight:'+height+'px');
		}
		else{
			if(typeof(window.showModalDialog)!="undefined"){
				return window.showModalDialog(link,'','scroll:0;status:no;dialogWidth:'+(width+9)+'px;dialogHeight:'+(height+1)+'px;dialogLeft:'+left+";dialogTop:"+top);					
			}			
			
			if(typeof(opt)=="undefined" || opt=="") opt='toolbar=no,menubar=no,scrollbars=no,location=no,resizable=0,width='+width+',height='+height+',left='+left+',top='+top
			else opt='width='+width+',height='+height+',left='+left+',top='+top+','+opt;	
	
			return window.open(link,'',opt);
		}
	}
}

function verEspere(){document.getElementById("divEspere").style.display="";}
function ocultarEspere(){document.getElementById("divEspere").style.display="none";}

function makevisible(obj,opt,opacity){	
	if(isIE()){
		if( typeof(opacity)=="undefined" ) opacity=50;
		obj.style.filter = (opt==1) ? "alpha(style=0,opacity="+opacity+")" : "alpha(style=0,opacity=100)";
	}else{
		if( typeof(opacity)=="undefined" ) opacity=.5;		
		obj.style.opacity = (opt==1) ? opacity : 1;
	}
}

if( typeof(set_opacity)=="undefined" ){
	// Los valores varian entre 1 - 10 (en 10 la opacidad se anula)
	function set_opacity(o, val) {
		if( document.all ) {  //For IE
			val = parseInt(val)*10;
			try {
				o.filters.item("DXImageTransform.Microsoft.Alpha").opacity = val;
				if( val==100 ) o.filters.item("DXImageTransform.Microsoft.Alpha").opacity="";
			} catch (e) { 
				// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
				o.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+val+')';
				
				if( val==100 ) o.style.filter = '';
			}
		} else {
			val = parseInt(val)*0.1;
			o.style.opacity = val;
			o.style.MozOpacity = val;  //This is for older Mozilla Browsers
		}
	}
}

if( typeof(remove_object)=="undefined" ){
	function remove_object(o){
		if( typeof(o)!="undefined" ){
			node = o.parentNode;
			if( node!=null)	node.removeChild(o);
		}
	}	
}

function _addEvent(elemento, nombre_evento, funcion, captura){ 
    // para IE 
    if (elemento.attachEvent){ 
        elemento.attachEvent('on' + nombre_evento, funcion); 
        return true; 
    }else   // para navegadores respetan Estándares DOM(Firefox,safari) 
        if (elemento.addEventListener){ 
            elemento.addEventListener(nombre_evento, funcion, captura); 
            return true; 
        }else  return false; 
}  

