var w3c = (document.getElementById);
var IE4 = (document.all && !w3c);

// preload off screen images
var cacheObj = new Array();
var graphicsDir;
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 = graphicsDir + argArray[i];
	}
}

function swapImage(id,url){
	if(w3c){
		document.getElementById(id).src = url;
	} else if(IE4){	
		document.all[id].src = url;
	} else {
		return;
	}
}

function printuploadmsg(){
	if(w3c && document.forms[0].photo.value != ""){
		document.getElementById("uploadmsg").style.display = "block";
		document.getElementById("uploadmsg").innerHTML = "UPLOADING DATA...<br>Please wait while the browser sends your application and photograph <br>to the server for processing.";
	}
}

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

function mailovsps(){
	mail("lyonsden","ameritech.net");
}


// conference registration form
function calculateFees(formobj){
	var f = formobj;
	var totalfee = 0;
	var numtickets = (typeof f.numtickets != "undefined") ? Number(f.numtickets.value) : 0
	
	// find selected membership radio button
	for(var i=0; i<f.membership.length; i++){
		if(f.membership[i].checked){
			totalfee = fees[f.membership[i].value];
			break;
		}
	}
	
	if(f.guest.checked){ totalfee += fees['guest']; }
	if(numtickets > 0){ totalfee += numtickets * fees['specialevent'];}
	
	totalfee = CurrencyFormatted(totalfee); // get format with trailing 0's and 2 decimals
	
	var msg = "Total Registration Fee: $";
	if(document.getElementById){
		document.getElementById("total").innerHTML = msg + totalfee;
	} else if(document.all){
		document.all("total").innerHTML = msg + totalfee;
	} else {
		alert(msg + totalfee);
	}
}

function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}
