function toggleEmployeesVisibility() { if ($('#employeesVisibility').attr('checked')) $('div.employees').show(); else $('div.employees').hide(); } function toggleHighlightSupervisor() { if ($('#highlightSupervisor').attr('checked')) $('p.supervisor').css('font-weight', 'bold'); else $('p.supervisor').css('font-weight', 'normal'); } function toggleOrgchartPathVisibility() { if ($('#orgchartPathVisibility').attr('checked')) { $('span.orgchartPath').css('visibility', 'visible').show(); } else { if ($('#orgchartPathIndentation').attr('checked')) $('span.orgchartPath').show().css('visibility', 'hidden'); else $('span.orgchartPath').hide(); } } function toggleOrgchartPathIndentation() { if ($('#orgchartPathIndentation').attr('checked')) { $('div.employees').each(function() { $(this).css('margin-left', (0 + $($(this).parent().children('h1').children().get(0)).width()) + 'px'); } ); if (!$('#orgchartPathVisibility').attr('checked')) $('span.orgchartPath').show().css('visibility', 'hidden'); } else { $('div.employees').css('margin-left', '0px'); if (!$('#orgchartPathVisibility').attr('checked')) $('span.orgchartPath').css('visibility', 'visible').hide(); else $('span.orgchartPath').css('visibility', 'visible'); } } function printAction() { window.print(); } function bindEvents() { $('#employeesVisibility').click(toggleEmployeesVisibility); $('#highlightSupervisor').click(toggleHighlightSupervisor); $('#orgchartPathVisibility').click(toggleOrgchartPathVisibility); $('#orgchartPathIndentation').click(toggleOrgchartPathIndentation); $('#printButton').click(printAction); } function initialSetup() { toggleEmployeesVisibility(); toggleHighlightSupervisor(); toggleOrgchartPathVisibility(); toggleOrgchartPathIndentation(); } function pageLoad() { bindEvents(); initialSetup(); } $(window).load(pageLoad);