//Foundation EQ diplay of questions/sections
$(document).ready(function() {

	var ineligibleReason=new Array();
	ineligibleReason[0]="The Campbell Soup Foundation can only provide support to 501(c)(3) nonprofit organizations. Thank you for your interest in the Campbell Soup Foundation.<br/><br/>Questions?  Please contact us by emailing: <a href=\"mailto:community_relations@campbellsoup.com\">community_relations@campbellsoup.com</a>";
	ineligibleReason[1]="The Campbell Soup Foundation has a geographic focus on Camden, N.J., Campbell's hometown and birthplace, and on other communities across the U.S. where the company has operating facilities. Thank you for your interest in the Campbell Soup Foundation.";
	ineligibleReason[2]="The Campbell Soup Foundation supports programs that address the following areas: hunger relief, wellness, education and community revitalization. Thank you for your interest in the Campbell Soup Foundation.";
	ineligibleReason[3]="Unfortunately, the Campbell Soup Foundation does not support grant requests for any of the items listed. Thank you for your interest in the Campbell Soup Foundation.";
	ineligibleReason[4]="The Campbell Soup Foundation does not provide funding for the same or similar program more than once in a fiscal year. Thank you for your interest in the Campbell Soup Foundation.";

    $('.eligibility_questionnaire-options input').click(function() {
        var fieldName = $(this).attr("name");
        var questionNumber = parseInt((fieldName).replace(/^question-/g,''));
        var previousQuestion = questionNumber-1;
        var nextQuestion = questionNumber+1;
        var answer = $(this).val();
        
		if (answer ==1) {	
		    tagQuestion('Question ' + questionNumber, 'Foundation', 'Eligibility Questionnaire');	
		    if (questionNumber ==5) {
			    tagTab(document.title + ": Confirmation");
			    $('#questionnairePanel').hide();
			    $('input[name=question-' + previousQuestion +']').attr("disabled", "disabled");
			    $('#eligiblePanel').show();
			} else {
			    $('#question'+ nextQuestion + 'PlaceHolder').show();
			    $('input[name=' + fieldName +']').attr("disabled", "disabled");
			}			
		} else {
			tagTab(document.title + ": Denied");
			$('#questionnairePanel').hide();
			$('#ineligibleReason').html(ineligibleReason[previousQuestion]);
			$('#ineligiblePanel').show();
		}              

    });
    
    $('#download-proposal-form input').click(function() { // bind click event to link
        tagPDF(this,'Foundation: Eligibility Questionnaire: Complete');
    });
    
});