var IE = true;
IE=document.all?true:false;
//captura de mouse *************************************************************
var tempX = 0;
var tempY = 0;
var evento=null;
if (!IE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMouseXY;
function getMouseXY(e) {
  if (IE) {
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  }
  else {
    tempX = e.pageX;
    tempY = e.pageY;
  }
  if (tempX < 0){tempX = 0;}
  if (tempY < 0){tempY = 0;}
  return true;
}
//fin captura de mouse *********************************************************
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,'') }
//borrar del telematica_v4.js todo el codigo que se pone aca y agregar en los jsp la referencia a este js
var FF = null;
var CR = null;
var SF = null;
var OP = null;
var IE = true;
IE=document.all?true:false;
var restoWin=0;
var winW=null;
var winH=null;
/*if(window.screen.width==1024)*/restoWin=18;
if(IE){
  winW = document.documentElement.clientWidth-restoWin;
  winH = document.documentElement.clientHeight;
}
else{
  winW = window.innerWidth-restoWin;
  winH = window.innerHeight;
}
function cargo_evento(evt,obj,fnc){
var pasoFunc=fnc;
var pasoObj=objt(obj);
if(evt.toLowerCase()=="onclick")pasoObj.onclick=pasoFunc;
if(evt.toLowerCase()=="onblur")pasoObj.onblur=pasoFunc;
if(evt.toLowerCase()=="onfocus")pasoObj.onfocus=pasoFunc;
if(evt.toLowerCase()=="onchange")pasoObj.onchange=pasoFunc;
if(evt.toLowerCase()=="onkeypress")pasoObj.onkeypress=pasoFunc;
if(evt.toLowerCase()=="onkeyup")pasoObj.onkeyup=pasoFunc;
if(evt.toLowerCase()=="onscroll")pasoObj.onscroll=pasoFunc;
if(evt.toLowerCase()=="onmouseover")pasoObj.onmouseover=pasoFunc;
if(evt.toLowerCase()=="onmouseout")pasoObj.onmouseout=pasoFunc;
if(evt.toLowerCase()=="onsubmit")pasoObj.onsubmit=pasoFunc;
}
function error(texto, elemento){
	alert(texto);
	elemento.focus();
}
function sobreImg (src, imagen){
	src.style.backgroundImage="url("+imagen+")";
}
function fueraImg (src, imagen){
	src.style.backgroundImage="url("+imagen+")";
}
function objGen(tipoObj,nombreClass,nombre,id){
  var objeto = document.createElement(tipoObj);
  objeto.className = nombreClass;
  if(id==null)objeto.setAttribute('id', nombre);
  else objeto.setAttribute('id', id);
  objeto.setAttribute('name', nombre);
  return objeto;
}
function ancGen(base,objeto){
  var ancla = null;
  if(base=="body") ancla=document.body;
  else ancla=objt(base);
  ancla.appendChild(objeto);
}
function dimGen(objeto,x,y,ancho,alto){
  if(x!=null)objeto.style.left=x;
  if(y!=null)objeto.style.top=y;
  if(ancho!=null)objeto.style.width=ancho;
  if(alto!=null)objeto.style.height=alto;
}
function borGen(objeto,borde,bordeW,bordeC){
  if(borde!=null)objeto.style.borderStyle=borde;
  if(bordeW!='null'&&bordeW!=null)objeto.style.borderWidth=bordeW;
  if(bordeC!='null'&&bordeC!=null)objeto.style.borderColor="#"+bordeC;
  else if(!IE)objeto.style.borderColor="#000000";
}
function colGen(objeto,color,Bcolor){
  if(color!='null'&&color!=null)objeto.style.color="#"+color;
  if(Bcolor!='null'&&Bcolor!=null){
    if(Bcolor.length==6)objeto.style.backgroundColor="#"+Bcolor;
    else objeto.style.backgroundColor=Bcolor;
  }
}
function imgGen(objeto,imagen,x,y){
  if(imagen==null) objeto.style.backgroundImage="none";
  else objeto.style.backgroundImage="url("+imagen+")";
  if(x!=null)objeto.style.backgroundPosition=x+"px "+y+"px";
  objeto.style.backgroundRepeat="no-repeat";
}
function devuelvo_form(nombre){
  for(var i=0;i<document.forms.length;i++){
    if(document.forms[i].name==nombre)return document.forms[i];
  }
}
function genero_form(base,nombre){
	var form = objGen("form","generico",nombre);
        form.setAttribute("method","POST");
        form.setAttribute("action","#");
        ancGen(base,form);
}
function genero_input_hidden(form,nombre,valor){
	var input = objGen("input","invis",nombre);
	input.setAttribute('type', 'hidden');
        if(valor==null)input.value="";
        else input.value=valor;
        ancGen(form,input);
}
function genero_div_input(x,y,ancho,alto,base,fontS,align,nombre,borde,bordeW,bordeC,color,Bcolor,valor,pass){
	var inputDiv = objGen("div","inputDiv","d_"+nombre);
        if(borde==null||borde=='null')borde="solid";
        if(alto==null)alto="auto";
        if(borde=="solid"||borde=="dotted"||borde=="dashed"){
          if(bordeW==null)bordeW=1;
          ancho=ancho-(2*bordeW);
          if(alto!="auto")alto=alto-(2*bordeW);
        }
        else if(borde=="none"||borde=="hidden"){
          bordeW=0;
        }
        else{
          bordeW=null;
          if(IE){
            ancho=ancho-8;
            if(alto!="auto")alto=alto-8;
          }
          else{
            ancho=ancho-6;
            if(alto!="auto")alto=alto-6;
          }
        }
        dimGen(inputDiv,x,y,ancho,alto);
        borGen(inputDiv,borde,bordeW,bordeC);
        colGen(inputDiv,color,Bcolor);
	if(align=="izq")clase="izquierdaN";
	if(align=="cen")clase="centroN";
	if(align=="der")clase="derechaN";
	var input = objGen("input",clase,nombre);
        if(fontS>=100){
          input.style.fontSize=fontS-100;
          input.style.fontWeight="bold";
        }
        else{
          input.style.fontSize=fontS;
        }
        dimGen(input,0,0,ancho,null);
        colGen(input,color,Bcolor);
	if(pass==0||pass==null)input.setAttribute('type', 'text');
        else input.setAttribute('type', 'password');
        if(valor==null)input.value="";
        else input.value=valor;
        ancGen(base,inputDiv);
        ancGen("d_"+nombre,input);
}
function genero_div_password(x,y,ancho,alto,base,fontS,align,nombre,borde,bordeW,bordeC,color,Bcolor,valor){
         genero_div_input(x,y,ancho,alto,base,fontS,align,nombre,borde,bordeW,bordeC,color,Bcolor,valor,1);
}
function genero_div_check(x,y,ancho,alto,base,nombre,borde,bordeW,bordeC,color,Bcolor,tooltiptext,xtt,ytt){
	var checkDiv = objGen("div","inputDiv","d_"+nombre);
	var check = objGen("input","checkbox",nombre);
	check.setAttribute('type', 'checkbox');
        dimGen(checkDiv,x,y,ancho,alto);
        dimGen(check,null,null,ancho,alto);
        borGen(check,borde,bordeW,bordeC)
        colGen(check,color,Bcolor);
        ancGen(base,checkDiv);
        ancGen("d_"+nombre,check);
        if(tooltiptext!=null){
          funcion=function(){genero_tooltiptext(xtt,ytt,tooltiptext);};
          cargo_evento("onmouseover",nombre,funcion);
          funcion=function(){elimino_tooltiptext();};
          cargo_evento("onmouseout",nombre,funcion);
        }
}
function genero_div_radio(x,y,ancho,alto,base,nombre,id){
	var radioDiv = objGen("div","inputDiv","d_"+id);
	var radio = objGen("input","radio",nombre,id);
	radio.setAttribute('type', 'radio');
        dimGen(radioDiv,x,y,ancho,alto);
        //dimGen(radio,null,null,ancho,alto);
        ancGen(base,radioDiv);
        ancGen("d_"+id,radio);
}
function genero_area_sensible(x,y,ancho,alto,base,nombre,tooltiptext,xtt,ytt){
	var sensibleDiv = objGen("div","sensibleDiv",nombre);
        dimGen(sensibleDiv,x,y,ancho,alto);
        ancGen(base,sensibleDiv);
        if(tooltiptext!=null){
          funcion=function(){genero_tooltiptext(xtt,ytt,tooltiptext);};
          cargo_evento("onmouseover",nombre,funcion);
          funcion=function(){elimino_tooltiptext();};
          cargo_evento("onmouseout",nombre,funcion);
        }
}
function genero_boton_imagen(x,y,ancho,alto,base,nombre,imagen,Bimagen,tooltiptext,xtt,ytt){
        if(Bimagen!=null)genero_div_img(x,y,ancho,alto,base,"i_"+nombre,Bimagen);
	var botonImg = objGen("div","botonImg",nombre);
        dimGen(botonImg,x,y,ancho,alto);
        botonImg.style.clip="rect(0,"+ancho+","+alto+",0)";
        imgGen(botonImg,imagen,null,null);
        botonImg.style.cursor="pointer";
        ancGen(base,botonImg);
        if(Bimagen!=null){
          if(tooltiptext==null){
            funcion=function(){sobreImg(objt(nombre),Bimagen);};
            cargo_evento("onmouseover",nombre,funcion);
            funcion=function(){fueraImg(objt(nombre),imagen);};
            cargo_evento("onmouseout",nombre,funcion);
          }
          else{
            funcion=function(){sobreImg(objt(nombre),Bimagen);
                               genero_tooltiptext(xtt,ytt,tooltiptext);};
            cargo_evento("onmouseover",nombre,funcion);
            funcion=function(){fueraImg(objt(nombre),imagen);
                               elimino_tooltiptext();};
            cargo_evento("onmouseout",nombre,funcion);
          }
        }
        else if(tooltiptext!=null){
          funcion=function(){genero_tooltiptext(xtt,ytt,tooltiptext);};
          cargo_evento("onmouseover",nombre,funcion);
          funcion=function(){elimino_tooltiptext();};
          cargo_evento("onmouseout",nombre,funcion);
        }
}
function genero_div_img(x,y,ancho,alto,base,nombre,imagen){
	var imgDiv = objGen("div","imagen",nombre);
        dimGen(imgDiv,x,y,ancho,alto);
        imgDiv.style.clip="rect(0,"+ancho+","+alto+",0)";
        imgDiv.style.backgroundImage="url("+imagen+")";
        ancGen(base,imgDiv);
}
function objt(nombre){
  return document.getElementById(nombre);
}
function genero_tooltiptext(left, tope, texto){
	var sumoTop=tope;
	var sumoLeft=left;
        var ttt = objGen("div","tooltiptext","tooltiptext");
        dimGen(ttt,tempX+sumoLeft,tempY+sumoTop,null,null);
	ttt.innerHTML='<font class="verdana11">&nbsp;'+texto+'&nbsp;</font>';
	ttt.style.zIndex=1001;
        ttt.style.visibility="visible";
        ancGen("body",ttt);
}
function elimino_tooltiptext(){
        var Base=document.body;
        var tablaNodos=document.body.childNodes;
        for(var i=0; i<tablaNodos.length;i++){
          if(tablaNodos[i].id=="tooltiptext"){
            Base.removeChild(tablaNodos[i]);
            break;
          }
        }
}

