$(function(){
/*
	 * Styling
	 */
	$('#main-right .content table.calendar tr:odd').addClass('alt');
		
	$('#header').append('<div id="header-cap-left"></div><div id="header-cap-right"></div>');
	$('#footer').append('<div id="footer-cap-left"></div><div id="footer-cap-right"></div>');
	
	/*
	 * Pretty forms
	 */
	$('form.prettyform input[@type*=radio]').css('border','none');
	$('form.prettyform input[@type*=checkbox]').css('border','none');
	if($.browser.mozilla) { prettyform(); }
	
	/*
	 * LI hover fix for IE6
	 */
	$('#navigation ul li').each( function(){
		$(this).mouseover( function(){ $(this).addClass('hover'); } ).mouseout( function(){ $(this).removeClass('hover'); } );
	});
	
	/*
	 * Blur on focus
	 */
	$('a').focus(function() { this.blur(); });
	$('input[@type*=submit]').focus(function() { this.blur(); });
	$('input[@type=text], input[@type=password]').addClass("input");
	
    if( $("a.lightbox").length > 0 ) {
        $('a.lightbox').lightBox({
            imageLoading: '/asset/images/lightbox/lightbox-ico-loading.gif',
            imageBtnClose: '/asset/images/lightbox/lightbox-btn-close.gif',
            imageBtnPrev: '/asset/images/lightbox/lightbox-btn-prev.gif',
            imageBtnNext: '/asset/images/lightbox/lightbox-btn-next.gif',
            fixedNavigation:true
        }); // Select all links with lightbox class
    }
    
    $('a.help').each(function() {
    	var id = $(this).attr('id');
    	$(this).click(function() {
    		$('#helpText-' + id).toggle();
    	});
    });
    
    $('.red-button').after('<div class="red-button-border">&nbsp;</div>');
    
    // Fix album name with apostrophe
    $('h2 a[href=/gallery/Old+Boys/Old-Boys-Photo-Album]').html("Old Boys' Photo Album");
    
    if ($('#gallery-html').length) {
    	if ($('#gallery-html').prev().html() == "Old Boys Photo Album") {
    		$('#gallery-html').prev().html("Old Boys' Photo Album");
    	}
    }
});


/*
 * Pretty forms
 */
function prettyform(){
  /*
   * Hide forms
   */
  $( 'form.prettyform' ).hide().end();
  /*
   * Label & list formatting
   */
  $( 'form.prettyform' ).find( 'label' ).not( '.noprettyform' ).each( function( i ){
    var labelContent = this.innerHTML;
    var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );
    var labelSpan = document.createElement( 'span' );
        labelSpan.style.display = 'block';
        labelSpan.style.width = labelWidth;
        labelSpan.innerHTML = labelContent;
    this.style.display = '-moz-inline-box';
    this.innerHTML = '';
    this.appendChild( labelSpan );
  } ).end();
  
  /*
   * Show forms
   */
  $( 'form.prettyform' ).show().end();
}
