//==================================================================
// WP7 Standalone Push Buttons
// Timur Prokopiev 2011
//==================================================================


function setDefaultValues() {
  var values = new Array();
  
// Button Label
  values.push({ name:"Label", type:"text", value:"button" });
  
// Button States
  values.push({ name:"State", type:"ComboBox", value:"Normal,Normal,Down,Disable"});

// Enable Colorize
  values.push({ name:"Colorize", type:"Boolean",  value:"false" });

// Button Text Color
  values.push({ name:"Text Color", type:"color", value:"#0000FF" });

// Button Bg Color
  values.push({ name:"Bg Color", type:"color", value:"#FF0000" });

Widget.elem.customData["currentValues"] = values;

}

function applyCurrentValues() {
  var values = Widget.elem.customData["currentValues"];
  var state  = values[1].value.split(",")[0].toString();
  var enabled = (values[2].value.toString()=="false");


if (values[2].value.toString() == "true") {
		Widget.GetObjectByName("text_normal").pathAttributes.fillColor = values[3].value;
		Widget.GetObjectByName("text_down").pathAttributes.fillColor = values[3].value;
		Widget.GetObjectByName("text_disable").pathAttributes.fillColor = values[3].value;

		Widget.GetObjectByName("bg_normal").pathAttributes.brushColor = values[4].value;
		Widget.GetObjectByName("bg_down").pathAttributes.fillColor = values[4].value;
		Widget.GetObjectByName("bg_disable").pathAttributes.brushColor = values[4].value;

	} else {
		Widget.GetObjectByName("text_normal").pathAttributes.fillColor = "#ffffff";
		Widget.GetObjectByName("text_down").pathAttributes.fillColor = "#000000";
		Widget.GetObjectByName("text_disable").pathAttributes.fillColor = "#666666";

		Widget.GetObjectByName("bg_normal").pathAttributes.fillColor = "#ffffff";
		Widget.GetObjectByName("bg_down").pathAttributes.fillColor = "#ffffff";
		Widget.GetObjectByName("bg_disable").pathAttributes.fillColor = "#666666";

	}

  		Widget.GetObjectByName("text_normal").textChars = values[0].value;
 		Widget.GetObjectByName("text_down").textChars = values[0].value;
  		Widget.GetObjectByName("text_disable").textChars = values[0].value;

  		Widget.GetObjectByName("text_normal").visible = (state == "Normal");
  		Widget.GetObjectByName("text_down").visible = (state == "Down");
  		Widget.GetObjectByName("text_disable").visible = (state == "Disable");

  		Widget.GetObjectByName("bg_normal").visible = (state == "Normal");
  		Widget.GetObjectByName("bg_down").visible = (state == "Down");
  		Widget.GetObjectByName("bg_disable").visible = (state == "Disable");

}

switch (Widget.opCode)
{
	case 1: setDefaultValues();   break;
	case 2: applyCurrentValues(); break;
}