﻿// JScript File

// Prints the element (and its contents) with the specified id.
function CallPrint(elementId)
{
    var contentToPrint = document.getElementById(elementId);
    var printWindow = window.open('','','left=0,top=0,width=800,toolbar=0,scrollbars=1,status=0');
    printWindow.document.write("<link rel='stylesheet' type='text/css' href='./Css/Registers.css' />" 
                               + contentToPrint.innerHTML);
    // Disable all the links.
    DisableLinks(printWindow.document);
    printWindow.document.close();
    printWindow.focus();
    printWindow.print();
    printWindow.close();
}

// Disables all links in a document.
function DisableLinks(currentDocument)
{
    allLinks = currentDocument.links;
    
    for(i=0; i<allLinks.length; i++)
    {
        allLinks[i].disabled = 'disabled';
        allLinks[i].onclick = function() { return false; }
    }
}

String.prototype.getFuncBody = function()
{ 
    var bodyString = this.toString(); 
    bodyString = bodyString.replace(/[^{]+{/,"");
    bodyString = bodyString.substring(0,bodyString.length-1);   
    bodyString = bodyString.replace(/\n/gi,"");
    if(!bodyString.match(/\(.*\)/gi)) { bodyString += ")"; }
    return bodyString; 
} 



// Opens a popup window to the specified url with the specified name, width and height properties.
function OpenWindow(url, name, width, height)
{
    // Factors for window decoration space.
    var win = window.open(url, name, 
    'width=' + width + ', height=' + height + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=no, resizable=yes' +
    'left=100,top=100,screenX=100,screenY=100');
    win.focus();
}

// Function to set the inner text of a specified element with the specified text.
function SetInnerText(elementId, innerText)
{
    document.getElementById(elementId).innerHTML = innerText;
}

// Function to reset the Firm search dropdowns 
function resetFirmDropDownControls() 
{
    var mainDropDowntoReset = document.getElementById('ctl00_cphRegistersMasterPage_ddlFirms');    
    mainDropDowntoReset.options[0].selected = true;
    mainDropDowntoReset.selectedIndex = 0;

    var mainDropDowntoReset = document.getElementById('ctl00_cphRegistersMasterPage_ddlSubTypes');    
     for (var i = (mainDropDowntoReset.options.length-1); i >= 0; i--){
         mainDropDowntoReset.options[i]=null;
     }
     mainDropDowntoReset.options[0]=new Option('All', '');
        
}    

// Function to reset the Fund search dropdowns 
function resetFundDropDownControls() 
{
    var mainDropDowntoReset = document.getElementById('ctl00_cphRegistersMasterPage_ddlFunds');    
    mainDropDowntoReset.options[0].selected = true;
    mainDropDowntoReset.selectedIndex = 0;        
}    

function hideErrors() {

    if (document.getElementById)
    {
    if (document.getElementById('ctl00_cphRegistersMasterPage_errorPanel').style)
    document.getElementById('ctl00_cphRegistersMasterPage_errorPanel').style.visibility="hidden";
    }
    else if (document.all && !document.getElementById)
    document.ctl00_cphRegistersMasterPage_errorPanel.visibility="hidden";

}

function roll_over(img_name, img_src)
   {
   document.getElementById(img_name).src = img_src;
   }
