﻿/*
this is just a note for some future use... was interesting way to remove an element and 
find it's parent.
A typical way to delete an element since there is no removeElement DOM method, 
you need to grab a reference of the element, find it’s parent, then remove the element reference.
eg.
var el = document.getElementById('abc');
el.parentNode.removeChild(el);

AND, either one of these will work to get PARENT, which is HELPFUL
var item = document.getElementById('myspan');
alert(item.parentNode.id);
OR
alert(document.getElementById('myspan').parentNode.id);
AND
I will most likely to an appendChild technique at some point

I IMPLEMENTED A WAY TO PULL ALL JS FORM VALUES INTO AN AJAX POST 
see ajaxTest.php
*/




/* THIS is basically the JS version of the AJAX controller */
/*
	STANDARD FUNCTION
	all we need is to pass the module name to use, and the div id where we put the results, and the next 
	function to call AFTER process url function
*/
function standard_div_load(modName,divID,urlExtra)
{
	//using clean urls
  var url = '/ajax/' + modName + '/' + divID + '/' + urlExtra;
  next_function = 'standard_div_load_2';  
  http_process(url);  // function in ajaxBase, which then calls "next function" below
}
//STANDARD FUNCTION 2
function standard_div_load_2()
{
  var i = 0;
  if(xmlDocument.getElementsByTagName('divID').item(i))
  {
    var divID = xmlDocument.getElementsByTagName('divID').item(0).firstChild.data;
    var data = xmlDocument.getElementsByTagName('data').item(0).firstChild.data;
	}
	if(document.getElementById(divID))
	{
		set_inner_html(divID,data);
	}		
} 

/*
	******* CUSTOM FUNCTIONS GO HERE *******
	there should always be a PAIR of functions 
*/	
function load_test_div(modName,divID)
{
	//using clean urls
  var url = '/ajax/' + modName + '/' + divID + '/' + urlExtra;
  next_function = 'load_test_div_2';  
  http_process(url);  // function in ajaxBase, which then calls "next function" below
}

/*
	CUSTOM FUNCTION 2
	IF using the custom functions, need to put PART 2 here 
*/
function load_test_div_2()
{
	//do really cool custom stuff, HANDLE the xml
  var i = 0;
  while(xmlDocument.getElementsByTagName('divID').item(i))
  {
    var divID = xmlDocument.getElementsByTagName('divID').item(0).firstChild.data;
    var data = xmlDocument.getElementsByTagName('data').item(0).firstChild.data;
	}
	if(document.getElementById(divID))
	{
		set_inner_html(divID,data);
	}		
} 