/*jslint for, multivar, this */

/* global Style */

/*property
    KonBackgroundFill, KonShadow, KonShadowColor, KonShadowOffset,
    KonTextTruncation, background, backgroundAttachment, backgroundColor,
    backgroundImage, backgroundPosition, backgroundRepeat, color, fontFamily,
    fontSize, fontStretch, fontStyle, fontWeight, length, opacity, prototype,
    replace, setStyle, split, textAlign, textDecoration
*/

"use strict";

///////////////////////////////// Start of the setStyle function ///////////////////////////////////
Style.prototype.setStyle = function (styleString) {
    var item, key, value, i;
    var items = styleString.split(";");

    for (i = 0; i < items.length; i += 1) {
        item = items[i].split(":");
        key = item[0].replace(/^(\s*)(.*?)(\s*)$/, "$2");
        value = item[1].replace(/^(\s*)(.*?)(\s*)$/, "$2");

        switch (key) {
        case "background":
            this.background = value;
            break;
        case "background-attachment":
			this.backgroundAttachment = value;
			break;
        case "background-color":
			this.backgroundColor = value;
			break;
        case "background-image":
			this.backgroundImage = value;
			break;
        case "background-position":
			this.backgroundPosition = value;
			break;
        case "background-repeat":
			this.backgroundRepeat = value;
			break;
        case "color":
			this.color = value;
			break;
        case "font-family":
			this.fontFamily = value;
			break;
        case "font-size":
			this.fontSize = value;
			break;
        case "font-style":
			this.fontStyle = value;
			break;
        case "font-stretch":
			this.fontStretch = value;
			break;
        case "font-weight":
			this.fontWeight = value;
			break;
        case "opacity":
			this.opacity = value;
			break;
        case "text-align":
			this.textAlign = value;
			break;
        case "text-decoration":
			this.textDecoration = value;
			break;
        case "-kon-background-fill":
			this.KonBackgroundFill = value;
			break;
        case "-kon-shadow":
			this.KonShadow = value;
			break;
        case "-kon-shadow-color":
			this.KonShadowColor = value;
			break;
        case "-kon-shadow-offset":
			this.KonShadowOffset = value;
			break;
        case "-kon-text-truncation":
			this.KonTextTruncation = value;
			break;
        }
    }
};
///////////////////////////////// End  of  the setStyle function ///////////////////////////////////
