function confirm_entry()
            {

            if (confirm("Are you sure you want to delete the selected record/s?"))
            {
			 return true;
            }
                  else
                  {
                    return false;
                  }

            }


function confirm_entry(txt)
            {

            if (confirm("Are you sure you want to "+txt+" the selected record/s?"))
            {
			 return true;
            }
                  else
                  {
                    return false;
                  }

            }

function check_records_to_delete(f,msg)
{

var d=f.elements;
selected_chk = false;
a_check_box_exists = false;

for(var i=0;i<d.length;i++)
 {
  if(d[i].type=='checkbox')
   {
    a_check_box_exists = true;

    if(d[i].checked)
     {
      selected_chk = true;
      break;
     }
   }

  }

if(a_check_box_exists == false)
 {
  alert("There are no records to "+msg+".");
 }
else
 {
  if (selected_chk == true)
   {
     if (confirm_entry(msg))
      {
       f.submit();
     }
   }
  else
   {
    alert("Check at least one checkbox.");
   }
 }
}


function check_records_to_approve(f,print_txt)
{

var d=f.elements;
selected_chk = false;
a_check_box_exists = false;

for(var i=0;i<d.length;i++)
 {
  if(d[i].type=='checkbox')
   {
    a_check_box_exists = true;

    if(d[i].checked)
     {
      selected_chk = true;
      break;
     }
   }

  }

if(a_check_box_exists == false)
 {
  alert("There are no records to "+print_txt+".");
 }
else
 {
  if (selected_chk == true)
   {
     if (confirm_entry(print_txt))
      {
       f.submit();
     }
   }
  else
   {
    alert("Check at least one checkbox.");
   }
 }
}



function empty_textbox(txt)
{
 if (txt.disabled == false)
  {
   if (trimAll(txt.value) == "")
    {
     alert("The information "+ name_trimer(txt.name) +" should be filled.");
     txt.focus();
     return true;
    }
    else
    {
     return false;
    }
  }
  return false;
}

function trimAll(sString)
{
  while (sString.substring(0,1) == ' ')
  {
   sString = sString.substring(1, sString.length);
  }

  while (sString.substring(sString.length-1, sString.length) == ' ')
  {
   sString = sString.substring(0,sString.length-1);
  }
 return sString;
}

function name_trimer(str)
{
  str = str.substring(3);
  return str;
}

function no_selected_combo(cbo)
{
 if (cbo.selectedIndex == 0)
  {
   alert("A value in the "+ name_trimer(cbo.name) +" combobox should be selected.");
   cbo.focus();
   return true;
  }
  else
   {return false;
   }

}

 function no_selected_rdo(rdo, rdo_name)
{
 //alert(rdo.name)
// set var radio_choice to false
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter < rdo.length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (rdo[counter].checked)
 {
   radio_choice = true;
 }
}

if (!radio_choice)
{
// If there were no selections made display an alert box
alert("Please select a radiobutton from the "+ name_trimer(rdo_name) +" list");
return true;
}
return false;
}

function password_mismatch(pass1, pass2)
{
  if(pass1 != pass2)
  {
   alert("Passwords do not match!");
   return true;
  }
  return false;
}

function string_mismatch(pass1, pass2, txt, ctrl)
{
  if(pass1 != pass2)
  {
   alert(txt);
   ctrl.focus();
   return true;
  }
  return false;
}

 function textfocus(txt)
                {
                    txt.focus();
                }

function testing()
{
alert("");
}


function already_selected_combo1(cbo,text_to_search,msg)
{
// alert("1");
 match = 0;
 for(i=0; i<cbo.options.length; i++)
  {
    if(cbo.options[i].text == text_to_search)
     {
      match = 1;
     }
  }

 if (match == 1)
  {
   alert(msg);
   cbo.focus();
   return true;
  }
 else
  {
    return false;
  }

}

function already_selected_combo(cbo,text_to_search,src_cbo)
{
// alert("2");
 match = 0;
 for(i=0; i<cbo.options.length; i++)
  {
    if(cbo.options[i].text == text_to_search)
     {
      match = 1;
     }
  }

 if (match == 1)
  {
   alert(text_to_search +" is already in the list.");
   src_cbo.selectedIndex = 0;
   cbo.focus();
   return true;
  }
 else
  {
    return false;
  }

}

function already_selected_combo2(cbo,text_to_search,src_cbo)
{
// alert("3");
 match = 0;
 for(i=0; i<cbo.options.length; i++)
  {
   /*	
    if(cbo.options[i].value.indexOf(text_to_search)>=0)//kasi nasa string din ung id nya as assigner
     {
      match = 1;
     }
   */
    strko = cbo.options[i].value.substring(0,9);

   if(strko.indexOf(text_to_search)>=0)//kasi nasa string din ung id nya as assigner
     {
      match = 1;
     }
  }

 if (match == 1)
  {
  // alert(text_to_search +" is already a member \n to continue remove the name from the members' list!");
  // src_cbo.selectedIndex = 0;
  // cbo.focus();
   return true;
  }
 else
  {
    return false;
  }

}

function ask_overwrite(msg)
 {
//  input(
 }

function select_partner_combo(src_cbo,partner_cbo)
{
   partner_cbo.selectedIndex = src_cbo.selectedIndex;
   //alert("");
}

function get_index(text_to_search, cbo)
{
  ind = 0;
  for(i=0; i<cbo.options.length; i++)
  {
    if(cbo.options[i].text == text_to_search)
     {
      ind = i;
      break;
     }
  }

  return ind;
}

function select_partner_src_combo(cbo,cbopartner,srccbo,srcpartnercbo)
{
  //alert(cbo.name +" "+cbopartner.name+" "+srccbo.name);

  select_partner_combo(cbo,cbopartner)
  //alert("");

  text_to_search = cbo.options[cbo.selectedIndex].text;

  ind = 0;
  for(i=0; i<srccbo.options.length; i++)
  {
    if(srccbo.options[i].text == text_to_search)
     {
      ind = i;
      break;
     }
  }

  srccbo.selectedIndex = ind;

  //THE OTHER COMBO EITHER THE CBO OR THE STATUS CBO
  text_to_search = cbopartner.options[cbopartner.selectedIndex].text;

  ind = 0;
  for(i=0; i<srcpartnercbo.options.length; i++)
  {
    if(srcpartnercbo.options[i].text == text_to_search)
     {
      ind = i;
      break;
     }
  }

  srcpartnercbo.selectedIndex = ind;
 //alert("y");
}


function IsNotYear(txt)
{
   sText = txt.value;

   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

if (trimAll(sText).length != 4)
   {
     alert("Enter a valid year!");
     txt.focus();
     return true;
   }

   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   if (IsNumber == false)
    {
     alert("Enter a valid year!");
     txt.focus();
     return true;
    }
   else
    {
     return false;
    }


   }

function IsNotNumeric(txt)
{
  // alert("1");

   sText = txt.value;

   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   if (IsNumber == false)
    {
     //alert("Enter a valid year!");
     //txt.focus();
     return true;
    }
   else
    {
     return false;
    }


   }
