/*------------------------------------ RIP Search ---------------------------------*/

function XMLHttpBrouser() {
  if (document.all) {
    var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
  } else {
    var XhrObj = new XMLHttpRequest();
  }
  return XhrObj;
}

function sendDataSearch(v1,v2) {
  var XhrObj = XMLHttpBrouser();
  XhrObj.open("POST", "s1.asp");
  XhrObj.onreadystatechange = function() {
    if (XhrObj.readyState == 4 && XhrObj.status == 200) {
      eval(XhrObj.responseText);
    }
  }
  XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  XhrObj.send("id="+v1+"&v2="+v2);
}


//-------------------------------------------------------------------------------

function get_daysofmonth(monthNo, p_year) { 
  var anneeBiss = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  var anneeNorm = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  monthNo = eval(monthNo)-1;

  
  if ((p_year%4==0&&p_year%100!=0)||p_year%400==0) {
	return anneeBiss[monthNo];
  } else {
    return anneeNorm[monthNo];
  }	
}

function dateok(ladate) {
	jour=ladate.substring(0,ladate.indexOf("/"));
	mois=ladate.substring(ladate.indexOf("/")+1, ladate.lastIndexOf("/"));
	annee=ladate.substring(ladate.lastIndexOf("/")+1);
	if ((jour.length != 2) || (mois.length != 2) || (annee.length != 4)) {
	  return false;
	} else {
	  moismax = get_daysofmonth(mois,annee);
	  if ((jour>0 && jour<=moismax) && (mois>0 && mois<13) && (annee>=1900 && annee<=2200)) {
		return true;
	  } else {
		return false;
	  }
    }
}


function MM_validateForm2() {
  var errors = ''
  
  var form = document.form1
  
  if (form.from.value.length > 0) {
    if (!dateok(form.from.value)) {
      errors += '- Date format: From (jj/mm/aaaa)\n';
    }
  }
  
  if (form.to.value.length > 0) {
    if (!dateok(form.to.value)) {
       errors += '- Date format: to (jj/mm/aaaa)\n';
    }
  }
  
  if (errors) {
    alert('The following error(s) occurred:\n'+errors)
  } 
  document.MM_returnValue = (errors == '');
}

function resetform() {
    var form = document.form1;
    form.Surname.value = "";
    form.CountyID.options[0].selected = true;
	form.TownID.options[0].selected = true;
    form.from.value = "";
    form.to.value = "";

    var s = document.forms["form1"].elements["TownID"];  
    s.options.length = 1;

}

