// ** Declaracio variables globals

var isNav,isIE,isFF,isOpera,isSafari;
var bw;
var tempX = 0;    
var tempY = 0;  
var topRows=new Array(200);   
var RowsLength = 0;
var rowFindKey = 0;
var rowFindKey2 = 0;
var rowFindKey3 = 0;
var rowFindKey4 = 0;
var rowFindKey5 = 0;
var rowFindKey6 = 0;
var rowFindKey7 = 0;
var activeColorRow2 = 1;

bw=new verifyCompatibleBrowser();

isIE=(bw.ie5||bw.ie4||bw.ie6||bw.ie4mac||document.all);
isNav=((bw.ns4||bw.ns6)&&(!bw.dom));
isFF=(bw.ff);     
isOpera=(bw.ope); 
isSafari=(bw.sf);
//alert(isSafari);

if (!isIE){
  // per altres navegadors a Explorer calculem continuament la posicio
  document.addEventListener("mousemove", getMouseXY, true);
}  

function verifyCompatibleBrowser(){
  var t=this;
  t.name=navigator.appName;
  t.cname=navigator.appCodeName;
  t.agent=navigator.userAgent;
  t.ver=navigator.appVersion;
  //alert(t.agent);
  t.dom=document.getElementById?1:0;
  t.ie6=(t.ver.indexOf("MSIE 6")>-1 && t.dom)?1:0;
  t.ie5=(t.ver.indexOf("MSIE 5")>-1 && t.dom)?1:0;
  t.ie4=(document.all && !t.dom)?1:0;
  t.ie4mac=(document.all && t.dom && t.ver.indexOf("Macintosh")>-1)?1:0;
  t.ns6=(t.dom && parseInt(t.ver)>=5)?1:0;
  t.ns4=(document.layers && !t.dom)?1:0;
  t.bw=(t.ie5||t.ie4||t.ns4||t.ns6||t.ie4mac);
  t.ope=(t.agent.indexOf("Opera")>-1 )?1:0;   
  t.ff=(t.agent.indexOf("Firefox")>-1 )?1:0;        
  t.sf=(t.agent.indexOf("Safari")>-1 )?1:0;         
  return this;
}


// Obte posicio absoluta del punter del ratoli
function getMouseXY(e) {
  if ( (isIE) || (isOpera)) { //para IE o Opera
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  }
  else { // per la resta
    tempX = e.pageX;
    tempY = e.pageY;
  }
  if (tempX < 0){tempX = 0;}
  if (tempY < 0){tempY = 0;}
  if (isOpera) { 
    // correccio bug Opera  
    tempY = tempY + 11;
  }
  //window.status=tempY;   
  return true;
}

function getAbsoluteElementPosition(element) {
  if (typeof element == "string")
    element = document.getElementById(element);

  if (!element) 
    return { top:0,left:0,height:0,width:0 };

  var y = 0;
  var x = 0;
  var h = 0;
  var w = 0;  
  if (isIE) { //para IE
    w = element.clientWidth;
	while (element.offsetParent) {
	  x += element.offsetLeft;
	  y += element.offsetTop;
	  h += element.offsetHeight;
	  element = element.offsetParent;
	}
  }else{ // para el resto
    while (element.offsetParent) {
      x += element.offsetLeft;
      y += element.offsetTop;
      h += element.offsetHeight;    
      w += element.offsetWidth;             
      element = element.offsetParent;
    }
  }
  return {top:y,left:x,height:h,width:w};
} 



// Crida a la funci? que canvia de color la linia seleccionada
function colorRowOverOut(id,indexrowcode){
  if ( isIE ) { //para IE 
    colorRow(id,indexrowcode);
  }  
  //if ( !isIE ) { //para FF 
    //colorRow(id,indexrowcode)
  //}  
}


// Crida a la funci? que canvia de color la linia seleccionada
function colorRowMove(id,indexrowcode){
  if ( ! isIE ) { //para FF
    colorRow(id,indexrowcode);
  }
  //if ( isIE ) { //para IE
    //colorRow(id,indexrowcode)
  //}  
}

// Canvia de color la linea en la que est? el cursor
function colorRow(id,indexrowcode){
  var count=1;  
  var oTable = document.getElementById(id) ;
  RowsLength = oTable.rows.length;    
  topRows[0] = 0; 
  for (var i=1; i < 200; i++)
    topRows[i] = 9999;    
    
  if (isIE) { //per IE 
    tempX = event.clientX + document.body.scrollLeft;   
    tempY = event.clientY + document.body.scrollTop;
    scrollY = document.documentElement.scrollTop ;
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows(i);
      topRows[i] = getAbsoluteElementPosition(oRow).top - scrollY;      	
    }     
  }else if (isOpera) { //per Opera
    tempX = event.clientX + document.body.scrollLeft;   
    tempY = event.clientY + document.body.scrollTop;
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows(i);
    // correccio bug Opera  
    if (i == 1) {
        topRows[RowsLength-2] = getAbsoluteElementPosition(oRow).top ;
      } else if (i == 2) {
        topRows[RowsLength-1] = getAbsoluteElementPosition(oRow).top ;
    } else {
        topRows[i-2] = getAbsoluteElementPosition(oRow).top ;
      }
    }     

  }else if (isSafari) {     //per Safari & Chrome
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows[i];
      topRows[i] = getAbsoluteElementPosition(oRow).top  ;
    } 
  }else {     //per resta 
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows[i];
      topRows[i] = getAbsoluteElementPosition(oRow).top ;
    }                 
  }
  if (tempY < 0){
    tempY = 0;
  }   
  
  //window.status=RowsLength;
  //window.status=topRows;    
  //window.status=tempY;        
  //window.status= tempY.toString() + ":" + topRows[0].toString() + ":" + topRows[1].toString() + ":" + topRows[2].toString() + ":" + topRows[3].toString() + ":...:" + topRows[RowsLength-2].toString() + ":" + topRows[RowsLength-1].toString() + ":" + topRows[RowsLength].toString();         
  //alert(tempY);
  //alert(topRows); 
  // FF     9999 , 211, 235, 258, 282, 392, ..., 9999    
  // IE        0 , 219  242  265  288  311, ..., 9999 
  // NS     9999 , 220, 241, 262, 283, 298, ..., 9999
  // Chrome 9999 , 244, 268, 292, 318, 331, ..., 9999
  // Safari 9999 , 251, 275, 299, 325, 338, ..., 9999        
  // Opera  9999 , 271, 281, 211, 231, 251, ..., 9999                
  
  // IE??   9999 , 227, 250, 273, 296, 306, ..., 9999  

  // tempY FF        211, 232, 257, 282 
  // tempY IE        204, 227, 248, 274     
  // tempY Opera     210, 231, 250, 270             
  // tempY NS        221, 242, 264, 285 
  
  // tempY?? IE        227, 251, 274, 295         
  
  
  if (isOpera) { //per Opera    
  
    // correccio bug Opera  
    for (var i=3; i < RowsLength; i++){
      var oCells = oTable.rows.item(i).cells;
      var CellsLength = oCells.length;
      
      for (var j=0; j < CellsLength; j++) 
      {
          var newi = i - 2 ;
          if ( (tempY>=topRows[newi]) && (tempY<topRows[newi+1]) ){
            oCells.item(j).style.background="orange"; 
            rowFindKey= oCells.item(indexrowcode).textContent;  
          }else{
            if ( ( (newi % 2) == 0 ) )
              oCells.item(j).style.background="#fea";
            else
              oCells.item(j).style.background="#fff";           
          }
      }
    }   
  
  }else{

    for (var i=1; i < RowsLength-1; i++){
      var oCells = oTable.rows.item(i).cells;
      var CellsLength = oCells.length;
      
      for (var j=0; j < CellsLength; j++) 
      {
        if (isFF) { //per Firefox     
          if ( (tempY>topRows[i]) && (tempY<=topRows[i+1]) ){
            if (i < RowsLength-2){         
              oCells.item(j).style.background="orange"; 
              rowFindKey= oCells.item(indexrowcode).textContent;
            }
          }else{
            if (i < RowsLength-2){
              if ( ( (i % 2) == 0 ) )
                oCells.item(j).style.background="#fea";
              else
                oCells.item(j).style.background="#fff";           
            }
          }
        }else{     // per la resta
          if ( (tempY>=topRows[i]) && (tempY<topRows[i+1]) ){         
            if (i < RowsLength-2){         
              oCells.item(j).style.background="orange"; 
              //window.status=oCells.item(0).innerText ;
              rowFindKey= oCells.item(indexrowcode).innerText;
            }
          }else{
            if (i < RowsLength-2){
              if ( ( (i % 2) == 0 ) )
                oCells.item(j).style.background="#fea";
              else
                oCells.item(j).style.background="#fff";           
            }
          }
        }
      }
    }
  
  }
  
  
} 









// Crida a la funci? que canvia de color la linia seleccionada
function colorRowOverOut2(id,indexrowcode){
  if ( isIE ) { //para IE 
    colorRow2(id,indexrowcode);
  }  
  // if ( !isIE ) { //para FF
    //colorRow(id,indexrowcode)
  // }   
}

// Crida a la funci? que canvia de color la linia seleccionada
function colorRowMove2(id,indexrowcode){
  if ( !isIE ) { //para FF
    colorRow2(id,indexrowcode);
  }
  // if ( isIE ) { //para IE
    //colorRow(id,indexrowcode)
  // }  
}

// Crida a la funci? que canvia de color la linia seleccionada
// Igual que colorRow() per? amb funcionalitat activat / desactivat
function colorRow2(id,indexrowcode){
  var count=1;  
  var oTable = document.getElementById(id) ;

  if (activeColorRow2 == 0 ){
   return;
  }
  
  RowsLength = oTable.rows.length;    
  topRows[0] = 0; 
  for (var i=1; i < 200; i++)
    topRows[i] = 9999;    
    
  if (isIE) { //per IE 
    tempX = event.clientX + document.body.scrollLeft;   
    tempY = event.clientY + document.body.scrollTop;
    scrollY = document.documentElement.scrollTop ;    
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows(i);
      topRows[i] = getAbsoluteElementPosition(oRow).top - scrollY ;
    }     
  }else if (isOpera) { //per Opera
    tempX = event.clientX + document.body.scrollLeft;   
    tempY = event.clientY + document.body.scrollTop;
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows(i);
      // correccio bug Opera  
      if (i == 1) {
        topRows[RowsLength-2] = getAbsoluteElementPosition(oRow).top ;
      } else if (i == 2) {
        topRows[RowsLength-1] = getAbsoluteElementPosition(oRow).top ;
      } else {
        topRows[i-2] = getAbsoluteElementPosition(oRow).top ;
      }
    }     

  }else if (isSafari) {     //per Safari & Chrome
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows[i];
      topRows[i] = getAbsoluteElementPosition(oRow).top  ;
    } 
  }else {     //per resta 
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows[i];
      topRows[i] = getAbsoluteElementPosition(oRow).top ;
    }                 
  }
  if (tempY < 0){
    tempY = 0;
  }   
  
  if (isOpera) { //per Opera    
  
    // correccio bug Opera  
    for (var i=3; i < RowsLength; i++){
      var oCells = oTable.rows.item(i).cells;
      var CellsLength = oCells.length;
      
      for (var j=0; j < CellsLength; j++) 
      {
          var newi = i - 2 ;
          if ( (tempY>=topRows[newi]) && (tempY<topRows[newi+1]) ){
            oCells.item(j).style.background="orange"; 
            rowFindKey= oCells.item(indexrowcode).textContent;  
          }else{
            if ( ( (newi % 2) == 0 ) )
              oCells.item(j).style.background="#fff";
            else
              oCells.item(j).style.background="#fff";           
          }
      }
    }   
  
  }else{

    for (var i=1; i < RowsLength-1; i++){
      var oCells = oTable.rows.item(i).cells;
      var CellsLength = oCells.length;
      
      for (var j=0; j < CellsLength; j++) 
      {
        if (isFF) { //per Firefox     
          if ( (tempY>topRows[i]) && (tempY<=topRows[i+1]) ){
            if (i < RowsLength-2){         
              oCells.item(j).style.background="orange"; 
              rowFindKey= oCells.item(indexrowcode).textContent;
            }
          }else{
            if (i < RowsLength-2){
              if ( ( (i % 2) == 0 ) )
                oCells.item(j).style.background="#fff";
              else
                oCells.item(j).style.background="#fff";           
            }
          }
        }else{     // per la resta
          if ( (tempY>=topRows[i]) && (tempY<topRows[i+1]) ){         
            if (i < RowsLength-2){         
              oCells.item(j).style.background="orange"; 
              //window.status=oCells.item(0).innerText ;
              rowFindKey= oCells.item(indexrowcode).innerText;
            }
          }else{
            if (i < RowsLength-2){
              if ( ( (i % 2) == 0 ) )
                oCells.item(j).style.background="#fff";
              else
                oCells.item(j).style.background="#fff";           
            }
          }
        }
      }
    }
  
  }
  
  
} 


function disableColorRow2() { 
  activeColorRow2 = 0 ;
  return;
} 
  
function enableColorRow2() {  
  activeColorRow2 = 1 ;
colorRowMove2('row',0);
  return;
} 



// Canvia de color la linea en la que est? el cursor
// Igual que colorRow() per? amb funcionalitat de desactivar tots els controls que no estiguin a la linia seleccionada o en la linia d'un element
function colorRow3(id,indexrowcode,element){
  var count=1;  
  var oTable = document.getElementById(id) ;
  RowsLength = oTable.rows.length;    
  topRows[0] = 0; 
  
  for (var i=1; i < 200; i++)
    topRows[i] = 9999;    
    
  if (isIE) { //per IE 
    tempX = event.clientX + document.body.scrollLeft;   
    tempY = event.clientY + document.body.scrollTop;
    scrollY = document.documentElement.scrollTop ;    
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows(i);
      topRows[i] = getAbsoluteElementPosition(oRow).top - scrollY ;
    }     
  }else if (isOpera) { //per Opera
    tempX = event.clientX + document.body.scrollLeft;   
    tempY = event.clientY + document.body.scrollTop;
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows(i);
    // correccio bug Opera  
    if (i == 1) {
        topRows[RowsLength-2] = getAbsoluteElementPosition(oRow).top ;
      } else if (i == 2) {
        topRows[RowsLength-1] = getAbsoluteElementPosition(oRow).top ;
    } else {
        topRows[i-2] = getAbsoluteElementPosition(oRow).top ;
      }
    }     

  }else if (isSafari) {     //per Safari & Chrome
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows[i];
      topRows[i] = getAbsoluteElementPosition(oRow).top  ;
    } 
  }else {     //per resta 
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows[i];
      topRows[i] = getAbsoluteElementPosition(oRow).top ;
    }                 
  }
  if (tempY < 0){
    tempY = 0;
  }   
  
  // si s'indica un element agafo posici? de l'element
  if (element != null){
    tempY = getAbsoluteElementPosition(element).top;
  } 
  
  
  if (isOpera) { //per Opera    
  
    // correccio bug Opera  
    for (var i=3; i < RowsLength; i++){
      var oCells = oTable.rows.item(i).cells;
      var CellsLength = oCells.length;
      
      for (var j=0; j < CellsLength; j++) 
      {
          var newi = i - 2 ;
          if ( (tempY>=topRows[newi]) && (tempY<topRows[newi+1]) ){
            oCells.item(j).style.background="orange"; 
            rowFindKey= oCells.item(indexrowcode).textContent;  
          }else{
            if ( ( (newi % 2) == 0 ) ){
              oCells.item(j).style.background="#fff";
              desactivar2(oCells.item(j));
            } else{
              oCells.item(j).style.background="#fff";
			  desactivar2(oCells.item(j));              
            }
          }
      }
    }   
  
  }else{

    for (var i=1; i < RowsLength-1; i++){
      var oCells = oTable.rows.item(i).cells;
      var CellsLength = oCells.length;
      
      for (var j=0; j < CellsLength; j++) 
      {
        if (isFF) { //per Firefox     
          if ( (tempY>topRows[i]) && (tempY<=topRows[i+1]) ){
            if (i < RowsLength-2){         
              oCells.item(j).style.background="orange"; 
              rowFindKey= oCells.item(indexrowcode).textContent;
            }
          }else{
            if (i < RowsLength-2){
              if ( ( (i % 2) == 0 ) ){
                oCells.item(j).style.background="#fff";
			    desactivar2(oCells.item(j));              
              }else{
                oCells.item(j).style.background="#fff";
			    desactivar2(oCells.item(j));                
              }
            }
          }
        }else{     // per la resta
          if ( (tempY>=topRows[i]) && (tempY<topRows[i+1]) ){         
            if (i < RowsLength-2){         
              oCells.item(j).style.background="orange"; 
              //window.status=oCells.item(0).innerText ;
              rowFindKey= oCells.item(indexrowcode).innerText;
            }
          }else{
            if (i < RowsLength-2){
              if ( ( (i % 2) == 0 ) ){
                oCells.item(j).style.background="#fff";
			    desactivar2(oCells.item(j));
              } else{
                oCells.item(j).style.background="#fff";
			    desactivar2(oCells.item(j));                          
              }
            }
          }
        }
      }
    }
  
  }
  
  
} 











// Canvia de color la linea en la que est? el cursor
// Igual que colorRow() per? amb funcionalitat de fer "check" a un dels controls i carregar el seu identificador.
function selectRow2(id,indexrowmark,keyfield,indexrowcode,keyfield2,indexrowcode2,keyfield3,indexrowcode3,keyfield4,indexrowcode4,keyfield5,indexrowcode5,keyfield6,indexrowcode6,keyfield7,indexrowcode7) {
  var oTable = document.getElementById(id) ;  
  RowsLength = oTable.rows.length;    
  topRows[0] = 0; 
  for (var i=1; i < 200; i++)
    topRows[i] = 9999;
    
  if (isIE) { //per IE 
    tempX = event.clientX + document.body.scrollLeft;   
    tempY = event.clientY + document.body.scrollTop;
    scrollY = document.documentElement.scrollTop ;    
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows(i);
      topRows[i] = getAbsoluteElementPosition(oRow).top  - scrollY ;
    }     
  }else if (isOpera) { //per Opera
    tempX = event.clientX + document.body.scrollLeft;   
    tempY = event.clientY + document.body.scrollTop;
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows(i);
      // correccio bug Opera  
      if (i == 1) {
        topRows[RowsLength-2] = getAbsoluteElementPosition(oRow).top ;
      } else if (i == 2) {
        topRows[RowsLength-1] = getAbsoluteElementPosition(oRow).top ;
      } else {
        topRows[i-2] = getAbsoluteElementPosition(oRow).top ;
      }
    }       
  }else if (isSafari) {     //per Safari & Chrome
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows[i];
      topRows[i] = getAbsoluteElementPosition(oRow).top ;
    }       
  }else {     //per resta 
    for (var i=1; i < RowsLength; i++){
      var oRow = oTable.rows[i];
      topRows[i] = getAbsoluteElementPosition(oRow).top ;
    }             
  }
  if (tempY < 0){
    tempY = 0;
  }   

  //window.status=topRows;  
  //window.status= tempY.toString() + ":" + topRows[0].toString() + ":" + topRows[1].toString() + ":" + topRows[2].toString() + ":" + topRows[3].toString() + ":...:" + topRows[RowsLength-2].toString() + ":" + topRows[RowsLength-1].toString() + ":" + topRows[RowsLength].toString();                   
    
  if (isOpera) { //per Opera 
  
    // correccio bug Opera  
    for (var i=3; i < RowsLength; i++){
      var oCells = oTable.rows.item(i).cells;

      var newi = i - 2 ;
      //window.status= tempY.toString() + ":" + topRows[newi].toString() + ":" + topRows[newi+1].toString() ;                   
      if ( (tempY>=topRows[newi]) && (tempY<topRows[newi+1]) ){
        if (! keyfield=="")
          rowFindKey= oCells.item(indexrowcode).textContent;  
        if (! keyfield2=="")              
          rowFindKey2= oCells.item(indexrowcode2).textContent;      
        if (! keyfield3=="")              
          rowFindKey3= oCells.item(indexrowcode3).textContent;                  
        if (! keyfield4=="")              
          rowFindKey4= oCells.item(indexrowcode4).textContent;          
        if (! keyfield5=="")              
          rowFindKey5= oCells.item(indexrowcode5).textContent;          
        if (! keyfield6=="")              
          rowFindKey6= oCells.item(indexrowcode6).textContent;          
        if (! keyfield7=="")              
          rowFindKey7= oCells.item(indexrowcode7).textContent;          
                      
        oTable.rows[i].cells[indexrowmark].getElementsByTagName('input')[0].checked = true;               
      }else{
        oTable.rows[i].cells[indexrowmark].getElementsByTagName('input')[0].checked = false;          
      }
    }  
  
  }else{
  
    for (var i=1; i < RowsLength-1; i++){
      var oCells = oTable.rows.item(i).cells;
      
      if (isFF) { //per Firefox     
        if ( (tempY>topRows[i]) && (tempY<=topRows[i+1]) ){
          if (i < RowsLength-2){         
            if (! keyfield=="")
              rowFindKey= oCells.item(indexrowcode).textContent;
            if (! keyfield2=="")              
              rowFindKey2= oCells.item(indexrowcode2).textContent;
            if (! keyfield3=="")              
              rowFindKey3= oCells.item(indexrowcode3).textContent;
            if (! keyfield4=="")              
              rowFindKey4= oCells.item(indexrowcode4).textContent;              
            if (! keyfield5=="")              
              rowFindKey5= oCells.item(indexrowcode5).textContent;              
            if (! keyfield6=="")              
              rowFindKey6= oCells.item(indexrowcode6).textContent;              
            if (! keyfield7=="")              
              rowFindKey7= oCells.item(indexrowcode7).textContent;
                            
            oTable.rows[i].cells[indexrowmark].getElementsByTagName('input')[0].checked = true;
          }
        }else{
          if (i < RowsLength-2){
            oTable.rows[i].cells[indexrowmark].getElementsByTagName('input')[0].checked = false;
          }
        }
      }else{     // per la resta
        if ( (tempY>=topRows[i]) && (tempY<topRows[i+1]) ){
          if (i < RowsLength-2){         
            if (! keyfield=="")
              rowFindKey= oCells.item(indexrowcode).innerText;
            if (! keyfield2=="")
              rowFindKey2= oCells.item(indexrowcode2).innerText;
            if (! keyfield3=="")
              rowFindKey3= oCells.item(indexrowcode3).innerText;
            if (! keyfield4=="")
              rowFindKey4= oCells.item(indexrowcode4).innerText;              
            if (! keyfield5=="")
              rowFindKey5= oCells.item(indexrowcode5).innerText;              
            if (! keyfield6=="")
              rowFindKey6= oCells.item(indexrowcode6).innerText;              
            if (! keyfield7=="")
              rowFindKey7= oCells.item(indexrowcode7).innerText;              
                            
            oTable.rows[i].cells[indexrowmark].getElementsByTagName('input')[0].checked = true;
          }
        }else{
          if (i < RowsLength-2){
            oTable.rows[i].cells[indexrowmark].getElementsByTagName('input')[0].checked = false;
          }
        }
      }
    }
  
  } 
  
  if (! keyfield=="") {
    if (rowFindKey.charAt(0)=="\n")  
      rowFindKey = rowFindKey.substring(1, rowFindKey.length) ;           
    document.getElementById(keyfield).value = rowFindKey ;
  }
  if (! keyfield2=="") {
    if (rowFindKey2.charAt(0)=="\n")   
      rowFindKey2 = rowFindKey2.substring(1, rowFindKey2.length) ;       
    document.getElementById(keyfield2).value = rowFindKey2 ;    
  }
  if (! keyfield3=="") {
    if (rowFindKey3.charAt(0)=="\n")   
      rowFindKey3 = rowFindKey3.substring(1, rowFindKey3.length) ;
    document.getElementById(keyfield3).value = rowFindKey3 ;
  }   
  if (! keyfield4=="") {
    if (rowFindKey4.charAt(0)=="\n")   
      rowFindKey4 = rowFindKey4.substring(1, rowFindKey4.length) ;
    document.getElementById(keyfield4).value = rowFindKey4 ;
  }  
  if (! keyfield5=="") {
    if (rowFindKey5.charAt(0)=="\n")   
      rowFindKey5 = rowFindKey5.substring(1, rowFindKey5.length) ;
    document.getElementById(keyfield5).value = rowFindKey5 ;
  }  
  if (! keyfield6=="") {
    if (rowFindKey6.charAt(0)=="\n")   
      rowFindKey6 = rowFindKey6.substring(1, rowFindKey6.length) ;
    document.getElementById(keyfield6).value = rowFindKey6 ;
  }  
  if (! keyfield7=="") {
    if (rowFindKey7.charAt(0)=="\n")   
      rowFindKey7 = rowFindKey7.substring(1, rowFindKey7.length) ;
    document.getElementById(keyfield7).value = rowFindKey7 ;
  }  
    
}



function desactivar(arrel){
  var fills = arrel.childNodes;
  if (fills.length > 0){
    for (var i = 0; i < fills.length; i ++){
      //document.write(fills[i].nodeName + " : " + fills[i].nodeValue + " : " + fills[i].nodeType + "<br>");            
      //alert(fills[i].nodeName + " : " + fills[i].nodeValue + " : " + fills[i].nodeType + "<br>");                 
      if( fills[i].nodeName == "A") { 
        fills[i].href="javascript:void(0)";
      }                 
      if (fills[i].nodeType == 1) {
        desactivar(fills[i]);
      } 
    }   
  }
}

function desactivar2(arrel){
  var fills = arrel.childNodes;
  if (fills.length > 0){
    for (var i = 0; i < fills.length; i ++){
      //document.write(fills[i].nodeName + " : " + fills[i].nodeValue + " : " + fills[i].nodeType + "<br>");            
      //alert(fills[i].nodeName + " : " + fills[i].nodeValue + " : " + fills[i].nodeType + " : " + fills[i].disabled + "<br>");                 
      if( fills[i].nodeName == "INPUT") { 
        fills[i].disabled="true";
      }                 
      if (fills[i].nodeType == 1) {
        desactivar2(fills[i]);
      } 
    }   
  }
}


function desactivar3(arrel){
  var fills = arrel.childNodes;
  if (fills.length > 0){
    for (var i = 0; i < fills.length; i ++){
      //document.write(fills[i].nodeName + " : " + fills[i].nodeValue + " : " + fills[i].nodeType + "<br>");            
      //alert(fills[i].nodeName + " : " + fills[i].nodeValue + " : " + fills[i].nodeType + " : " + fills[i].disabled + "<br>");                             
      if( fills[i].nodeName == "SELECT") { 
        fills[i].disabled="true";
      }                 
    if (fills[i].nodeType == 1) {
      desactivar3(fills[i]);
      } 
    }   
  }
}


function refresh(){
  if (!document.getElementById('exportlinks')) {
    return;
  }
   
  document.getElementById('exportlinks').style.position = "absolute";       
  var widthExportLinks = getAbsoluteElementPosition('taula').width - 32 ;
  if (isIE) { //para IE
    var heightExportLinks = getAbsoluteElementPosition('escriptori').height - 33 ;
    var leftExportLinks = getAbsoluteElementPosition('pagebanner').left ;
    if (!leftExportLinks==0){
      // Explorer 5,6,7    	
      document.getElementById('exportlinks').style.left = leftExportLinks ;
    }else{   
      // Explorer 8         
      heightExportLinks = heightExportLinks-33 ; 
    }
  }else{ // para el resto
    var heightExportLinks = getAbsoluteElementPosition('escriptori').height - 23 ;
  }
  
  document.getElementById('exportlinks').style.top = heightExportLinks + "px" ;         
  document.getElementById('exportlinks').style.width = widthExportLinks + "px"  ;    
}  


  
function send(URL) {
  window.top.location = URL;  
}





