//var reqA = new Array('title','author','url','cont','keywords');
//var reqH = {'auser' : 'Admin', 'apass' : 'Pasword'};
//CheckFields(reqA, reqH);
//========================================================================================
function CheckFields(ta) {
   d = ' | ';
   err = 0;
   for (var i=0;i<ta.length;i++) {
      var e = ta[i];
      //alert(e);
      //tInp = document.getElementById(e);
      tInp = getElementByMy(e);

      if (tInp.type == 'checkbox') {
         //alert(tInp.name + d + tInp.type + d + tInp.value + d  + tInp.value.length + d + tInp.checked);
         tInp1 = document.getElementById(tInp.name + '0');
         if (tInp1) {
            if (err!=1) {
               err=1;
               for (a=0; a<100; a=a+2) {
                  tInp1 = document.getElementById(tInp.name + a);
                  if (tInp1) {
                     //alert(tInp.name + d + tInp.type + d + tInp.value + d  + tInp.value.length + d + tInp.checked);
                     if (tInp1.checked == true) {
                        err=0;
                        break;
                     }
                  }
               }
            }
         } else {
            if (tInp.checked == false) {
               err=1;
            }
         }
      } else {
         //alert(tInp.name + d + tInp.type + d + tInp.value + d  + tInp.value.length + d + tInp.checked);
         if (tInp.value.length<1) {
            err=1;
            //alert('err');
            //htmo = document.getElementById(e.toString());
         }
      }
   }

   //alert(err);
   //return false;

   if (err>0) {
      alert("Please fill in all required (*) fields");
      return false;
   } else {
      return true;
   }
}
//========================================================================================
function SubmitAction(act, id) { //, id, cpos_null
   //Alert('a');
   frm.substep.value = act;
   frm.id.value = id;
   //if (cpos_null>0) {
   //   frm.cpos.value = 0;
   //}
   frm.submit();
}
//========================================================================================
function QstDel(link) {
   if (window.confirm('Delete item ?') == true) {
      window.location=link;
   }
   return false;
}
//========================================================================================
function SubmitAction1(act, id) { //, id, cpos_null
   document.frm1.substep.value = act;
   document.frm1.id.value = id;
   if ((act=='del') && (window.confirm('Delete item ?') != true)) {
      return;
   }
   document.frm1.submit();
}
//========================================================================================
function SubmitAction2(act, id) { //, id, cpos_null
   document.frm1.substep.value = act;
   document.frm1.id.value = id;
   document.frm1.cpos.value = 0;
   if ((act=='del') && (window.confirm('Delete item ?') != true)) {
      return;
   }
   document.frm1.submit();
}
//========================================================================================
function CheckAll() {
   frm=document.frm1;
   for (var i=0;i<frm.elements.length;i++) {
      var e = frm.elements[i];
      if ((e.name != 'allbox') && (e.type=='checkbox')) {
         e.checked = frm.allbox.checked;
      }
   }
}
//========================================================================================
function ChangeContinent() {

   var SelectedContinent = document.frm.continent.options[document.frm.continent.selectedIndex].value;
   var oldSelectedCountry = document.frm.country.options[document.frm.country.selectedIndex].value;


   // (clear)
   var k = document.frm.country.options.length;
   for (var i = 0; i < k; i++) {
      document.frm.country.options[0] = null;
   }

   var result = '';
   var k=0;
   document.frm.country.options[k] = new Option('All', 'all');
   for (var i in ctr_cnt_h) {
      if ((ctr_cnt_h[i] == SelectedContinent) || (SelectedContinent == 'all')) {
         k++;
         document.frm.country.options[k] = new Option(i, i);
         if (oldSelectedCountry == i) document.frm.country.selectedIndex = k;
         result += i;
      }
   }
   //alert(result);
}
//===============================================================================
//## <AJAX>
//===============================================================================
function getElementByMy(name) {
   if (document.getElementById) {
      curElement = document.getElementById(name);
   } else {
      curElement = document.all[name];
   }
   if (! curElement) {
      if (document.forms["frm"]) {
         curElement = document.frm[name];
      }
      if (! curElement) {
         if (document.forms["frm1"]) {
            curElement = document.frm1[name];
         }
      }
   }
   return curElement;
}
//===============================================================================
function getElementByMy_(name) {
   curElement = document.getElementById(name);
   if (! curElement) {
      if (navigator.appName != 'Netscape') {
         curElement = document.all[name];
      }
      if (! curElement) {
         curElement = document.frm[name];
         if (! curElement) {
            curElement = document.frm1[name];
         }
      }
   }
   return curElement;
}
//========================================================================================
//## <DEBUG>
//========================================================================================
function v(str) {
   alert(str);
}
//========================================================================================
function c(str) {
   var debug = getElementByMy('debug');
   if (debug) {
     debug.innerHTML += ' [' + str + '] ';
   }
}
//========================================================================================//========================================================================================