/**********************************************
VYOM AJAX PROCESSOR
(c) Vyom Technosoft Pvt. Ltd.
Author - Amit Mathur, 18 Jun 2006

Unauthorised copying or distribution is
prohibited.
***********************************************/

function vyomAJAXProcessor(strURL,divName)
{
	
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) 
	{
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			updatepage(self.xmlHttpReq.responseText,divName);
		}
	}
	self.xmlHttpReq.send(strURL);
}

function vyomAJAXCheckUser()
{    
	updatepage("<font class='specialtext'>Checking...</font>","result");
	strURL = "/include/checkavailability.asp?uname=" + document.forms['frms'].uname.value //+ "&firstName=" + document.forms['registration'].firstName.value + "&lastName=" + document.forms['registration'].lastName.value;
	vyomAJAXProcessor(strURL,"result");
}
function vyomAJAXYear()
	{
		//alert(document.myform.referralCompany.value)
		updatepage("<font class='textbox'>Retrieving ...</font>","result4");
		strURL = "/patients/selectYear.asp?id=" + document.forms['appointment'].appointmentMonth.value;
		vyomAJAXProcessor(strURL,"result4");
	}

function changeyear()
{
	//alert(document.forms['appointment'].appointmentMonth.value)
	currentmonth = document.forms['appointment'].appointmentMonth.value;
	//alert(currentmonth)
	strURL = "/year-change.asp?cm="+currentmonth;
	vyomAJAXProcessor(strURL,"mydiv")
}

function vyomUserTypes(utype)
{
	//alert(utype);
	utype = utype;
	//alert(utype);
	strURL = "/user-role-form.asp?ut="+utype;
	vyomAJAXProcessor(strURL,"utyp")
}


function updatepage(str,divName){
	document.getElementById(divName).innerHTML = str;
}

function changeoption()
{
  	currentchoosen=document.forms['myform'].drop1frm.value;
	if (currentchoosen=="99")
    {
	 alert("Please select a time ")
	 document.forms['myform'].drop1frm.focus();
    }
	else
    {
	  strURL="/patients/change-option.asp?dd=1&current="+currentchoosen;
	}
  vyomAJAXProcessor(strURL,"dd2tochange")
}

function timeslotthreefrom()
{
   	currentchoosen=document.forms['myform'].drop2frm.value
	if (currentchoosen=="99")
    {
     alert("Please select a time1 ")
	 document.forms['myform'].drop2frm.focus();
	}
	else
	{
	   strURL="/patients/change-option.asp?dd=2&current="+currentchoosen;
	}
	vyomAJAXProcessor(strURL,"dd3tochange")
}

function checkfilled(day,month,year,flag)
{
    //alert("entering the function")
	var date1=""
		date1+=month
		date1+="/"
		date1+=day
		date1+="/"
		date1+=year
	//alert("the date is"+date1)
	//alert("flag"+flag)
	var value="1"
	strURL="/patients/booking.asp?dte="+date1+"&flag="+flag;
	vyomAJAXProcessor(strURL,"book")
	return value;
}

	function AJAXCalulateAge(value)
	{
		//alert("entering function" +value)
		updatepage("Calculating...","ageValue");
		strURL = "/display-age.asp?did=" + value;
		
		vyomAJAXProcessor(strURL,"ageValue");
	}

	function AJAXOtherArea(otherV)
	{
		//alert(otherV)
		updatepage("","others");
		strURL = "/patients/other-area.asp?val=" + otherV
		vyomAJAXProcessor(strURL,"others");
	}
	function AJAXTotalPrice(qty,price,vat)
	{ 
		//alert("qty:" +qty);
		//alert("price:" +price);
		//alert("vat:" +vat);
        updatepage("text","totalprice");
        strURL = "/patients/calculate-price.asp?qty="+qty +"&price="+price +"&vat="+vat;
        vyomAJAXProcessor(strURL,"totalprice");
	}	
	function calculateQty(qty,id)
	{ 
		//alert("qty::" +qty);
		//alert("Name:" +id);
		
        updatepage("text","qty");
        strURL = "/patients/calculate-quantity.asp?qty="+qty + "&medicineId="+id;
        vyomAJAXProcessor(strURL,"qty");
	}	
	function AjaxTotal()
	{
	   var quantity = document.forms['add'].Quantity.value
	   var product	= document.forms['add'].product.value
	   strURL = "/shopping-cart/calculate-total.asp?qty="+quantity+"&prd="+product;
       vyomAJAXProcessor(strURL,"total-price");

	}
   function AjaxcalculatePrice()
   {
	    var quantity = document.forms['edit'].quantity.value
        var product  = document.forms['edit'].product.value
			alert("quantity"+quantity)
			alert("product"+product)
   }
   function AjaxStates()
   {
	   var value = document.forms['frms'].country.value
       //alert(value)
	   strURL = "/change-state.asp?id="+value
	   vyomAJAXProcessor(strURL,"state");
   }
   function AjaxCity()
   {
	   var value = document.forms['frms'].State.value
	   //alert("value"+value)
	   strURL = "/change-city.asp?id="+value
	   vyomAJAXProcessor(strURL,"city");
   }
   function AjaxCalculate(arg)
   {
	  
	   var value = document.forms['frm'].Quantity.value
	   strURL = "/users/edit-quantity-ajax.asp?id="+value+"&prd="+arg;
	   vyomAJAXProcessor(strURL,"changed");
   }
   function changeSub()
   {
	   //alert("hi")
	   var value = document.forms['searchFrm'].searchCategory.value
	   strURL = "/inventory-management/report-list/select-subCat.asp?id="+value;
	   vyomAJAXProcessor(strURL,"replaced");
   }

