
MessengerGadgetUpdateUIObj = function(objContainer)
{
	this.container = objContainer;
	this.container.id = "container";
	
	// Add Title Div
	var divTitle = document.createElement("div");
	divTitle.id = "title";
	divTitle.innerHTML = UpdateLocalizedConstants.LOC_UPDATE_TITLE;
	this.container.appendChild(divTitle);
	
	// Add Content Div
	var content = document.createElement("div");
	content.id = "content";
	this.container.appendChild(content);

	// Add Update Body
	var updateBody = document.createElement("div");
	updateBody.innerHTML = UpdateLocalizedConstants.LOC_UPDATE_BODY
	updateBody.id = "updateBody";
	content.appendChild(updateBody);
	
	// Radio Selection Options
	this.updateOptionsSelector = new RadioSelectorObj("UPDATE_OPTIONS");
	this.updateOptionsSelector.addOption(new OptionObj(UpdateLocalizedConstants.LOC_UPDATE_GO_TO_DOWNLOAD, GadgetConstants.UPDATE_OPTION_DOWNLOAD));
	this.updateOptionsSelector.addOption(new OptionObj(UpdateLocalizedConstants.LOC_UPDATE_NEXT_TIME, GadgetConstants.UPDATE_OPTION_REMIND));
	this.updateOptionsSelector.addOption(new OptionObj(UpdateLocalizedConstants.LOC_UPDATE_DONT_NOTIFY_ME, GadgetConstants.UPDATE_OPTION_NEVER));
	content.appendChild(this.updateOptionsSelector.getDiv());
	
	var divButton = document.createElement("div");
	divButton.id = "divButton";
	this.container.appendChild(divButton);
	
	var self = this;
	
	var buttonOK = document.createElement("button");
	buttonOK.innerHTML = UpdateLocalizedConstants.LOC_UPDATE_OK;
	buttonOK.onclick = function() {self.onClickOK()};
	divButton.appendChild(buttonOK);
	
	var buttonCancel = document.createElement("button");
	buttonCancel.innerHTML = UpdateLocalizedConstants.LOC_UPDATE_CANCEL;
	buttonCancel.onclick = function() {self.onClickCancel()};
	divButton.appendChild(buttonCancel);
	
	this.gadgetSettings = new MessengerGadgetSettingsObj();
	this.gadgetSettings.loadUpdateSettings();
}

MessengerGadgetUpdateUIObj.prototype =
{
	onClickOK:function()
	{
		debug("this.updateOptionsSelector.getValue() = " + this.updateOptionsSelector.getValue());
		if (this.updateOptionsSelector.getValue() == GadgetConstants.UPDATE_OPTION_DOWNLOAD)
		{
			var updateURL = System.Gadget.Settings.readString("updateURL");
			debug("updateURL =" +  updateURL);
		    if (updateURL != null && updateURL != "")
		    {
		        location.replace(updateURL);
		    }
		}
	   
		this.gadgetSettings.gadgetGetUpdateNotifications = this.updateOptionsSelector.getValue();
		this.gadgetSettings.saveSettings();
	   
	    System.Gadget.Settings.writeString("hideUpdateBar", "true");
	    System.Gadget.Flyout.show = false;
	},

	onClickCancel:function()
	{
		debug("Click Cancel");
		debug(System.Gadget.Flyout.show);
		System.Gadget.Flyout.show = false;
	}
}

 /************************************************************
          DEBUG FUNCTION
            * To see the debug output use DebugView
 ************************************************************/
function debug(message)
{
    if (message == null)
    {
        System.Debug.outputString("null");
    }
    else
    {
        System.Debug.outputString(message);
    }
}

