var _Debug = true, _UseConsole = true,  _UsePopups = false;

function myAlert(value) {
	if (_Debug) {
		if ((_UseConsole) && (window.console)) {
			console.log(value);
		} else if (_UsePopups) {
			alert(value);
		}
	}
}

var img1 = new Image();
img1.src = "/assets/images/loading-animation.gif";

var img2 = new Image();
img2.src = "/assets/images/harveyNorman/loading-animation.gif";

function linkClicked() {
	$('loading-popup').style.display = "block";
}

function setupLoadingEvents() {
	$A(document.getElementsByTagName("A")).each(function(element) {
		// The last argument in the IF statement below, is a regular expression that filters out
		// links with mailto: at the start of them (links to send an email).
		if (element.target == "" && element.onclick == null && !/.*#.*/.test(element.href) && !/mailto:.*/.test(element.href) && element.className != 'noLoadingDisplay' && !/x-tree-node-anchor/.test(element.href)) {
			element.onclick = linkClicked;
		}
	});
	$A(document.getElementsByTagName("FORM")).each(function(element) {
		element.onsubmit = linkClicked;
	});
}

function confirmDelete(delUrl) {
  if (confirm("Are you sure you want to delete this record")) {
	document.location = delUrl;
  }
}

function doMoreInformation(thisLink, sourceLink, title, url, width) {
	// generic popup.
	if (window.treeWindow) { 
		window.treeWindow.hide();	
	}
	if (width == null) { 
		width = 600;
	}
	window.treeWindow = new Ext.Window({
		layout:'fit',
		width: width,
		closeAction:'hide',
//			maximizable: true,
		plain: true,
		title: title,
		autoScroll: true,
		modal: true,
		animateTarget: sourceLink,
		contentEl: thisLink,
		buttons: [{
			text: 'Close',
			handler: function(){
				window.treeWindow.hide();
			}
		}]
	});
	window.treeWindow.show();
}
