//==================================================================
// iPhone Table
// Timur Prokopiev 2011
//==================================================================

function setDefaultValues() {
  var values = new Array();
  
// Item State
  values.push({ name:"Item State", type:"ComboBox", value:"Single,Single,Top,Center,Bottom"});

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

// Label State
  values.push({ name:"Label State", type:"ComboBox", value:"Single,Single,With Icon,With Title,Button"});

// Label Style
  values.push({ name:"Label Style", type:"ComboBox", value:"Active,Active,Selected,Disabled"});

// Label Text
  values.push({ name:"Label Text", type:"text", value:"Label"});

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

// Blue Label Text
  values.push({ name:"Blue Label Text", type:"text", value:"Old Phone"});

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

// Sub Icon Type
  values.push({ name:"Sub Icon Type", type:"ComboBox", value:"Arrow,Arrow,Checkmark"});

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

// Blue Title Label Text
  values.push({ name:"Title Text", type:"text", value:"address"});

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

function applyCurrentValues() {
  var values = Widget.elem.customData["currentValues"];
  var itemstate  = values[0].value.split(",")[0].toString();
  var labelenable = (values[1].value.toString()=="false");
  var labelstate  = values[2].value.split(",")[0].toString();
  var labelstyle  = values[3].value.split(",")[0].toString();
  var bluelabelenable = (values[5].value.toString()=="false");
  var subiconenable = (values[7].value.toString()=="false");
  var subicontype  = values[8].value.split(",")[0].toString();
  var titlelabel = (values[9].value.toString()=="false");

// Table State
  Widget.GetObjectByName("table_single").visible = (itemstate == "Single");
  Widget.GetObjectByName("table_top").visible = (itemstate == "Top");
  Widget.GetObjectByName("table_medium").visible = (itemstate == "Center");
  Widget.GetObjectByName("table_bottom").visible = (itemstate == "Bottom");

// Labels State 
		if (labelstate == "Single") {
	  Widget.GetObjectByName("label").visible = true;
	  Widget.GetObjectByName("label_icon").visible = false;
	  Widget.GetObjectByName("label_title").visible = false;
	  Widget.GetObjectByName("label_button").visible = false;
		}
		else if (labelstate == "With Icon") {
	  Widget.GetObjectByName("label").visible = false;
	  Widget.GetObjectByName("label_icon").visible = true;
	  Widget.GetObjectByName("label_title").visible = false;
	  Widget.GetObjectByName("label_button").visible = false;
		}
		else if (labelstate == "With Title") {
	  Widget.GetObjectByName("label").visible = false;
	  Widget.GetObjectByName("label_icon").visible = false;
	  Widget.GetObjectByName("label_title").visible = true;
	  Widget.GetObjectByName("label_button").visible = false;
		}
		else if (labelstate == "Button") {
	  Widget.GetObjectByName("label").visible = false;
	  Widget.GetObjectByName("label_icon").visible = false;
	  Widget.GetObjectByName("label_title").visible = false;
	  Widget.GetObjectByName("label_button").visible = true;
		}

// Labels Style 
		if (labelstyle == "Active") {
	  Widget.GetObjectByName("label").pathAttributes.fillColor = "#000000";
	  Widget.GetObjectByName("label_icon").pathAttributes.fillColor = "#000000";
	  Widget.GetObjectByName("label_title").pathAttributes.fillColor = "#000000";
	  Widget.GetObjectByName("label_button").pathAttributes.fillColor = "#000000";
		}
		else if (labelstyle == "Selected") {
	  Widget.GetObjectByName("label").pathAttributes.fillColor = "#324F85";
	  Widget.GetObjectByName("label_icon").pathAttributes.fillColor = "#324F85";
	  Widget.GetObjectByName("label_title").pathAttributes.fillColor = "#324F85";
	  Widget.GetObjectByName("label_button").pathAttributes.fillColor = "#324F85";
		}
		else if (labelstyle == "Disabled") {
	  Widget.GetObjectByName("label").pathAttributes.fillColor = "#B8B8B8";
	  Widget.GetObjectByName("label_icon").pathAttributes.fillColor = "#B8B8B8";
	  Widget.GetObjectByName("label_title").pathAttributes.fillColor = "#B8B8B8";
	  Widget.GetObjectByName("label_button").pathAttributes.fillColor = "#B8B8B8";
		}

// Labels Text
  Widget.GetObjectByName("label").textChars = values[4].value;
  Widget.GetObjectByName("label_icon").textChars = values[4].value;
  Widget.GetObjectByName("label_title").textChars = values[4].value;
  Widget.GetObjectByName("label_button").textChars = values[4].value;
 
// Blue Label
  Widget.GetObjectByName("label_blue").visible = (!bluelabelenable);
  Widget.GetObjectByName("label_blue").textChars = values[6].value;

// Title Label
  Widget.GetObjectByName("title_label").visible = (!titlelabel);
  Widget.GetObjectByName("title_label").textChars = values[10].value;

// Sub Icon Enable
  Widget.GetObjectByName("arrow").visible = (!subiconenable) & (subicontype == "Arrow");
  Widget.GetObjectByName("checkmark").visible = (!subiconenable) & (subicontype == "Checkmark");

}

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