// JavaScript Document
//#########This Function is used by Adding Services in Backend#######################
function showServicesDepartment(val)
{
	//alert(val);
	var name= "#DepartmentDiv";
	 $.post("../ServicesDropDown.php", { SpecialityId: val },
	  function(data){
		//alert("Data Loaded: " + data);
		$(name).html(data);
	  });
}

//#########This Function is used by Adding Doctor Information in Backend#############
function showDepartment(SpecialityVal)
{
	//alert("manohar");
	var DoctorId = document.getElementById("id").value;
	//alert(SpecialityVal+"   "+DoctorId);
	var name= "#DepartmentDiv";
	 $.post("../OnChangeDropDowns.php", { SpecialityId: SpecialityVal, DoctorId: DoctorId},
	  function(data){
		//alert("Data Loaded: " + data);
		$(name).html(data);
		$("#ServicesDiv").html('<select name="ddlServices" id="ddlServices" style="width:248px;"><option value="">Choose Services</option></select>');
	  });
}

//#########This Function is used by Adding Hosiptals in Backend#######################
function showHospitals(location_val)
{
	//alert(val);
	var name= "#HospitalsDiv";
	 $.post("../DepartmentDrop.php", { LocationId: location_val },
	  function(data){
		//alert("Data Loaded: " + data);
		$(name).html(data);
	  });
}


//#########This Function also used by Adding Doctor Information in Backend#############
function showServices(DepartmentVal)
{	
	var DoctorId = document.getElementById("id").value;
	var SpecialityId = document.getElementById("ddlSpeciality").value;
	//alert(SpecialityId+"   "+DepartmentVal+"   "+DoctorId);
	var name= "#ServicesDiv";
	 $.post("../OnChangeDropDowns.php", { SpecialityId: SpecialityId, DepartmentId: DepartmentVal, DoctorId: DoctorId},
	  function(data){
		//alert("Data Loaded: " + data);
		if(DepartmentVal!="")
		{
			$(name).html(data);
		}else{
			$("#ServicesDiv").html('<select style="width:250px;" name="ddlServices" id="ddlServices" style="width:248px;"><option value="">Choose Services</option></select>');
		}
	  });
}




//#########This Function is used by Searcing by Doctor(Hospital)  in Frontend#########
function showFindHospitals(location_val)
{
	//alert("mahesh");
	var name= "#HospitalsDiv";
	 $.post("../DepartmentDrop.php", { LocationId: location_val },
	  function(data){
		//alert("Data Loaded: " + data);
		 	$(name).html(data);
		 	var hospital_value= document.getElementById("ddlHospitals").value;
		 	showFindSpeciality_Hospitals(hospital_value);
			//$("#Hospital_SpecialityDiv").html('<select style="width:250px;" name="ddlSpeciality" id="ddlSpeciality"><option value="">Choose Speciality</option></select>');
			//$("#Hospital_SpecialityDepartmentDiv").html('<select style="width:250px;" name="ddlDepartment" id="ddlDepartment"><option value="">Choose Department</option></select>');
			//$("#HospitalServicesDiv").html('<select style="width:250px;" name="ddlServices" id="ddlServices"><option value="">Choose Services</option></select>');
	  }); 
}
s
//Here you can get speciality values based on location and hospital
function showFindSpeciality_Hospitals(hospital_value)
{	
	var LocationId1 = document.getElementById("ddlLocation").value;
	var HospitalId1 = hospital_value;
	//alert("ddlLocation "+ddlLocation);
	//alert("HospitalId1 "+hospital_value);
	
	var name= "#Hospital_SpecialityDiv";
	 $.post("DepartmentDrop.php", { LocationId: LocationId1, HospitalId: HospitalId1,action: 'getSpecialitiy'},
	  function(data){
		//alert("Data Loaded: " + data);
		 
		 
		if(HospitalId1!="")
		{
			//$(name).html();
			$("#Hospital_SpecialityDiv").html(data);
			//$("#Hospital_SpecialityDepartmentDiv").html('<select style="width:250px;" name="ddlDepartment" id="ddlDepartment"><option value="">Choose Department</option></select>');
			//$("#HospitalServicesDiv").html('<select style="width:250px;" name="ddlServices" id="ddlServices"><option value="">Choose Services</option></select>');
		}else{
			$("#Hospital_SpecialityDiv").html(data);
			//$("#Hospital_SpecialityDiv").html('<select style="width:250px;" name="ddlSpeciality" id="ddlSpeciality"><option value="">Choose Specilaity</option></select>');
			//$("#Hospital_SpecialityDepartmentDiv").html('<select style="width:250px;" name="ddlDepartment" id="ddlDepartment"><option value="">Choose Department</option></select>');
			//$("#HospitalServicesDiv").html('<select style="width:250px;" name="ddlServices" id="ddlServices"><option value="">Choose Services</option></select>');
		}
	  });
}


function showFindDepartmentHospitals(speciality_value)
{
	var SpecialityId1 = speciality_value;
	var LocationId1 = document.getElementById("ddlLocation").value;
	var HospitalId1 = document.getElementById("ddlHospitals").value;	
	
	var name= "#Hospital_SpecialityDepartmentDiv";
	 $.post("DepartmentDrop.php", { SpecialityId: SpecialityId1, LocationId: LocationId1, HospitalId: HospitalId1},
	  function(data){
		//alert("Data Loaded: " + data);
		if(SpecialityId1!="")
		{
			$(name).html(data);
			$("#HospitalServicesDiv").html('<select style="width:250px;" name="ddlServices" id="ddlServices"><option value="">Choose Services</option></select>');
		}else{
			$("#Hospital_SpecialityDepartmentDiv").html('<select style="width:250px;" name="ddlDepartment" id="ddlDepartment"><option value="">Choose Department</option></select>');
			$("#HospitalServicesDiv").html('<select style="width:250px;" name="ddlServices" id="ddlServices"><option value="">Choose Services</option></select>');
		}
	  });
}

function showFindServicesHospitals(department_value)
{
	var DepartmentId = department_value;
	var SpecialityId1 = document.getElementById("ddlSpeciality").value;
	var LocationId1 = document.getElementById("ddlLocation").value;
	var HospitalId1 = document.getElementById("ddlHospitals").value;	
	
	var name= "#HospitalServicesDiv";
	 $.post("DepartmentDrop.php", { DepartmentId: DepartmentId, SpecialityId: SpecialityId1, LocationId: LocationId1, HospitalId: HospitalId1},
	  function(data){
		//alert("Data Loaded: " + data);
		if(DepartmentId!="")
		{
			$(name).html(data);
		}else{
			$("#HospitalServicesDiv").html('<select style="width:250px;" name="ddlServices" id="ddlServices"><option value="">Choose Services</option></select>');
		}
	  });
}








//#########This Function is used by Searcing by Doctor in Frontend#############
function showFindDepartment(SpecialityVal)
{
	//alert(SpecialityVal);
	var name= "#DepartmentDiv";
	 $.post("../Find_OnChangeDropDowns.php", { FindSpecialityId: SpecialityVal},
	  function(data){
		//alert("Data Loaded: " + data);
		$(name).html(data);
		$("#ServicesDiv").html('<select name="ddlServices" id="ddlServices"><option value="">Choose Services</option></select>');
	  });
}

//#########This Function also used by Searcing by Doctor in Frontend#############
function showFindServices(DepartmentVal)
{	
	var SpecialityId = document.getElementById("ddlSpeciality").value;
	
	var name= "#ServicesDiv";
	 $.post("../Find_OnChangeDropDowns.php", { FindSpecialityId: SpecialityId, FindDepartmentId: DepartmentVal},
	  function(data){
		//alert("Data Loaded: " + data);
		if(DepartmentVal!="")
		{
			$(name).html(data);
		}else{
			$("#ServicesDiv").html('<select name="ddlServices" id="ddlServices"><option value="">Choose Services</option></select>');
		}
	  });
}


//#########This Function is used by Adding Doctor Information in Backend#############
function more_days_func(adminForm)
{
	var HiddenValue = document.getElementById("txtHideValue").value
	var name = "#MoreDaysDiv";
	 $.post("../more_days.php", { HideValue: HiddenValue},
	  function(data){
		//alert("Data Loaded: " + data);
		$(name).append(data);
	  });
	HiddenValue = (HiddenValue - 1) + 2;
	document.getElementById("txtHideValue").value = HiddenValue;
}

function removeElement(divNum) {
	var d = document.getElementById('MoreDaysDiv');
	var olddiv = document.getElementById(divNum);
	//alert(divNum);
	var response = confirm("Are you sure you want to delete the field?");
	if( response == true )
	{
		d.removeChild(olddiv);
	}
}

function more_phone_func(adminForm)
{
	var PhoneHiddenValue = document.getElementById("txtPhoneHiddenValue").value
	var name = "#MorePhoneDiv";
	 $.post("../more_days.php", { PhoneHideValue: PhoneHiddenValue},
	  function(data){
		//alert("Data Loaded: " + data);
		$(name).append(data);
	  });
	PhoneHiddenValue = (PhoneHiddenValue - 1) + 2;
	document.getElementById("txtPhoneHiddenValue").value = PhoneHiddenValue;
}

function removePhoneElement(divNum) {
	var d = document.getElementById('MorePhoneDiv');
	var olddiv = document.getElementById(divNum);
	//alert(divNum);
	var response = confirm("Are you sure you want to delete the field?");
	if( response == true )
	{
		d.removeChild(olddiv);
	}
}

function more_email_func(adminForm)
{
	var EmailHiddenValue = document.getElementById("txtEmailHiddenValue").value
	var name = "#MoreEmailDiv";
	 $.post("../more_days.php", { EmailHideValue: EmailHiddenValue},
	  function(data){
		//alert("Data Loaded: " + data);
		$(name).append(data);
	  });
	EmailHiddenValue = (EmailHiddenValue - 1) + 2;
	document.getElementById("txtEmailHiddenValue").value = EmailHiddenValue;
}

function removeEmailElement(divNum) {
	//alert(divNum);
	var d = document.getElementById('MoreEmailDiv');
	//alert(d);
	var olddiv = document.getElementById(divNum);
	//alert(olddiv);
	var response = confirm("Are you sure you want to delete the field?");
	if( response == true )
	{
		d.removeChild(olddiv);
	}
}

function DivHide(val)
{
	var div = document.getElementById(val);
	div.parentNode.removeChild(div);
	//document.getElementById(val).style.visibility="hidden";
}

