
/**
 * Changes the background CSS properties of the #page element
 *
 * @param string Colour specified in hex, e.g. #000000
 * @param string URL to background image
 * @author Nick Giles
 */
    function bg_switch(arg)
    {
        // Prepre the input variables
        
            // Split the arguments
            var args = arg.split(',');
            
            // Extract the relevant bits
            var colour   = args[0];
            var image    = args[1];
            var position = args[2];
            var shadow   = args[3];
            
            //alert(colour);
            
            // Check the position variable
            if (typeof (position) != 'undefined')
            {
                // Split the position string if it's not tile (i.e. it's something like l,r) and create a valid CSS value or 'tile' as failsafe
                if (position != 'tile')
                {
                    var positions = position.split("");
                    
                    // Prepare horizontal argument
                    switch (positions[0])
                    {
                        case 'l':
                            var position_h = 'left';
                            break;
                        case 'c':
                            var position_h = 'center';
                            break;
                        case 'r':
                            var position_h = 'right';
                            break;
                    }
                    
                    // Prepare vertical argument
                    switch (positions[1])
                    {
                        case 't':
                            var position_v = 'top';
                            break;
                        case 'c':
                            var position_v = 'center';
                            break;
                        case 'b':
                            var position_v = 'bottom';
                            break;
                    }
                    
                    // Now create a valid CSS value
                    if (position_h && position_v)
                    {
                        position = position_v + ' ' + position_h;
                    }
                    else
                    {
                        // Both properties were not set, so default to 'tile'
                        position = 'tile';
                    }
                }
            }
            else
            {
                // Position is not set, so default to 'tile'
                position = 'tile';
            }
        
        // Now we're ready to start applying the styles
        
        // Colour
        if (typeof( colour ) != 'undefined')
        {
            $("#userbg").css("background-color", colour);
        }
        
        // Image
        if (typeof( image ) != 'undefined')
        {
            // Set the background image
            $("#userbg").css("background-image", "url(" + image + ")");
            
            // Set the position
            if (position == 'tile')
            {
                // Repeat X and Y
                $("#userbg").css("background-repeat", "repeat");
            }
            else
            {
                // Specific position
                $("#userbg").css("background-repeat", "no-repeat");
                $("#userbg").css("background-position", position);
            }
        }

        // Shadow
        if (typeof( shadow ) != 'undefined')
        {
            if (shadow == 'true')
            {
                if ($.browser.msie && $.browser.version < 7)
                {
                    // IE 6
                    $("#shadow").css("background-image", "url(/css/gfx/usershadow.gif)");
                    $("#shadow").css("background-position", "center");
                    $("#shadow").css("background-repeat", "repeat-y");
                    //$("#shadow").css("filter", "alpha(opacity=25)");
                    $("#shadow").css("opacity", 0.30);
                }
                else
                {
                    // Not IE 6

                    //$("#content").wrap('<div id="shadow"></div>');
                    $("#shadow").css("background-image", "url(/css/gfx/usershadow.png)");
                    $("#shadow").css("background-position", "center");
                    $("#shadow").css("background-repeat", "repeat-y");
                }
            }
            else
            {
                if ($("shadow"))
                {
                    $("#shadow").css("background-image", "");
                }
            }
        }
    }



      function isSet( variable )
      {
        return( typeof( variable ) != 'undefined' );
      }





$(document).ready(function() {
//   bg_switch("#000000,http://im.glogster.com/images/homepage/homepage-pets.jpg,tile,true");

    //$("body").removeClass("shadowedBody");
    
    

});


