/*
Generic AJAX HTML library. Contains a few generalized functions to get a URL with XMLHTTPRequest and show it in a DIV
See Wiki for more information
*/
/*
OpenDIV( divname )
This function will make a div visible. It is only one way! If you want open and close then see below. Takes the id of a div
*/
function OpenDIV( divname ) {
if (document.getElementById) { // DOM3 = IE5, NS6
if (document.getElementById(divname).style.display == "none"){
document.getElementById(divname).style.display = 'block';
}
} else {
if (document.layers) {
if (document.divname.display == "none"){
document.divname.display = 'block';
}
} else {
if (document.all.divname.style.visibility == "none"){
document.all.divname.style.display = 'block';
}
}
}
}
/*
CloseDIV( divname )
This function will make a div invisible. It is only one way! If you want open and close then see below. Takes the id of a div
*/
function CloseDIV( divname ) {
if (document.getElementById) { // DOM3 = IE5, NS6
if (document.getElementById(divname).style.display != "none"){
document.getElementById(divname).style.display = 'none';
}
} else {
if (document.layers) {
if (document.divname.display != "none"){
document.divname.display = 'none';
}
} else {
if (document.all.divname.style.visibility != "none"){
document.all.divname.style.display = 'none';
}
}
}
}
/*
OpenCloseDIV( id )
This function takes an id. The function will look for a div named (id)_block and change the visibility of it. In addition to the _block div it will also try to switch images for (id)_img image tag. It will do a plus sign when (id)_block is not visible and minus when it is
*/
function OpenCloseDIV(id,img_path,table,image_open,image_close,custom_path) {
var divname = id + "_block";
var imgname = id + "_img";
var newimg
// make this useful to tables as well
var type = 'block';
if ( table == 1 ) { type = 'table'; }
if (document.getElementById) { // DOM3 = IE5, NS6
if ( type == 'block' ){
if (document.getElementById(divname).style.display == "none"){
document.getElementById(divname).style.display = "block";
newimg = 'minus'
} else {
document.getElementById(divname).style.display = 'none';
newimg = 'plus'
}
} else {
if (document.getElementById(divname).style.display == 'none'){
document.getElementById(divname).style.display = '';
newimg = 'minus'
} else {
document.getElementById(divname).style.display = 'none';
newimg = 'plus'
}
}
} else {
if (document.layers) {
if (document.divname.display == "none"){
document.divname.display = "block";
newimg = 'minus'
} else {
document.divname.display = 'none';
newimg = 'plus'
}
} else {
if (document.all.divname.style.visibility == "none"){
document.all.divname.style.display = "block";
newimg = 'minus'
} else {
document.all.divname.style.display = 'none';
newimg = 'plus'
}
}
}
if ( document.images[imgname] ) {
var Imgs = new Object;
if ( img_path ) {
Imgs.minus = img_path+"arrow_down.gif";
Imgs.plus = img_path+"arrow_right.gif";
}
else if ( custom_path ) {
Imgs.minus = custom_path+image_close;
Imgs.plus = custom_path+image_open;
}
else if ( image_open ) {
Imgs.minus = "https://secure.bizland.com/images"+image_close;
Imgs.plus = "https://secure.bizland.com/images"+image_open;
}
else {
Imgs.minus = "https://secure.bizland.com/images/greenarrow.gif";
Imgs.plus = "https://secure.bizland.com/images/redarrow.gif";
}
switchimg(imgname,Imgs[ newimg ]);
}
}
/*
getAJAXHTML( name , url , extras , append , noblink , showprogress , sucfunc , errfunc )
This is the main function for making an AJAX request. It takes several options:
name - the name of the div to change with the request
url - optional URL of the script to call. This allows you to use a script other than the one the javascript is called from.
extras - If you are calling back to the script that has the javascript in it , then you can just pass the parameters for the GET request. The script will prepend http://machine/script? to the extras.
append - Append to the div instead of overwriting
noblink - Turns off the 'Getting Data' blinking tag.
showprogress - If true it will write to the div as it loads ( doesn't work in IE )
sucfunc - A function to run on success. req object is passed in
errfunc - A function to run on error. req object is passed in
You need to send a div and you need url or extras
*/
function getAJAXHTML( name , url , extras, append, noblink , showprogress , sucfunc , errfunc ) {
if ( ! url ) {
url = window.location + '?' + extras
}
if (noblink != 1){
changeDiv( name ,'
')
}
var request = new makeReq( url , name, append , showprogress , sucfunc , errfunc )
// request.doGet() AJAX GET is a problem in IE
// because IE thinks it should cache it, so it does
// not frequently does not load fresh content
request.doPost();
}
/*
postAJAXHTML( name , url , formid, append , noblink , showprogress , sucfunc , errfunc )
POST version of getAJAXHTML. Rather than an optional list of 'extra' params to send
in the query string, requires the id of a form on the page to read parameters from.
Sends values of all non-blank inputs from the given form, except for unchecked radios
and checkboxes.
*/
function postAJAXHTML( name, url, form, append, noblink, showprogress, sucfunc, errfunc ) {
if ( ! url ) {
url = window.location;
}
var eForm = document.getElementById( form );
var aInputs = eForm.getElementsByTagName( "input" );
var aParams = new Array();
// gather list of form params to send with post
for ( var i = 0; i < aInputs.length; i++ ) {
var eI = aInputs[i];
if ((( eI.type == 'checkbox' ) || ( eI.type == 'radio' )) && ( ! eI.checked )) {
continue;
}
if ( eI.value ) {
aParams.push( eI.name + '=' + eI.value );
}
}
var request = new makeReq( url , name, append , showprogress , sucfunc , errfunc );
var postBody = aParams.join( '&' );
request.doPost( aParams.join( '&' ) );
if ( noblink != 1 ) {
changeDiv( name, '
' ) ;
}
}
/*
changeDiv( divname, contents )
Internal function to change the contents of a div.
*/
function changeDiv(divname,contents, append) {
var obj;
if (document.getElementById) { // DOM3 = IE5, NS6
//document.getElementById(divname).innerHTML = contents;
obj = document.getElementById(divname);
} else if (document.layers) {
//document.divname.innerHTML = contents;
obj = document.divname;
} else {
//document.all.divname = contents;
obj = document.all.divname;
}
// need to check if session expired, so it doesn't
// return the login page in a div...
if ( contents.match('