/* common AJAX stuff */

var base_url = window.location.protocol + "//" + window.location.host + "/";

xmlHttp = false;

function sendAJAXRequest(url, o) {
    
    //    document.write(url);
    xmlHttp = GetXmlHttpObject();
    
    xmlHttp.onreadystatechange = function(){
        if (xmlHttp.readyState == 4) {
	    if (xmlHttp.status == 200) {
		if (typeof(o) == 'object') {
		    o.processResponse();
		}
	    }
	}
    }
    xmlHttp.open('GET', url, true);
    xmlHttp.send(null);
}


function sendAJAXRequestSimple(url) {

    //    document.write(url);
    xmlHttp = GetXmlHttpObject();

    xmlHttp.onreadystatechange = function(){
        if (xmlHttp.readyState == 4) {
            if (xmlHttp.status == 200) {
		// great!
            }
        }
    }

    xmlHttp.open('GET', url, true);
    xmlHttp.send(null);
}



function GetXmlHttpObject() { 
    var http_request=null;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
	http_request = new XMLHttpRequest();
	if (http_request.overrideMimeType) {
	    // set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
	}
    } else if (window.ActiveXObject) { // IE
	try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
            try {
		http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
	}
    }
    if (!http_request) {
	alert('Cannot create XMLHTTP instance');
	return false;
    }    
    return http_request;
}

function closeWithParentReload() {
	window.close();
	if (window.opener && !window.opener.closed) {
		window.opener.location.reload();
	}
}

/* more common stuff -sjm */

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById && document.getElementById(id)) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers && document.id) { // Netscape 4
			document.id.display = 'none';
		}
		else if(document.all && document.all.id) { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function newWindowOpen(newWindowURL,newWindowName,newWindowOptions) {
                 var windowOptions = newWindowOptions;
                 if (!newWindowOptions) {
                        windowOptions = 'scrollbars=yes,menubar=no,height=750,width=800,resizable=yes,toolbar=no,location=no,status=no';
                 }
                 var evalstr = newWindowName+" = window.open(newWindowURL,newWindowName,windowOptions);";
                 eval (evalstr);

		 var focusstr = newWindowName+".focus()";
		 eval (focusstr);

}


function autoTab(original,destination) {
  if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
  destination.focus()
}

