﻿window.onload = reload;

function reload()
{
    //debugger;
	// Set flyouts by calling init
	init();
    SetUpSponsorShipForm();
}

function ShowEvents(totalEvents)
{
    //debugger;
    //show holder
    if(totalEvents > 0)
        $('EventHolder').show();
    //get sub div event holders
    var eventHolders = $$('#EventHolder div');
    for (var i = 0; i < eventHolders.length; i++)
	{
	    eventHolders[i].hide();
	}
    
    for (var i = 0; i < totalEvents; i++)
	{
	    eventHolders[i].show();
	}
}

function SetUpSponsorShipForm()
{
    //debugger;
    var showEventNum = $(controlPrefix + 'SpecificEvent_0');
    if(showEventNum != null && showEventNum.readAttribute('checked'))
    {
        $('EventNum').show();
    }
    
    var numberOfEvents = $(controlPrefix + 'NumberOfEvents')
    if(numberOfEvents != null)
    {
        ShowEvents(numberOfEvents.getValue())
    }
    
    var withOrg = $(controlPrefix + 'WithOrg_0');
    if(withOrg != null && withOrg.readAttribute('checked'))
    {
        $('q6').show();
    }
    
    var specificProgram = $(controlPrefix + 'SpecificProgram_0');
    if(specificProgram != null && specificProgram.readAttribute('checked'))
    {
        $('q7').show();
    }
    
    var startUp = $(controlPrefix + 'StartupProject_0');
    if(startUp != null && startUp.readAttribute('checked'))
    {
        $('8.1Required').show();
    }
    
    var fundPart = $(controlPrefix + 'FundingPartners_0');
    if(fundPart != null && fundPart.readAttribute('checked'))
    {
        $('9.1Required').show();
    }
    
    var otherIns = $(controlPrefix + 'OtherInsurance_0');
    if(otherIns != null && otherIns.readAttribute('checked'))
    {
        $('10.1Required').show();
    }
    
    var otherBene = $(controlPrefix + 'OtherBenefits_0');
    if(otherBene != null && otherBene.readAttribute('checked'))
    {
        $('12.1Required').show();
    }
}