//==================================================================
// iPhone Notification Center (Bg)
// Timur Prokopiev 2011
//==================================================================


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

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

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

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

// Meridiem
  values.push({ name:"Meridiem", type:"ComboBox", value:"AM,AM,PM"});

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

}

function applyCurrentValues() {
  var values = Widget.elem.customData["currentValues"];
  var current = (values[1].value.toString()=="true");

  var meridiem = "";
  var d = new Date();
  var curr_hour = d.getHours();
	if (curr_hour < 12)
	   {
	   meridiem = "AM";
	   }
	else
	   {
	   meridiem = "PM";
	   }
	if (curr_hour == 0)
	   {
	   curr_hour = 12;
	   }
	if (curr_hour > 12)
	   {
	   curr_hour = curr_hour - 12;
	   }

  var curr_min = d.getMinutes();

	curr_min = curr_min + "";

	if (curr_min.length == 1)
	   {
	   curr_min = "0" + curr_min;
	   }

if (current == true) {
  Widget.GetObjectByName("time").textChars = curr_hour + ':' + curr_min + ' ' + meridiem;
}
else if (current == false) {
  Widget.GetObjectByName("time").textChars = values[2].value + ':' +  values[3].value + ' ' +   values[4].value.split(",")[0].toString();
}

  Widget.GetObjectByName("net_name").textChars = values[0].value;
}

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