// JScript File
// Created by Kumuthini.L

function FieldListAddAll()
{
   var FieldListCount = document.getElementById('ctl00_Cp_System_lst_PayrollFieldList').options.length;
   var i;
   var SelectedFieldListCount = document.getElementById('ctl00_Cp_System_lst_PayrollSelectedFieldList').options.length;
   
   for (i = 0; i < FieldListCount; i++)
   {
      var FieldName = document.getElementById('ctl00_Cp_System_lst_PayrollFieldList').options[i].value;
      document.getElementById('ctl00_Cp_System_lst_PayrollSelectedFieldList').options[SelectedFieldListCount] = new Option(FieldName,FieldName);
      SelectedFieldListCount = SelectedFieldListCount + 1;
   }
   
   for (i = FieldListCount-1; i >= 0; i--)
   {
      document.getElementById('ctl00_Cp_System_lst_PayrollFieldList').options[i] = null;
   }
   
   FillHiddenField();
    
   return false;
}

function FieldListRemoveAll()
{
   var SelectedFieldListCount = document.getElementById('ctl00_Cp_System_lst_PayrollSelectedFieldList').options.length;
   var i;
   var FieldListCount = document.getElementById('ctl00_Cp_System_lst_PayrollFieldList').options.length;
    
   for (i = 0; i < SelectedFieldListCount; i++)
   {
      var FieldName = document.getElementById('ctl00_Cp_System_lst_PayrollSelectedFieldList').options[i].value;
      document.getElementById('ctl00_Cp_System_lst_PayrollFieldList').options[FieldListCount] = new Option(FieldName,FieldName);
      FieldListCount = FieldListCount + 1;
   }
   
   for (i = SelectedFieldListCount-1; i >= 0; i--)
   {
      document.getElementById('ctl00_Cp_System_lst_PayrollSelectedFieldList').options[i] = null;
   }
   
   FillHiddenField();
    
   return false;
}

function FieldListAdd()
{
   var FieldListSelectedIndex = document.getElementById('ctl00_Cp_System_lst_PayrollFieldList').selectedIndex;
   
   if(FieldListSelectedIndex == -1)
   {
      alert("Select any one Option to move");
      return false;
   }
   
   var FieldName = document.getElementById('ctl00_Cp_System_lst_PayrollFieldList').options[FieldListSelectedIndex].value;
   
   var SelectedFieldListCount = document.getElementById('ctl00_Cp_System_lst_PayrollSelectedFieldList').options.length;
   
   document.getElementById('ctl00_Cp_System_lst_PayrollSelectedFieldList').options[SelectedFieldListCount] = new Option(FieldName,FieldName);
   
   document.getElementById('ctl00_Cp_System_lst_PayrollFieldList').options[FieldListSelectedIndex] = null;
   
   FillHiddenField();
   
   return false;
}

function FieldListRemove()
{
   var FieldListSelectedIndex = document.getElementById('ctl00_Cp_System_lst_PayrollSelectedFieldList').selectedIndex;
   
   if(FieldListSelectedIndex == -1)
   {
      alert("Select any one Option to move");
      return false;
   }
   
   var FieldName = document.getElementById('ctl00_Cp_System_lst_PayrollSelectedFieldList').options[FieldListSelectedIndex].value;
   
   var FieldListCount = document.getElementById('ctl00_Cp_System_lst_PayrollFieldList').options.length;
   
   document.getElementById('ctl00_Cp_System_lst_PayrollFieldList').options[FieldListCount] = new Option(FieldName,FieldName);
   
   document.getElementById('ctl00_Cp_System_lst_PayrollSelectedFieldList').options[FieldListSelectedIndex] = null;
   
    FillHiddenField();
   
   return false;
}

function FillHiddenField()
{
   var SelectedFieldNames = "";

   var SelectedFieldListCount = document.getElementById('ctl00_Cp_System_lst_PayrollSelectedFieldList').options.length;
   
   for (var i = 0; i < SelectedFieldListCount; i++)
   {
      var FieldName = document.getElementById('ctl00_Cp_System_lst_PayrollSelectedFieldList').options[i].value;
      
      if (i < SelectedFieldListCount-1)
      {
         SelectedFieldNames = SelectedFieldNames + "ppd." + FieldName + ",";
      }
      else
      {
         SelectedFieldNames = SelectedFieldNames + "ppd." + FieldName;
      }
   }
   
   if(SelectedFieldNames != "")
   {
      document.getElementById('ctl00_Cp_System_lbl_Error').innerText = "";
   }
   
   document.getElementById('ctl00_Cp_System_hdn_SelectedFieldNames').value = SelectedFieldNames;
}