//==================================================================
// WP7 Chat Bubble
// Timur Prokopiev 2011
//==================================================================


function setDefaultValues() {
  var values = new Array();
  
// Label
  values.push({ name:"Label", type:"text", value:"Text bubble rest state" });

// Text
  values.push({ name:"Text", type:"text", value:"sample text for edit" });
  
// State
  values.push({ name:"State", type:"ComboBox", value:"Normal,Normal,Pressed,Disabled,Sent"});


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

}

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

  Widget.GetObjectByName("label").textChars = values[0].value;
  Widget.GetObjectByName("text").textChars = values[1].value;

  var strlength = Widget.GetObjectByName("text").height;		

  
if (state == "Normal") {
	Widget.GetObjectByName("label").pathAttributes.fillColor = "#BFBFBF";
	Widget.GetObjectByName("text").pathAttributes.fillColor = "#000000";
	Widget.GetObjectByName("bg").pathAttributes.fillColor = "#BFBFBF";
	Widget.GetObjectByName("triangle").pathAttributes.fillColor = "#BFBFBF";
}

if (state == "Pressed") {
	Widget.GetObjectByName("label").pathAttributes.fillColor = "#BFBFBF";
	Widget.GetObjectByName("text").pathAttributes.fillColor = "#000000";
	Widget.GetObjectByName("bg").pathAttributes.fillColor = "#FFFFFF";
	Widget.GetObjectByName("triangle").pathAttributes.fillColor = "#FFFFFF";
}

if (state == "Disabled") {
	Widget.GetObjectByName("label").pathAttributes.fillColor = "#666666";
	Widget.GetObjectByName("text").pathAttributes.fillColor = "#3D3D3D";
	Widget.GetObjectByName("bg").pathAttributes.fillColor = "#666666";
	Widget.GetObjectByName("triangle").pathAttributes.fillColor = "#666666";
}

if (state == "Sent") {
	Widget.GetObjectByName("label").pathAttributes.fillColor = "#FFFFFF";
	Widget.GetObjectByName("text").pathAttributes.fillColor = "#FFFFFF";
	Widget.GetObjectByName("bg").pathAttributes.fillColor = "#1BA1E2";
	Widget.GetObjectByName("triangle").pathAttributes.fillColor = "#1BA1E2";
}

}

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