<!--
/****************** Code inserted automatically by the CMX AJAX Loader behavior ***************************/
//Extension and briief documentation:  is located: http://www.communitymx.com/content/article.cfm?cid=D0C96



function createDirectRequestObject () {
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	 	try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  	} catch (E) {
	   		xmlhttp = false;
	  	}
	}
	@end @*/
	
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	
	return xmlhttp;
}

function loadNewFragment(targetURL, targetDivID, callbackFunc, startingFunc) {
	
	//If the user has supplied a function to be called when the transaction starts, then call it now
	// HBIZ: make the startFunc be called by default
	if (startingFunc != null ) {
		try {
			startingFunc(targetDivID);
		} catch (e) {
			
		}
	} else {
		try {
			startFunc(targetDivID);
		} catch (e) {
		}
	}
	
	//Create the request object
	var xmlHttpObj = createDirectRequestObject();
	
	//Create the callback
	xmlHttpObj.onreadystatechange = function () {
			
			if (xmlHttpObj.readyState == 4) {
				
				targetDiv = document.getElementById(targetDivID);
		
				if (targetDiv) {
					try {
						targetDiv.innerHTML = xmlHttpObj.responseText;
						
						processScriptTags( targetDiv );
						/*//Execute script tags
						var scriptTags = targetDiv.getElementsByTagName("script");
						//alert( 'scriptTags.length='+scriptTags.length);
						for (var f=0; f < scriptTags.length; f++) {
							try {
								//alert ( scriptTags[f].text );
								//window.eval(scriptTags.item(f).firstChild.nodeValue);
								window.eval(scriptTags[f].text );
							} catch (e) { 
								//alert( e );
							}
						}*/
					} catch (e) {
						//alert( e );
					}
				}
				
				//If the user supplies a function to be called when the transaction completes, call it now.
				if (callbackFunc != null) {
					try {
						callbackFunc(targetDivID, xmlHttpObj.responseText,  xmlHttpObj.responseXML);
					} catch (e) {
					
					}
				} else {
					try {
						completeFunc(targetDivID);
					} catch (e) {
					}
				}
				
				//xmlHttpObj = null;
			}
	}
	
	//Begin the transaction
	xmlHttpObj.open("GET", targetURL, true);
	xmlHttpObj.send("");
	
	
}

// HBIZ addition to process script tags
function processScriptTags( targetElem ){
	//Execute script tags
	var scriptTags = targetElem.getElementsByTagName("script");
	//alert( 'scriptTags.length='+scriptTags.length);
	for (var f=0; f < scriptTags.length; f++) {
		try {
			//alert ( scriptTags[f].text );
			//window.eval(scriptTags.item(f).firstChild.nodeValue);
			window.eval(scriptTags[f].text );
		} catch (e) { 
			alert( e );
		}
	}
}

/*  
Test script to load objects into the page 
Script modified from: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm
*/
var loadedobjects=""

function loadobjs(){
	if (!document.getElementById)
	return
	for (i=0; i<arguments.length; i++){
		var file=arguments[i]
		var fileref=""
		if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
			if (file.indexOf(".js")!=-1){ //If object is a js file
				fileref=document.createElement('script')
				fileref.setAttribute("type","text/javascript");
				fileref.setAttribute("src", file);
			}
			else if (file.indexOf(".css")!=-1){ //If object is a css file
				fileref=document.createElement("link")
				fileref.setAttribute("rel", "stylesheet");
				fileref.setAttribute("type", "text/css");
				fileref.setAttribute("href", file);
			}
		}
		if (fileref!=""){
			document.getElementsByTagName("head").item(0).appendChild(fileref)
			loadedobjects+=file+" " //Remember this object as being already added to page
		}
	}
}


/****************** End Code Inserted Automatically by the CMX AJAX Loader Behavior ****************************/ 
 

/* A custom JS function to be called each time a load operation begins. This function receives the ID of the target element
and uses that information to display a "Loading one moment" dialog overtop of it.

This function uses some techniques described in the Dynamic CSA series of articles to position the "loading" element overtop of the
target one. For a detailed explanation of these techniques please take a look at that series, available at:
http://www.communitymx.com/abstract.cfm?cid=00E2F  
*/
function startFunc(theID) {

	//Get a reference to the element with the given ID
	var theDiv = document.getElementById(theID);
	
	//If the element exists (basic error check
	if (theDiv) {
	
		//Create a new element that will contain our loading message
		var loadingDiv = document.createElement("div");
		
		//Read the width and height of the given element. We'll match our overlaying DIV to these so that it will 
		//completely cover the element
		var oldWidth = theDiv.offsetWidth;
		var oldHeight = theDiv.offsetHeight;
		
		//Set our new "loading message" to the same size as the target
		loadingDiv.style.width = oldWidth + "px";
		loadingDiv.style.height = oldHeight + "px";
		
		//Set a background color so that it covers up the existing target element
		loadingDiv.style.backgroundColor = "";
		
		
		/* Determine the correct position of the Target Element relative to the Document Body
		(take a look at Dynamic CSAs: Part 3, page 4)
		http://www.communitymx.com/content/article.cfm?page=4&cid=D6677
		*/
		
		
		//this is our inspection element. We start here
   		//and continue to work our way up through parentNodes
   		//until there aren't any more (we hit document)
		var ele = theDiv;
		
	   	//start with a left offset of 0
	   	var offsetL = 0;
	   
	   	//start with a top offset of 0
	   	var offsetT = 0;
	
	   	//repeat until we hit our break statement
	   	while (true) {
			//Add the offsets of the current inspection element
		  	//to our total count.
		  	offsetL += ele.offsetLeft;
		  	offsetT += ele.offsetTop;
	
			//If the current node has a parent, then we need to get
			//its offsets as well, so we point our inspection element
			//variable to the parent, and start the loop again
			if (ele.offsetParent != null) {
				ele = ele.offsetParent;
			} else {
				//We've hit the top of the DOM (the document), so
				//we can now safely break out of the loop
				break;
			}
		 }
		 
		 /* Now that we have an absolute position for the target element (relative to the document body)
		 we can proceed to set our "Loading" element to the same position */
		loadingDiv.style.top = offsetT + "px";
		loadingDiv.style.left = offsetL + "px";
		loadingDiv.style.position = "absolute";
		
		//We also need to set a Z-Index value for our new element so that it can be placed overtop of the target
		loadingDiv.style.zIndex = "10";
		
		//We also want our text to be centered
		loadingDiv.style.textAlign = "left";
		
		//Now simply create the text content and add it to the loadingDiv
		//var loadingDivText = document.createTextNode("Loading...");
		//loadingDiv.appendChild(loadingDivText);
		
		//HBIZ: Add a loading meter instead of the text
		loadingDiv.innerHTML = '<img src="/sharedlibraries2/assets/images/ProgressBar.gif" alt="Loading...">';
		
		//We also need to set an id for our loading div so that we can easily remove it again once the content has been loaded
		loadingDiv.id = "tempLoadingDiv";
		
		//Now simply append it to the document body.
		document.body.appendChild(loadingDiv);
		
	}
}


/* A custom JS function to be called each time a load operation finishes. This function removes the "Loading one moment" dialog
box. */

function completeFunc (theID) {
	//Get a reference to the "loading" message element
	var loadingDiv = document.getElementById("tempLoadingDiv");
	
	//Remove it from the document structure
	loadingDiv.parentNode.removeChild(loadingDiv);
	
	// if sIFR is being used, then replace all the elements again
	if (typeof(replacesIFRElements) == 'function')
	{
		replacesIFRElements();
	}
}



//-->