( function( $ ) 
{
    /**
     * Add strings to the get_strings object
     *
     * Takes an object with stringtokens and the strings
     * adds them to the get_strings object
     * { 'stringtoken' : 'string $a' }
     *
     * @param strings object with stringtokens and strings
     */
    $.addGetStrings = function( strings )
    {
        if( !strings || typeof( strings ) != "object" ) return false;
        
        if( !window.get_strings ) window.get_strings = {};
        $.extend( window.get_strings, strings );
        
        return window.get_strings;
    };
    
    /**
     * Get a language string
     *
     * Takes a stringtoken and an optional replacement text
     * and returns the specified text
     *
     * @param stringtoken the name of the text
     * @return string
     */
    $.get_string = function( stringtoken, replacevar )
    {
        if( !window.get_strings ) return '';
        
        var returnstring = '';
        
        if( window.get_strings[ stringtoken ] !== undefined )
        {
            returnstring = window.get_strings[ stringtoken ];
        }
        
        if( returnstring.indexOf( '$a' ) !== -1  && replacevar != undefined )
        {
            returnstring = returnstring.replace( /\B\$a\b/g, replacevar );
        }
        
        return returnstring;
    };
    
    /**
     * Switch classes for example the show/hide class
     * $( '.ftoggler-img' ).changeHideShowClass( true, classobj );
     *
     * @param twoactive boolean
     * @param classes object { open: 'open-name', closed: 'closed-name' }
     * @return the selected collection
     */
    $.fn.switchClass = function( twoactive, classes )
    {
        if( typeof( classes ) != 'object' )
        {
            classes = {
                one: 'ftoggler-open',
                two: 'ftoggler-closed'
            };
        }
        
        if( twoactive )
        {
            $( this )
                .addClass( classes.two )
                .removeClass( classes.one );
        }
        else
        {
            $( this )
                .addClass( classes.one )
                .removeClass( classes.two );
        }
        
        return $( this );
    };
})( jQuery );
