﻿// JScript File

        var clientid;
        function fnSetFocus(txtClientId)
        {
        	clientid=txtClientId;
        	setTimeout("fnFocus()",500);
            
        }  
        function fnFocus()
        {
            eval("document.getElementById('"+clientid+"').focus()");
        }


        function pagetop()
        {
            window.location="#pagetop"
        }
        
        /*
        function EndRequestHandler(sender, args) {
           if (args.get_error() == undefined)
               window.location="Default.aspx#gridtop"
           else
               alert("There was an error" + args.get_error().message);
        }
        function load() {
           Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        }
*/


        function ChangeCheckBoxState(id, checkState)
        {
            var cb = document.getElementById(id);
            if (cb != null)
               cb.checked = checkState;
        }
        
        function ChangeAllCheckBoxStates(checkState)
        {
            // Toggles through all of the checkboxes defined in the CheckBoxIDs array
            // and updates their value to the checkState input parameter
            if (CheckBoxIDs != null)
            {
                for (var i = 0; i < CheckBoxIDs.length; i++)
                {
                   ChangeCheckBoxState(CheckBoxIDs[i], checkState);
                   
                   // If i is greater than 0 because we don't want to highlight the header row.
                   if (i > 0)
                   {
                    var cb = document.getElementById(CheckBoxIDs[i]);
                    HighlightRow(cb);
                   }
                }
            }
        }
                       
        function HighlightRow(obj)
        {
            if (obj != null)
            {        
                // Do color change
                var rowObject = getParentRow(obj)
                var parentTable = document.getElementById("GridView1");
                
                if (obj.checked)
                {
                    //rowObject.onmouseover = null;
                    //rowObject.onmouseout = null;                
                    //rowObject.onmouseover = "rowObject.style.backgroundColor='#e3e1e1'";                
                    rowObject.style.backgroundColor = '#DEE8F5';
    //                rowObject.onmouseover = "style.backgroundColor='#DEE8F5';";           
    //                rowObject.onmouseout = '#DEE8F5';
                }
                else
                {
                    //rowObject.onmouseout = this.style.backgroundColor='#F6F6F6';                
                    // This will return the row back to its original color.                
                    //rowObject.onmouseover = "rowObject.style.backgroundColor='#e3e1e1'";                
                    rowObject.style.backgroundColor = '';
    //                rowObject.onmouseover = "style.backgroundColor='#e3e1e1';";
    //                rowObject.onmouseout = '';
                }      
            }  
        }
        
        function GridViewRowOnMouseOver(objRow, CheckBoxClientId, index)
        {
            //checked = new Boolean(boolChecked); 
            
            //var CheckBox = objRow.getElementById("RowLevelCheckBox")
            var CheckBox = document.getElementById(CheckBoxClientId);
            if (CheckBox != null)
            {
                var boolChecked = CheckBox.checked;
                
                if (boolChecked == true)
                    objRow.style.backgroundColor = '#373737';
                else
                    objRow.style.backgroundColor = '#161616';
            }
            
            var shareDiv = document.getElementById("share" + index);
            if (shareDiv != null)
            {
                shareDiv.style.visibility = "visible";
            }
                 
//            var IsChecked = objCheckBox.checked;       
//            if (IsChecked)
//                objRow.style.backgroundColor = '#DEE8F5';
//            else
//                objRow.style.backgroundColor = '#e3e1e1';
        }
        function GridViewRowOnMouseOut(objRow, CheckBoxClientId, index)
        {
            //checked = new Boolean(boolChecked);
            
            //var CheckBox = objRow.getElementById("RowLevelCheckBox")
            
            var CheckBox = document.getElementById(CheckBoxClientId);
            if (CheckBox != null)
            {
                var boolCheckedOut = CheckBox.checked;            
                
                if (boolCheckedOut == true)              
                    objRow.style.backgroundColor = '#373737';
                else
                    objRow.style.backgroundColor = '';
            }
            
            var shareDiv = document.getElementById("share" + index);
            if (shareDiv != null)
            {
                shareDiv.style.visibility = "hidden";
            }             
//            var IsChecked = objCheckBox.checked; 
//            if (IsChecked)
//                objRow.style.backgroundColor = '#DEE8F5';
//            else
//                objRow.style.backgroundColor = '';

        }        
        
        var color = ''; 
        function ChangeHeaderAsNeeded(obj)
        {
            // Do color change
            var rowObject = getParentRow(obj)
            var parentTable = document.getElementById("GridView1");
            
            if (obj.checked)
            {
                //rowObject.onmouseover = null;
                //rowObject.onmouseout = null;                
                //rowObject.onmouseover = "rowObject.style.backgroundColor='#e3e1e1'";                
                rowObject.style.backgroundColor = '#DEE8F5';   
                
//                GridViewRowOnMouseOver(rowObject, true);
//                GridViewRowOnMouseOut(rowObject, true);
                   
                //rowObject.onmouseover.className = '';
                //rowObject.onmouseover = '';
                //rowObject.onmouseout.className = '';                
            }
            else
            {
                //rowObject.onmouseout = this.style.backgroundColor='#F6F6F6';                
                // This will return the row back to its original color.                
                //rowObject.onmouseover = "rowObject.style.backgroundColor='#e3e1e1'";
                //rowObject.onmouseout = '';                
                rowObject.style.backgroundColor = '';
                
//                GridViewRowOnMouseOver(rowObject, false);
//                GridViewRowOnMouseOut(rowObject, false);
                
                //rowObject.onmouseover = '';
                //rowObject.onmouseout = '';  
            }
//            if(color == '') 
//            {
//                color =  getRowColor();      
//            }               
//            if(obj.checked) 
//            {              
//                rowObject.onmouseover = null;
//                rowObject.onmouseout = null;
//                rowObject.style.backgroundColor = 'Yellow';    
//                
//                //rowObject.className = 'classnamehere';        
//            }
//            else 
//            {
//                rowObject.onmouseover = '#e3e1e1';
//                rowObject.onmouseout = color;            
//                rowObject.style.backgroundColor = color; 
//                color = '';                 
//            }
//            // private method
//            function getRowColor() 
//            {
//                if(rowObject.style.backgroundColor == '') return parentTable.style.backgroundColor; 
//                else return rowObject.style.backgroundColor; 
//            }
       
       
            // HIGHLIGHT ROW
            // Whenever a checkbox in the GridView is toggled, we need to
            // check the Header checkbox if ALL of the GridView checkboxes are
            // checked, and uncheck it otherwise
            if (CheckBoxIDs != null)
            {
                // check to see if all other checkboxes are checked
                for (var i = 1; i < CheckBoxIDs.length; i++)
                {
                    var cb = document.getElementById(CheckBoxIDs[i]);
                    if (!cb.checked)
                    {
                        // Whoops, there is an unchecked checkbox, make sure
                        // that the header checkbox is unchecked
                        ChangeCheckBoxState(CheckBoxIDs[0], false);
                        return;
                    }
                }
                
                // If we reach here, ALL GridView checkboxes are checked
                ChangeCheckBoxState(CheckBoxIDs[0], true);
            }
        }
        
        // This method returns the parent row of the object
        function getParentRow(obj) 
        { 
            if (obj != null)
            {
                do 
                {
                    if(isFireFox()) 
                    {
                        obj = obj.parentNode; 
                    }
                    else {
                    obj = obj.parentElement; 
                    }
                }
                while(obj.tagName != "TR") 
            }

           return obj;   
        } 
        function isFireFox() 
        {
            return navigator.appName == "Netscape"; 
        }
        
        
        
        
        
        function OnMouseOver_Row(objRow, index)
        {
            if (objRow != null)
            {
                objRow.style.backgroundColor = '#161616';
                
                var shareDiv = document.getElementById("share" + index);
                if (shareDiv != null)
                {
                    shareDiv.style.visibility = "visible";
                }
            }                 
        } 
        function OnMouseOut_Row(objRow, index)
        {
            if (objRow != null)
            {
                objRow.style.backgroundColor = '#222';
                
                var shareDiv = document.getElementById("share" + index);
                if (shareDiv != null)
                {
                    shareDiv.style.visibility = "hidden";
                }                
            }                 
        }   
        function OnMouseOver_RowAlt(objRow, index)
        {
            if (objRow != null)
            {
                objRow.style.backgroundColor = '#161616';
                
                var shareDiv = document.getElementById("share" + index);
                if (shareDiv != null)
                {
                    shareDiv.style.visibility = "visible";
                }                
            }                 
        } 
        function OnMouseOut_RowAlt(objRow, index)
        {
            if (objRow != null)
            {
                objRow.style.backgroundColor = '#222';
                
                var shareDiv = document.getElementById("share" + index);
                if (shareDiv != null)
                {
                    shareDiv.style.visibility = "hidden";
                }                
            }                 
        }       
        
        
        
function showShare(strRowId) {
    //var shareDiv = document.getElementById("'" + strRowId + "'");
    var shareDiv = document.getElementById(strRowId);

    shareDiv.style.visibility = "visible";
}
function hideShare(strRowId) {

    //var shareDiv = document.getElementById("'" + strRowId + "'");
    var shareDiv = document.getElementById(strRowId);
    
    shareDiv.style.visibility = "hidden";
}                      
