﻿
window.attachEvent("onload", init);

var colorAnt
var rowAnt
var primeraVez = true
function init()
{


if (document.all.ctl00_ContentPlaceHolder1_GridView1)
{
grid = document.all.ctl00_ContentPlaceHolder1_GridView1
FreezeGridViewHeader('ctl00_ContentPlaceHolder1_GridView1','WrapperDiv');
}



if (document.all.ctl00_ContentPlaceHolder1_GridView1)
{
//document.all.gridDIV.children[0].scrollTop = document.all.ctl00_ContentPlaceHolder1_scrollTB.value


id_selected = document.all.ctl00_ContentPlaceHolder1_usernameSelectedTB.value
var i = 1
while (i<document.all.ctl00_ContentPlaceHolder1_GridView1.rows.length)
{
row = document.all.ctl00_ContentPlaceHolder1_GridView1.rows[i]

if (row.id == id_selected)
{
rowAnt = row
colorAnt = row.style.backgroundColor
row.style.backgroundColor = "gold"
}
i++
}




}

}



    function FreezeGridViewHeader(gridID,wrapperDivCssClass) 

    {


        var grid = document.getElementById(gridID);



        if (grid != 'undefined')
        {


    
            grid.style.visibility = 'hidden';
            
            var div = null;
            if (grid.parentNode != 'undefined') 
            {
           
      
                           //Find wrapper div output by GridView
                div = grid.parentNode;
                if (div.tagName == "DIV")
                {
                
                   div.className = wrapperDivCssClass;  
                    div.style.overflow = "auto";                   
                }
            }                
            
            //Find DOM TBODY element and remove first TR tag from 
            //it and add to a THEAD element instead so CSS styles
            //can be applied properly in both IE and FireFox
            
            var tags = grid.getElementsByTagName('TBODY');
    
     
            if (tags != 'undefined')
            {
                              
                var tbody = tags[0];

                var trs = tbody.getElementsByTagName('TR');
                if (trs != 'undefined') 
                {
        
                    var headTR = tbody.removeChild(trs[0]);
                 
                   var head = document.createElement('THEAD');
                    head.appendChild(headTR);
                   grid.insertBefore(head, grid.firstChild);
                
              
       
                 
         
                
               
                }
                

            }
            grid.style.visibility = 'visible';
       
         


        }
    }


function revisaScroll()
{

document.all.ctl00_ContentPlaceHolder1_scrollTB.value = document.all.gridDIV.children[0].scrollTop
}



function mouseover(elm)
{
colorAnt = elm.style.backgroundColor
elm.style.backgroundColor = "#E0FFFF"

if (primeraVez)
{
if (rowAnt) rowAnt.style.backgroundColor = colorAnt
primeraVez =false
}
}

function mouseout(elm)
{
elm.style.backgroundColor = colorAnt
}


function rowClick(row)
{
revisaScroll()
document.all.ctl00_ContentPlaceHolder1_usernameSelectedTB.value = row.id
document.all.ctl00_ContentPlaceHolder1_editPB.click() 
}
