//checking the time-fields of the date custom tags for correct values
//used in the pages with selectiong the both date custom tags
function checkDate(pForm){
   var mStop  = getStopDate(pForm);
   var mStart = getStartDate(pForm);
   if ((mStart*mStop)==0){
     return false;
   }else if (mStart>=mStop) {
     alert(timeIntervalWrongMessage);
     return false;
   }else{
     return true;
   }
}

//return the value of the 'StartDate' custom tag in milliseconds
function getStartDate(pForm) {
  var day_f,month_f,year_f;
  if( isNaN(parseInt(pForm.day_from.value, 10))) {
    alert(desiganetCorrectTime+designateDay);
    return 0;
  }else{
    day_f = parseInt(pForm.day_from.value, 10);
    if (day_f<1 || day_f>31){
      alert(desiganetCorrectTime+designateDay);
      return 0;
    }
  }
  month_f = pForm.month_from.selectedIndex;
  if (month_f<0 || month_f>11) {
    alert(desiganetCorrectTime+designateMonth);
    return 0;
  }
  year_f = pForm.year_from.selectedIndex;
  year_f = pForm.year_from.options[year_f].value;
  year_f = parseInt(year_f, 10);
  if (year_f<1990 || year_f>(1900+(new Date()).getYear())) {
    alert(desiganetCorrectTime+designateYear);
    return 0;
  }
  date_f=new Date(year_f,month_f,day_f,0,0,0);
  return date_f.getTime();
}

//return the value of the 'StopDate' custom tag in milliseconds
function getStopDate(pForm) {
  var day_f,month_f,year_f;
  if( isNaN(parseInt(pForm.day_to.value, 10))) {
    alert(desiganetCorrectTime+designateDay);
    return 0;
  }else{
    day_f = parseInt(pForm.day_to.value, 10);
    if (day_f<1 || day_f>31){
      alert(desiganetCorrectTime+designateDay);
      return 0;
    }
  }
  month_f = pForm.month_to.selectedIndex;
  if (month_f<0 || month_f>11) {
    alert(desiganetCorrectTime+designateMonth);
    return 0;
  }
  year_f = pForm.year_to.selectedIndex;
  year_f = pForm.year_to.options[year_f].value;
  year_f = parseInt(year_f, 10);
  if (year_f<1990 || year_f>(1900+(new Date()).getYear())) {
    alert(desiganetCorrectTime+designateYear);
    return 0;
  }
  date_f=new Date(year_f,month_f,day_f,23,59,0);
  return date_f.getTime();
}

//Function change_visibility makes visible and unvisible block of page. Gets ID block
// of page as parameter
function change_visibility(pSRC){
  for(i=0; i<document.all.length;i++){
    if(document.all[i].id!="" && document.all[i].id.indexOf("tr")==0){
      //document.all[i].style.backgroundColor='transparent';
      //document.all[i].style.backgroundColor='#faf3e8';
    }
  }

  var tr = document.all['tr'+pSRC];
  var dv = document.all['div'+pSRC];
  var dvl= document.all['div_link'+pSRC];

  //tr.style.backgroundColor='#efe8dd';
  if(dv.style.display=='none'){
    dv.style.display="";
    dvl.style.display="";
  }else{
    dv.style.display="none";
    dvl.style.display="none";
  }
 return false;
}

//Function reset_form resets form
function reset_form() {
  document.changetype.reset();
}

//Function reset_form2() sets docName and keyWords document elements to ""
function reset_form2() {
  document.changetype.docName.value = "";
  document.changetype.keyWords.value = "";

}

// Function markSearch sets fields_filled document element to "YES"
function markSearch(){
  if(isSearchForm)
    document.changetype.fields_filled.value="YES";
}

//This function submits "forumselect" form
function change_forum(){
    document.forms["forumselect"].submit();
    return true;
}

//Function change_visibility makes visible and unvisible block of page (for Forum PAGE ONLY). Gets ID block
// of page as parameter
function change_visibility2(pSRC){
  var dv = document.all['div'+pSRC];
  if(dv.style.display=='none'){
    dv.style.display="";
  }else{
    dv.style.display="none";
  }
 return false;
}

