1 // Fix the header and navigation at the top of the page
4 var $nav_float = $('#nav_flow').clone().attr('id','nav_float').appendTo('#outer');
8 $(window).bind('load resize scroll',function () {
9 var header_height = $('#header').height();
10 var top = $(this).scrollTop();
12 if( top > header_height ){
15 $('#nav_flow').css('visibility','hidden');
21 $('#nav_flow').css('visibility','visible');
27 $('#outer > .right_bar, #outer > .left_bar').addClass('display');
30 // Add branding for mirrors
31 if (document.location.href.match(/^https?:\/\/([^\/]+\.)*exim\.org\//)) {
32 $('#branding').remove();
34 $('#branding').ready(function () {
36 var doc = $('#branding')[0].contentWindow.document;
37 if (doc.title.match(/\b(found|404)\b/i)) { // Crude but "good enough" check to see if the branding request failed
38 $('#branding').remove();
40 $(doc).find('a').each(function () {
41 if ($(this).attr('title') == '') $(this).attr('title', 'Sponsor of this mirror');
42 $(this).css('opacity', 0.8).mouseover(function () {
43 $(this).css('opacity', 1)
44 }).mouseout(function () {
45 $(this).css('opacity', 0.8)
48 $('#branding').height($(doc).find('img').height() ? $(doc).find('img').height() + 16 + 'px' : 'auto').hide().css('visibility', 'visible').fadeIn(2000);
51 $('#branding').remove();
59 setTimeout(function () {
60 $('#footer').fadeIn('slow')
67 // Add placeholder functionality to browsers which don't support it
68 if (!('placeholder' in document.createElement('input'))) $('.nav li.search input.search_field').focus(function (e) {
69 if ($(this).val() === ' ' + $(this).attr('placeholder')) $(this).val('').css('color', '#000');
70 }).blur(function (e) {
71 if ($(this).val() === ' ' + $(this).attr('placeholder') || $(this).val() === '') $(this).css('color', '#666').val(' ' + $(this).attr('placeholder'));
74 // Add rounded borders to search field on Gecko based browsers
75 if (document.body.style.MozBorderRadius !== undefined) $('.search_field_container').addClass('roundit').click(function () {
76 $(this).find('input').focus()
80 // Jump to the right location on the page. Fixed header can cause problems.
82 // Jump to the given ID
83 var jump = function (id) {
84 if ($('#' + id).length == 0) return false;
86 document.location.href = document.location.href.replace(/#.+/, '') + '#' + id;
88 $('html,body').animate({
89 scrollTop: $('#' + id).position()['top'] - $('.nav').height() - 5
95 var uri = document.location.pathname;
96 var uri_end = uri.replace(/^.*\//, '');
99 if (document.location.href.match(/#./)) jump(document.location.href.replace(/^.*#(.+)$/, '$1'));
102 $('a').live('click', function (e) {
103 var href = $(this).attr('href');
104 if (!href.match(/^.*#.+$/)) return true; // No # in the anchor
105 var href_uri = href.replace(/^([^#]*)(#.*)?/, '$1'); // href without the #
106 if (href_uri.match(/^([a-z]+:)?\/\//)) return true; // Ignore full URLs
107 if (href_uri.match(/^[^\/]/) && href_uri != uri_end) return true; // Ignore relative links to other pages
108 if (href_uri.match(/^\//) && href_uri != uri) return true; // Ignore absolute links to other pages
109 if (jump(href.replace(/^.*#(.+)$/, '$1'))) e.preventDefault();
112 // For browsers which support it, detect when the hash in the address bar changes
113 $(window).bind('hashchange', function (e) {
114 if (jump(document.location.href.replace(/^.*#(.+)$/, '$1'))) e.preventDefault();