// Ajax Content Loader

function ahah(url, target, anum, loadWaitImage, postProc, ldWaitDiv) {
	if(loadWaitImage != null) {
		if(ldWaitDiv != null) {
			if(loadWaitImage == 2) {
				document.getElementById(ldWaitDiv).innerHTML = '<img src="/images/loading-image-gen.gif" id="loading" class="loadblock" />';
			} else {
				document.getElementById(ldWaitDiv).innerHTML = '<img src="/images/loading-image.gif" id="loading" />';
			}
		} else {
			if(loadWaitImage == 2) {
				document.getElementById(target).innerHTML = '<img src="/images/loading-image-gen.gif" id="loading" class="loadblock" />';
			} else {
				document.getElementById(target).innerHTML = '<img src="/images/loading-image.gif" id="loading" />';
			}
		}
	}
	var reqvar = "req";
	if(anum != null) {
		reqvar = "req"+anum;
	}
	if (window.XMLHttpRequest) {
		eval(reqvar+' = new XMLHttpRequest();');
	} else if (window.ActiveXObject) {
		eval(reqvar+' = new ActiveXObject("Microsoft.XMLHTTP");');
	}
	if (eval(reqvar+' != undefined')) {
		eval(reqvar+'.onreadystatechange = function() {ahahDone(url, target, anum, postProc);};');
		//alert(reqvar+'.open("GET", url, true);');
		eval(reqvar+'.open("GET", url, true);');
		eval(reqvar+'.send("");');
	}
}  

function ahahDone(url, target, anum, postProc) {
	var reqvar = "req";
	if(anum != null) {
		reqvar = "req"+anum;
	}
	if (eval(reqvar+'.readyState == 4')) { // only if req is "loaded"
		if (eval(reqvar+'.status == 200')) { // only if "OK"
			if(postProc != null) {
				eval('document.getElementById(target).value = '+reqvar+'.responseText;');
				eval(postProc);
			} else {
				if(document.getElementById(target) != null) {
					eval('document.getElementById(target).innerHTML = '+reqvar+'.responseText;');
				}
			}
		} else {
			document.getElementById(target).innerHTML=" Sorry! This page could not be loaded. ";
		}
	}
}

function load(name, div, instance, loadWaitImage, postProc, ldWaitDiv) {
	if(instance) {
		ahah(name,div,instance, loadWaitImage, postProc, ldWaitDiv);
	} else {
		ahah(name, div, null , loadWaitImage, postProc, ldWaitDiv);
	}
	return false;
}


// Toggle Comment Adder

function toggleCommentAdd(){

	if(document.getElementById('comment-adder').state == 'open'){
		document.getElementById('comment-adder').state = 'closed';
		document.getElementById('comment-adder').style.display='none';

		document.getElementById('addComment').className = "addcommentbutton";

	} else {
		document.getElementById('comment-adder').state = 'open';
		document.getElementById('comment-adder').style.display='block';

		document.getElementById('addComment').className = "cancelbutton";


	}

}

/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
