Type.registerNamespace('Kaos.UI');

// updates drop down list removing from it all items that are less than selected value of manageControl
// manageControl - should be of type select
// controlToUpdate - should be of type select
// changeActualValue - if true selected value of controlToUpdate would be change if needed; otherwise not.
Kaos.UI.updateYearList = function(manageControl, controlToUpdate, changeActualValue)
  {
    //debugger;
    // arguments are invalid
    if (!controlToUpdate || !manageControl)
      return;
    
    // if controlToUpdate selected value is less than manageControl
    // selected value than update control's values set
    var maxManageValue = parseInt(manageControl.options[1].value, 10);

    var selectedManageValue = parseInt(manageControl.value);
    var selectedControlValue = parseInt(controlToUpdate.value);
    
    // first remove all options
    while (controlToUpdate.options.length > 1)
    {
      controlToUpdate.removeChild(controlToUpdate.options[controlToUpdate.options.length - 1]);
    }
    
    var inferiorLimit = selectedManageValue;
    if (selectedControlValue < inferiorLimit && !changeActualValue)
      inferiorLimit = selectedControlValue;
    
    // append options with correct values
    for (var i = 1; i < manageControl.options.length; ++i)
    {
      
      if (parseInt(manageControl.options[i].value, 10) >= inferiorLimit)
      {
        controlToUpdate.appendChild(manageControl.options[i].cloneNode(true));
      }
    }
    
    if (selectedControlValue > selectedManageValue)
      controlToUpdate.value = selectedControlValue;
    else
      controlToUpdate.value = inferiorLimit;
    
    if (manageControl.value == "")
      controlToUpdate.selectedIndex = 0;
  }
  
Kaos.UI.generateCompetencyUrlParams = function(prefix)
{
    
    var el = document.forms[0].elements;
    var params = "";
    for (count = 0; count < el.length; count ++ )
    {
        if(el[count].id != null && el[count].id.trim() != '' && el[count].id.indexOf(prefix) == 0 && el[count].checked)
        {  
            
            if (params.trim() != '')
            {
                params += "&";
            }         
            params += "comp=" + el[count].id.substring(prefix.length);
            
        }
    }
    
    if (params.trim() == '')
    {

        params += "comp=0"; 
        }
    return params;
}

// Notify ScriptManager that this is the end of the script.
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();