var odxmlHttp;

function odGETSendRequest(CallBackURL,DivID,IsPostMethod, PostParameters)
{
odShowLoader(DivID, true);

	var odResponseText = ""; 
	odxmlHttp=odGetXmlHttpObject()
	
	if (odxmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	// Check URL
	if(CallBackURL == "")
	{
		alert ("Please provide callback URL");
		return;
	}
	
	// Check Data send type
	var sendMetheodType = "GET";
	if(IsPostMethod == true)
	{
		sendMetheodType = "POST";
	}
	// Set CallBack URL
	odxmlHttp.open(sendMetheodType,CallBackURL,false);
	odxmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	
	// Check Parameter is Blank or filled 	
	if(PostParameters == "")
	{
		PostParameters = null;
	}
	
	// Make Asynchronus request
	odxmlHttp.send(PostParameters);

	// Final Output tex
	odResponseText=odxmlHttp.responseText; 
	
	if (odxmlHttp.status!=200)
	{
	    odResponseText = "AJAX: Error in "+CallBackURL;	
		//alert('Error in ');
	}
	// Hide the loader	
	odShowLoader(DivID, false);
	
	//Finally return the output text
	return odResponseText;
}


function odShowLoader(divid, IsVisible)
{

	if(document.getElementById(divid) != null)
	{

		if(IsVisible == true)
		{
			document.getElementById(divid).style.display = 'block';
		}
		else
		{
			document.getElementById(divid).style.display = 'none';
		}
	}
	else
	{

		//alert('div is not found');
	} 
	
}


// Make ajax object function
function odGetXmlHttpObject()
{
var odxmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 odxmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  odxmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  odxmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return odxmlHttp;
}

