//==================================================================
// WP7 Command Button
// Timur Prokopiev 2011
//==================================================================

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

// Secondary Text
  values.push({ name:"Secondary", type:"text", value:"Lorem ipsum dolor sit amet, consectetur elit adipisicing elit, sed do eiusmod." });

// 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 theme  = values[2].value.split(",")[0].toString();

		Widget.GetObjectByName("primary_text").textChars = values[0].value;
		Widget.GetObjectByName("secondary_text").textChars = values[1].value;
		Widget.GetObjectByName("bg_small").visible = true;
		Widget.GetObjectByName("primary_text").visible = true;
		Widget.GetObjectByName("secondary_text").visible = true;

		var strlength = Widget.GetObjectByName("secondary_text").height;		
				
if (theme == "Dark") {

	Widget.GetObjectByName("primary_text").pathAttributes.fillColor = "#FFFFFF";
	Widget.GetObjectByName("bg_small").pathAttributes.brushColor = "#FFFFFF";
	Widget.GetObjectByName("bg_big").pathAttributes.brushColor = "#FFFFFF";

	
		if (strlength >24) {
		Widget.GetObjectByName("bg_big").visible = true;
		Widget.GetObjectByName("bg_small").visible = false;
		
		} if (strlength > 50) {
		
		Widget.GetObjectByName("error").visible = true;
		Widget.GetObjectByName("primary_text").visible = false;
		Widget.GetObjectByName("secondary_text").visible = false;
		Widget.GetObjectByName("bg_small").visible = false;
		Widget.GetObjectByName("bg_big").visible = false;
		}

}

if (theme == "Light") {

	Widget.GetObjectByName("primary_text").pathAttributes.fillColor = "#000000";
	Widget.GetObjectByName("bg_small").pathAttributes.brushColor = "#000000";
	Widget.GetObjectByName("bg_big").pathAttributes.brushColor = "#000000";

		if (strlength >24) {
		Widget.GetObjectByName("bg_big").visible = true;
		Widget.GetObjectByName("bg_small").visible = false;
		
		} if (strlength > 50) {
		
		Widget.GetObjectByName("error").visible = true;
		Widget.GetObjectByName("primary_text").visible = false;
		Widget.GetObjectByName("secondary_text").visible = false;
		Widget.GetObjectByName("bg_small").visible = false;
		Widget.GetObjectByName("bg_big").visible = false;
		}

}

}

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