﻿// JScript File
function SelectAllCheckBoxes(strCBoxId)
{
    var cBoxes = document.getElementsByName(strCBoxId);
    if (cBoxes!=null)
    {
        
	    if(typeof(cBoxes[0])!="undefined")
	    {
	        var iLength = cBoxes.length;
	        for(var i=0; i<iLength; i++)
	        {
	           if (cBoxes[i].disabled!=true)
	           {
	             cBoxes[i].checked=true; 
	           }
	        }
	    }else{
	       if (cBoxes.disabled!=true)
	       {
	        cBoxes.checked=true;
	       }
	    }
    }
}

function SelectAllUnselectAll(strCBoxId)
{
    if(isCBoxChecked(strCBoxId))
    {
        SelectUnselectKids(strCBoxId,false);
    }else{
        SelectUnselectKids(strCBoxId,true);
    }
}


function UnselectAllCheckBoxes(strCBoxId)
{
    var cBoxes = document.getElementsByName(strCBoxId);
    if (cBoxes!=null)
    {
	    if(typeof(cBoxes[0])!="undefined")
	    {
	        var iLength = cBoxes.length;
	        for(var i=0; i<iLength; i++)
	        {
	           if (cBoxes[i].disabled!=true)
	           {
	             cBoxes[i].checked=false; 
	           }
	        }
	    }else{
	        if (cBoxes.disabled!=true)
	       {
	        cBoxes.checked=false;
	       }
	    }
    }
}

function SelectUnselectKids(strCBoxId, bChecked)
{
    if(bChecked==true)
    {
       SelectAllCheckBoxes(strCBoxId);
    }else{
        UnselectAllCheckBoxes(strCBoxId);
    }
}

function isCBoxChecked(strCBoxId)
{
    var cBoxes = document.getElementsByName(strCBoxId);
    var bRetVal=false;
    if (cBoxes!=null)
    {
	    if(typeof(cBoxes[0])!="undefined")
	    {
	        var iLength = cBoxes.length;
	        for(var i=0; i<iLength; i++)
	        {
	           if (cBoxes[i].checked)
	           {
	            bRetVal=true;
	            break;
	           }
	        }
	    }else{
	           if (cBoxes.checked)
	           {
	            bRetVal=true;
	           }
	    }
    }
    return bRetVal;
}

function isTextBoxEmpty(textboxid)
{
    var textbox = document.getElementById(textboxid);
    if (textbox!=null && textbox.value!='')
    {
        return false;
    }else{
        return true;
    }
}

function SubmitForm(formname, action, target)
{       
    //var form = $get(formname);
    var form = window.document.getElementById(formname);
    if (form!=null)
    {
        form.action=action;
        form.target=target;
        form.method='POST';
        form.submit();
    }
}

function openHelp(helpurl)
{
    var wnd = window.open(helpurl, 'Help_File', 'width=400,height=600,resizable=yes, location=no, toolbar=0,scrollbars=yes');
    wnd.focus();
    return false;
}

function openDataDetails(data_details_url)
{
    var wnd = window.open(data_details_url, 'Data_Details', 'width=600,height=600,resizable=yes, location=no, toolbar=0,scrollbars=yes');
    wnd.focus();
    return false;
}


function GetFilings(strTicker)
{       
        if (strTicker!=null && strTicker!="Ticker" && strTicker!="")
        {
            var url = "/net/secfilings/resultframe.aspx?EntityInput=" + strTicker+"&Entity=Ticker&SearchTypeID=1&SectionTypeID=0&ShowPreview=1";
         //   var hwn = window.open(url);
         //   hwn.focus();
            window.top.location = url;
        }
        else
        {
            alert('Please enter a company ticker.');
        }
}

function GetReleases(strReg)
{   
    if (strReg!=null && strReg!="33-, 34-")
    {
        var url = "/net/sm/QuickRelease.aspx?Item=" + strReg;
        window.top.location = url;
    }
}


function GetSiteIndex(strSiteIndex)
{   
    if (strSiteIndex!=null && strSiteIndex!="e.g., no-action letters")
    {
        var url = "/net/public/SiteIndex.aspx?key=" + strSiteIndex;
        window.top.location = url;
    }
}

function CloseThisWindow()
{
    if (parent.window)
    {
        parent.window.close();
    }
}

function GoBack()
{
    window.history.back();
}
