// source: http://lyncd.com/2009/03/better-google-analytics-javascript/ function ga_load (acct) { var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."), pageTracker, s; s = document.createElement('script'); s.src = gaJsHost + 'google-analytics.com/ga.js'; s.type = 'text/javascript'; s.onloadDone = false; function init () { pageTracker = _gat._getTracker(acct); pageTracker._trackPageview(); } s.onload = function () { s.onloadDone = true; init(); }; s.onreadystatechange = function() { if (('loaded' === s.readyState || 'complete' === s.readyState) && !s.onloadDone) { s.onloadDone = true; init(); } }; document.getElementsByTagName('head')[0].appendChild(s); } $(document).ready(function() { if ($("#focus_image_home").length > 0){ $('#focus_image_home').orbit({ animation: 'fade', pauseOnHover: true, startClockOnMouseOut: true, startClockOnMouseOutAfter: 1000, directionalNav: true }); } // colorbox everything $('#content_top_left img, #content_wrap img').each(function() { if( !$(this).parent().is('a') ){ $(this).wrap(""); } }); $('#content_top_left a, #content_wrap a').has('img').colorbox(); if ($(".home_split_25percent").length > 0){ // focus box caption hovers $('div[class^="home_split_"][class$="percent"]') // matches home_split_%percent .each(function() { // set initial opacity $(this).find('.home_split_blurb').css({ opacity: 0 }); }) .hover(function() { // mouseover $(this).find('.home_split_blurb').stop(true, true).fadeTo('fast', 0.9); }, function() { // mouseleave $(this).find('.home_split_blurb').stop(true, true).fadeTo('fast', 0); }); } // navigation submenus var liElements = new Array(); var count_read = 0; var count_write = 0; var left_pos = 0; $('div[id="navigation_wrap"]').children('ul').children('li') .each(function() { liElements[count_read] = $(this).find('a').width() + 22; // +22px for the 10px padding and 1px border //alert( $(this).find('a').width() ); count_read++; $(this).find('.submenu').css({ opacity: 1 }); $(this).find('.submenu').hide(); }) .each(function() { // set positions of submenus /* $(this).find('.submenu').css("left", left_pos); left_pos += liElements[count_write]; */ count_write++; }) .hover(function() { // mouseover $(this).children('a').addClass('hover'); $(this).find('.submenu').show(); }, function() { // mouseleave $(this).children('a').removeClass('hover'); $(this).find('.submenu').hide(); }); // set submenu column widths equal; same as the widest $('.submenu').css({ visibility: "hidden", display: "block" }); // nice hack.. // set all drop down menu columns and links to same width widest = 0; $('.submenu-col').each(function() { thisWidth = $(this).width(); if(thisWidth > widest) { widest = thisWidth; } }); $('.submenu-col').width(widest); $('.submenu-col').find('a').width(widest); // make submenu wide enough for cols $('.submenu').each(function() { thisWidth = 0; $(this).find('.submenu-col').each(function() { thisWidth += $(this).width(); }); $(this).width(thisWidth + 15); }); $('.submenu').css({ visibility: "", display: "none" }); // font size; accessibility if ($("#header_accessibility").length > 0){ $("a#fontsize-minus").fontscale(".footer_split_left ul, .home_split_title, .home_split_blurb, #home_issueresponse_title, #home_issueresponse_infowrap, .home_more_btn, #search_input, #search_btn, #content_right, #content_top h1, #content_top p, .box_header, #content_top_right a, #content_right p, #content_right h1","-"); $("a#fontsize-default").fontscale(".footer_split_left ul, .home_split_title, .home_split_blurb, #home_issueresponse_title, #home_issueresponse_infowrap, .home_more_btn, #search_input, #search_btn, #content_right, #content_top h1, #content_top p, .box_header, #content_top_right a, #content_right p, #content_right h1","reset"); $("a#fontsize-plus").fontscale(".footer_split_left ul, .home_split_title, .home_split_blurb, #home_issueresponse_title, #home_issueresponse_infowrap, .home_more_btn, #search_input, #search_btn, #content_right, #content_top h1, #content_top p, .box_header, #content_top_right a, #content_right p, #content_right h1","+"); } var calendar_src = ''; if ($("#goto_prev_month").length > 0){ $('#goto_prev_month').live('click', function() { calendar_src = 'php/small_calendar.php?month='+$('#prev_month').val()+'&year='+$('#prev_year').val(); if( $('#townevents_filter').hasClass('selected') ){ calendar_src = calendar_src + '&town_events'; }else if( $('#mayoralevents_filter').hasClass('selected') ){ calendar_src = calendar_src + '&mayoral_events'; } $.get(calendar_src, function(data) { $("#cal_box").replaceWith(data); }); return false; }); } if ($("#goto_next_month").length > 0){ $('#goto_next_month').live('click', function() { calendar_src = 'php/small_calendar.php?month='+$('#next_month').val()+'&year='+$('#next_year').val(); if( $('#townevents_filter').hasClass('selected') ){ calendar_src = calendar_src + '&town_events'; }else if( $('#mayoralevents_filter').hasClass('selected') ){ calendar_src = calendar_src + '&mayoral_events'; } $.get(calendar_src, function(data) { $("#cal_box").replaceWith(data); }); return false; }); } if ($("#town_meeting_filter").length > 0){ $('#town_meeting_filter') .click(function() { calendar_src = 'php/small_calendar.php?month='+$('#month').val()+'&year='+$('#year').val(); if( $('#town_meeting_filter').hasClass('selected') ){ calendar_src = calendar_src; $('#town_meeting_filter').removeClass('selected'); $('#town_event_filter').removeClass('selected'); }else{ calendar_src = calendar_src + '&town_meeting'; $('#town_meeting_filter').addClass('selected'); $('#town_event_filter').removeClass('selected'); } $.get(calendar_src, function(data) { $("#cal_box").replaceWith(data); }); return false; }); } if ($("#town_event_filter").length > 0){ $('#town_event_filter') .click(function() { calendar_src = 'php/small_calendar.php?month='+$('#month').val()+'&year='+$('#year').val(); if( $('#town_event_filter').hasClass('selected') ){ calendar_src = calendar_src; $('#town_meeting_filter').removeClass('selected'); $('#town_event_filter').removeClass('selected'); }else{ calendar_src = calendar_src + '&town_event'; $('#town_meeting_filter').removeClass('selected'); $('#town_event_filter').addClass('selected'); } $.get(calendar_src, function(data) { $("#cal_box").replaceWith(data); }); return false; }); } // document subcat toggle visibility (financial documents payments over £500 if ($(".toggle_subcat").length > 0){ $(".toggle_subcat") .each(function() { $(this).css({ cursor: 'pointer' }); }) .hover(function() { // mouseover $(this).css({'background-color': '#F4F4F4' }); }, function() { // mouseleave $(this).css({'background-color': '#fff' }); }) .click(function() { $( '#'+$(this).attr('data-toggle-element') ).toggle(); }) } // disable IE alt hover tooltips $('img') .each(function() { if(!$(this).attr('title')){ $(this).attr('title', ''); } }); });