$(document).ready(function() {
	
	// Are you Eightteen
	$("#rblEighteenOrOlder_1").click(function() {
		$("#overeighteenno").slideDown();
	});
	$("#rblEighteenOrOlder_0").click(function() {
		$("#overeighteenno").slideUp();
	});
	
	//Convicted of a crime
	$("#ctl00_cphMain_ucMod164_rblConvictedOfACrime_0").click(function() {
		$("#convictedofacrime").slideDown();
	});
	$("#ctl00_cphMain_ucMod164_rblConvictedOfACrime_1").click(function() {
		$("#convictedofacrime").slideUp();
	});
	
	//Have you worked here before
	$("#rblHaveYouWorkedAtDePaulBefore_0").click(function() {
		$("workedbefore").slideDown();
	});
	$("#rblHaveYouWorkedAtDePaulBefore_1").click(function() {
		$("workedbefore").slideUp();
	});
	
});

function ResizeContainer()
{  
    var difference = 0;
    
    $('div[id^="mod"]').each(function()
    {
        var currentDifference = parseInt($(this).height() - $(this).css('min-height').replace('px', ''));
        
        if(currentDifference > difference)
        {
            difference = currentDifference;
        }
    });
    
	if($("body").attr("id") == "ctl00_ViewJobApplication"){
		var h = ($('#container').height() + difference) + "px";
		//$('#container').css("height", h);
	}else{
		$('#container').height($('#container').height() + difference);
	}
	
}

function ResizeContainerBoth()
{  
	var maxOffset = 0, initialOffset = 0;
	var footerHeight = parseInt($('#mod190').outerHeight());
	$('#container>div').each(function(){
		if($(this).attr('id') != 'mod190'){ //footer
			var currentOffset = parseInt($(this).position().top) + parseInt($(this).outerHeight()) + footerHeight;
			//alert($(this).attr('id') + ":" + maxOffset + ":" + currentOffset);
			maxOffset = Math.max(maxOffset, currentOffset);
		}
	});
	if(maxOffset != initialOffset) $('#container').css('height', (maxOffset) + 'px'); 
}

function ResizeForm(formID, numberOfValidators)
{
    if($('.form' + formID + ' .formValidator').css('display') == 'none') //only run once
    {
        var offset = 15; 
		
		
		$('#container').height($('#container').height() + (offset * numberOfValidators));
		
        
    }
}

function ResizeModule(name)
{
    if (typeof(Page_Validators) != 'undefined') 
    {
        if(!Page_IsValid)
        {
            if(!$('.' + name).parent().attr('style'))
            {
                var offset = 10; 
                var numberOfValidators = $('span[id*="RequiredFieldValidator"]').length;
            
                $('.' + name).parent().height($('.' + name).parent().height() + (offset * numberOfValidators));
                ResizeContainer();
            }
        }
    }
}

$(document).ready(function() {

    var nav = window.location.pathname;
    $('ul[id^="ni"] li[^="link"] a[href$="' + nav + '"] ').addClass('activeLink');
    
    if($('ul[id^="ni"] li[^="link"] a[href$="' + nav + '"] ').parent().parents('li').length > 0)
    {
        $('ul[id^="ni"] li[^="link"] a[href$="' + nav + '"] ').parent().parents('li').find('a:first').addClass('activeLink');
    }
    
    var url = window.location.href;

    url = url.substring(url.lastIndexOf("/"), url.length);
    //$('.applicationHeader li span,.applicationHeader li img').css({ "opacity": "0.3", "filter": "alpha(opacity = 30)", "zoom": "1" });
    $('.applicationHeader li img').css({ "opacity": "0.3", "filter": "alpha(opacity = 30)", "zoom": "1" });
    $('.applicationHeader li span').css({ "color": "#cccccc" });

    if (url.indexOf("application.aspx") != -1) 
    {
        //$('.applicationHeader #1 span,.applicationHeader #1 img').css({ "opacity": "1", "filter": "alpha(opacity = 100)", "zoom": "1" });
        $('.applicationHeader #1 img').css({ "opacity": "1", "filter": "alpha(opacity = 100)", "zoom": "1" });
        $('.applicationHeader #1 span').css({ "color": "#000000" });
        $('.applicationHeader #2 span, .applicationHeader #3 span').css({ "color": "#cccccc" });
    }
    else if (url.indexOf("application-step-2") != -1) 
    {
        //$('.applicationHeader #2 span,.applicationHeader #2 img').css({ "opacity": "1", "filter": "alpha(opacity = 100)", "zoom": "1" });
        $('.applicationHeader #2 img').css({ "opacity": "1", "filter": "alpha(opacity = 100)", "zoom": "1" });
        $('.applicationHeader #2 span').css({ "color": "#000000" });
        $('.applicationHeader #1 span, .applicationHeader #3 span').css({ "color": "#cccccc" });
    }
    else if (url.indexOf("application-step-3") != -1) 
    {
       // $('.applicationHeader #3 span,.applicationHeader #3 img').css({ "opacity": "1", "filter": "alpha(opacity = 100)", "zoom": "1" });
        $('.applicationHeader #3 img').css({ "opacity": "1", "filter": "alpha(opacity = 100)", "zoom": "1" });
        $('.applicationHeader #3 span').css({ "color": "#000000" });
        $('.applicationHeader #1 span, .applicationHeader #2 span').css({ "color": "#cccccc" });
    }
});

$(window).load(function () {
    ResizeContainer();
});


$(document).ready(function() {
	$('.jobsGrid table tr:last').addClass('lastRow');
	$('.jobsGrid table tr td:first').addClass('first');
	$('.jobsGrid table tr td:last').addClass('lasttd');
});

