// JavaScript Document
function familyValidation()
{
	if(document.frmFamily.txtFamily.value=='')
	{
		alert("Enter Plant Family");
		document.frmFamily.txtFamily.focus();
		return false;
	}
	else
	{
		document.frmFamily.action="Familyprocess.php";
		document.frmFamily.submit();
	}
}

function refernceValidation()
{
	if(document.frmReference.txtReference.value=='')
	{
		alert("Enter Reference Title");
		document.frmReference.txtReference.focus();
		return false;
	}
	else
	{
		document.frmReference.action="Referenceprocess.php";
		document.frmReference.submit();
	}
}

function plantValidation()
{
	if(document.frmPlant.Family.value=='Select')
	{
		alert("Select Plant Family");
		document.frmPlant.Family.focus();
		return false;
	}
	else if(document.frmPlant.txtBname.value=='')
	{
		alert("Enter Botnical Name");
		document.frmPlant.txtBname.focus();
		return false;
	}
	else
	{
		document.frmPlant.action="Plantprocess.php";
		document.frmPlant.submit();
	}
	
}
function updateplantValidation()
{
	if(document.frmPlant.Family.value=='Select')
	{
		alert("Select Plant Family");
		document.frmPlant.Family.focus();
		return false;
	}
	else if(document.frmPlant.txtBname.value=='')
	{
		alert("Enter Botnical Name");
		document.frmPlant.txtBname.focus();
		return false;
	}
	else
	{
		document.frmPlant.action="updatePlantDetail.php";
		document.frmPlant.submit();
	}
}
function editFamilyValidation()
{
	if(document.frmFamily.txtFamily.value=='')
	{
		alert("Enter Plant Family");
		document.frmFamily.txtFamily.focus();
		return false;
	}
	else
	{
		document.frmFamily.action="Familyprocess.php";
		document.frmFamily.submit();
	}
}
function ask()
{
	if(confirm('Are you sure ?'))
	{
		return true;
	}
	else
	{
		return false;
	}
}
function selectallrows(chked)
{
	var chks = document.getElementsByTagName('INPUT');
	for(i=0;i<chks.length;i++)
	{
		if(chks[i].type=='checkbox')
		{
			chks[i].checked = chked;
		}
	}
}
function family_delete()
{
	document.frmFamily.action="familyDelete.php";
	document.frmFamily.submit();
}
/**********************************For Create The Object Of Ajax ********************************************/
function getXMLHTTP() { 
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
/********************************For Getting List Of Family Which User Enter in Text Box************************/
function getFamilyData() {		
		
		var fam=document.getElementById('txtFamily').value;
		var strURL="family_list.php?family="+fam;
		var req = getXMLHTTP();
		
		
		if (req) {
	
				req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('family_list').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
	}
/******************************Check Family Name Alredy Exiest or Not*******************************************/
function chkfamily(val) {		
		var strURL="check_family.php?family="+val;
		var req = getXMLHTTP();
		
		
		if (req) {
	
				req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('check_family').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
	}
	
/******************************Check Family Name Alredy Exiest or Not*******************************************/
function chkreference(val) {		
		var strURL="check_reference.php?ref="+val;
		var req = getXMLHTTP();
		
		
		if (req) {
	
				req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('check_reference').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
	}
	
/****************************Check Botnical Name Available or Not***********************************************/
function chkbotnical(val) {		
		var strURL="check_botnical.php?bot="+val;
		var req = getXMLHTTP();
		
		
		if (req) {
	
				req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('check_botnical').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
	}

/*********************************To Delete Multiple Family*****************************************************/
function multiDeleteFamily()
{
	document.frmFamily.action="family_multi_delete.php";
	document.frmFamily.submit();
}
/********************************For Getting List Of Plant Which User Enter in Text Box************************/
function getPlantData() {		
		
		var bot=document.getElementById('txtBotnical').value;
		var fam=document.getElementById('txtFamily').value;
		var strURL="plant_list.php?family="+fam+"&bot="+bot;
		var req = getXMLHTTP();
		
		
		if (req) {
	
				req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('plant_list').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
	}
	
/********************************Change Password Validation**************************************************/
function passvalidation()
{
	if(document.frmpass.txtCpass.value=='')
	{
		alert("Please Enter Old Password");
		document.frmpass.txtCpass.focus();
		return false;
	}
	else if(document.frmpass.txtpass.value=='')
	{
		alert("Please Enter New Password");
		document.frmpass.txtpass.focus();
		return false;
	}
	else if(document.frmpass.txtConpass.value=='')
	{
		alert("Please Enter New Conformation Password");
		document.frmpass.txtConpass.focus();
		return false;
	}
	else if(document.frmpass.txtpass.value==document.frmpass.txtConpass.value)
	{
		alert("New Password & Conformation Password Must be Same");
		document.frmpass.txtpass.focus();
		return false;
	}
	else
	{
		document.frmpass.action="changepassprocess.php";
		document.frmpass.submit();
	}
}
/*********************************Add User Validation*********************************************************/
function validateUser()
{
	if(document.frm_adduser.txtUserName.value=='')
	{
		alert("Please Enter User Name");
		document.frm_adduser.txtUserName.focus();
		return false;
	}
	else if(document.frm_adduser.txtUserPassword.value=='')
	{
		alert("Please Enter Password");
		document.frm_adduser.txtUserPassword.focus();
		return false;
	}
	else
	{
		document.frm_adduser.action="userprocess.php";
		document.frm_adduser.submit();
	}
	
}
/***********************User Validation When User Update Information******************************************/
function validateUpdateUser()
{
	if(document.frm_adduser.txtUserName.value=='')
	{
		alert("Please Enter User Name");
		document.frm_adduser.txtUserName.focus();
		return false;
	}
	else
	{
		document.frm_adduser.action="userprocess.php";
		document.frm_adduser.submit();
	}
}

/****************************Check User Name Available or Not***********************************************/
function chkuser(val) {		
		var strURL="check_user.php?user="+val;
		var req = getXMLHTTP();
		
		
		if (req) {
	
				req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('check_user').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
	}
/***********************Delete Multiple User****************************************************************/
function multiDeleteUser()
{
	document.manage_user.action="user_multi_delete.php";
	document.manage_user.submit();
}

/***********************Select Data Accroding to Botnical Name**************************************************/
function select_plant(val)
{
	document.form1.action="index.php?id="+val;
	document.form1.submit();
}
/**********************Select Plant Data Accroding to Plant Family Select*************************************/
function select_family(val)
{
	document.form1.action="index.php?fid="+val;
	document.form1.submit();
}
/***************************************Find Name of Plants Which Value not inserted for selected lanaguage****/
function plant_name(val) {		
		
		var strURL="find_remain_plant.php?lan="+val;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('plant_list').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}


