/** GetAreaContent( int blog_cID, int ref_cID, string sTargetId, string arHandle)
 * Grabs Atrea content asynchronously and transplants the templated result to an element's innerHTML
 * NOTE: throwException() is part of /config/user_defined/js_main_library.js, the lot of which will be 
 * one day trimmed and rightfully placed in /js/
 * 
 * @param	blog_cID		cID of the Blog page in the Sitemap
 * @param	ref_cID			cID of the Page to reference; i.e. 1 would referecne the Home Page
 * @param	sTargetId		The ID of the HTML element where the result will be written
 * @param	arHandle		The name of the Area to grab content from
 * @param	arguments[4]	(optional) Block Type (.BlockType) and Template (.Template) info to pass to the Area
 *  
 * @returns	result			The Area contents
 * 
 * @since	5.3.0
*/
function GetAreaContent( blog_cID, ref_cID, sTargetId, arHandle)
{
	try
	{
		var QueryString = 
		{
			cID: blog_cID
			,ref_cID: ref_cID
			,arHandle: arHandle
		}
		
		if(arguments[4] && typeof(arguments[4].BlockType) != 'undefined')
		{
			//alert(ListProperties(arguments[4]))
			QueryString.block_type = arguments[4].BlockType;
			QueryString.template = arguments[4].Template;
		}
		
		$.get(
			"/index.php"
			,QueryString
			,function(result)
			{
				try
				{ 
					//alert(result); return;
					$(sTargetId).html(result);
					/*
					if( arHandle == "Main Navigation")
					{
						alert(result);
					}
					*/
				}
				catch(e){ throwException( '/js/blog.js : GetAreaContent()', e.lineNumber, e, e.message ); }
			}	
		);
	}catch(e){ throwException( '/js/blog.js : GetAreaContent()', e.lineNumber, e, e.message ); }
}


function ListProperties(obj) { //dumpProps()
	var obj_props = "";
	// Go through all the properties of the passed-in object
	for (var i in obj) {
		
		// if a parent (2nd parameter) was passed in, then use that to
		// build the message. Message includes i (the object's property name)
		// then the object's property value on a new line
		if (arguments[1]) { var msg = arguments[1] + "." + i + " : " + obj[i]; } else { var msg = i + " : " + obj[i]; }
		obj_props += msg + "\n";
		
		// Display the message. If the user clicks "OK", then continue. If they
		// click "CANCEL" then quit this level of recursion
		//if (!confirm(msg)) { return; }
		
		// If this property (i) is an object, then recursively process the object
		if (typeof obj[i] == "object") {
			if (arguments[1]) { ListProperties(obj[i], parent + "." + i); } else { ListProperties(obj[i], i); }
		}
	}
	
	return obj_props;
	//return obj.getAttribute('al-filepath');
	
}