function sniffBrowsers() {
	ns4	= document.layers;
	op5	= (navigator.userAgent.indexOf("Opera 5")!=-1) || (navigator.userAgent.indexOf("Opera/5")!=-1);
	op6	= (navigator.userAgent.indexOf("Opera 6")!=-1) || (navigator.userAgent.indexOf("Opera/6")!=-1);
	agt	= navigator.userAgent.toLowerCase();
	mac	= (agt.indexOf("mac")!=-1);
	ie	= (agt.indexOf("msie") != -1);
	mac_ie	= mac && ie;
}
function getElementHeight(Elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.height;
	} else {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all) {
			var elem = document.all[Elem];
		}
		if (op5) {
			xPos = elem.style.pixelHeight;
		} else {
			xPos = elem.offsetHeight;
		}
		return xPos;
	}
}
function getObjNN4(obj,name) {
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++) {
		if (x[i].id == name)
			foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}
/* REMOVE RESIZING
function resizeMain() {
	//var mainBoxHeight = document.getElementById('mainTable').offsetHeight;
	//document.getElementById('content').style.height=mainBoxHeight+"px";
	//document.getElementById('content').style.minHeight=mainBoxHeight+"px";
	/*if(document.getElementById('modbg')) {
		var mainBoxHeight	= getElementHeight('mainTable') - getElementHeight('modbg') - 60;
	}
	else {
		var mainBoxHeight	= getElementHeight('mainTable') - 60;
	}*/
/*
	var mainBoxHeight	= getElementHeight('mainTable') - 60;
	var menuHeight		= getElementHeight('cbleft');
	var contentHeight	= getElementHeight('content');
	if((menuHeight >= contentHeight) && (mainBoxHeight >= contentHeight)) {
		document.getElementById('mainBox').style.minHeight=mainBoxHeight+"px";
		if((ie) || (mac_ie)) { document.getElementById('mainBox').style.height=mainBoxHeight+"px"; }
		else { document.getElementById('mainBox').style.height="auto"; }
	}
}
*/
/* *** */
function goUrl(uri) {
	if(uri != "0") {
		document.location.href = uri;
	}
	return false;
}
/* *** */
oldImgId = 1;
function teamImg(teamImgId,teamImgSrc,teamImgAlt,teamImgTitle) {
	tImgId    = teamImgId;
	tImgSrc   = teamImgSrc;
	tImgAlt   = teamImgAlt;
	tImgTitle = teamImgTitle;
	if(tImgId != oldImgId) {
		Effect.Fade('teamImage', { duration: 0.250 });
		setTimeout('document.getElementById(\'teamImage\').src=""',260);
		setTimeout('document.getElementById(\'teamImage\').src="/thumb/phpThumb.php?src="+tImgSrc+"&w=468"',261);
		setTimeout('document.getElementById(\'teamImage\').alt=""',262);
		setTimeout('document.getElementById(\'teamImage\').alt=tImgAlt',263);
		setTimeout('document.getElementById(\'teamImage\').title=""',264);
		setTimeout('document.getElementById(\'teamImage\').title=tImgTitle',265);
		setTimeout('document.getElementById(\'teamPopup\').onclick=function(){popImage(tImgSrc);}',266);
		setTimeout('Effect.Appear(\'teamImage\', { duration: 0.250 })',270);
	}
	oldImgId = tImgId;
	return false;
}
/* *** */
function outreachMonth(monthOut,monthIn) {
	Effect.Fade('outreach'+monthOut, { duration: 0.250 });
	setTimeout('Effect.Appear(\'outreach'+monthIn+'\', { duration: 0.250 })', 260);
	//document.getElementById('outreach'+monthOut).style.display="none";
	//document.getElementById('outreach'+monthIn).style.display="block";
}
/* *** */
function validate_required(field,alerttxt) {
	with (field) {
		if((value == null) || (value == "") || (value == "0")) { alert(alerttxt); return false; }
		else { return true; }
	}
}
function validate_email(field,alerttxt) {
	with (field) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if((apos < 1) || (dotpos - apos < 2)) { alert(alerttxt); return false; }
		else { return true; }
	}
}
function validate_newsletter(thisform) {
	with (thisform) {
		if(validate_required(shhdd,"You must enter an email address.")==false) { shhdd.focus(); return false; }
		if(validate_email(shhdd,"You must enter a valid email address.")==false) { shhdd.focus(); return false; }
	}
}
function validate_form(thisform) {
	with (thisform) {
		if(validate_required(Name,"Your Name is a required field.")==false) { Name.focus(); return false; }
		if(validate_required(Email,"Your Email is a required field.")==false) { Email.focus(); return false; }
		if(validate_email(Email,"Your Email must be a valid email address.")==false) { Email.focus(); return false; }
	}
}
function validate_donate(thisform) {
	if(thisform.x_amount.value == "0.00") { alert("Total Amount must be greater than $"+thisform.x_amount.value); return false; }
	if(thisform.x_amount.value <= "0.99") { alert("Total Amount must be greater than $"+thisform.x_amount.value); return false; }
	if(thisform.x_method.value == "CC") {
		with (thisform) {
			if(validate_required(x_first_name,"First Name on Card is a required field.")==false)	{ x_first_name.focus(); return false; }
			if(validate_required(x_last_name,"Last Name on Card is a required field.")==false)	{ x_last_name.focus(); return false; }
			if(validate_required(x_card_num,"Card Number is a required field.")==false)		{ x_card_num.focus(); return false; }
		}
	}
	with (thisform) {
		if(validate_required(x_contact_first,"First Name is a required field.")==false)	{ x_contact_first.focus(); return false; }
		if(validate_required(x_contact_last,"Last Name is a required field.")==false)	{ x_contact_last.focus(); return false; }
		if(validate_required(x_address,"Address is a required field.")==false)		{ x_address.focus(); return false; }
		if(validate_required(x_city,"City is a required field.")==false)		{ x_city.focus(); return false; }
		if(validate_required(x_state,"You must select a State.")==false)		{ x_state.focus(); return false; }
		if(validate_required(x_zip,"Zip is a required field.")==false)			{ x_zip.focus(); return false; }
		if(validate_required(x_country,"You must select a Country.")==false)		{ x_country.focus(); return false; }
		if(validate_required(x_phone_home,"Home Phone is a required field.")==false)	{ x_phone_home.focus(); return false; }
		if(validate_required(x_email,"Email Address is a required field.")==false)	{ x_email.focus(); return false; }
		if(validate_email(x_email,"Email Address must be valid.")==false)		{ x_email.focus(); return false; }
		if(validate_required(x_amount,"Total Amount is a required field.")==false)	{ x_amount.focus(); return false; }
	}
	thisform.submit.disabled=true;
	thisform.submit.style.color="#999";
	thisform.submit.style.backgroundColor="#eee";
	thisform.submit.style.borderColor="#999";
}
/* *** */
var GrandTotal = 0;
generalFund = 0;
truckFund = 0;
ministryTeamFund = 0;
printMaterialFund = 0;
function donateTotal() {
	generalFund = CurrencyFormatted(document.donate.x_amount_general.value);
	truckFund = CurrencyFormatted(document.donate.x_amount_truck.value);
	ministryTeamFund = CurrencyFormatted(document.donate.x_amount_team.value);
	printMaterialFund = CurrencyFormatted(document.donate.x_amount_print.value);
	document.donate.x_amount_general.value = CurrencyFormatted(document.donate.x_amount_general.value);
	document.donate.x_amount_truck.value = CurrencyFormatted(document.donate.x_amount_truck.value);
	document.donate.x_amount_team.value = CurrencyFormatted(document.donate.x_amount_team.value);
	document.donate.x_amount_print.value = CurrencyFormatted(document.donate.x_amount_print.value);
	GrandTotal = (parseFloat(generalFund) + parseFloat(truckFund) + parseFloat(ministryTeamFund) + parseFloat(printMaterialFund));
	if (GrandTotal<.01) { GrandTotal=0; }
	GrandTotal = CurrencyFormatted(GrandTotal);
	document.donate.x_amount.value = GrandTotal;
}
function donateType(thisType) {
	if(thisType == 'monthly') { Effect.SlideDown('monthly', { duration: 0.500 }); }
	else { Effect.SlideUp('monthly', { duration: 0.500 }); }
}
function donateMethod(thisMethod) {
	if(thisMethod == 'CC') {
		Effect.SlideUp('CHECK', { duration: 0.500 });
		setTimeout('Effect.SlideDown(\'CC\', { duration: 0.500 })',510);
	}
	else {
		Effect.SlideUp('CC', { duration: 0.500 });
		setTimeout('Effect.SlideDown(\'CHECK\', { duration: 0.500 })',510);
	}
}

function IsNumeric(sText) {
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.length && IsNumber == true; i++) {
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1) { IsNumber = false; }
	}
	return IsNumber;
}
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;
}
/* *** */
PositionX = 100;
PositionY = 100;
defaultWidth  = 800;
defaultHeight = 500;
var AutoClose = false;
if (parseInt(navigator.appVersion.charAt(0))>=4){
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}
var optNN='scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=yes,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
	if(isNN) { imgWin=window.open('about:blank','',optNN); }
	if(isIE) { imgWin=window.open('about:blank','',optIE); }
	with(imgWin.document) {
		writeln('<html><head><title>Loading...</title><style>body{margin:0;}</style>');writeln('<sc'+'ript>');
		writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
		writeln('width=300-(document.body.clientWidth-document.images[0].width);');
		writeln('height=300-(document.body.clientHeight-document.images[0].height);');
		writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
		writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
		writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
		if (!AutoClose) writeln('</head><body bgcolor="#000000" onload="reSizeToImage();doTitle();self.focus()">')
		else writeln('</head><body bgcolor="#000000" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
		writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
		close();		
	}
}
var recNN='scrollbars=yes,width=500,height=700,left='+PositionX+',top='+PositionY;
var recIE='scrollbars=yes,width=500,height=700,left='+PositionX+',top='+PositionY;
function showReceipt() {
	if(isNN) { recWin=window.open('about:blank','',recNN); }
	if(isIE) { recWin=window.open('about:blank','',recIE); }
	with(recWin.document) {
		writeln('<html><head><title>Loading Receipt...</title><style>body{margin:0;}</style>');writeln('<sc'+'ript>');
		//writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
		//writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		//writeln('function doReSize() { if(isIE) { window.resizeTo(500,700); } if(isNN) { window.innerWidth=500; window.innerHeight=700; } }');
		writeln('function doTitle() { document.title="Print Receipt"; }');writeln('</sc'+'ript>');
		writeln('<link rel="stylesheet" type="text/css" media="all" href="/css/style_receipt.css" />');
		writeln('</head><body onload="doTitle();self.focus();">');
		/* *** */
		writeln('<div id="donation"><div class="step7"><h6>Delivering Africa: Contribution Receipt</h6>');
		writeln(document.getElementById('receipt').innerHTML);
		writeln('</div></div>');
		/* *** */
		writeln('</body></html>');
		close();
	}
}
