1 // Fix the header and navigation at the top of the page
3 $('#header').addClass('fixed');
4 if ($('#header').css('position') === 'fixed') {
5 $('.navigation').before($('.navigation').clone().addClass('spacer')).addClass('fixed');
6 $('#outer > .right_bar, #outer > .left_bar').addClass('display');
10 // Add branding for mirrors
11 if (document.location.href.match(/^https?:\/\/([^\/]+\.)*exim\.org\//)) {
12 $('#branding').remove();
14 $('#branding').ready(function () {
16 var doc = $('#branding')[0].contentWindow.document;
17 if (doc.title.match(/\b(found|404)\b/i)) { // Crude but "good enough" check to see if the branding request failed
18 $('#branding').remove();
20 $(doc).find('a').each(function () {
21 if ($(this).attr('title') == '') $(this).attr('title', 'Sponsor of this mirror');
22 $(this).css('opacity', 0.8).mouseover(function () {
23 $(this).css('opacity', 1)
24 }).mouseout(function () {
25 $(this).css('opacity', 0.8)
28 $('#branding').height($(doc).find('img').height() ? $(doc).find('img').height() + 16 + 'px' : 'auto').hide().css('visibility', 'visible').fadeIn(2000);
31 $('#branding').remove();
39 setTimeout(function () {
40 $('#footer').fadeIn('slow')
47 // Add placeholder functionality to browsers which don't support it
48 if (!('placeholder' in document.createElement('input'))) $('.navigation li.search input.search_field').focus(function (e) {
49 if ($(this).val() === ' ' + $(this).attr('placeholder')) $(this).val('').css('color', '#000');
50 }).blur(function (e) {
51 if ($(this).val() === ' ' + $(this).attr('placeholder') || $(this).val() === '') $(this).css('color', '#666').val(' ' + $(this).attr('placeholder'));
54 // Add rounded borders to search field on Gecko based browsers
55 if (document.body.style.MozBorderRadius !== undefined) $('.search_field_container').addClass('roundit').click(function () {
56 $(this).find('input').focus()
60 // Jump to the right location on the page. Fixed header can cause problems.
61 if ($('#header').css('position') === 'fixed') {
63 // Jump to the given ID
64 var jump = function (id) {
65 if ($('#' + id).length == 0) return false;
67 document.location.href = document.location.href.replace(/#.+/, '') + '#' + id;
69 $('html,body').animate({
70 scrollTop: $('#' + id).position()['top'] - $('#header').height() - $('.navigation.fixed').height() - 5
76 var uri = document.location.pathname;
77 var uri_end = uri.replace(/^.*\//, '');
80 if (document.location.href.match(/#./)) jump(document.location.href.replace(/^.*#(.+)$/, '$1'));
83 $('a').live('click', function (e) {
84 var href = $(this).attr('href');
85 if (!href.match(/^.*#.+$/)) return true; // No # in the anchor
86 var href_uri = href.replace(/^([^#]*)(#.*)?/, '$1'); // href without the #
87 if (href_uri.match(/^([a-z]+:)?\/\//)) return true; // Ignore full URLs
88 if (href_uri.match(/^[^\/]/) && href_uri != uri_end) return true; // Ignore relative links to other pages
89 if (href_uri.match(/^\//) && href_uri != uri) return true; // Ignore absolute links to other pages
90 if (jump(href.replace(/^.*#(.+)$/, '$1'))) e.preventDefault();
93 // For browsers which support it, detect when the hash in the address bar changes
94 $(window).bind('hashchange', function (e) {
95 if (jump(document.location.href.replace(/^.*#(.+)$/, '$1'))) e.preventDefault();