//auto default values (focus and blur)
startUp( function( ){
    jQuery( "input.auto_default" ).each( function( ){
        var o = jQuery( this );
        o.attr( 'def_value', o.val( ) );
        o.focus( function( ){
            var o = jQuery( this );
            if( o.val( ) == o.attr( 'def_value' ) )
            {
                o.val( '' ).removeClass( 'focus' );
            }
        } );
        o.blur( function( ){
            var o = jQuery( this );
            if( o.val( ) == '' )
            {
                o.addClass( 'focus' ).val( o.attr( 'def_value' ) );
            }
        } );
    } );
} );


jQuery( document ).ready(function( ){
    jQuery('#inc_size').click(function(){
        current = parseInt(jQuery('.body').css('font-size'));
        jQuery('.body').css('font-size', current + 1);
    }).css('cursor', 'pointer');
    jQuery('#dec_size').click(function(){
        current = parseInt(jQuery('.body').css('font-size'));
        jQuery('.body').css('font-size', current - 1);
    }).css('cursor', 'pointer');
});


//shortcut
function startUp( action ) { jQuery( document ).ready( action ); }

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)


jQuery.fn.maxlength = function(n)
{
    var t;

    jQuery(this).data('maxlength',n);
    jQuery(this).keypress(function(e)
    {
        if(jQuery(this).val().length >= n && e.which != 0 && e.which != 8)
        {
            return false;
        }
    });
    jQuery(this).bind('paste',function()
    {
        t = this;
        setTimeout(function()
        {
            jQuery(t).val(jQuery(t).val().substring(0,n));
        },0);
    });
    return jQuery(this);
}

jQuery.fn.attach = function(o)
{
    m = jQuery(this).data('maxlength');
    jQuery(o).text(m);
    jQuery(this).keyup(function()
    {
        jQuery(o).text(m - jQuery(this).val().length)
    });
    jQuery(o).text(m - jQuery(this).val().length)
}


startUp( function( ){
    jQuery( '#photos_accordion, #videos_accordion' ).accordion( {
        header: 'div.acc_header',
        icons: false,
        fillSpace: false,
        autoHeight: false,
        event: 'mouseover',
        changestart: function( event, ui ){
            ui.oldHeader.parent().removeClass( 'hover' );
            ui.newHeader.parent().addClass( 'hover' );
        }
    } );
    jQuery( "div.acc span" ).remove( );
    //jQuery( "div.acc " )
} )


function nifty_corners_load( )
{
    startUp( function( ){        
        Nifty( 'div.quote_border' );
        Nifty( 'div.content' );
    } );
}
