/**
 *******************************************
 * $Id: styleManager.js 189 2006-10-22 21:10:16Z gregbrown $
 * 
 * StyleManager
 * Copyright 2006 REVVER, Inc.
 *
 * Author: John Kimmich john@12dnetworks.net
 * 
 * Description:
 *  Manages setting and changing styles.  Uses a JSON
 *  structure to maintain the styles. Uses the prototype.js class library.
 * 
 *******************************************
 */

REVVER.util.StyleManager = Class.create();
REVVER.util.StyleManager.prototype = {

    initialize:function(styleCollection)
    {
        REVVER.log("REVVER.util.StyleManager initialize");
        this.styleList = styleCollection;
    },
    
    /*
     * Retrieve one style by selector name.
     */
    getStyle:function(styleName)
    {
        if (this.styleList) {
            try {
                return (this.styleList[styleName][0]);
            } catch (e) {
                return "";
            }
        }
        else {
            return "";
        }
    },
    /*
     * Remove one style by selector name.
     */
    removeStyle:function(styleName)
    {
        if (this.styleList) {
            try {
                this.styleList[styleName] = null;
                return;
            } catch (e) {
                return;
            }
        }
        else {
            return;
        }
    },    
    /*
     * Get the value of a selector in a style rule
     */
    getStyleSelectorValue:function(styleName, selectorName)
    {
        if (this.styleList) {
            try {
                return (this.styleList[styleName][0][selectorName]);
            } catch (e) {
                return "";
            }
        }
        else {
            return "";
        }
    },
    
    /*
     * Set the value of a selector in a style rule
     */
    setStyleSelectorValue:function(styleName, selectorName, selectorValue)
    {
        if (this.styleList) {
            try {
                this.styleList[styleName][0][selectorName] = selectorValue;
            } catch (e) {
                return;
            }
        }
        else {
            return;
        }
    },
    
    /*
     * Remove the value of a selector in a style rule
     */
    removeStyleSelectorValue:function(styleName, selectorName)
    {
        if (this.styleList) {
            try {
                if (this.styleList[styleName][0][selectorName]) {
                    this.styleList[styleName][0][selectorName] = null;
                }
            } catch (e) {
                return;
            }
        }
        else {
            return;
        }
    }

};