﻿var checkflag = "false";
function select_deselectAll() {
    //checkflag = false;
       if (chk_Array_IDs != null)
       {
          if (checkflag == "false")
          {
             for (i=0;i<chk_Array_IDs.length;i++)
             {
                var ref_chk = document.getElementById(chk_Array_IDs[i]);
                if (ref_chk != null)
                   ref_chk.checked = true;
                   rowAppearanceOnDeleteMode('row' + i);
             }
             checkflag = "true";
             
             //return "غیر انتخاب";
          }
          else
          {
             for (i=0;i<chk_Array_IDs.length;i++)
             {
                var ref_chk = document.getElementById(chk_Array_IDs[i]);
                if (ref_chk != null)
                   ref_chk.checked = false;
                   rowAppearanceOnDeleteMode('row' + i);
             }
             checkflag = "false";
             //return "انتخاب همه";
          }
       }
   }
   //////////////////////////////////////////////
   function rowAppearanceOnDeleteMode(rowID) {
       var color = document.getElementById(rowID).style.backgroundColor;
       var ref_check = document.getElementById(rowID).getElementsByTagName("input").item(0);
       if (ref_check.checked) {
           document.getElementById(rowID).style.backgroundColor = 'lightyellow';  //'LightCoral';
           document.getElementById(rowID).style.fontStyle = 'italic';
       }
       else {
           document.getElementById(rowID).style.backgroundColor = '#AACCFF';
           document.getElementById(rowID).style.fontStyle = 'normal';
       }
   }

   //////////////////////////////////////////////

   function rowAppearanceOnDeleteMode1(rowID) {
       var color = document.getElementById(rowID).style.backgroundColor;
       var ref_check = document.getElementById(rowID).getElementsByTagName("input").item(0);
       if (ref_check.checked) {
           //document.getElementById(rowID).style.backgroundColor = 'lightyellow';  //'LightCoral';
           document.getElementById(rowID).style.fontStyle = 'italic';
           //document.getElementById(rowID).style.fontsize = '18';
       }
       else {
           //document.getElementById(rowID).style.backgroundColor = '#AACCFF';
           document.getElementById(rowID).style.fontStyle = 'normal';
       }
   }
   //////////////////////////////////////////////    
	function confirmDelete()
	{
	   var xCounter = 0;
	   if (chk_Array_IDs != null)
	   {
          for (i=0;i<chk_Array_IDs.length;i++)
          {
             var ref_chk = document.getElementById(chk_Array_IDs[i]);
             if (ref_chk != null)
                if (ref_chk.checked == true)
                   ++xCounter;
          }
          if (xCounter == 0)
          {
             alert("!هیچ رکوردی انتخاب نشده است");
             return false;
          }
          else
          {
              var ret_confirm = confirm("آیا مطمئن به حذف " +xCounter+ " رکورد انتخابی هستید؟");
              if (ret_confirm == true)
              {
                 checkclick = "true";
                 return true;
              }
              else
                 return false;
          }
       }
   }
   ////////////////////////////////////////////// 
   function confirmToShow() {
       var xCounter = 0;
       if (chk_Array_IDs != null) {
           for (i = 0; i < chk_Array_IDs.length; i++) {
               var ref_chk = document.getElementById(chk_Array_IDs[i]);
               if (ref_chk != null)
                   if (ref_chk.checked == true)
                   ++xCounter;
           }
           if (xCounter == 0) {
               alert("!هیچ رکوردی انتخاب نشده است");
               return false;
           }
           else {
               var ret_confirm = confirm("آیا مطمئن به نمایش  " + xCounter + " رکورد انتخابی  در سایت هستید؟");
               if (ret_confirm == true) {
                   checkclick = "true";
                   return true;
               }
               else
                   return false;
           }
       }
   }
   //////////////////////////////////////////////
   function confirmNotToShow() {
       var xCounter = 0;
       if (chk_Array_IDs != null) {
           for (i = 0; i < chk_Array_IDs.length; i++) {
               var ref_chk = document.getElementById(chk_Array_IDs[i]);
               if (ref_chk != null)
                   if (ref_chk.checked == true)
                   ++xCounter;
           }
           if (xCounter == 0) {
               alert("!هیچ رکوردی انتخاب نشده است");
               return false;
           }
           else {
               var ret_confirm = confirm("آیا مطمئن به عدم نمایش  " + xCounter + " رکورد انتخابی  در سایت هستید؟");
               if (ret_confirm == true) {
                   checkclick = "true";
                   return true;
               }
               else
                   return false;
           }
       }
   }

   //////////////////////////////////////////////
   function confirmChange() {
       var xCounter = 0;
       if (chk_Array_IDs != null) {
           for (i = 0; i < chk_Array_IDs.length; i++) {
               var ref_chk = document.getElementById(chk_Array_IDs[i]);
               if (ref_chk != null)
                   if (ref_chk.checked == true)
                   ++xCounter;
           }
           if (xCounter == 0) {
               alert("!هیچ رکوردی انتخاب نشده است");
               return false;
           }
           else {
               var ret_confirm = confirm("آیا مطمئن به اعمال تغیرات در  " + xCounter + " رکورد انتخابی  هستید؟");
               if (ret_confirm == true) {
                   checkclick = "true";
                   return true;
               }
               else
                   return false;
           }
       }
   }
   function confirmٍEmail() {
       var xCounter = 0;
       if (chk_Array_IDs != null) {
           for (i = 0; i < chk_Array_IDs.length; i++) {
               var ref_chk = document.getElementById(chk_Array_IDs[i]);
               if (ref_chk != null)
                   if (ref_chk.checked == true)
                   ++xCounter;
           }
           if (xCounter == 0) {
               alert("!هیچ رکوردی انتخاب نشده است");
               return false;
           }
           else {
               var ret_confirm = confirm("آیا مطمئن به ارسال ایمیل به   " + xCounter + " کاربر انتخابی  هستید؟");
               if (ret_confirm == true) {
                   checkclick = "true";
                   return true;
               }
               else
                   return false;
           }
       }
   }

        
        function rowOver(rowID)
        {
            document.getElementById(rowID).style.backgroundColor = 'lightyellow'; //'#FFEEC2';
        }
        //////////////////////////////////////////////
        function rowOut(rowID)
        {
           var ref_check = document.getElementById(rowID).getElementsByTagName("input").item(0);
           if (!ref_check.checked)
               document.getElementById(rowID).style.backgroundColor = '#AACCFF';
        }
        //////////////////////////////////////////////
        function numRows(editMode)
        {
           var intNumRows = document.getElementById("GridView1").getElementsByTagName("tr");
           // Rows which doesen't included: HeaderRow, Dynamic Row in Header Row
           if (editMode == "yes")
              return intNumRows.length - 2;
           else if (editMode == "no")
           // Rows which doesen't included: HeaderRow, FooterRow, Dynamic Row in Header Row
              return intNumRows.length - 3;
         }


