function onLoaded() {
    var a = new CSInterface,
    b = a.hostEnvironment.appName;
    "FLPR" != b && loadJSX();
    for (var c = ["PHXS"], d = 0; d < c.length; d++) {
        var e = c[d];
        if (0 <= b.indexOf(e) && (e = document.getElementById("btn_" + e))) e.disabled = !1
    }
    updateThemeWithAppSkinInfo(a.hostEnvironment.appSkinInfo);
    a.addEventListener(CSInterface.THEME_COLOR_CHANGED_EVENT, onAppThemeColorChanged)
}

function updateThemeWithAppSkinInfo(a) {
    var b = a.panelBackgroundColor.color;
    document.body.bgColor = toHex(b);
    var c = (new CSInterface).hostEnvironment.appName;
    "PHXS" == c && addRule("ppstyle", "button, select, input[type=button], input[type=submit]", "border-radius:3px;");
    if ("PHXS" == c || "PPRO" == c || "PRLD" == c) {
        var c = "background-image: -webkit-linear-gradient(top, " + toHex(b, 40) + " , " + toHex(b, 10) + ");",
        d = "background-image: -webkit-linear-gradient(top, " + toHex(b, 15) + " , " + toHex(b, 5) + ");",
        e,
        f,
        g,
        h,
        k;
        127 < b.red ? (e = "#000000;", 
        f = "color:" + toHex(b, -70) + ";", g = "border-color: " + toHex(b, -90) + ";", h = toHex(b, 54) + ";", k = "background-image: -webkit-linear-gradient(top, " + toHex(b, -40) + " , " + toHex(b, -50) + ");") : (e = "#ffffff;", f = "color:" + toHex(b, 100) + ";", g = "border-color: " + toHex(b, -45) + ";", h = toHex(b, -20) + ";", k = "background-image: -webkit-linear-gradient(top, " + toHex(b, -20) + " , " + toHex(b, -30) + ");");
        addRule("ppstyle", ".default", "font-size:" + a.baseFontSize + "px; color:" + e + "; background-color:" + toHex(b) + ";");
        addRule("ppstyle", "button, select, input[type=text], input[type=button], input[type=submit]", 
        g);
        addRule("ppstyle", "button, select, input[type=button], input[type=submit]", c);
        addRule("ppstyle", "button, select, input[type=button], input[type=submit]", "-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.2);");
        addRule("ppstyle", "button:enabled:active, input[type=button]:enabled:active, input[type=submit]:enabled:active", k);
        addRule("ppstyle", "button:enabled:active, input[type=button]:enabled:active, input[type=submit]:enabled:active", "-webkit-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.6);");
        addRule("ppstyle", "[disabled]", d);
        addRule("ppstyle", "[disabled]", f);
        addRule("ppstyle", "input[type=text]", "padding:1px 3px;");
        addRule("ppstyle", "input[type=text]", "background-color: " + h) + ";";
        addRule("ppstyle", "input[type=text]:focus", "background-color: #ffffff;");
        addRule("ppstyle", "input[type=text]:focus", "color: #000000;")
    } else addRule("ppstyle", ".default", "font-size:" + a.baseFontSize + "px; color:" + reverseColor(b) + "; background-color:" + toHex(b, 20)),
    addRule("ppstyle", "button", "border-color: " + toHex(panelBgColor, 
    -50))
}
function addRule(a, b, c) {
    if (a = document.getElementById(a)) a = a.sheet,
    a.addRule ? a.addRule(b, c) : a.insertRule && a.insertRule(b + " { " + c + " }", a.cssRules.length)
}
function reverseColor(a, b) {
    return toHex({
        red: Math.abs(255 - a.red),
        green: Math.abs(255 - a.green),
        blue: Math.abs(255 - a.blue)
    },
    b)
}
function toHex(a, b) {
    function c(a, b) {
        var c = !isNaN(b) ? a + b: a;
        0 > c ? c = 0: 255 < c && (c = 255);
        c = c.toString(16);
        return 1 == c.length ? "0" + c: c
    }
    var d = "";
    if (a) with(a) d = c(red, b) + c(green, b) + c(blue, b);
    return "#" + d
}
function onAppThemeColorChanged(a) {
    a = JSON.parse(window.__adobe_cep__.getHostEnvironment()).appSkinInfo;
    updateThemeWithAppSkinInfo(a)
}
function loadJSX() {
    var a = new CSInterface,
    b = a.getSystemPath(SystemPath.EXTENSION) + "/jsx/";
    a.evalScript('$._ext.evalFiles("' + b + '")')
}
function evalScript(a, b) { (new CSInterface).evalScript(a, b)
}
function onClickButton1(a) {
    "FLPR" == a ? evalScript('fl.createDocument(); fl.getDocumentDOM().addNewText({left:100, top:100, right:300, bottom:300} , "Hello Flash!" ); ') : evalScript("$._ext_" + a + ".run()")
}



function onClickButton(a) {
  "FLPR" == a ? evalScript('fl.createDocument(); fl.getDocumentDOM().addNewText({left:100, top:100, right:300, bottom:300} , "Hello Flash!" ); ') :
	evalScript("ext_CallAtion('"+a+"','" + RadioChoice("RadioGroup1") + "')")
}

function onClickButton2(a) {
	var Anchorx1 = 0,
    Anchory1 = 0,
    Rotation1 = 0,
    Zoomx1 = 0,
    Zoomy1 = 0,
    FadeoutHead1 = 0,
    FadeoutTail1 = 0,
    Group1 = document.getElementsByName("CheckboxGroup1");
	Anchorx1=Anchorx.value;
	Anchory1=Anchory.value;
	if(Group1.item(0).checked==true){Rotation1 = Rotation.value};
    if(Group1.item(1).checked==true){Zoomx1 = Zoomx.value, Zoomy1 = Zoomy.value};
    if(Group1.item(2).checked==true){FadeoutHead1 = FadeoutHead.value, FadeoutTail1 =FadeoutTail.value};
    evalScript("ext_CreativeStarrail(" +Anchorx1 + "," + Anchory1 + "," + Rotation1 + "," + Zoomx1 + "," + Zoomy1 + "," + FadeoutHead1 + "," + FadeoutTail1 + ")")
}
function onClickButton3(a)
{
	var Long=0,Num=0,LayerNum=0;
		if(a=='YYTools53')
		{
		Long=Sharplong.value;
		Num=SharpNum.value;
        evalScript("ext_Sharp(" + Long + "," + Num + ")")
		}
		else
		{
		LayerNum=Duplicatelayer.value;
        evalScript("ext_Duplicatelayer(" + LayerNum+ ")")
		}
	}

function RadioChoice(a) {
    a = document.getElementsByName(a);
    for (var b = 0; b < a.length; b++) {
        if (a.item(b).checked) return a.item(b).id;
        if ("radio" !== a[0].type) return null
    }
}
;