
	
function makeNewAjax()
	{
    if( window.XMLHttpRequest ) 
    	{
	   		return new XMLHttpRequest(); 
    	} 
    else 
    	{
	   		return  new ActiveXObject("MSXML2.XMLHTTP");
    	}
	}

var	global_AJAX_Array	= new Array();
var	global_AJAX_Count	= 0;
var	quickSearch_NeedSearch				= true;


function queryForInnerHTML( query, elementId, needRepositionFooter )
	{
		var	body;
		var	index = global_AJAX_Count;
		global_AJAX_Array[index] = makeNewAjax();
		++global_AJAX_Count;
		
		body	 = "var ajax = global_AJAX_Array[" + index + "];\n";
		body	+= "if( 4 == ajax.readyState )\n";
		body	+= "{ document.getElementById(\"" + elementId + "\").innerHTML = ajax.responseText;\n";
		if( needRepositionFooter )
			body += "repositionFooter();\n";
		body	+= " }\n";
		
    global_AJAX_Array[index].onreadystatechange = new Function( body );
    
    global_AJAX_Array[index].open( "GET", query, true );
    global_AJAX_Array[index].send(null);
	}

function queryForInnerHTMLWithFunction( query, elementId, funcName )
	{
		var	body;
		var	index = global_AJAX_Count;
		global_AJAX_Array[index] = makeNewAjax();
		++global_AJAX_Count;
		
		body	 = "var ajax = global_AJAX_Array[" + index + "];\n";
		body	+= "if( 4 == ajax.readyState )\n";
		body	+= "{ document.getElementById(\"" + elementId + "\").innerHTML = ajax.responseText;\n";
		if( null != funcName )
			body += funcName + "();\n";
		body	+= " }\n";
		
    global_AJAX_Array[index].onreadystatechange = new Function( body );
    
    global_AJAX_Array[index].open( "GET", query, true );
    global_AJAX_Array[index].send(null);
	}


	
// If you plan on doing anything outside of North America, then you'd better encode the things you pass back and forth
// the escape() method in Javascript is deprecated -- should use encodeURIComponent if available
function encode( uri ) 
	{
    if( encodeURIComponent) 
    	{
        return encodeURIComponent(uri);
    	}

    if( escape ) 
    	{
        return escape(uri);
    	}
	}

function decode( uri ) 
	{
    uri = uri.replace(/\+/g, ' ');

    if( decodeURIComponent ) 
    	{
        return decodeURIComponent(uri);
  	  }

    if( unescape ) 
    	{
        return unescape(uri);
    	}

    return uri;
	}

window.onresize = repositionFooter;
function repositionFooter()
	{
		var	mainContent = document.getElementById('mainContent');
		if( null != mainContent )
			{
				var mainContentHeight 	= mainContent.offsetHeight;
				var	leftSideBarHeight		= document.getElementById('leftSideBar').offsetHeight;
				var	bodyObject					= document.getElementById('body');
				
				var	maxHeight						= mainContentHeight > leftSideBarHeight ? mainContentHeight : leftSideBarHeight;
				bodyObject.style.height	= maxHeight + 'px';
				
			}

		quickSearchStopWorking();
			
		element = document.getElementById( 'footer' );
		if( null != element )
			{
				element.style.visibility = 'visible';
			}
	}

function quickSearchStartWorking()
	{	
		var	element = document.getElementById( 'quickSaveWorkingImage' );
		if( null == element )
			return;
		element.style.display = 'inline';
	}

function quickSearchStopWorking()
	{
		var	element = document.getElementById( 'quickSaveWorkingImage' );
		if( null == element )
			return;
		element.style.display = 'none';
		
		if( quickSearch_NeedSearch )
			{
				doQuickSearch();
			}
	}

function quickSearchIsWorking()
	{
		var	element = document.getElementById( 'quickSaveWorkingImage' );
		if( null == element )
			return false;
		return 'inline' == element.style.display;
	}
