//==================================================================
// WP7 Tile
// Timur Prokopiev 2011
//==================================================================


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

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

// Bubble Count
  values.push({ name:"Count", type:"text", value:"7" });

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

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

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

}

function applyCurrentValues() {
  var values = Widget.elem.customData["currentValues"]; 
  var bubble = (values[1].value.toString()=="true");
  var color  = values[3].value.split(",")[0].toString();
  
  var magenta = "#FF0097";
  var purple = "#A200FF";
  var teal = "#00ABA9";
  var lime = "#8CBF26";
  var brown = "#996600";
  var pink = "#E671B8";
  var orange = "#F09609";
  var blue = "#1BA1E2";
  var red = "#E51400";
  var green = "#339933";


  		Widget.GetObjectByName("Title").textChars = values[0].value;
  		Widget.GetObjectByName("Count").textChars = values[2].value;
		Widget.GetObjectByName("bg").pathAttributes.fillColor = values[4].value;

		Widget.GetObjectByName("Count").visible = bubble;
		Widget.GetObjectByName("Bubble").visible = bubble;


		if (color == "Magenta") {
		Widget.GetObjectByName("Bubble").pathAttributes.fillColor = magenta;

		}

		if (color == "Purple") {
		Widget.GetObjectByName("Bubble").pathAttributes.fillColor = purple;

		}

		if (color == "Teal") {
		Widget.GetObjectByName("Bubble").pathAttributes.fillColor = teal;

		}

		if (color == "Lime") {
		Widget.GetObjectByName("Bubble").pathAttributes.fillColor = lime;

		}
		
		if (color == "Brown") {
		Widget.GetObjectByName("Bubble").pathAttributes.fillColor = brown;

		}

		if (color == "Pink") {
		Widget.GetObjectByName("Bubble").pathAttributes.fillColor = pink;

		}

		if (color == "Orange") {
		Widget.GetObjectByName("Bubble").pathAttributes.fillColor = orange;

		}

		if (color == "Blue") {
		Widget.GetObjectByName("Bubble").pathAttributes.fillColor = blue;

		}

		if (color == "Red") {
		Widget.GetObjectByName("Bubble").pathAttributes.fillColor = red;

		}

		if (color == "Green") {
		Widget.GetObjectByName("Bubble").pathAttributes.fillColor = green;

		}
		

}

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