function init() {
	$('#navigation div').hover(nav_over, nav_out);
    $('#navigation div').click(goto_nav_id);
    $('#navigation_home div').hover(nav_over, nav_out);
    $('#navigation_home div').click(goto_nav_id);
	$('.callout_box ul li').hover(sub_nav_over, sub_nav_out);
    $('.callout_box ul li').click(switch_section);
	$('.subnav_body ul li').hover(sub_nav_over, sub_nav_out);
    $('.subnav_body ul li').click(switch_section);
    if (page == '') {
  		page = '1'; 
	}
    display_section(page);
    render_progressbar();
    $('#previous').click(function(e) { history.back(); });
}

function render_progressbar() {
    page = $('#page').val();
    width = 500 * (parseInt(page) / 11);
    percent = parseInt(100 * (parseInt(page) / 11));
    $('#progress').css('width', width);
    $('#progress').html(percent + "%");
}

function nav_over(e) {
	if (!$(this).parent().hasClass('nav_home')) {
    	$(this).css('background','url("/images/'+$(this).attr('id')+'_over.gif")');
	} else {
    	$(this).css('background','url("/images/'+$(this).attr('id')+'_over_home.gif")');
	}
}

function nav_out(e) {
    $(this).css('background','none');
}

function sub_nav_over(e) {
    if (!$(this).hasClass('current')) {
        $(this).find('.arrow').addClass('over');
    }
}

function sub_nav_out(e) {
    if (!$(this).hasClass('current')) {
        $(this).find('.arrow').removeClass('over');
    }
}

function goto_nav_id(e) {
    id = $(this).attr('id');
    page = id.substring(4);
    location.href='/' + page + '.php';
}

function display_section(pg) {
    $('.content_section').css('display', 'none');
    $('#content_' + pg).css('display', 'block');
    $('.callout_box ul li').removeClass('current');
    $('.callout_box ul li div').removeClass('over');
    $('.subnav_body ul li').removeClass('current');
    $('.subnav_body ul li div').removeClass('over');
	$('.subnav_body ul li#' + pg).addClass('current');
}

function switch_section(e) {
    id = $(this).attr('id');
    /*$('.callout_box ul li').removeClass('current');
    $('.callout_box ul li div').removeClass('over');
    $('.subnav_body ul li').removeClass('current');
    $('.subnav_body ul li div').removeClass('over');
    $(this).addClass('current');
    display_section(id);*/
	location.href='/' + section + '.php?page=' + id;
}

