﻿// 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)
    Service.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)
    Service.SetActiveTab(control.get_activeTabIndex());
}

function SendProjectTypeChanged(control)
{
  var options = document.getElementsByName(control);
  
  if (options == null)
    return;
    
  for (var i = 0; i < options.length; i++)
  {
    if (options[i].checked)
      Service.SetActiveTab(options[i].value - 1);
  }
}
