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

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

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=='decimal'){
			if(tecla(e)!=8 && tecla(e)!=13 && tecla(e)!=46 && (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=='decimal'){
			if(tecla(e)!=8 && tecla(e)!=13 && tecla(e)!=0 && tecla(e)!=46 && (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;	
			}						
		}		
	}
}

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

function darFormato(e,obj){	
	if(obj.value.length<13){
		if((obj.value.length==2 || obj.value.length>10) && tecla(e)!=8 && tecla(e)!=0)
			obj.value+="-";				
	}
}

function empty(obj){
	if(obj.value.length==0||obj.value=="")
		return true;
	else
		return false;
}

// FUNCION PARA INSTANCIAR EL OBJECTO XMLHttpRequest  (A J A X)
var XMLHttp;
function crearInstanciaAJAX()
{
	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){}
		}
	}
}

function openWindow(link, width, height,opt, windowopen){
	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( typeof(windowopen)=="undefined" ){
		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:no;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 invertir_fecha(date){
	if(date.indexOf("/")>-1){
		parent="/";
		date=date.split("/");
	}
	else if(date.indexOf("-")>-1){
		parent="-";
		date=date.split("-");		
	}
	return date[2]+parent+date[1]+parent+date[0];
}