function fix_obfuscation(whichpage) {
	var tags = document.body.getElementsByTagName("span");
	for( var i=0; i<tags.length; i++ ) {
		name=-1;
		switch( tags[i].className ) {
		case 'yqr':
			name=0,subj=1,link=-1,dom='bethelsf.org';
			break;
		case 'lyqr':
			link=0,name=1,subj=2,dom='bethelsf.org';
			break;
		case 'yqq':
			dom=0,name=1,subj=2,link=-1;
			break;
		case 'lyqq':
			link=0,dom=1,name=2,subj=3;
			break;
		}
		if(name>=0) {
			arr=tags[i].innerHTML.split("|");
			subj=arr[subj]?arr[subj]:whichpage;
			addr=arr[name]+"@"+((dom.length>3)?dom:arr[dom]);
			link=link<0?addr:arr[link];
			tags[i].innerHTML = '<a href="mailto:'+addr+'?subject='+subj+'">'+link+'</a>';
			tags[i].style.display = "inline";
		}
	}
}

// RGJ event insert
function RGJ_addEvent( obj, type, fn ) {
	if( obj.attachEvent ) {
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
		obj.attachEvent( 'on'+type, obj[type+fn] );
	} else obj.addEventListener( type, fn, false );
}

// RGJ img dissolver
function RGJ_PRobj(dir,id,period,dissolve,names){this.dir=dir;this.id=id;this.period=period;this.dissolve=dissolve;this.names=names;this.index=this.fimg=this.fstrt=this.fid=0;}
function RGJ_PRinit(i) {
	var pr = new Array;
	for( j=0; j<gpr[i].names.length; j++ ) {
		pr[j] = new Image;
		pr[j].src = gpr[i].dir+'/'+gpr[i].names[j];
	}
	setInterval('RGJ_PRcallback('+i+')',gpr[i].period);
}
function RGJ_PRsetOp(elem,op){elem.style.opacity=op/100;elem.style.filter="alpha(opacity="+op+")";}
function RGJ_PRcallback(i) {
	if(++gpr[i].index>=gpr[i].names.length) gpr[i].index=0;
	div=document.getElementById(gpr[i].id);
	gpr[i].fimg=div.getElementsByTagName('img')[0];
	div.style.backgroundImage="url('"+gpr[i].fimg.src+"')";
	div.style.backgroundRepeat="no-repeat";
	gpr[i].fimg.src=gpr[i].dir+'/'+gpr[i].names[gpr[i].index];
	if( gpr[i].dissolve ) {
		RGJ_PRsetOp(gpr[i].fimg,0);
		dt=new Date();gpr[i].fstrt=dt.getTime();
		gpr[i].fid=setInterval('RGJ_PRfservice('+i+')',33.33);
	}
}
function RGJ_PRfservice(i) {
	dt=new Date();op=Math.round((dt.getTime()-gpr[i].fstrt)/gpr[i].dissolve*100);
	if(op<=1)op=1;if(op>=100){op=100;clearInterval(gpr[i].fid);}
	RGJ_PRsetOp(gpr[i].fimg,op);
}

// ajax
function ajaxDivUpdate( div, url ) {
	var hr,ajax=true;
	try { hr=new XMLHttpRequest(); }
	catch(e) { try { hr=new ActiveXObject("Msxml2.XMLHTTP"); }
	catch(e) { try { hr=new ActiveXObject("Microsoft.XMLHTTP"); }
	catch(e) { ajax = false; } } }
	if( ajax ) {
		hr.onreadystatechange=function() { if( hr.readyState==4 ) document.getElementById(div).innerHTML = hr.responseText; }
		hr.open("GET",url,true);
		hr.send(null);
	}
}

// pop-ups
function bulletin( which ) { popup_center( which, '/happenings/bulletin_popup/?b=' + which, 484, 736 ); }
function popcalendar() { popup_center( '', '/happenings/calendar/popup_calendar.php', 900,776 ); }
function popup_center( name, link, popW, popH ) {
	x = (document.all)?window.screenLeft:window.screenX;
	y = (document.all)?window.screenTop:window.screenY;
	yslop = 0;
	w = document.body.clientWidth;
	h = document.body.clientHeight;
	return window.open(js_bethel_baseURL+link, name, 'width='+popW+',height='+popH+',top=' + (((h-popH)/2)+y+yslop) + ',left=' + (((w-popW)/2)+x) +',status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes,menubar=no' );
}
