//==================================================================
// WP7 Application List
// Timur Prokopiev 2011
//==================================================================


function setDefaultValues() {
  var values = new Array();
  
// Application Title
  values.push({ name:"Title", type:"text", value:"Application" });

// Tile Color
  values.push({ name:"Tile Color", type:"ComboBox", value:"Orange,Magenta,Purple,Teal,Lime,Brown,Pink,Orange,Blue,Red,Green"});

// Theme
  values.push({ name:"Theme", type:"ComboBox", value:"Dark,Dark,Light" });

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

}

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

  var colors = {
  Magenta: "#FF0097",
  Purple: "#A200FF",
  Teal: "#00ABA9",
  Lime: "#8CBF26",
  Brown: "#996600",
  Pink: "#E671B8",
  Orange: "#F09609",
  Blue: "#1BA1E2",
  Red: "#E51400",
  Green: "#339933",
  }

  		Widget.GetObjectByName("text").textChars = values[0].value;
		Widget.GetObjectByName("rectangle").pathAttributes.fillColor = colors[values[1].value.split(",")[0].toString()];

		if (theme == "Dark") {
		Widget.GetObjectByName("text").pathAttributes.fillColor = "#FFFFFF";
		}
	
		if (theme == "Light") {
		Widget.GetObjectByName("text").pathAttributes.fillColor = "#000000";
		}
}

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