﻿// JScript File

var hCurrent = 0;
var hCount = -1;
var hMax = 3; //3 hidden controls at most.

var i = window.setInterval("ChangeLink()", 1000);

function ChangeLink()
{
    if (hCount == -1) {
        hCount = GetHCount();
        window.clearTimeout(i);
        window.setInterval("ChangeLink()", 5000);
    }
    
    if (hCount == 1) {
        SetNextH(1);
    }
    else if (hCount > 1) {
    
        hCurrent = GetNextH(hCurrent);
        SetNextH(hCurrent);
    }
}

function GetHCount() 
{
    var o = document.getElementById("ctl00_pnlHidden");
    var iCount = 0;
    var oChild;
    for (var i = 0; i < hMax; i++)
    {
        oChild = o.childNodes[i];
        if (oChild != null) {
            if (oChild.id != null) {
                if (oChild.id.substr("hyp").length > -1) {
                iCount++;
                }
            }
        }
    }
    return iCount;
}

function GetNextH(hCurrent)
{
    if ((hCurrent >= hCount) || (hCurrent == 0)) {
        return 1;
    }
    else {
        return hCurrent + 1;
    }
}

function SetNextH(nextH)
{
    var nextID = "ctl00_hyp" + nextH;
    var oChild;
    var o = document.getElementById("ctl00_pnlHidden");
    
    for (var i = 0; i <= hMax; i++)
    {
        oChild = o.childNodes[i];
        if (oChild != null) {
            if (oChild.id != null) {
                if (oChild.id == nextID) {

                    var c = document.getElementById("ctl00_cllSpecial");
                    
                    // Remove the existing hyperlink.
                    if (c.children.length > 0) {
                        c.removeChild(c.children(0))
                    }
                    
                    // Get pos of the splitter char.
                    var ind = oChild.value.indexOf("~");
                    
                    // Add a new hyperlink to the table cell.
                    var a = document.createElement("a");
                    a.setAttribute("href", oChild.value.substr(ind + 1));
                    a.setAttribute("target", "_blank");
                    a.style.color = "blue";
                    a.appendChild(document.createTextNode(oChild.value.substring(0, ind)));
                    c.appendChild(a);
                }
            }
        }    
            
    }
}

function ConfirmDelete() 
{ 
// Popup confirmation for delete. 
    
    var ans; 
    ans = confirm('Are you sure you want to delete this record?'); 
    if (ans == false) { 
    
        event.cancelBubble = true; 
        event.returnValue = false; 
        
    } 
    
} 

