function ct(bar, foo){
	if(bar.value==foo) bar.value='';
}



/*
*    Animated Navbar Code
*/

var curr = '';

function showhome(){ animShow('tl_home',25,0,0); animHide('tl_whatson');}
function showwhatson(){ animShow('tl_whatson',25,0,0); animHide('tl_home');}
function showannouncements(){ animHide('tl_home'); animHide('tl_whatson');}
function showhomebut(){ animHide('tl_home'); animHide('tl_whatson');}

function shownav(sect){
	
	if(curr == '') curr = 'homebut';
	
	if(curr != sect){
		document.getElementById('tm_'+curr).style.backgroundImage = 'none';
		document.getElementById('tm_'+sect).style.backgroundImage = 'url(../images/navbg_over.jpg)';
		
		try {
			var myAnim = new YAHOO.util.Anim('tl_'+curr);
			myAnim.attributes.height = {to: 0, unit: 'px' };
			myAnim.duration = 0.2;
			myAnim.method = YAHOO.util.Easing.easeOut;
			myAnim.onComplete.subscribe(eval('show'+sect));
			myAnim.animate();
		} catch(err){
			var obj = document.getElementById('tl_'+curr);
			obj.style.height = '0px';
			obj.style.paddingTop = '0px';
			obj.style.paddingBottom = '0px';
			obj.style.marginTop = '0px';
			obj.style.marginBottom = '0px';
			obj.style.opacity = '0';
		}
		
		curr = sect;
	}
}


/*
*
*    Archive Javascript
*
*/

var archiveError = "An error has occurred while archiving\r\n\r\nPlease try again.\r\nIf it still won't work, email the webmaster via the contact page";


function mArchiveOK(req){
	
	var xml = Spry.XML.documentToObject(req.xhRequest.responseXML);	
	var xmlElement = xml.xmlresponse.element._value();
	var xmlOk = xml.xmlresponse.ok._value();
	var xmlString = xml.xmlresponse.string._value();
	
	if(xmlOk == 'true'){
		animDestroy(xmlElement);
	} else {
		alert(xmlString);
	}
}

function mArchiveError(req){
	alert(archiveError);
}


function mArchive(id,title,element,act,what){
	if(confirm('Are you sure you want to archive "'+title+'" ?') && id != '' && element != ''){	
		var req = Spry.Utils.loadURL("GET", "/church/edit/archiver.php?id="+id+"&element="+escape(element)+'&archive='+act+'&what='+what, true, mArchiveOK, { headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" }, errorCallback: mArchiveError });
	} else {
		alert(archiveError);
	}
}
