function Style()
{   
    this.data = init();
    /*####################+++get methods+++########################*/
    this.getBackgroundColor         = getBgColor;
    this.getBackgroundImage         = getBgImage;
    this.getFontColor               = getColor;
    this.getImageByID               = getImgById;
    /*####################+++set methods+++########################*/
    this.setBackgroundColor         = setBgColor;
    this.setBackgroundImage         = setBgImage;
    this.setFontColor               = setColor;
    this.setImageByID               = setImgById;
    /*####################+++other methods+++######################*/
    this.changeColor                = changeVal;
    this.changeBgImage              = changeVal;
}



/*###################################################################################################*/
function init()
{
    var dflvl = new Array();
    dflvl["bgColor"] = "F5F5F5";
    dflvl["bgImage"] = "none";
    dflvl["txtColor"] = "000000";
    dflvl["idImage"] = "";
    return dflvl;
}
/*####################+++get functions+++########################*/
function getBgColor(id)
{
    if(typeof id != "undefined" && id != null && id != "")
    {
        if(obj = fetch_object(id))
        {
            return obj.style.backgroundColor;
        }
        else
        {
            p_showErrorMessage("The function \"getBgColor(id)\" cannot be implemented!\n\n   - The Object \""+id+"\" cannot be read!\n   -> Object is not found");
            return this.data["bgColor"];
        }
    }
    else
    {
        return this.data["bgColor"];
    }
}
function getBgImage()
{
    return this.data["bgImage"];
}
function getColor()
{
    return this.data["txtColor"];
}
function getImgById()
{
    return this.data["idImage"];
}
/*####################+++set functions+++########################*/
function setBgColor(id,color)
{
    this.changeColor("bgColor","setBgColor(id,color)",id,color);
}
function setBgImage(id,imageUrl)
{
    this.changeBgImage("bgImage","setBgImage(id,imageUrl)",id,imageUrl);
}
function setColor(id,color)
{
    this.changeColor("txtColor","setColor(id,color)",id,color);
}
function setImgById(id,pathandimage)
{
    if(typeof pathandimage == "undefined" || pathandimage == null || pathandimage == "")
    {
        p_showErrorMessage("The function \"setImgById(id,pathandimage)\" cannot be implemented!\n\n   - The Object cannot be init for set a imagefile!\n   -> Param 2 (pathandimage) is not defined or null!");
        return false;
    }
    if(typeof id != "undefined" && id != null)
    {
        if(obj = fetch_object(id))
        {
            obj.src = pathandimage;
        }
        else
        {
            p_showErrorMessage("The function \"setImgById(id,pathandimage)\" cannot be implemented!\n\n   - The Object \""+id+"\" cannot be init for set a imagefile!\n   -> Object is not found");
            return false;
        }
    }
    this.data["idImage"] = pathandimage;
}
function changeVal(setval,funcsyntax,id,val)
{
    if(typeof val == "undefined")
        val = "";
    if(typeof id != "undefined" && id != null)
    {
        if(obj = fetch_object(id))
        {
            switch(setval)
            {
                case "bgColor":
                    if(obj.style.backgroundColor && typeof val == "undefined")
                    {
                        val = obj.style.backgroundColor;
                    }
                    else if(!obj.style.backgroundColor && typeof val == "undefined")
                    {
                        val = this.getBgColor;
                    }
                    obj.style.backgroundColor = val;
                break;
                case "bgImage":
                    if(obj.style.backgroundImage && typeof val == "undefined")
                    {
                        val = obj.style.backgroundImage;
                    }
                    else if(!obj.style.backgroundImage && typeof val == "undefined")
                    {
                        val = this.getBgImage;
                    }
                    obj.style.backgroundImage = "url("+val+")";
                break;
                case "txtColor":
                    if(obj.style.color && typeof val == "undefined")
                    {
                        val = obj.style.color;
                    }
                    else if(!obj.style.color && typeof color == "undefined")
                    {
                        val = this.getColor;
                    }
                    obj.style.color = val;
                break;
            }
        }
        else
        {
            p_showErrorMessage("The function \""+funcsyntax+"\" cannot be implemented!\n\n   - The Object \""+id+"\" cannot be init for set background color!\n   -> Object is not found");
            return false;
        }
    }
    switch(setval)
    {
        case "bgColor":
            if(typeof val != "undefined")
                val = (val.search("/^rgb+/i") != -1)?val:"#"+val;
            else
                val = this.getBgColor;            
        break;
        case "bgImage":
            val = this.getBgImage;
        break;
        case "txtColor":
            if(typeof val != "undefined")
                val = (val.search("/^rgb+/i") != -1)?val:"#"+val;
            else
                val = this.getColor;
        break;
    }
    this.data[setval] = val;
}
