/********************************************
Pass a URL and id of an element and the below
function with insert the contents of the page
into that element.
********************************************/

function loadFragmentInToElement(strURL, strElementId) {
    var objPageElement = document.getElementById(strElementId);
	var objXMLHTTP;
	
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
		try {
			objXMLHTTP = new ActiveXObject("Msxml2.XMLHTTP")
			}
			catch (e) {
				try {
					objXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {
					objXMLHTTP = false;
				}
			}
	@else
		if (!objXMLHTTP && document.createElement) {
			try {
				objXMLHTTP = new XMLHttpRequest();
			}
			catch (e) {
				objXMLHTTP = false;
			}
		}
	@end @*/
	
	if (!objXMLHTTP && document.createElement) {
		objXMLHTTP = new XMLHttpRequest(); 
	}

    objXMLHTTP.open("GET", strURL);
    
    objXMLHTTP.onreadystatechange = function() {
        if (objXMLHTTP.readyState == 4 && objXMLHTTP.status == 200) {
            objPageElement.innerHTML = objXMLHTTP.responseText;
        }
    }
    
    objXMLHTTP.send(null);
}


/********************************************
A wrapper function for loadFragmentInToElement to
insert a specified TOS page into the contentarea div 
********************************************/

var objCurrentLink;

function loadTOS(strPage, objLink) {
	// Unstyle the previous link
	if (objCurrentLink)
		objCurrentLink.className = '';
		
	// And style the new one
	if (objLink) {
		objLink.className = 'selected';
		objCurrentLink = objLink;
	}
	
	loadFragmentInToElement('./DatabaseImport.asp?page=' + strPage, 'contentarea');
	
	document.getElementById("contentarea").scrollTop = 0;
}


/********************************************
Prints the current page
********************************************/

function printPage() {
	window.print();	
}

/********************************************
Closes the window
********************************************/

function closeWindow() {
	window.close();	
}
