function FieldListAddAll()
{
   var FieldListCount = document.getElementById('ctl00_BodyContentPH_lst_PayrollFieldList').options.length;
   var i;
   var SelectedFieldListCount = document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options.length;
   for (i = 0; i < FieldListCount; i++)
   {
      var FieldName = document.getElementById('ctl00_BodyContentPH_lst_PayrollFieldList').options[i].value;
      var FieldName_Text = document.getElementById('ctl00_BodyContentPH_lst_PayrollFieldList').options[i].text;
      document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options[SelectedFieldListCount] = new Option(FieldName_Text,FieldName);
      SelectedFieldListCount = SelectedFieldListCount + 1;
   }
   for (i = FieldListCount-1; i >= 0; i--)
   {
      document.getElementById('ctl00_BodyContentPH_lst_PayrollFieldList').options[i] = null;
   }
   FillHiddenField();
   return false;
}
function FieldListRemoveAll()
{
   var SelectedFieldListCount = document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options.length;
   var i;
   var FieldListCount = document.getElementById('ctl00_BodyContentPH_lst_PayrollFieldList').options.length;
   for (i = 0; i < SelectedFieldListCount; i++)
   {
      var FieldName = document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options[i].value;
      var FieldName_Text = document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options[i].text;
      document.getElementById('ctl00_BodyContentPH_lst_PayrollFieldList').options[FieldListCount] = new Option(FieldName_Text,FieldName);
      FieldListCount = FieldListCount + 1;
   }
   for (i = SelectedFieldListCount-1; i >= 0; i--)
   {
      document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options[i] = null;
   }
   FillHiddenField();
   return false;
}
function FieldListAdd(SelectanyoneOptiontomove)
{
   var FieldListSelectedIndex = document.getElementById('ctl00_BodyContentPH_lst_PayrollFieldList').selectedIndex;
   if(FieldListSelectedIndex == -1)
   {
      //alert("Select any one Option to move");
      alert(SelectanyoneOptiontomove);
      return false;
   }
   var FieldName = document.getElementById('ctl00_BodyContentPH_lst_PayrollFieldList').options[FieldListSelectedIndex].value;
   var FieldName_Text = document.getElementById('ctl00_BodyContentPH_lst_PayrollFieldList').options[FieldListSelectedIndex].text;
   var SelectedFieldListCount = document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options.length;
   document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options[SelectedFieldListCount] = new Option(FieldName_Text,FieldName);
   document.getElementById('ctl00_BodyContentPH_lst_PayrollFieldList').options[FieldListSelectedIndex] = null;
   FillHiddenField();
   return false;
}
function FieldListRemove(SelectanyoneOptiontomove)
{
   var FieldListSelectedIndex = document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').selectedIndex;
   if(FieldListSelectedIndex == -1)
   {
      //alert("Select any one Option to move");
      alert(SelectanyoneOptiontomove);
      return false;
   }
   var FieldName = document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options[FieldListSelectedIndex].value;
   var FieldName_Text = document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options[FieldListSelectedIndex].text;
   var FieldListCount = document.getElementById('ctl00_BodyContentPH_lst_PayrollFieldList').options.length;
   document.getElementById('ctl00_BodyContentPH_lst_PayrollFieldList').options[FieldListCount] = new Option(FieldName_Text,FieldName);
   document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options[FieldListSelectedIndex] = null;
    FillHiddenField();
   return false;
}
function FillHiddenField() {
    if (document.getElementById('ctl00_BodyContentPH_rblMonthDateWise_0').checked == true) {
        var SelectedFieldNames = "";
        var SelectedFieldListCount = document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options.length;
        for (var i = 0; i < SelectedFieldListCount; i++) {
            var FieldName = document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options[i].value;
            if (i < SelectedFieldListCount - 1) {
                if (FieldName == 'LevelCode') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(250),LD.description) as [Level Name],";
                }
                else if (FieldName == 'Hours_Worked') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd.HrsWork) as [Hours Worked],";
                }
                else if (FieldName == 'Total_OT') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd.HrsOt) as [Total OT],";
                }
                else if (FieldName == 'WeekDay_OT') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd.NormOt) as [WeekDay OT],";
                }
                else if (FieldName == 'WeekOff_OT') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd.OffOT) as [WeekOff OT],";
                }
                else if (FieldName == 'Holiday_OT') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd.HolOT) as [Holiday OT],";
                }
                else if (FieldName == 'Defined_WorkHours') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd.WorkHrs) as [Defined Work Hours],";
                }
                else if (FieldName == 'Employee_Id') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),E.Employee_Code_Id) as [Employee Id],";
                }
                else {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd." + FieldName + ") as " + FieldName + ",";
                }
            }
            else {
                if (FieldName == 'LevelCode') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(250),LD.description) as [Level Name]";
                }
                else if (FieldName == 'Hours_Worked') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd.HrsWork) as [Hours Worked]";
                }
                else if (FieldName == 'Total_OT') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd.HrsOt) as [Total OT]";
                }
                else if (FieldName == 'WeekDay_OT') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd.NormOt) as [WeekDay OT]";
                }
                else if (FieldName == 'WeekOff_OT') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd.OffOT) as [WeekOff OT]";
                }
                else if (FieldName == 'Holiday_OT') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd.HolOT) as [Holiday OT]";
                }
                else if (FieldName == 'Defined_WorkHours') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd.WorkHrs) as [Defined Work Hours]";
                }
                else if (FieldName == 'Employee_Id') {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),E.Employee_Code_Id) as [Employee Id],";
                }
                else {
                    SelectedFieldNames = SelectedFieldNames + "convert(varchar(100),ppd." + FieldName + ") as " + FieldName;
                }
            }
        }
        if (SelectedFieldNames != "") {
            document.getElementById('ctl00_BodyContentPH_lbl_Error').innerText = "";
        }
        document.getElementById('ctl00_BodyContentPH_hdn_SelectedFieldNames').value = SelectedFieldNames;
    }
        //For Daily data
    else {
        var SelectedFieldNames = "";
        var SelectedFieldListCount = document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options.length;
        for (var i = 0; i < SelectedFieldListCount; i++) {
            var FieldName = document.getElementById('ctl00_BodyContentPH_lst_PayrollSelectedFieldList').options[i].value;
            if (i < SelectedFieldListCount - 1) {
                SelectedFieldNames = SelectedFieldNames + " " + FieldName + ",";
            }
            else {
                SelectedFieldNames = SelectedFieldNames + " " + FieldName;
            }
        }
        if (SelectedFieldNames != "") {
            document.getElementById('ctl00_BodyContentPH_lbl_Error').innerText = "";
        }
        document.getElementById('ctl00_BodyContentPH_hdn_SelectedFieldNames').value = SelectedFieldNames;
    }
}