function getXMLHttp()
{
  var xmlHttp

  try
  {
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    //Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}

function MakeRequest(resno,catid,mode)
{
  var xmlHttp = getXMLHttp();
  
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse(xmlHttp.responseText,resno);
    }
  }
var url1="ajax.php?catid="+catid+"&resno="+resno+"&mode="+mode;

  xmlHttp.open("GET", url1, true); 
  xmlHttp.send(null);
}

function MakeUpdate(resno,catid,mode)
{
  var xmlHttp = getXMLHttp();
  
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse(xmlHttp.responseText,resno);
    }
  }
  var catname=document.getElementById("category").value;
  
  if(catname.length>25)
	{
		alert("Your tree name cannot be exceded more than 25 characters.");	
		//MakeRequest('1','{$categoryid1}','edit');

	}
	if(!/^([a-z A-Z.])+$/.test(catname))
	{
		alert("Enter Your tree name in alphabet.");	
		//MakeRequest('1','{$categoryid1}','edit');

	}
	else {
  
var url1="ajax.php?catid="+catid+"&resno="+resno+"&mode="+mode+"&catname="+catname;
  xmlHttp.open("GET", url1, true); 
  xmlHttp.send(null);
	}
}

function HandleResponse(response,resno)
{

	var divna='ResponseDiv'+resno;
		var divdob='divdob'+resno;
  document.getElementById(divna).innerHTML = response;

}
// date of Bearth
function MakeRequestDOB(resno,catid,mode)
{
  var xmlHttp = getXMLHttp();
  
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse1(xmlHttp.responseText,resno);
    }
  }
var url1="ajaxdob.php?catid="+catid+"&resno="+resno+"&mode="+mode;

  xmlHttp.open("GET", url1, true); 
  xmlHttp.send(null);
}

function MakeRequestTname(resno,catid,mode)
{
	
  var xmlHttp = getXMLHttp();
  
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponseim(xmlHttp.responseText,resno);
    }
  }
var url1="ajaxTname.php?catid="+catid+"&resno="+resno+"&mode="+mode;

  xmlHttp.open("GET", url1, true); 
  xmlHttp.send(null);
}
function MakeUpdateim(resno,catid,mode)
{
  var xmlHttp = getXMLHttp();
  
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponseim(xmlHttp.responseText,resno);
    }
  }
  var catname=document.getElementById("category").value;
  
  if(catname.length>25)
	{
		alert("Your tree name cannot be exceded more than 25 characters.");	
		//return false;
	}
	
	else {
var url1="ajaxTname.php?catid="+catid+"&resno="+resno+"&mode="+mode+"&category="+catname;
  xmlHttp.open("GET", url1, true); 
  xmlHttp.send(null);
	}
}

function HandleResponseim(response,resno)
{
	

	var divna='divim';
		
  document.getElementById(divna).innerHTML = response;

}
function MakeUpdatedob(resno,catid,mode)
{
  var xmlHttp = getXMLHttp();
  
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse1(xmlHttp.responseText,resno);
    }
  }
  var catname=document.getElementById("category").value;
  var memdod=document.getElementById("dodofmem").value;
  var curyear = new Date();
  var yearBirth = curyear.getFullYear();
   //if(catname.length>4)
   if(!/^(\d{4})$/.test(catname))
	{
		alert("Pleae insert correct Birth Year.");	
		
	}
	if(catname>yearBirth)
	{
		alert("Pleae insert correct Birth Year.");	
		
	}
	if((catname>memdod) && (memdod!=""))
	{
		alert("Pleae insert correct Birth Year.");	
		
	}
	if(!/^[0-9]+$/.test(catname))
	{
		alert("Enter Numbers Only.");	
		//MakeRequest('1','{$categoryid1}','edit');

	}
	else {
		
var url1="ajaxdob.php?catid="+catid+"&resno="+resno+"&mode="+mode+"&catname="+catname;
  xmlHttp.open("GET", url1, true); 
  xmlHttp.send(null);
	}
}

function HandleResponse1(response1,resno)
{

	
		var divdob='divdob'+resno;
   document.getElementById(divdob).innerHTML = response1;
}
// date of Death
function MakeRequestDOD(resno,catid,mode)
{
  var xmlHttp = getXMLHttp();
  //by ajay
  
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse2(xmlHttp.responseText,resno);
    }
  }
var url1="ajaxdod.php?catid="+catid+"&resno="+resno+"&mode="+mode;

  xmlHttp.open("GET", url1, true); 
  xmlHttp.send(null);
}
function MakeUpdatedod(resno,catid,mode)
{
  var xmlHttp = getXMLHttp();
  
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse2(xmlHttp.responseText,resno);
    }
  }
  var catname=document.getElementById("category").value;
  var memdob=document.getElementById("dobofmem").value;
  var curyear1 = new Date();
  var yearDeath = curyear1.getFullYear();
 /* if(catname.length>4)
	{
		alert("Pleae insert correct Death Year.");	
	}*/
	if(!/^(\d{4})$/.test(catname))
	{
		alert("Pleae insert correct Death Year.");	
	}
	if(catname>yearDeath)
	{
		alert("Pleae insert correct Death Year.");	
		
	}
	if((memdob==""))
	{
		alert("Pleae insert correct Birth Year first.");	
		}
	else if((catname<memdob) && (memdob!=""))
	{
		alert("Death Year must greater then Birth Year.");	
		
	}
	if(!/^[0-9]+$/.test(catname))
	{
		alert("Enter Numbers Only.");	
		//MakeRequest('1','{$categoryid1}','edit');

	}
	
	else {
var url1="ajaxdod.php?catid="+catid+"&resno="+resno+"&mode="+mode+"&catname="+catname;
  xmlHttp.open("GET", url1, true); 
  xmlHttp.send(null);
	}
}

function HandleResponse2(response2,resno)
{

	
		var divdob='divdod'+resno;
   document.getElementById(divdob).innerHTML = response2;
}

//// image
//
//function MakeRequestimg(resno,catid,mode)
//{
//  var xmlHttp = getXMLHttp();
//  
//  xmlHttp.onreadystatechange = function()
//  {
//    if(xmlHttp.readyState == 4)
//    {
//      HandleResponse(xmlHttp.responseText,resno);
//    }
//  }
//var url1="ajaximg.php?catid="+catid+"&resno="+resno+"&mode="+mode;
//
//  xmlHttp.open("GET", url1, true); 
//  xmlHttp.send(null);
//}
//
//function MakeUpdateimg(resno,catid,mode)
//{
//  var xmlHttp = getXMLHttp();
//  
//  xmlHttp.onreadystatechange = function()
//  {
//    if(xmlHttp.readyState == 4)
//    {
//      HandleResponse(xmlHttp.responseText,resno);
//    }
//  }
//  var catname=document.getElementById("category").value;
//var url1="ajaximg.php?catid="+catid+"&resno="+resno+"&mode="+mode+"&catname="+catname;
//  xmlHttp.open("GET", url1, true); 
//  xmlHttp.send(null);
//}
//
//function HandleResponse(responseimg,resno)
//{
//
//	
//		var divimg='divimg'+resno;
//  document.getElementById(divimg).innerHTML = responseimg;
//
//}