
function printme(url)
{
window.open(url,'printpreview','height=600 width=800,scrollbars');
}

function statechanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("div1").innerHTML=xmlHttp.responseText;
}     
}

function getdetails(url)
{
document.getElementById("div1").innerHTML="<br><br><br><br><br><br><center><img src='Loading1.gif'><br>Loading....</center>";
xmlHttp=init();
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function getnewcmhvars()
{
	var vars=null;
	vars="allow=ok";
for(i=0;i<document.medication.condition_med1.length;i++)
{
	if(document.medication.condition_med1[i].checked)
	{
	vars=vars+"&condition_med1="+encodeURIComponent(document.medication.condition_med1[i].value);
	}
}
for(i=0;i<document.medication.condition_med2.length;i++)
{
	if(document.medication.condition_med2[i].checked)
	{
       vars=vars+"&condition_med2="+encodeURIComponent(document.medication.condition_med2[i].value);
	}
}
for(i=0;i<document.medication.condition_med3.length;i++)
{
	if(document.medication.condition_med3[i].checked)
	{
       vars=vars+"&condition_med3="+encodeURIComponent(document.medication.condition_med3[i].value);
	}
}
for(i=0;i<document.medication.condition_med4.length;i++)
{
	if(document.medication.condition_med4[i].checked)
	{
       vars=vars+"&condition_med4="+encodeURIComponent(document.medication.condition_med4[i].value);
	}
}
for(i=0;i<document.medication.condition_med5.length;i++)
{
	if(document.medication.condition_med5[i].checked)
	{
       vars=vars+"&condition_med5="+encodeURIComponent(document.medication.condition_med5[i].value);
	}
}
for(i=0;i<document.medication.condition_med6.length;i++)
{
	if(document.medication.condition_med6[i].checked)
	{
       vars=vars+"&condition_med6="+encodeURIComponent(document.medication.condition_med6[i].value);
	}
}
for(i=0;i<document.medication.condition_med7.length;i++)
{
	if(document.medication.condition_med7[i].checked)
	{
       vars=vars+"&condition_med7="+encodeURIComponent(document.medication.condition_med7[i].value);
	}
}

for(i=0;i<document.medication.condition_med8.length;i++)
{
	if(document.medication.condition_med8[i].checked)
	{
	vars=vars+"&condition_med8="+encodeURIComponent(document.medication.condition_med8[i].value);
	}
}
for(i=0;i<document.medication.condition_med9.length;i++)
{
	if(document.medication.condition_med9[i].checked)
	{
       vars=vars+"&condition_med9="+encodeURIComponent(document.medication.condition_med9[i].value);
	}
}
for(i=0;i<document.medication.condition_med10.length;i++)
{
	if(document.medication.condition_med10[i].checked)
	{
       vars=vars+"&condition_med10="+encodeURIComponent(document.medication.condition_med10[i].value);
	}
}
for(i=0;i<document.medication.condition_med11.length;i++)
{
	if(document.medication.condition_med11[i].checked)
	{
       vars=vars+"&condition_med11="+encodeURIComponent(document.medication.condition_med11[i].value);
	}
}
for(i=0;i<document.medication.condition_med12.length;i++)
{
	if(document.medication.condition_med12[i].checked)
	{
       vars=vars+"&condition_med12="+encodeURIComponent(document.medication.condition_med12[i].value);
	}
}
for(i=0;i<document.medication.condition_med13.length;i++)
{
	if(document.medication.condition_med13[i].checked)
	{
       vars=vars+"&condition_med13="+encodeURIComponent(document.medication.condition_med13[i].value);
	}
}
for(i=0;i<document.medication.condition_med14.length;i++)
{
	if(document.medication.condition_med14[i].checked)
	{
       vars=vars+"&condition_med14="+encodeURIComponent(document.medication.condition_med14[i].value);
	}
}

for(i=0;i<document.medication.condition_med15.length;i++)
{
	if(document.medication.condition_med15[i].checked)
	{
	vars=vars+"&condition_med15="+encodeURIComponent(document.medication.condition_med15[i].value);
	}
}
for(i=0;i<document.medication.condition_med16.length;i++)
{
	if(document.medication.condition_med16[i].checked)
	{
       vars=vars+"&condition_med16="+encodeURIComponent(document.medication.condition_med16[i].value);
	}
}
for(i=0;i<document.medication.condition_med17.length;i++)
{
	if(document.medication.condition_med17[i].checked)
	{
       vars=vars+"&condition_med17="+encodeURIComponent(document.medication.condition_med17[i].value);
	}
}

for(i=0;i<document.medication.condition_med18.length;i++)
{
	if(document.medication.condition_med18[i].value!=null)
	{
       vars=vars+"&condition_med18="+encodeURIComponent(document.medication.condition_med18[i].value);
	}
}

//alert(vars);
return vars;
}

function addcmh()
{
	var vars=null;
	vars=getnewcmhvars();
	document.getElementById("div1").innerHTML="<center><br><br><br><br><b>Adding Conditional Medication History....Please Wait....</b></center>";
	xmlHttp=init();
	xmlHttp.onreadystatechange=statechanged;
	xmlHttp.open("POST","cmhadded.asp",true);
	xmlHttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("content-length",vars.length);
	xmlHttp.setRequestHeader("connection","open");
	xmlHttp.send(vars);
}

function delcmh(id,user)
{
var answer=confirm("Are you sure to delete?");
if(answer)
{
xmlHttp=init();
document.getElementById("div1").innerHTML="<center><br><br><br><br><b>Deleting....Please wait....</b></center>";
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("GET","cmh_list.asp?mode=remove&id="+id+"&user="+user,true);
xmlHttp.send(null);
}
}
function getcmhvars()
{
var i;
var vars;
var vars="medstat=";
var vars=vars+encodeURIComponent(document.form1.medstat[document.form1.medstat.selectedIndex].value);
var vars=vars+"&medcond=";
var vars=vars+encodeURIComponent(document.form1.medcond[document.form1.medcond.selectedIndex].value);
var vars=vars+"&onsetdate=";
var vars=vars+encodeURIComponent(document.getElementById("onsetdate").value);
var vars=vars+"&resolutiondate=";
var vars=vars+encodeURIComponent(document.getElementById("resolutiondate").value);
var vars=vars+"&treatmentdate=";
var vars=vars+encodeURIComponent(document.getElementById("treatmentdate").value);
for(i=1;i<=6;i++)
{
var chk;
if(document.getElementById("treatment"+i).checked==true)
{
chk="True";
}
else
{
chk="False";
}
var vars=vars+"&treatment"+i+"=";
var vars=vars+chk;
//var vars=vars+document.getElementById("treatment"+i).checked;
}
var vars=vars+"&clinician=";
var vars=vars+encodeURIComponent(document.getElementById("clinician").value);
var vars=vars+"&comment=";
var vars=vars+encodeURIComponent(document.getElementById("comment").value);
return vars;
}

//adding details to CMH
function addrecord(id,user)
{
xmlHttp=init();
//alert(document.getElementById("medstat").value);
vars=getcmhvars();
document.getElementById("div1").innerHTML="<br><br><br><br><center><b>Updating Conditional Medication histor....Please Wait.....</b></center>"
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("POST","cmhdetailsadded.asp?id="+id+"&user="+user,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", vars.length);
xmlHttp.setRequestHeader("Connection", "open");
xmlHttp.send(vars);
}

function getimmunizationvars()
{
var vars=null;
vars="Allow=OK";
for(i=0;i<document.form1.immunization.length;i++)
{
	if(document.form1.immunization[i].checked)
	{
	vars=vars+"&immunization="+document.form1.immunization[i].value;
	}
}
for(i=0;i<document.form1.immunization1.length;i++)
{
	vars=vars+"&immunization1="+document.form1.immunization1[i].value;
}
return vars;
}

function addimmunization()
{
	var vars=getimmunizationvars();
	document.getElementById("div1").innerHTML="<center><br><br><br><br><b>Adding Immunization....Please Wait....</b></center>";
	xmlHttp=init();
	xmlHttp.onreadystatechange=statechanged;
	xmlHttp.open("POST","immunizationadded.asp",true);
	xmlHttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("content-length",vars.length);
	xmlHttp.setRequestHeader("connection","open");
	xmlHttp.send(vars);
}

function delimmunization(id,user)
{
var answer=confirm("Are you sure to delete?");
if(answer)
{
xmlHttp=init();
document.getElementById("div1").innerHTML="<center><br><br><br><br><b>Deleting Immunization....Please Wait....</b></center>";
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("GET","immunization_list.asp?mode=remove&id="+id+"&user="+user,true);
xmlHttp.send(null);
}
}

function getvars_immunization()
{
var vars;
vars="dosedate=";
vars=vars+encodeURIComponent(document.getElementById("dosedate").value);
vars=vars+"&doseby=";
vars=vars+encodeURIComponent(document.getElementById("providedby").value);
vars=vars+"&comment=";
vars=vars+encodeURIComponent(document.getElementById("comment").value);
return vars;
}

function addimmunizationdetails(id,user)
{
document.getElementById("mytd").innerHTML="<center>Please wait....<br></center>";
var url="immunizationdetailsadded.asp?id="+id+"&user="+user+"&mode=add";
//alert(url);
var var1=getvars_immunization();
//alert(var1);
xmlHttp=init();
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", var1.length);
xmlHttp.setRequestHeader("Connection", "open");
xmlHttp.send(var1);
}

function getallergyvars()
{
var vars=null;
vars="Allow=OK";
for(i=0;i<document.form1.allergy1.length;i++)
{
	if(document.form1.allergy1[i].checked)
	{
		vars=vars+"&allergy1="+encodeURIComponent(document.form1.allergy1[i].value);
	}
}
for(i=0;i<document.form1.allergy2.length;i++)
{
	if(document.form1.allergy2[i].checked)
	{
		vars=vars+"&allergy2="+encodeURIComponent(document.form1.allergy2[i].value);
	}
}

for(i=0;i<document.form1.allergy3.length;i++)
{
	if(document.form1.allergy3[i].checked)
	{
		vars=vars+"&allergy3="+encodeURIComponent(document.form1.allergy3[i].value);
	}
}

for(i=0;i<document.form1.allergy4.length;i++)
{
	if(document.form1.allergy4[i].checked)
	{
		vars=vars+"&allergy4="+encodeURIComponent(document.form1.allergy4[i].value);
	}
}

for(i=0;i<document.form1.allergy5.length;i++)
{
	if(document.form1.allergy5[i].checked)
	{
		vars=vars+"&allergy5="+encodeURIComponent(document.form1.allergy5[i].value);
	}
}

for(i=0;i<document.form1.allergy6.length;i++)
{
	if(document.form1.allergy6[i].checked)
	{
		vars=vars+"&allergy6="+encodeURIComponent(document.form1.allergy6[i].value);
	}
}

for(i=0;i<document.form1.allergy7.length;i++)
{
	if(document.form1.allergy7[i].checked)
	{
		vars=vars+"&allergy7="+encodeURIComponent(document.form1.allergy7[i].value);
	}
}

for(i=0;i<document.form1.allergy8.length;i++)
{
		vars=vars+"&allergy8="+encodeURIComponent(document.form1.allergy8[i].value);
}
return vars;

}

function addnewallergy()
{
	var vars=null;
	vars=getallergyvars();
	document.getElementById("div1").innerHTML="<center><br><br><br><br><b>Adding Allergy....Please Wait....</b></center>";
	xmlHttp=init();
	xmlHttp.onreadystatechange=statechanged;
	xmlHttp.open("POST","Allergy_list.asp?mode=Add",true);
	xmlHttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("content-length",vars.length);
	xmlHttp.setRequestHeader("connection","open");
	xmlHttp.send(vars);
	alert('Allergies added successfully');
}


function editdosedetails(id,user,doseid)
{
//alert(id);
document.getElementById("updatetable").style.visibility="visible";
if(navigator.appName=="Microsoft Internet Explorer")
{
document.getElementById("editdosedate").value=document.getElementById("dosedate"+doseid).innerText;
document.getElementById("editdoseby").value=document.getElementById("doseby"+doseid).innerText;
document.getElementById("editcomment").value=document.getElementById("comment"+doseid).innerText;
document.getElementById("hiddendoseid").value=doseid;
document.getElementById("activeuser").value=user;
document.getElementById("normalid").value=id;
}
else if(navigator.appName=="Netscape")
{
document.getElementById("editdosedate").value=document.getElementById("dosedate"+doseid).textContent;
document.getElementById("editdoseby").value=document.getElementById("doseby"+doseid).textContent;
document.myform.editcomment.value =document.getElementById("comment"+doseid).textContent;
document.getElementById("hiddendoseid").value=doseid;
document.getElementById("activeuser").value=user;
document.getElementById("normalid").value=id;
}
else
{
alert("Your browser does not support Javascript");
}
}

function updatedosedetailshere()
{
alert("Dose details updated");
xmlHttp=init();
document.getElementById("mytd").innerHTML="<center>Please wait....<br></center>";
var doseid=document.getElementById("hiddendoseid").value;
var id=document.getElementById("normalid").value;
var user=document.getElementById("activeuser").value;
var url;
var url="immunizationdetailsadded.asp?id="+id+"&doseid="+doseid+"&user="+user+"&mode=update";
//alert(url);
var vars;
vars="dosedate=";
vars=vars+encodeURIComponent(document.getElementById("editdosedate").value);
vars=vars+"&doseby=";
vars=vars+encodeURIComponent(document.getElementById("editdoseby").value);
vars=vars+"&comment=";
vars=vars+encodeURIComponent(document.myform.editcomment.value);
//alert(vars);
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("content-length",vars.length);
xmlHttp.setRequestHeader("connection","open");
xmlHttp.send(vars);
}

function deletedosedetails(id,user,doseid)
{
var answer;
answer=confirm("Are you sure To delete this record?")
if(answer)
{
document.getElementById("mytd").innerHTML="<center>Deleting....Please wait....<br></center>";
var url="immunizationdetailsadded.asp?id="+id+"&user="+user+"&doseid="+doseid+"&mode=delete";
xmlHttp=init();
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
}

function getvars_allergy()
{
var vars;
vars="reactions=";
vars=vars+encodeURIComponent(document.getElementById("reactions").value);
for(i=1;i<=16;i++)
{
var vars=vars+"&reaction"+i+"=";
var vars=vars+document.getElementById("reaction"+i).checked;
}
vars=vars+"&onsetdate=";
vars=vars+encodeURIComponent(document.getElementById("onsetdate").value);
vars=vars+"&resolutiondate=";
vars=vars+encodeURIComponent(document.getElementById("resolutiondate").value);
vars=vars+"&clinician=";
vars=vars+encodeURIComponent(document.getElementById("clinician").value);
vars=vars+"&comment=";
vars=vars+encodeURIComponent(document.getElementById("comment").value);
return vars;
}

function updateallergy(id,user)
{
var var1=getvars_allergy();
xmlHttp=init();
document.getElementById("div1").innerHTML="<br><br><center>Updating....<br></center>";
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("POST","allergydetailsadded.asp?id="+id+"&user="+user,true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", var1.length);
xmlHttp.setRequestHeader("Connection", "open");
xmlHttp.send(var1);
}

function delallergy(id,user)
{
var answer=confirm("Are you sure to delete?");
if(answer)
{
document.getElementById("div1").innerHTML="<center><br><br><br><br><b>Deleting Allergy....Please Wait....</b></center>";
xmlHttp=init();
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("GET","allergy_list.asp?mode=remove&id="+id+"&user="+user,true);
xmlHttp.send(null);
}
}

function editsocialhistory()
{
var vars=getsocialhistoryvars()
xmlHttp=init();
document.getElementById("div1").innerHTML="<center><br><br><br><br><b>Updating....Please Wait....</b></center>";
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("POST","updatesocialhistory.asp",true);
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", vars.length);
xmlHttp.setRequestHeader("Connection", "open");
xmlHttp.send(vars);
}


function livingstatvalue()
{
	var cnt=-1;
	for(var i=document.form1.livingstat.length-1;i>-1;i--)
	{
		if(document.form1.livingstat[i].checked)
		{
				cnt=i;
			i=-1;
		}
	}
	if(cnt>-1)
	{
		return document.form1.livingstat[cnt].value
	}
	else
	{
		return null;
	}
}
function addfamilyhistory()
{
	var livingstat;
	livingstat=livingstatvalue();
	var vars;
	vars="Relationship=";
	vars=vars+encodeURIComponent(document.form1.relationship[document.form1.relationship.selectedIndex].value);
	vars=vars+"&membername="+encodeURIComponent(document.form1.membername.value);
	vars=vars+"&birthplace="+encodeURIComponent(document.form1.birthplace.value);
	vars=vars+"&birthyear="+encodeURIComponent(document.form1.birthyear.value);
	vars=vars+"&livingstat="+encodeURIComponent(livingstat);
	vars=vars+"&deathage="+encodeURIComponent(document.form1.deathage.value);
	vars=vars+"&deathyear="+encodeURIComponent(document.form1.deathyear.value);
	vars=vars+"&deathcause="+encodeURIComponent(document.form1.deathcause.value);
	vars=vars+"&comment="+encodeURIComponent(document.form1.comment.value);
	xmlHttp=init();
	document.getElementById("div1").innerHTML="<br><br><br><br><center>Updating....</center>";
	xmlHttp.onreadystatechange=statechanged;
	xmlHttp.open("POST","FamilyHistoryAdded.asp",true);
	xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length",vars.length);
	xmlHttp.setRequestHeader("Connection","open");	
	xmlHttp.send(vars);
}

function hide()
{
document.form1.deathage.value="";
document.form1.deathyear.value="";
document.form1.deathcause.value="";
document.form1.deathage.disabled=true;
document.form1.deathyear.disabled=true;
document.form1.deathcause.disabled=true;
}

function show()
{
document.form1.deathage.disabled=false;
document.form1.deathyear.disabled=false;
document.form1.deathcause.disabled=false;
}

function delfamilyhistory(id)
{
var answer=confirm("Are you sure to delete the record?");
if(answer)
{
	xmlHttp=init();
	xmlHttp.onreadystatechange=statechanged;
	xmlHttp.open("GET","DeleteFamilyHistory.asp?fid="+id,true);
	xmlHttp.send(null);
}
}

function updatefamilyhistory(id)
{
	var livingstat;
	livingstat=livingstatvalue();
	var vars;
	vars="Relationship=";
	vars=vars+encodeURIComponent(document.form1.relationship[document.form1.relationship.selectedIndex].value);
	vars=vars+"&membername="+encodeURIComponent(document.form1.membername.value);
	vars=vars+"&birthplace="+encodeURIComponent(document.form1.birthplace.value);
	vars=vars+"&birthyear="+encodeURIComponent(document.form1.birthyear.value);
	vars=vars+"&livingstat="+encodeURIComponent(livingstat);
	vars=vars+"&deathage="+encodeURIComponent(document.form1.deathage.value);
	vars=vars+"&deathyear="+encodeURIComponent(document.form1.deathyear.value);
	vars=vars+"&deathcause="+encodeURIComponent(document.form1.deathcause.value);
	vars=vars+"&comment="+encodeURIComponent(document.form1.comment.value);
	xmlHttp=init();
	document.getElementById("div1").innerHTML="<br><br><br><br><center>Updating....</center>";
	xmlHttp.onreadystatechange=statechanged;
	xmlHttp.open("POST","FamilyHistoryAdded.asp?mode=update&fid="+id,true);
	xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length",vars.length);
	xmlHttp.setRequestHeader("Connection","open");	
	xmlHttp.send(vars);
}

function getsurgeryvalues()
{
	var cnt,i,vars;
	vars="";
	cnt=0;
	for(i=document.form1.surgery.length-1;i>0;i--)
	{
		if(document.form1.surgery[i].checked)
		{			
			vars=vars+"&surgery="+encodeURIComponent(document.form1.surgery[i].value);
		}
	}
return vars;
}

function addsurgeries()
{
	var xmlHttp,vars="";
	vars="Add=OK";
	vars=vars+getsurgeryvalues();
	for(i=document.form1.others.length-1;i>-1;i--)
	{		
		if(document.form1.others[i].value!="")
		{
		vars=vars+"&others="+encodeURIComponent(document.form1.others[i].value);
		}
	}
xmlHttp=init();
document.getElementById("div1").innerHTML="<br><br><br><br><center>Adding Surgeries</center>";
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("POST","Surgeriesadded.asp",true);
xmlHttp.setRequestHeader("Content-type","Application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length",vars.length);
xmlHttp.setRequestHeader("Connection","open");	
xmlHttp.send(vars);
}

function delsurgery(id)
{
var answer=confirm("Are you sure to delete the record?");
if(answer)
{
alert("Surgery Deleted Successfully");
xmlHttp=init();
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("GET","surgery_list.asp?mode=delete&id="+id,true);
xmlHttp.send(null);
}
}

function getsurgeryvars()
{
	var vars=null;
	vars="SurgeryDate="+encodeURIComponent(document.form1.surgerydate.value);;
	vars=vars+"&surgeryReason="+encodeURIComponent(document.form1.surgeryReason.value);
	vars=vars+"&surgerylocation="+encodeURIComponent(document.form1.surgeryLocation.value);
	vars=vars+"&surgeryResult="+encodeURIComponent(document.form1.surgeryResult.value);
	vars=vars+"&surgeryTakenBy="+encodeURIComponent(document.form1.surgeryTakenBy.value);
	vars=vars+"&surgeryComment="+encodeURIComponent(document.form1.surgeryComment.value);	
return vars;
}

function addsurgerydetails(id)
{
var vars=null;
vars=getsurgeryvars();
document.getElementById("div1").innerHTML="<br><br><center>Adding surgery Details....Please wait....</center>";
xmlHttp=init();
xmlHttp.onreadystatechange=statechanged;
xmlHttp.open("POST","surgerydetailsadded.asp?id="+id,true);
xmlHttp.setRequestHeader("Content-Type","Application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-Length",vars.length);
xmlHttp.setRequestHeader("Connection","Open");
xmlHttp.send(vars);
}

function checknumeric(number,id)
{
if(number!=null)
{
if(!number.toString().match(/^[-]?\d*\.?\d*$/))
{
	alert("Only numeric are allowed in phone number");
	document.getElementById(id).value="";
    document.getElementById(id).focus();
}
}
}

function getdoctorvars()
{
	var vars=null;
	vars="doctorname="+encodeURIComponent(document.form1.name.value);
	vars=vars+"&speciality="+encodeURIComponent(document.form1.speciality[document.form1.speciality.selectedIndex].value);
	vars=vars+"&office_phone="+encodeURIComponent(document.form1.office_phone.value);
	vars=vars+"&home_phone="+encodeURIComponent(document.form1.home_phone.value);
	vars=vars+"&mobile="+encodeURIComponent(document.form1.mobile.value);
	vars=vars+"&email="+encodeURIComponent(document.form1.email.value);
	vars=vars+"&address="+encodeURIComponent(document.form1.address.value);
	vars=vars+"&city="+encodeURIComponent(document.form1.city.value);
	vars=vars+"&state="+encodeURIComponent(document.form1.state.value);
	vars=vars+"&country="+encodeURIComponent(document.form1.country[document.form1.country.selectedIndex].value);
	vars=vars+"&pincode="+encodeURIComponent(document.form1.pincode.value);
	vars=vars+"&website="+encodeURIComponent(document.form1.website.value);
	vars=vars+"&comment="+encodeURIComponent(document.form1.comment.value);
	//alert(vars);
	return vars;
}

function add_doctor()
{
	if(document.form1.name.value.length>0)
	{
	var vars=null;
	vars=getdoctorvars();
	document.getElementById("div1").innerHTML="<center><br><br><br><br><b>Adding Record....Please Wait....</b></center>";
	xmlHttp=init();
	xmlHttp.onreadystatechange=statechanged;
	xmlHttp.open("POST","doctoradded.asp",true);
	xmlHttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("content-length",vars.length);
	xmlHttp.setRequestHeader("connection","open");
	xmlHttp.send(vars);
	}
	else
	{
		alert("Please Enter Doctor/Hospital Name");
	}
}

function deletedoctor(id)
{
	var answer=confirm("Are you sure to delete?");
	if(answer)
	{
		getdetails("Doctor_list.asp?Mode=Delete&id="+id);
	}
}

function update_doctordetails(id)
{
	vars=getdoctorvars();
	document.getElementById("div1").innerHTML="<center><br><br><br><br><b>Updating Record....Please Wait....</b></center>";
	xmlHttp=init();
	xmlHttp.onreadystatechange=statechanged;
	xmlHttp.open("POST","Doctor_list.asp?mode=update&id="+id,true);
	xmlHttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("content-length",vars.length);
	xmlHttp.setRequestHeader("connection","open");
	xmlHttp.send(vars);	
}


function getuserdetailsvars()
{
var vars=null;
vars="Fullname="+encodeURIComponent(document.form1.fullname.value);
vars=vars+"&Email="+encodeURIComponent(document.form1.email.value);
vars=vars+"&Gender="+encodeURIComponent(document.form1.gender[document.form1.gender.selectedIndex].value);
vars=vars+"&Address="+encodeURIComponent(document.form1.address.value);
vars=vars+"&city="+encodeURIComponent(document.form1.city.value);
vars=vars+"&state="+encodeURIComponent(document.form1.state.value);
vars=vars+"&country="+encodeURIComponent(document.form1.country.value);
vars=vars+"&pincode="+encodeURIComponent(document.form1.pincode.value);
vars=vars+"&ContactNo="+encodeURIComponent(document.form1.contactno.value);
vars=vars+"&Height="+encodeURIComponent(document.form1.height.value+" "+document.form1.heightmeasure[document.form1.heightmeasure.selectedIndex].value);
vars=vars+"&Weight="+encodeURIComponent(document.form1.weight.value+" "+document.form1.weightmeasure[document.form1.weightmeasure.selectedIndex].value);
vars=vars+"&BloodGroup="+encodeURIComponent(document.form1.bloodgroup[document.form1.bloodgroup.selectedIndex].value);
return vars;
}

function validateuseribfo()
{
	var flag=true;
	if(document.form1.fullname.value=="" || document.form1.fullname.value==null)
	{
		alert("Enter Your Name");
		document.form1.fullname.focus();
		flag=false;
	}
	return flag;

}

function EditUserDetails()
{
	var flag=null;
	flag=validateuseribfo();
	if(flag==true)
	{
	var vars=null;
	vars=getuserdetailsvars();
	document.getElementById("div1").innerHTML="<center><br><br><br><br><b>Updating Information....Please Wait....</b></center>"
	xmlHttp=init();
	xmlHttp.onreadystatechange=statechanged;
	xmlHttp.open("POST","PersonalInfoUpdated.asp",true);
	xmlHttp.setRequestHeader("Content-Type","Application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-Length",vars.length);
	xmlHttp.setRequestHeader("Connection","open");
	xmlHttp.send(vars);
	}
}

function sendusercredentials()
{
	if(document.form1.username.value=="" || document.form1.username.value==null)
	{
		alert("Enter Username");
	}
	else if(document.form1.password.value=="" || document.form1.password.value==null)
	{
		alert("Enter Password");
	}
	else
	{
		xmlHttp=init();
		var vars=null;
		vars="username="+encodeURIComponent(document.form1.username.value);
		vars=vars+"&password="+encodeURIComponent(document.form1.password.value);
		vars=vars+"&lasturl="+encodeURIComponent(document.form1.lasturl.value);
		document.getElementById("div1").innerHTML="<br><br><br><br><center><b>Logging You In....Please Wait</b></center>";
		xmlHttp.onreadystatechange=statechanged;
		xmlHttp.open("POST","LoggedIn.asp",true);
		xmlHttp.setRequestHeader("Content-Type","Application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-Length",vars.length);
		xmlHttp.setRequestHeader("Connection","Open");
		xmlHttp.send(vars);
	}
}

function get_radio_value(obj,c)
{
	for(i=0;i<c;i++)
	{
			if(obj[i].checked)
				return obj[i].value;
	}
	return " ";
}



function getbloodtestvars()
{
	var vars=null;
	vars="conductedon="+encodeURIComponent(document.form1.conductedon.value);
	vars=vars+"&illness="+encodeURIComponent(document.form1.illness.value);
	vars=vars+"&hemoglobin="+encodeURIComponent(document.form1.hemoglobin.value+" "+get_radio_value(document.form1.hemoglobinmeasure,document.form1.hemoglobinmeasure.length));	
	vars=vars+"&wbccount="+encodeURIComponent(document.form1.wbccount.value+" "+get_radio_value(document.form1.wbcmeasure,document.form1.wbcmeasure.length));	
	vars=vars+"&platelets="+encodeURIComponent(document.form1.platelets.value+" "+get_radio_value(document.form1.paletemeasure,document.form1.paletemeasure.length));	
	vars=vars+"&pcv="+encodeURIComponent(document.form1.pcv.value);
	vars=vars+"&esrrate="+encodeURIComponent(document.form1.esrrate.value);
	vars=vars+"&otherinfo="+encodeURIComponent(document.form1.otherinfo.value);
	vars=vars+"&comment="+encodeURIComponent(document.form1.comment.value);	
	return vars;
}

function AddBloodTest()
{
	var vars=null;
	vars=getbloodtestvars();
	document.getElementById("div1").innerHTML="<br><br><br><br><center><b>Adding....Please Wait....</b></center>"
	xmlHttp=init();
	xmlHttp.onreadystatechange=statechanged;
	xmlHttp.open("POST","BloodTestAdded.asp",true);
	xmlHttp.setRequestHeader("content-type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("content-length",vars.length);
	xmlHttp.setRequestHeader("connection","open");
	xmlHttp.send(vars);
}

function DeleteBloodTest(id)
{
var answer=confirm("Are you sure to delete the record?");
if(answer)
{
	xmlHttp=init();
	xmlHttp.onreadystatechange=statechanged;
	xmlHttp.open("GET","BloodTestDeleted.asp?id="+id,true);
	xmlHttp.send(null);
}
}



function UpdateBloodTest(id)
{
	vars=getbloodtestvars();
	xmlHttp=init();
	document.getElementById("div1").innerHTML="<br><br><br><br><center><b>Updating....Please Wait....</b></center>"
	xmlHttp.onreadystatechange=statechanged;
	xmlHttp.open("POST","BloodTestUpdated.asp?id="+id,true);
	xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length",vars.length);
	xmlHttp.setRequestHeader("Connection","open");
	xmlHttp.send(vars);
}


function validatenumeric(number,size,id,field)
{
	var len=size;
	if(number!=null)
	{
		if(!number.toString().match(/^[-]?\d*\.?\d*$/))
		{
			alert("Enter only numeric in "+field+" number");
			document.getElementById(id).value="";
			//document.getElementById(id).focus();
    		
		}		
		if(number.length!=len)
		{
			alert(field+" must be "+len+" digit numeric")
			document.getElementById(id).value="";
			//document.getElementById(id).focus();
    		
		}
	}
}

function validaterangenumeric(number,minvalue,maxvalue,id,field,message)
{
	if(number!=null)
	{
		if(!number.toString().match(/^[-]?\d*\.?\d*$/))
		{
			alert("Enter only numeric in "+field+" number");
			document.getElementById(id).value="";
			//document.getElementById(id).focus();
    		
		}		
		if(number<minvalue)
		{
			alert(field+" value is low message");
			//document.getElementById(id).value="";  
  			//document.getElementById(id).focus();
		}
	}
}