﻿// Drop Down Custom Validator
function DropDownValidator(src, args)
{
  if (args.Value == "--") args.IsValid = false;
  else args.IsValid = true;
}

var control;
function SetActiveTab(tabControl)
{
  // get the tab control
  control = $find(tabControl);
  
  // if we have a tab control, lets try to get the active tab
  if (control != null)
    Services.GetActiveTab(SetActiveTabSuccessCallBack, SetActiveTabFailedCallBack);
}

function SetActiveTabSuccessCallBack(result)
{
  control.set_activeTab(control.get_tabs()[result]);
}

function SetActiveTabFailedCallBack(result)
{
  // do nothing on failure
}

function SendTabChanged()
{
  // send the active tab to the server
  if (control != null)
    Services.SetActiveTab(control.get_activeTabIndex());
}
