function createRequestObject()
{
	var request_o;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else
	{
		request_o = new XMLHttpRequest();
	}
	return request_o;
}

var http = createRequestObject();

////////////////////////////////////////////////////////////

//Global variable to store the div id where the output will be placed
var dynamic_div_id;

//Global variable to store the id the of the list menu
//whos onChange the ajax will be called 
var dynamic_list_id; 



/////////////////////////////////////////////////////////////////////////////
/////////////////////////Vertical Ajax Output ///////////////////////////////
/////////////////////////////////////////////////////////////////////////////
function getVerticalOutput(action,id,modid,startid,parentid,childid,folderid)
{
	//What is the need of user_id

	http.open('get', '/_Admin/Modules/'+folderid+'/common_vertical_ajax_output.php?action='+action+'&id='+id+'&module='+modid+'&start='+startid+'&parent='+parentid+'&child='+childid);
	http.onreadystatechange = handleVerticalOutput; 
	http.send(null);
}

function handleVerticalOutput()
{
	if(http.readyState == 4)
	{ 
		var vertical_response = http.responseText;
		document.getElementById('the_div').innerHTML = vertical_response;
	}
}

/////////////////////////////////////////////////////////////////////////////
/////////////////////////Normal Pulldown Ajax Output ////////////////////////
/////////////////////////////////////////////////////////////////////////////
function getNormalPulldownOutput(action)
{
	//Show retrieving data message
	document.getElementById('the_sublist_div').innerHTML = "<span class='form_field_div'><img src='_images/black_dot_loading.gif' /></span>";
	
	http.open('get', 'common_pulldown_ajax_output.php?action='+action+'&id=' 
			+ document.myform.the_list[document.myform.the_list.selectedIndex].value);
	http.onreadystatechange = handleNormalPulldownOutput; 
	http.send(null);
}

function handleNormalPulldownOutput()
{
	if(http.readyState == 4){ 
		var response = http.responseText;
		document.getElementById('the_sublist_div').innerHTML = response;
	}
}

/////////////////////////////////////////////////////////////////////////////
/////////////////////////Multilevel Pulldown Ajax Output ////////////////////
/////////////////////////////////////////////////////////////////////////////
function getPulldownOutput(action,listid,divisionid,folderid)
{
	dynamic_div_id = divisionid;
	dynamic_list_id = listid;
	
	//Show retrieving data message
	document.getElementById('div_'+dynamic_div_id).innerHTML = "<img src='_images/black_dot_loading.gif' />";
	
	http.open('get', 'Modules/'+folderid+'/common_pulldown_ajax_output.php?action='+action+'&id=' 
			+ eval('document.myform.list_' + dynamic_list_id + '[document.myform.list_' + dynamic_list_id + '.selectedIndex].value'));
	
	http.onreadystatechange = handlePulldownOutput; 
	http.send(null);
	
}

function handlePulldownOutput()
{
	if(http.readyState == 4)
	{ 
		var response = http.responseText;
		//document.getElementById('the_div').innerHTML = response;
		
		//dynamic_div_id = 8;
		document.getElementById('div_'+dynamic_div_id).innerHTML = response;
	}
}


/////////////////////////////////////////////////////////////////////////////
///////////////////// Multilevel Pulldown Ajax Output for Filter Form ///////
/////////////////////////////////////////////////////////////////////////////
function getPulldownOutputFilterForm(action,listid,divisionid,folderid,parent_category)
{
	dynamic_div_id = divisionid;
	dynamic_list_id = listid;
	
	var parent_category = (parent_category == null) ? 0 : parent_category;

	
	//Show retrieving data message
	document.getElementById('div_'+dynamic_div_id).innerHTML = "<img src='http://www.dentaids.com/_Admin/_images/black_dot_loading.gif' />";
	
	http.open('get', '/_Admin/Modules/'+folderid+'/common_pulldown_ajax_output.php?action='+action+'&parent_category='+parent_category+'&id=' 
			+ eval('document.filter_form.list_' + dynamic_list_id + '[document.filter_form.list_' + dynamic_list_id + '.selectedIndex].value'));
	
	
	
	http.onreadystatechange = handlePulldownOutputFilterForm; 
	http.send(null);
	
}

function handlePulldownOutputFilterForm()
{
	if(http.readyState == 4)
	{ 
		var response = http.responseText;
		//document.getElementById('the_div').innerHTML = response;
		
		//dynamic_div_id = 8;
		document.getElementById('div_'+dynamic_div_id).innerHTML = response;
	}
}

/////////////////////////////////////////////////////////////////////////////
/////////////////////////Show Details Ajax Output ///////////////////////////
/////////////////////////////////////////////////////////////////////////////

function showDetails(action,id,modid,startid,parentid,childid,user_id,div_id,folderid)
{
	dynamic_div_id = div_id;
	
	http.open('get', 'Modules/'+folderid+'/common_vertical_ajax_output.php?action='+action+'&id='+id+'&module='+modid+'&start='+startid+'&parent='+parentid+'&child='+childid+'&user='+user_id);
	http.onreadystatechange = handleDetails; 
	http.send(null);
}

function handleDetails()
{
	if(http.readyState == 4)
	{ 
		var response = http.responseText;
		document.getElementById('the_div').innerHTML = response;
		
		//dynamic_div_id = 8;
		//document.getElementById('newitem'+dynamic_div_id).innerHTML = "<img src='_images/openmail.gif' />";
		document.getElementById('newitem'+dynamic_div_id).innerHTML = "&nbsp;";
	}
}



/////////////////////////////////////////////////////////////////////////////
/////////////////////////Filter Form Pulldown Ajax Output ///////////////////
/////////////////////////////////////////////////////////////////////////////

//NOTE:
//ff stands for "filter form"

function getFFPulldownOutput(action)
{
	//Show retrieving data message
	document.getElementById('pulldown_div').innerHTML = "<img src='_images/black_dot_loading.gif' />";
			
	http.open('get', 'common_pulldown_ajax_output.php?action='+action+'&id=' 
			+ document.filter_form.parent[document.filter_form.parent.selectedIndex].value);
	
	http.onreadystatechange = handleFFPulldownOutput; 
	http.send(null);
	
}

function handleFFPulldownOutput()
{
	if(http.readyState == 4)
	{ 
		var response = http.responseText;
		document.getElementById('pulldown_div').innerHTML = response;
	}
}

/////////////////////////////////////////////////////////////////////////////
/////////////////////////Check Username Availability ////////////////////////
/////////////////////////////////////////////////////////////////////////////
function checkUsername()
{
	http.open('get', '/_Admin/common_check_username_availability.php?id=' + document.frm_registration.user_name.value);
	http.onreadystatechange = displayMessage; 
	http.send(null);
}

function displayMessage()
{
	if(http.readyState == 4)
	{ 
		var response = http.responseText;
		alert(response);
	}
}




/////////////////////////////////////////////////////////////////////////////
///////////////////// Multilevel Pulldown Ajax Output for Reg Form //////////
/////////////////////////////////////////////////////////////////////////////
function getPulldownOutputRegForm(action,listid,divisionid,folderid,parent_category)
{
	dynamic_div_id = divisionid;
	dynamic_list_id = listid;
	
	var parent_category = (parent_category == null) ? 0 : parent_category;

	
	//Show retrieving data message
	document.getElementById('div_'+dynamic_div_id).innerHTML = "<img src='http://www.dentaids.com/_Admin/_images/black_dot_loading.gif' />";
	
	http.open('get', '/_Admin/Modules/'+folderid+'/common_pulldown_ajax_output.php?action='+action+'&parent_category='+parent_category+'&id=' 
			+ eval('document.frm_registration.list_' + dynamic_list_id + '[document.frm_registration.list_' + dynamic_list_id + '.selectedIndex].value'));	
	
	http.onreadystatechange = handlePulldownOutputRegForm; 
	http.send(null);
	
}

function handlePulldownOutputRegForm()
{
	if(http.readyState == 4)
	{ 
		var response = http.responseText;
		//document.getElementById('the_div').innerHTML = response;
		
		//dynamic_div_id = 8;
		document.getElementById('div_'+dynamic_div_id).innerHTML = response;
	}
}


/////////////////////////////////////////////////////////////////////////////
/////// Multilevel Pulldown Ajax Output for Shipping and Payment Info Form //
/////////////////////////////////////////////////////////////////////////////
function getPulldownOutputShippingPaymentInfoForm(action,listid,divisionid,folderid,parent_category)
{
	dynamic_div_id = divisionid;
	dynamic_list_id = listid;
	
	var parent_category = (parent_category == null) ? 0 : parent_category;

	
	//Show retrieving data message
	document.getElementById('div_'+dynamic_div_id).innerHTML = "<img src='http://www.dentaids.com/_Admin/_images/black_dot_loading.gif' />";
	
	http.open('get', '/_Admin/Modules/'+folderid+'/common_pulldown_ajax_output.php?action='+action+'&parent_category='+parent_category+'&id=' 
			+ eval('document.frmCheckout.list_' + dynamic_list_id + '[document.frmCheckout.list_' + dynamic_list_id + '.selectedIndex].value'));	
	
	http.onreadystatechange = handlePulldownOutputShippingPaymentInfoForm; 
	http.send(null);
	
}

function handlePulldownOutputShippingPaymentInfoForm()
{
	if(http.readyState == 4)
	{ 
		var response = http.responseText;
		//document.getElementById('the_div').innerHTML = response;
		
		//dynamic_div_id = 8;
		document.getElementById('div_'+dynamic_div_id).innerHTML = response;
	}
}


