 //*************To select RM Group************
function SelectSearchRMGroup(CheckBoxControl) 
{
if (CheckBoxControl.checked == true) 
{
//document.getElementById("ctl00_MainContent_chkAllItems").checked=true 
//alert (document.getElementById("ctl00_MainContent_chkAllItems").id)
var i;
for (i=0; i < document.forms[0].elements.length; i++) 
{
if ((document.forms[0].elements[i].type == 'checkbox') && 
(document.forms[0].elements[i].name.indexOf('dgRMGroup') > -1)) 
{
document.forms[0].elements[i].checked = true;
}
}
} 
else 
{
var i;
for (i=0; i < document.forms[0].elements.length; i++) 
{
if ((document.forms[0].elements[i].type == 'checkbox') && 
(document.forms[0].elements[i].name.indexOf('dgRMGroup') > -1)) 
{
document.forms[0].elements[i].checked = false;
}
}
}
  
}
 //*************To select RM List************
function SelectSearchRMList(CheckBoxControl) 
{
if (CheckBoxControl.checked == true) 
{
//document.getElementById("ctl00_MainContent_chkAllItems").checked=true 
//alert (document.getElementById("ctl00_MainContent_chkAllItems").id)
var i;
for (i=0; i < document.forms[0].elements.length; i++) 
{
if ((document.forms[0].elements[i].type == 'checkbox') && 
(document.forms[0].elements[i].name.indexOf('dgRMList') > -1)) 
{
document.forms[0].elements[i].checked = true;
}
}
} 
else 
{
var i;
for (i=0; i < document.forms[0].elements.length; i++) 
{
if ((document.forms[0].elements[i].type == 'checkbox') && 
(document.forms[0].elements[i].name.indexOf('dgRMList') > -1)) 
{
document.forms[0].elements[i].checked = false;
}
}
}
  
}

//*************To select Customer Group************
function SelectSearchCustomergroup(CheckBoxControl) 
{
if (CheckBoxControl.checked == true) 
{
//document.getElementById("ctl00_MainContent_chkAllItems").checked=true 
//alert (document.getElementById("ctl00_MainContent_chkAllItems").id)
var i;
for (i=0; i < document.forms[0].elements.length; i++) 
{
if ((document.forms[0].elements[i].type == 'checkbox') && 
(document.forms[0].elements[i].name.indexOf('dgMCustmerGroup') > -1)) 
{
document.forms[0].elements[i].checked = true;
}
}
} 
else 
{
var i;
for (i=0; i < document.forms[0].elements.length; i++) 
{
if ((document.forms[0].elements[i].type == 'checkbox') && 
(document.forms[0].elements[i].name.indexOf('dgMCustmerGroup') > -1)) 
{
document.forms[0].elements[i].checked = false;
}
}
}
  
}

 //*************To select Customer************
function SelectSearchMCustomer(CheckBoxControl) 
{
if (CheckBoxControl.checked == true) 
{
//document.getElementById("ctl00_MainContent_chkAllItems").checked=true 
//alert (document.getElementById("ctl00_MainContent_chkAllItems").id)
var i;
for (i=0; i < document.forms[0].elements.length; i++) 
{
if ((document.forms[0].elements[i].type == 'checkbox') && 
(document.forms[0].elements[i].name.indexOf('dgMCustomer') > -1)) 
{
document.forms[0].elements[i].checked = true;
}
}
} 
else 
{
var i;
for (i=0; i < document.forms[0].elements.length; i++) 
{
if ((document.forms[0].elements[i].type == 'checkbox') && 
(document.forms[0].elements[i].name.indexOf('dgMCustomer') > -1)) 
{
document.forms[0].elements[i].checked = false;
}
}
}
  
}


//*************To select Unmapped Customer Group************
function SelectSearchUCustomerGroup(CheckBoxControl) 
{
if (CheckBoxControl.checked == true) 
{
//document.getElementById("ctl00_MainContent_chkAllItems").checked=true 
//alert (document.getElementById("ctl00_MainContent_chkAllItems").id)
var i;
for (i=0; i < document.forms[0].elements.length; i++) 
{
if ((document.forms[0].elements[i].type == 'checkbox') && 
(document.forms[0].elements[i].name.indexOf('dgUCustomerGroup') > -1)) 
{
document.forms[0].elements[i].checked = true;
}
}
} 
else 
{
var i;
for (i=0; i < document.forms[0].elements.length; i++) 
{
if ((document.forms[0].elements[i].type == 'checkbox') && 
(document.forms[0].elements[i].name.indexOf('dgUCustomerGroup') > -1)) 
{
document.forms[0].elements[i].checked = false;
}
}
}
  
}

//*************messagebox to confirm update Customer RM Mapping

 function ConfirmCustomerRMMap()
{
if (confirm("Are you sure, you want to Update Customer RM mapping ? "))
 {
return true
}
else
{
return false
}
 }

//*************To select chkAllItemsRMGroup************
 function chkAllCheckBoxRMGroup(CheckBoxControl) {
     if (CheckBoxControl.checked == true) {
         var i;
         var isCheckAll =true;

         for (i = 0; i < document.forms[0].elements.length; i++) {
             if ( (document.forms[0].elements[i].type == 'checkbox') && 
                   (document.forms[0].elements[i].name.indexOf('dgRMGroup') > 1))
             {
                 if ((document.forms[0].elements[i].id != "ctl00_MainContent_dgRMGroup_ctl02_chkAllItems") && (document.forms[0].elements[i].checked != true ))
                 {
                     isCheckAll = false;
                 }
             }
                     
         }
          
         if (isCheckAll) {
             document.getElementById("ctl00_MainContent_dgRMGroup_ctl02_chkAllItems").checked = true;
         }
         else {
             document.getElementById("ctl00_MainContent_dgRMGroup_ctl02_chkAllItems").checked = false;
         }
               
     }
     else {

         document.getElementById("ctl00_MainContent_dgRMGroup_ctl02_chkAllItems").checked = false;
        
     }

 }

 //*************To select chkAllItemsRMGroup************
 function chkAllCheckBoxRM(CheckBoxControl) {
     if (CheckBoxControl.checked == true) {
         var i;
         var isCheckAll = true;

         for (i = 0; i < document.forms[0].elements.length; i++) {
             if ((document.forms[0].elements[i].type == 'checkbox') &&
                   (document.forms[0].elements[i].name.indexOf('dgRMList') > 1)) {
                 if ((document.forms[0].elements[i].id != "ctl00_MainContent_dgRMList_ctl02_chkAllItems") && (document.forms[0].elements[i].checked != true)) {
                     isCheckAll = false;
                 }
             }

         }

         if (isCheckAll) {
             document.getElementById("ctl00_MainContent_dgRMList_ctl02_chkAllItems").checked = true;
         }
         else {
             document.getElementById("ctl00_MainContent_dgRMList_ctl02_chkAllItems").checked = false;
         }

     }
     else {

         document.getElementById("ctl00_MainContent_dgRMList_ctl02_chkAllItems").checked = false;

     }

 }

 function chkAllCheckCustomerRM(CheckBoxControl) {
     if (CheckBoxControl.checked == true) {
         var i;
         var isCheckAll = true;

         for (i = 0; i < document.forms[0].elements.length; i++) {
             if ((document.forms[0].elements[i].type == 'checkbox') &&
                   (document.forms[0].elements[i].name.indexOf('dgMCustmerGroup') > 1)) {
                 if ((document.forms[0].elements[i].id != "ctl00_MainContent_dgMCustmerGroup_ctl02_chkAllItems") && (document.forms[0].elements[i].checked != true)) {
                     isCheckAll = false;
                 }
             }

         }

         if (isCheckAll) {
             document.getElementById("ctl00_MainContent_dgMCustmerGroup_ctl02_chkAllItems").checked = true;
         }
         else {
             document.getElementById("ctl00_MainContent_dgMCustmerGroup_ctl02_chkAllItems").checked = false;
         }

     }
     else {

         document.getElementById("ctl00_MainContent_dgMCustmerGroup_ctl02_chkAllItems").checked = false;

     }

 }

 function chkAllCheckCustomer(CheckBoxControl) {
     if (CheckBoxControl.checked == true) {
         var i;
         var isCheckAll = true;

         for (i = 0; i < document.forms[0].elements.length; i++) {
             if ((document.forms[0].elements[i].type == 'checkbox') &&
                   (document.forms[0].elements[i].name.indexOf('dgMCustomer') > 1)) {
                 if ((document.forms[0].elements[i].id != "ctl00_MainContent_dgMCustomer_ctl02_chkAllItems") && (document.forms[0].elements[i].checked != true)) {
                     isCheckAll = false;
                 }
             }

         }

         if (isCheckAll) {
             document.getElementById("ctl00_MainContent_dgMCustomer_ctl02_chkAllItems").checked = true;
         }
         else {
             document.getElementById("ctl00_MainContent_dgMCustomer_ctl02_chkAllItems").checked = false;
         }

     }
     else {

         document.getElementById("ctl00_MainContent_dgMCustomer_ctl02_chkAllItems").checked = false;

     }

 }

