
var loadingAddress='http://www.magnapubsadmin.com/theme/images/sitebox_loading.gif'

// basic function to get the AJAX object and return it
function getXMLHttp() {
	var xmlHttp
	try {
		// ff, opera8, safari
		xmlHttp = new XMLHttpRequest();
	} catch(e) {
		// ie
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				alert("Your browser does not support AJAX!")
				return false;
			}
		}
	}
	return xmlHttp;
}

// function takes the address to load and the div id to load it into.
// this comes in handy for ajax calls all over the rest of the site as
// it's very easy to create new ajax content very easily.
function ajaxpage(page,div) {
	document.getElementById(div).innerHTML="<center><img src='"+loadingAddress+"' border=0 style='margin:50px;' /></center>"
	var jpg = 0
	var png = 0
	var gif = 0
	var is_image = false;
    jpg = page.indexOf('.jpg');
    png = page.indexOf('.png');
    gif = page.indexOf('.gif');
    if ( jpg>0 && is_image==false ) is_image=true;
    if ( gif>0 && is_image==false ) is_image=true;
    if ( png>0 && is_image==false ) is_image=true;
	if ( is_image ) {
		document.getElementById(div).innerHTML="<center><img src='"+page+"' border=0 style='margin:50px;border:1px solid #666;' /></center>"
	} else {
		var xmlHttp = getXMLHttp();
		xmlHttp.onreadystatechange = function() {
			if(xmlHttp.readyState == 4) {
				document.getElementById(div).innerHTML = xmlHttp.responseText;
			}
		}
		xmlHttp.open("GET", page, true); 
		xmlHttp.send(null);
	}
}




