1 // Fix the header and navigation at the top of the page
3 $('#header').addClass('fixed');
4 if( $('#header').css('position') === 'fixed' ){
6 .before( $('.navigation').clone().addClass('spacer') )
8 $('#outer > .right_bar, #outer > .left_bar').addClass('display');
12 // Add branding for mirrors
13 if( document.location.href.match(/^https?:\/\/([^\/]+\.)*exim\.org\//) ){
14 $('#branding').remove();
16 $('#branding').ready(function(){
18 var doc = $('#branding')[0].contentWindow.document;
19 if( doc.title.match(/\b(found|404)\b/i) ){ // Crude but "good enough" check to see if the branding request failed
20 $('#branding').remove();
22 $(doc).find('a').each(function(){
23 if( $(this).attr('title') == '' )
24 $(this).attr('title','Sponsor of this mirror');
25 $(this).css('opacity',0.8)
26 .mouseover(function(){ $(this).css('opacity',1) })
27 .mouseout(function(){ $(this).css('opacity',0.8) });
30 .height( $(doc).find('img').height() ? $(doc).find('img').height() + 16 + 'px' : 'auto' )
32 .css('visibility','visible')
36 $('#branding').remove();
44 setTimeout( function(){ $('#footer').fadeIn('slow') }, 2000 );
50 // Add placeholder functionality to browsers which don't support it
51 if( !('placeholder' in document.createElement('input')) )
52 $('.navigation li.search input.search_field')
54 if( $(this).val() === ' ' + $(this).attr('placeholder') )
55 $(this).val('').css('color','#000');
58 if( $(this).val() === ' ' + $(this).attr('placeholder') || $(this).val() === '' )
59 $(this).css('color','#666').val( ' ' + $(this).attr('placeholder') );
62 // Add rounded borders to search field on Gecko based browsers
63 if( document.body.style.MozBorderRadius !== undefined )
64 $('.search_field_container')
66 .click(function(){ $(this).find('input').focus() });
69 // Jump to the right location on the page. Fixed header can cause problems.
70 if( $('#header').css('position') === 'fixed' ){
72 // Jump to the given ID
73 var jump = function( id ){
74 if( $('#'+id).length == 0 ) return false;
76 document.location.href = document.location.href.replace(/#.+/,'') + '#' + id;
78 $('html,body').animate({
79 scrollTop: $('#'+id).position()['top'] - $('#header').height() - $('.navigation.fixed').height() -5
85 var uri = document.location.pathname;
86 var uri_end = uri.replace(/^.*\//,'');
89 if( document.location.href.match(/#./) ) jump( document.location.href.replace(/^.*#(.+)$/,'$1') );
92 $('a').live('click', function(e){
93 var href = $(this).attr('href');
94 if( !href.match(/^.*#.+$/) ) return true; // No # in the anchor
96 var href_uri = href.replace(/^([^#]*)(#.*)?/,'$1'); // href without the #
98 if( href_uri.match(/^([a-z]+:)?\/\//) ) return true; // Ignore full URLs
99 if( href_uri.match(/^[^\/]/) && href_uri != uri_end ) return true; // Ignore relative links to other pages
100 if( href_uri.match(/^\//) && href_uri != uri ) return true; // Ignore absolute links to other pages
102 if( jump( href.replace(/^.*#(.+)$/,'$1') ) ) e.preventDefault();
105 // For browsers which support it, detect when the hash in the address bar changes
106 $(window).bind('hashchange',function(e){
107 if( jump( document.location.href.replace(/^.*#(.+)$/,'$1') ) ) e.preventDefault();