function getXMLHTTP() { //fuction to return the xml http object

		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;

}


function getdoctors(sp_id)
{
       
	var strURL="getdoctors.php?sp_id="+sp_id

		var req = getXMLHTTP();



		if (req) {



			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {

					 document.getElementById('doctors').innerHTML=req.responseText;
					  }


					  else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}

			}
			req.open("GET", strURL, true);
			req.send(null);

		}
}

function askpassword()
{

	var obj=document.getElementById('doctor_name')

	var strURL="askpassword.php?doctor_id="+obj.value;



		var req = getXMLHTTP();



		if (req) {



			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {

					 document.getElementById('check').innerHTML=req.responseText;
					  }


					  else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}

			}

			req.open("GET", strURL, true);

			req.send(null);

		}






}

function askpassword()
{

	var obj=document.getElementById('doctor_name')

	var strURL="askpassword.php?doctor_id="+obj.value;



		var req = getXMLHTTP();



		if (req) {



			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {

					 document.getElementById('check').innerHTML=req.responseText;
					  }


					  else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}

			}

			req.open("GET", strURL, true);

			req.send(null);

		}






}

function loaddcotors(speciality,first_name,gender,working_day,num)
{

       var strURL="loaddcotors.php?speciality="+speciality+"&first_name="+first_name+"&gender="+gender+"&working_day="+working_day+"num="+num;

		var req = getXMLHTTP();



		if (req) {



			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {

					 document.getElementById('doctor_list').innerHTML=req.responseText;
					  }


					  else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}

			}

			req.open("GET", strURL, true);

			req.send(null);

		}







}


function doctorslist(sp_id)
{

	var strURL="doctorslist.php?sp_id="+sp_id
        document.getElementById("get_time").innerHTML="";
        document.getElementById("app_date").value="";

		var req = getXMLHTTP();



		if (req) {



			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {

					 document.getElementById('doctorlist').innerHTML=req.responseText;
					  }


					  else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}

				else
				 document.getElementById('doctorlist').innerHTML='<img src="images/Loading-01.gif" width="24" height="24" align="absmiddle" id="LoadingControl1_Image1" style="border-width: 0px;"/>'

			}

			req.open("GET", strURL, true);

			req.send(null);

		}






}


function docdetails(doctor_id)
{
        
	var strURL="docdetails.php?doctor_id="+doctor_id

        

		var req = getXMLHTTP();



		if (req) {



			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {
                                         document.getElementById('UpdateProgress1').innerHTML=req.responseText;
                                         var available=document.getElementById('availability');
                                         if(available.value==0){
                                             // alert("Please contact to our telephonic contact number +91 495 3091091");
                                             $("#error_appointment").hide();
                                         }
                                         else{
                                              $("#error_appointment").show();
                                         }
                                        var dt=document.getElementById("app_date").value;
                                        if(dt!="")
                                        {
                                                    setdatedisplay(dt,doctor_id);
                                        }
					 
                                     }


					  else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}

				else
				 document.getElementById('UpdateProgress1').innerHTML='<img src="images/Loading-01.gif" width="24" height="24" align="absmiddle" id="LoadingControl1_Image1" style="border-width: 0px;"/><span style="font-weight: bold;" id="LoadingControl1_lblTextToShow">&nbsp;Loading doctor of your choice...</span>'

			}

			req.open("GET", strURL, true);

			req.send(null);

		}






}


function showdoctors(sp_id)
{

	var strURL="showdoctors.php?sp_id="+sp_id


		var req = getXMLHTTP();



		if (req) {



			req.onreadystatechange = function() {

				if (req.readyState == 4) {

					// only if "OK"

					if (req.status == 200) {

					 document.getElementById('docs').innerHTML=req.responseText;
					  }


					  else {

						alert("There was a problem while using XMLHTTP:\n" + req.statusText);

					}

				}

				else
				 document.getElementById('docs').innerHTML='<img src="images/Loading-01.gif" width="24" height="24" align="absmiddle" id="LoadingControl1_Image1" style="border-width: 0px;"/>'

			}

			req.open("GET", strURL, true);

			req.send(null);

		}

		var obj=document.getElementById('hidediv');
		obj.style.display='none';




}
function setdatedisplay(seldate, did){

    var arr = seldate.split("/");
    var m=arr[0];
    var d=arr[1];
    var y=arr[2];
     r=document.form1;
var res=document.getElementById('oth_dob');
                                                
                                                            if(r.speciality.value=="")
                                                            {
                                                                if(res.value==""){
                                                                    alert("Please choose speciality");
                                                                }
                                                                r.speciality.focus();
                                                                r.app_date.value="";
                                                                return false;
                                                            }

                                                            if(r.DoctorName.value=="")
                                                            {
                                                                 if(res.value==""){
                                                                     alert("Please choose doctor name");
                                                                 }
                                                                r.DoctorName.focus();
                                                                r.app_date.value="";
                                                                return false;
                                                            }
                                                            
                                                            
  var strURL="doctortime.php?day="+d+"&month="+m+"&year="+y+"&did="+did;
  // alert(strURL);
   var req = getXMLHTTP();
            if (req) { 
                        req.onreadystatechange = function() {
                        
                        if (req.readyState == 4) {

					// only if "OK"
                                        
					if (req.status == 200) {
                                            var res=req.responseText;
                                            document.getElementById('get_time').innerHTML=req.responseText;
					}
                                      else {
                                            alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                               }
                        }
                       
            }
             req.open("GET", strURL, true);
                        req.send(null);
 
        }
}
 function doClear(theText) {
     if (theText.value == theText.defaultValue) {
         theText.value = ""
     }
 }
function todayStr() {
var today=new Date()
return today.getMonth()+1+"/"+today.getDate()+"/"+(today.getYear() + 1900)
}
function restrictfile(res){
 var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
 var length = res.length;
  for (var i = 0; i < length; i++) {
    if (iChars.indexOf(res.charAt(i)) != -1) {
            alert ("Please avoid usage of special charecters such as !,@,#,&... ");
            return false;
        }
     }
     return true;
}
//function validate_date(field)
//{
//var obj=document.getElementById(field)
//var date1=obj.value;
//
//arr=date1.split("/");
//
//seldate=arr[2]+Math.abs(arr[0])+arr[1];
////alert(seldate);
//todaysdate=todayStr();
//arr1=todaysdate.split("/");
//currdate=arr1[2]+Math.abs( arr1[0])+arr1[1];
//
//if(seldate<currdate)
//{
//
//alert("Please choose a date on or after "+todaysdate);
//return false;
//}
//else
//{
//	return true;
//}
//
//
//}
