// Add event handler to body when window loads
function addLoadEvent(func) {
	var oldonload = window.onload;
	
	if (typeof window.onload != "function") {
		window.onload = func;
	} else {
		window.onload = function () {
			oldonload();
			func();
		}
	}
}

addLoadEvent(function () {
	// More code to run on page load
	fixCallOuts();
});


// Adjust widths of callouts depending on size of image within
function fixCallOuts() {
	// Check for functionality
	if (!document.getElementById || !document.getElementsByTagName) return false;
	
	var arrBins = document.getElementsByTagName("div");
	var classRE = /call-[lr]/gi;
	
	// Set div width = image width
	for (var i = 0; i < arrBins.length; i++) {
		if (classRE.test(arrBins[i].className)) {
			var images = arrBins[i].getElementsByTagName("img");
			if (images.length >= 1) {
				arrBins[i].style.width = images[0].offsetWidth + "px";
			}
			
			var videos = arrBins[i].getElementsByTagName("object");
			if (videos.length >= 1) {
				arrBins[i].style.width = videos[0].width + "px";
			}
		}
	}
}