// preload off screen images
var cacheObj = new Array();
function loadOffScreenImages(){
	var argArray = (typeof arguments[0] == "object") ? arguments[0] : arguments;
	for (var i=0; i < argArray.length; i++){
		var indexNum = cacheObj.length;
		cacheObj[indexNum] = new Image();
		cacheObj[indexNum].src = argArray[i];
	}
}

// multi image swap
function switchImage(){
	if(document.getElementById){
		for (var i=0; i < arguments.length; i=i+2){
			document.getElementById(arguments[i]).src = arguments[i+1];
		}
	}
}
	
window.onload = function(){if(typeof(images) != "undefined"){loadOffScreenImages(images);}}

// open browser window
function openWindow(theURL,winName,features) {
	if(typeof viewer != "undefined" && viewer.closed == false) { // this object exists and is open
		//if(viewer.name != winName) {// content is for different window
			viewer.close(); // attempt to close the window
		//}
	}
	
  	viewer = window.open(theURL,winName,features); // open window
  	viewer.focus(); // bring open window to front
}

function openResultViewer2(topic,num_images){
	if(location.protocol == "http:"){
		if(location.hostname == "localhost"){
			var path = "http://localhost/fedele2/procedures/";
		} else {
			var path = "http://www.drfedele.com/procedures/";
		}
	} 
	var url = path + 'resultsviewer2.html?t=' + topic + '&p=' + num_images;
	openWindow(url,'resultviewer2','width=535,height=814,resizable=no');
}

// build email address and launch email app - protect from spam bots
function mail(account,domain){
	window.location.href = "mailto:" + account + "@" + domain;
}