function deletealert(divid)
{
	document.getElementById(divid).style.display = 'none';
}
function stristr( haystack, needle, bool ) {
	// http://kevin.vanzonneveld.net
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// *     example 1: stristr('Kevin van Zonneveld', 'Van');
	// *     returns 1: 'van Zonneveld'
	// *     example 2: stristr('Kevin van Zonneveld', 'VAN', true);
	// *     returns 2: 'Kevin '
	var pos = 0;
	pos = haystack.toLowerCase().indexOf( needle.toLowerCase() );
	if( pos == -1 ){
		return false;
	} else{
		if( bool ){
			return haystack.substr( 0, pos );
		} else{
			return haystack.slice( pos );
		}
	}
}
function draw_prayers(page,denomination)
{
	AjaxRequest.get(
	{
	'url':'http://www.churchtag.com/inc/php/drawPrayers.php?denomination=' + denomination + '&page=' + page
	,'onLoading':function() {
	}
	,'onSuccess':function(req){
		document.getElementById("prayers").innerHTML = req.responseText;
	}
	}
	)
}
function draw_album(page,aid)
{
	AjaxRequest.get(
	{
	'url':'http://www.churchtag.com/inc/php/draw_album.php?aid=' + aid + '&page=' + page
	,'onLoading':function() {
		document.getElementById("current-album").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	}
	,'onSuccess':function(req){
		document.getElementById("current-album").innerHTML = req.responseText;
	}
	}
	)
}
function draw_albums(cid)
{
	AjaxRequest.get(
	{
	'url':'http://www.churchtag.com/inc/php/draw_albums.php?cid=' + cid
	,'onLoading':function() {
		document.getElementById("albums").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	}
	,'onSuccess':function(req){
		document.getElementById("albums").innerHTML = req.responseText;
	}
	}
	)
}
function draw_picture(pid)
{
	AjaxRequest.get(
	{
	'url':'http://www.churchtag.com/inc/php/drawpicture.php?pid=' + pid
		,'onLoading':function() {
		document.getElementById("current-picture").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	}
	,'onSuccess':function(req){
		document.getElementById("current-picture").innerHTML = req.responseText;
	}
	}
	)
}
function show_blog(){
	var visibility = document.getElementById('blog-entry').style.display;
	if (visibility == "none")
	{
		document.getElementById('blog-entry').style.display="block";
	}else{
		document.getElementById('blog-entry').style.display="none";
	}
}
function showInvite(){
	var visibility = document.getElementById('invite').style.display;
	if (visibility == "none")
	{
		document.getElementById('invite').style.display="block";
	}else{
		document.getElementById('invite').style.display="none";
	}
}
function loadbible(bible,book,chapter,thing) {
			
				
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/get' + thing + '.php?bible=' + bible + '&chapter=' + chapter + '&book=' + book
			,'onLoading':function(){
				//document.getElementById("comments").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById(thing).innerHTML = req.responseText;
				if (thing == 'book')
				{
					document.getElementById('verse').innerHTML = 'Select a chapter';
					document.getElementById('chapter').innerHTML = 'Select a book';
					
				}
				if (thing == 'chapter')
				{
					document.getElementById('verse').innerHTML = 'Select a chapter';
				}
				
				
				
				
			}
			}
			);
		}
		
		
function show_blog_reply(){
	var visibility = document.getElementById('blog-reply-entry').style.display;
	if (visibility == "none")
	{
		document.getElementById('blog-reply-entry').style.display="block";
	}else{
		document.getElementById('blog-reply-entry').style.display="none";
	}
}
function submitForm1(theform) {
	var status = AjaxRequest.submit(
	theform
	,{
	'onLoading':function() { document.getElementById("blog-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	document.getElementById("blog-replys").innerHTML = '';
	}
	,'onSuccess':function(req){ document.getElementById("blog-reply-response").innerHTML = req.responseText;
	drawBlogReplys(document.forms['blog-post-reply'].bid.value);
	document.getElementById("blog-loading").innerHTML = '';
	if (stristr(req.responseText,'added'))
	{
		document.getElementById('blog-reply-entry').style.display="none";
	}
	}
	}
	);
	return status;
}
function submitformpost(bib) {
AjaxRequest.get(
	{
	'url':'http://www.churchtag.com/inc/php/dailyversecode.php?bib=' + bib
	,'onLoading':function() { document.getElementById("loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	}
	,'onSuccess':function(req){
		document.getElementById("response").innerHTML = req.responseText;
		document.getElementById("loading").innerHTML = '';
	}
	}
	)
}
function drawBlogReplys(bid) {
	AjaxRequest.get(
	{
	'url':'http://www.churchtag.com/inc/php/drawBlogReplys.php?bid=' + bid
	,'onLoading':function() { document.getElementById("blog-replys").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	document.getElementById("blog-replys").innerHTML = '';
	}
	,'onSuccess':function(req){
		document.getElementById("blog-replys").innerHTML = req.responseText;
	}
	}
	)
}
function submitForm(theform) {
	var status = AjaxRequest.submit(
	theform
	,{
	'onLoading':function() { document.getElementById("blog-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	//document.getElementById("blog").innerHTML = '';
	}
	,'onSuccess':function(req){ document.getElementById("blog-response").innerHTML = req.responseText;
	document.getElementById("blog-loading").innerHTML = '';
	drawBlog(document.forms['blog-post'].cid.value);
	if (stristr(req.responseText,'enter') || stristr(req.responseText,'login'))
	{
		document.getElementById('blog-entry').style.display="none";
	}
	}
	}
	);
	return status;
}
function getbiblequizwidget(theform) {
	var status = AjaxRequest.submit(
	theform
	,{
	'onLoading':function() { document.getElementById("showcode").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	//document.getElementById("blog").innerHTML = '';
	}
	,'onSuccess':function(req){ document.getElementById("showcode").innerHTML = req.responseText;

	}
	}
	);
	return status;
}

function addQuestion(theform) {
	var status = AjaxRequest.submit(
	theform
	,{
	'onLoading':function() { document.getElementById("question").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	}
	,'onSuccess':function(req){ 
		
		document.getElementById("question").innerHTML = req.responseText;
		draw_questions(document.forms['versepick'].category.value,'1');
	
	}
	}
	);
	return status;
}
function addbsComment(theform) {
	var status = AjaxRequest.submit(
	theform
	,{
	'onLoading':function() { document.getElementById("comments-response").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	}
	,'onSuccess':function(req){ 
		
		document.getElementById("comments-response").innerHTML = req.responseText;
		drawbsComments(document.forms['comment'].question.value);
	
	}
	}
	);
	return status;
}
function addmsComment(theform) {
	var status = AjaxRequest.submit(
	theform
	,{
	'onLoading':function() { document.getElementById("comments-response").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	}
	,'onSuccess':function(req){ 
		
		document.getElementById("comments-response").innerHTML = req.responseText;
		drawmsComments(document.forms['comment'].question.value);
	
	}
	}
	);
	return status;
}
function showmembers(church)
{
	AjaxRequest.get(
	{
	'url':'http://www.churchtag.com/inc/php/showmembers.php?church=' + church
	,'onSuccess':function(req){
		document.getElementById("members").innerHTML = req.responseText;
	}
	}
	)
}
function showMyQuestions()
{
	AjaxRequest.get(
	{
	'url':'http://www.churchtag.com/inc/php/showMyQuestions.php'
	,'onSuccess':function(req){
		document.getElementById("myquestions").innerHTML = req.responseText;
	}
	}
	)
}
function add_member(uid,cid) {
	Popup.showModal('member-response',null,null,{'screenColor':'#B4D7E0','screenOpacity':.5,'className':'divpopnew'});
	if (document.getElementById("crossboxcover"))
	{
	dismissboxv2();
	}
	
	
	AjaxRequest.get(
	{
	'onLoading':function() { 
		if (document.getElementById("member-loading")){
		document.getElementById("member-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
		}
	//dismissboxv2();
	}
	,'url':'http://www.churchtag.com/inc/php/add_member.php?uid=' + uid + '&cid=' + cid
	,'onSuccess':function(req){
		document.getElementById("member-response").innerHTML=req.responseText;
		if (document.getElementById("member-loading")){
		document.getElementById("member-loading").innerHTML = '';
		}
		showmembers(cid);
		
		;
	}
	}
	);}
	function addrsvp(eid,cid) {
		AjaxRequest.get(
		{
		'onLoading':function() { document.getElementById("rsvp-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>'; }
		,'url':'http://www.churchtag.com/inc/php/addrsvp.php?eid=' + eid + '&cid=' + cid
		,'onSuccess':function(req){
			document.getElementById("rsvp-response").innerHTML=req.responseText;
			document.getElementById("rsvp-loading").innerHTML = '';
			;
		}
		}
		);}
function draw_questions(category,page)
{
	AjaxRequest.get(
	{
	'url':'http://www.churchtag.com/inc/php/draw_questions.php?category=' + category + '&page=' + page
	,'onLoading':function() {
		document.getElementById("questions").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	}
	,'onSuccess':function(req){
		document.getElementById("questions").innerHTML = req.responseText;
	}
	}
	)
}
		
		function inviteFriends(theform) {
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() {
				document.getElementById("member-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
				document.getElementById("invite-response").innerHTML = '';
			}
			,'onSuccess':function(req){
				document.getElementById("invite-response").innerHTML = req.responseText;
				document.getElementById("member-loading").innerHTML = '';
				if (stristr(req.responseText,'sent'))
				{
					document.getElementById('invite').style.display="none";
				}
			}
			}
			);
			return status;
		}
		function getFriends(theform) {
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() { document.getElementById("member-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			//document.getElementById("blog").innerHTML = '';
			}
			,'onSuccess':function(req){ document.getElementById("invite-response").innerHTML = req.responseText;
			document.getElementById("member-loading").innerHTML = '';
			//document.getElementById('invite').style.display="none";
			}
			}
			);
			return status;
		}
		function addMessage(theform) {
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() { document.getElementById("message-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>'; }
			,'onSuccess':function(req){ document.getElementById("message-response").innerHTML = req.responseText;
			document.getElementById("message-loading").innerHTML = '';
			if (stristr(req.responseText,'sent'))
			{
				document.getElementById('message-post').style.display="none";
			}
			}
			}
			);
			return status;
		}
		function inviteQuiz(theform) {
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() { document.getElementById("quiz-response").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>'; }
			,'onSuccess':function(req){ document.getElementById("quiz-response").innerHTML = req.responseText;
			}
			}
			);
			return status;
		}
		function drawComments(book,chapter) {
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/drawComment.php?book=' + book + '&chapter=' + chapter
			,'onLoading':function(){
				document.getElementById("comments").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("comments").innerHTML = req.responseText;
			}
			}
			);
		}
		
		function drawbsComments(question) {
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/drawStudyComments.php?question=' + question
			,'onLoading':function(){
				document.getElementById("comments-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("comments-loading").innerHTML = '';
				document.getElementById("comments").innerHTML = req.responseText;
			}
			}
			);
		}
		
		function drawmsComments(question) {
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/drawMsComments.php?question=' + question
			,'onLoading':function(){
				document.getElementById("comments-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("comments-loading").innerHTML = '';
				document.getElementById("comments").innerHTML = req.responseText;
			}
			}
			);
		}
		function drawPicComments(pid) {
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/drawPicComments.php?pid=' + pid 
			,'onLoading':function(){
				document.getElementById("photo-comments").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("photo-comments").innerHTML = req.responseText;
			}
			}
			);
		}
		function addalbum(theform) {
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() {
				document.getElementById("add-album").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
				
							}
			,'onSuccess':function(req){
				document.getElementById("add-album").innerHTML = req.responseText;
				
			}
			}
			);
			return status;
		}
		function drawPrayerComments(pid) {
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/drawPrayerComments.php?pid=' + pid
			,'onLoading':function(){
				//document.getElementById("comments").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("PrayerComments").innerHTML = req.responseText;
			}
			}
			);
		}
		function drawprayer(pid) {
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/drawprayer.php?pid=' + pid
			,'onLoading':function(){
				//document.getElementById("comments").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("prayer").innerHTML = req.responseText;
			}
			}
			);
		}
		function joinprayer(pid) {
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/joinprayer.php?pid=' + pid
			,'onLoading':function(){
				//document.getElementById("comments").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("joinprayerresponse").innerHTML = req.responseText;
				showprayers();
			}
			}
			);
		}
		
		
		
		function addComment(theform) {
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() { document.getElementById("comment-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			document.forms['comment-post'].comment.disabled=true;
			//document.getElementById("comments").innerHTML = '';
			}
			,'onSuccess':function(req){
				document.getElementById("comment-response").innerHTML = req.responseText;
				document.getElementById("comment-loading").innerHTML = '';
				document.forms['comment-post'].comment.disabled=false;
				drawComments(document.forms['comment-post'].book.value,document.forms['comment-post'].chapter.value);
			}
 ,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
			}
			);
			return status;
		}
		
		function addpicComment(theform) {
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() { document.getElementById("comment-response").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			document.forms['comment-post'].comment.disabled=true;
			//document.getElementById("comments").innerHTML = '';
			}
			,'onSuccess':function(req){
				document.getElementById("comment-response").innerHTML = req.responseText;
				document.forms['comment-post'].comment.disabled=false;
			drawPicComments(document.forms['comment-post'].pid.value);
			}
			}
			);
			return status;
		}
		function editPrayer(theform)
		{
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() { //document.getElementById("comment-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
				document.forms['editprayer'].prayer.disabled=true;
				document.forms['editprayer'].title.disabled=true;
				//document.getElementById("comments").innerHTML = '';
			}
			,'onSuccess':function(req){
				document.getElementById("editprayerresponse").innerHTML = req.responseText;
				//document.getElementById("comment-loading").innerHTML = '';
				document.forms['editprayer'].prayer.disabled=false;
				document.forms['editprayer'].title.disabled=false;
				if (stristr(req.responseText,'edited'))
				{
					//expandcollapse("editprayer");
					drawprayer(document.forms['editprayer'].pid.value);
				}
			}
			}
			);
			return status;
		}
		function editChurchInfo(theform)
		{
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() {
				document.getElementById("update-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>a';
			}
			,'onSuccess':function(req){
				document.getElementById("editchurchresponse").innerHTML = req.responseText;
				document.getElementById("update-loading").innerHTML = '';
				if (stristr(req.responseText,'Edited') || stristr(req.responseText,'Login'))
				{
					expandcollapse("updateform");
					add_member(document.forms['editchurchinfo'].uid.value,document.forms['editchurchinfo'].cid.value);
				}
			}
			}
			);
			return status;
		}
		function addPrayerComment(theform) {
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() { document.getElementById("prayer-comment-response").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			document.forms['addprayercomment'].comment.disabled=true;
			//document.getElementById("comments").innerHTML = '';
			}
			,'onSuccess':function(req){
				document.getElementById("prayer-comment-response").innerHTML = req.responseText;
				document.forms['addprayercomment'].comment.disabled=false;
				drawPrayerComments(document.forms['addprayercomment'].pid.value);
			}
			}
			);
			return status;
		}
		function deleteComment(cid) {
			myConfirm("Do you really wish to delete this Comment? This is irreversible and all data within this comment will be lost.","Yes","No",
			function(answer) {
				if (answer == true){
					AjaxRequest.get(
					{
					'url':'http://www.churchtag.com/inc/php/delete_comment.php?cid=' + cid
					,'onLoading':function(){
						document.getElementById("comment-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
					}
					,'onSuccess':function(req){
						document.getElementById("comment-response").innerHTML = req.responseText;
						document.getElementById("comment-loading").innerHTML = '';
						drawComments(document.forms['comment-post'].book.value,document.forms['comment-post'].chapter.value);
					}
					}
					);
				}
			});
		}
		function deleteMyQuestion(question) {
			myConfirm("Do you really wish to delete this Question? This is irreversible and all data within this question will be lost.","Yes","No",
			function(answer) {
				if (answer == true){
					AjaxRequest.get(
					{
					'url':'http://www.churchtag.com/inc/php/deleteMyQuestion.php?question=' + question
					,'onLoading':function(){
					}
					,'onSuccess':function(req){
						document.getElementById("question-response").innerHTML = req.responseText;
						showMyQuestions();
					}
					}
					);
				}
			});
		}
		function deleteBlog(cid,bid) {
			myConfirm("Do you really wish to delete this Blog? This is irreversible and all data within this blog will be lost.","Yes","No",
			function(answer) {
				if (answer == true){
					AjaxRequest.get(
					{
					'url':'http://www.churchtag.com/inc/php/delete_blog.php?d=' + bid
					,'onLoading':function(){
						document.getElementById("show-blog-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
					}
					,'onSuccess':function(req){
						document.getElementById("show-blog-loading").innerHTML = req.responseText;
						drawBlog(cid);
					}
					}
					);
				}
			});
		}
		function addReply(theform) {
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() { document.getElementById("reply-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			document.forms['reply-post'].message.disabled=true;
			document.getElementById("replys").innerHTML = '';
			}
			,'onSuccess':function(req){ document.getElementById("reply-response").innerHTML = req.responseText;
			document.getElementById("reply-loading").innerHTML = '';
			document.forms['reply-post'].message.value = '';
			document.forms['reply-post'].message.disabled=false;
			drawReplys(document.forms['reply-post'].mid.value);
			}
			}
			);
			return status;
		}
		function drawReplys(mid) {
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/drawReplys.php?mid=' + mid
			,'onSuccess':function(req){
				document.getElementById("replys").innerHTML = req.responseText;
			}
			}
			);
		}
		var answerFunction;
		function myConfirm(text,button1,button2,answerFunc) {
			var box = document.getElementById("confirmBox");
			box.getElementsByTagName("p")[0].firstChild.nodeValue = text;
			var button = box.getElementsByTagName("input");
			button[0].value=button1;
			button[1].value=button2;
			answerFunction = answerFunc;
			x = 70;
			y = 70;
			if (document.documentElement)
			{
				theLeft = document.documentElement.scrollLeft;
				theTop = document.documentElement.scrollTop;
			}
			else if (document.body)
			{
				theLeft = document.body.scrollLeft;
				theTop = document.body.scrollTop;
			}
			theLeft += x;
			theTop += y;
			box.style.left = theLeft + 'px' ;
			box.style.top = theTop + 'px' ;
			box.style.visibility="visible";
		}
		function answer(response) {
			document.getElementById("confirmBox").style.visibility="hidden";
			answerFunction(response);
		}
		function deletememberchurch(church) {
			myConfirm("Do you really wish to not be a member of this church?","Yes","No",
			function(answer) {
				if (answer == true){
					AjaxRequest.get(
					{
					'url':'http://www.churchtag.com/inc/php/delete_member_church.php?church=' + church
					,'onLoading':function(){
						//document.getElementById("blog-loading").innerHTML = '';
						//document.getElementById("blog-response").innerHTML = '';
						//document.getElementById("blog").innerHTML = '';
					}
					,'onSuccess':function(req){
						showmemberchurches();
					}
					}
					);
				}
			});
		}
function deletealbum(album) {
			myConfirm("Do you really wish to delete this album?","Yes","No",
			function(answer) {
				if (answer == true){
					AjaxRequest.get(
					{
					'url':'http://www.churchtag.com/inc/php/delete_album.php?aid=' + album
					,'onLoading':function(){
						
					}
					,'onSuccess':function(req){
						
						document.getElementById("add-album").innerHTML = req.responseText;
						draw_albums(document.forms['newalbum'].cid.value);
					}
					}
					);
				}
			});
		}
		function deleteevent(eid) {
			myConfirm("Do you really wish to delete this event?","Yes","No",
			function(answer) {
				if (answer == true){
					AjaxRequest.get(
					{
					'url':'http://www.churchtag.com/inc/php/deleteevent.php?eid=' + eid
					,'onLoading':function(){
						//document.getElementById("blog-loading").innerHTML = '';
						//document.getElementById("blog-response").innerHTML = '';
						//document.getElementById("blog").innerHTML = '';
					}
					,'onSuccess':function(req){
						document.getElementById("event-response").innerHTML = req.responseText;
					}
					}
					);
				}
			});
		}
		function deleteBlogFromMember(member,blog) {
			myConfirm("Do you really wish to delete this blog post? This is irreversible and all data within this blog will be lost.","Yes","No",
			function(answer) {
				if (answer == true){
					AjaxRequest.get(
					{
					'url':'http://www.churchtag.com/inc/php/delete_blog.php?d=' + blog
					,'onLoading':function(){
						document.getElementById("blog-loading").innerHTML = '';
						document.getElementById("blog-response").innerHTML = '';
						document.getElementById("blog").innerHTML = '';
					}
					,'onSuccess':function(req){
						document.getElementById("blog-loading").innerHTML = req.responseText;
						drawBlogFromMember(member);
					}
					}
					);
				}
			});
		}
		function drawBlog(cid) {
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/drawblogs.php?church=' + cid
			,'onLoading':function() {
				
			}
			,'onSuccess':function(req){
				document.getElementById("blog").innerHTML = req.responseText;
				
			}
			}
			)
		}
		function drawPrayer(page) {
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/drawprayers.php?page=' + page
			,'onLoading':function() {
				//document.getElementById("show-blog-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("prayers").innerHTML = req.responseText;
				//document.getElementById("show-blog-loading").innerHTML = '';
			}
			}
			)
		}
		function drawBlogFromMember(member) {
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/drawblogsfrommember.php?member=' + member
			,'onLoading':function() { document.getElementById("blog").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>'; }
			,'onSuccess':function(req){
				document.getElementById("blog").innerHTML = req.responseText;
			}
			}
			)
		}
		function addtofavorites(bible,book,chapter)
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/addtofavorites.php?chapter=' + chapter + '&bible=' + bible + '&book=' + book
			,'onLoading':function() { document.getElementById("favorites").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>'; }
			,'onSuccess':function(req){
				document.getElementById("favorites").innerHTML = req.responseText;
				showfavorites();
			}
			}
			)
		}
		function showfavorites()
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/showfavorites.php'
			,'onLoading':function(){ document.getElementById("showfavorites").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>'; }
			,'onSuccess':function(req){
				document.getElementById("showfavorites").innerHTML = req.responseText;
			}
			}
			)
		}
		function showmemberchurches()
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/showmemberchurches.php'
			,'onLoading':function(){ document.getElementById("showmemberchurches").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>'; }
			,'onSuccess':function(req){
				document.getElementById("showmemberchurches").innerHTML = req.responseText;
			}
			}
			)
		}
		function shownotifications()
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/shownotifications.php'
			,'onLoading':function(){ document.getElementById("shownotifications").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>'; }
			,'onSuccess':function(req){
				document.getElementById("shownotifications").innerHTML = req.responseText;
			}
			}
			)
		}
		function showprayers()
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/showprayers.php'
			,'onLoading':function(){ //document.getElementById("shownotifications").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("your-prayers").innerHTML = req.responseText;
			}
			}
			)
		}
		function deletefavorite(id)
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/deletefavorite.php?id=' + id
			,'onSuccess':function(req){
				showfavorites();
			}
			}
			)
		}
		function deleteprayers(id)
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/deleteprayermember.php?id=' + id
			,'onSuccess':function(req){
				showprayers();
			}
			}
			)
		}
		function deletenotification(id)
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/deletenotification.php?id=' + id
			,'onSuccess':function(req){
				shownotifications();
			}
			}
			)
		}
		function showchatmessages()
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/showchatmessages.php'
			,'onSuccess':function(req){
				document.getElementById("chatinnerleft").innerHTML = req.responseText;
			}
			}
			)
		}
		function showloggedinchat()
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/showloggedinchat.php'
			,'onSuccess':function(req){
				document.getElementById("chatinnerright").innerHTML = req.responseText;
			}
			}
			)
		}
		function chatmessagesubmit(theform) {
			var status = AjaxRequest.submit(
			theform
			,{
			'onSuccess':function(req){
				theform.message.value = '';
				theform.message.focus();
				showchatmessages();
			}
			}
			);
			return status;
		}
		function expandcollapse(divid)
		{
			var visibility = document.getElementById(divid).style.display;
			if (visibility == "none")
			{
				document.getElementById(divid).style.display="block";
				/*if (document.getElementById('expand' + divid).style.display == "block")
				{
					document.getElementById('expand' + divid).style.display="none";
			}*/
				//	document.getElementById('expand').style.display="none";
				//	document.getElementById('collapse').style.display="block";
			}else{
				document.getElementById(divid).style.display="none";
				//document.getElementById('expand' + divid).style.display="block";
				// document.getElementById('expand').style.display="block";
			}
		}
		function hidechat()
		{
			expandcollapse('chat');
		}
		function switchToBlog(theelement)
		{
			//close 4 info div and map div and open the blog div
			document.getElementById('address').style.display = 'none';
			document.getElementById('membersmain').style.display = 'none';
			document.getElementById('info').style.display = 'none';
			document.getElementById('tagthischurch').style.display = 'none';
		//	document.getElementById('map').style.display = 'none';
			document.getElementById('mainblog').style.display = 'block';
			document.getElementById('blogtab').style.backgroundColor='#FFFFFF';
		//	document.getElementById('maptab').style.backgroundColor='#B4D7E0';
			document.getElementById('infotab').style.backgroundColor='#B4D7E0';
		}
		function switchToMap()
		{
			document.getElementById('address').style.display = 'none';
			document.getElementById('membersmain').style.display = 'none';
			document.getElementById('info').style.display = 'none';
			document.getElementById('tagthischurch').style.display = 'none';
			//document.getElementById('map').style.display = 'block';
			document.getElementById('mainblog').style.display = 'none';
			document.getElementById('blogtab').style.backgroundColor='#B4D7E0';
		//	document.getElementById('maptab').style.backgroundColor='#FFFFFF';
			document.getElementById('infotab').style.backgroundColor='#B4D7E0';
		}
		function switchToInfo()
		{
			document.getElementById('address').style.display = 'block';
			document.getElementById('membersmain').style.display = 'block';
			document.getElementById('info').style.display = 'block';
			document.getElementById('tagthischurch').style.display = 'block';
			//document.getElementById('map').style.display = 'none';
			document.getElementById('mainblog').style.display = 'none';
			document.getElementById('blogtab').style.backgroundColor='#B4D7E0';
		//	document.getElementById('maptab').style.backgroundColor='#B4D7E0';
			document.getElementById('infotab').style.backgroundColor='#FFFFFF';
		}
		function addchurch(theform) {
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() { document.getElementById("add-church-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){ document.getElementById("add-church-response").innerHTML = req.responseText;
			document.getElementById("add-church-loading").innerHTML = '';
			if (stristr(req.responseText,'successfully'))
			{
				expandcollapse("addchurch");
			}
			}
			}
			);
			return status;
		}
		function contactwidgetcode(theform) {
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() { document.getElementById("contact-widget-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){ 
			document.getElementById("contact-widget-loading").innerHTML = req.responseText;
			}
			}
			);
			return status;
		}
		
		
		
		function showcomments(chapter,book,verse)
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/drawVerseComments.php?book=' + book + '&chapter=' + chapter + '&verse=' + verse
			,'onLoading':function(){
				document.getElementById("versecomments").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("versecomments").innerHTML = req.responseText;
			}
			}
			);
		}
		function showupcomingeventssmall(cid)
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/upcomingeventssmall.php?cid=' + cid
			,'onLoading':function(){
				
			}
			,'onSuccess':function(req){
				document.getElementById("upcomingevents").innerHTML = req.responseText;
			}
			}
			);
		}
		
		
		function showupcomingevents(cid)
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/upcomingevents.php?cid=' + cid
			,'onLoading':function(){
				
			}
			,'onSuccess':function(req){
				document.getElementById("upcomingevents").innerHTML = req.responseText;
			}
			}
			);
		}
		
		
		
		
		
		function showcalendar(month,year,cid)
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/showcalendar.php?month=' + month + '&year=' + year + '&cid=' + cid
			,'onLoading':function(){
				document.getElementById("calendar").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("calendar").innerHTML = req.responseText;
			}
			}
			);
		}
		
		function showcalendarsmall(month,year,cid)
		{
			AjaxRequest.get(
			{
			'url':'http://www.churchtag.com/inc/php/showcalendarsmall.php?month=' + month + '&year=' + year + '&cid=' + cid
			,'onLoading':function(){
				
			}
			,'onSuccess':function(req){
				document.getElementById("calendar").innerHTML = req.responseText;
			}
			}
			);
		}
		function showversecomments(chapter,book,verse)
		{
			var visibility = document.getElementById('commentsnotes').style.display;
			if (visibility == "none")
			{
				document.getElementById('commentsnotes').style.display="block";
			}else{
				document.getElementById('commentsnotes').style.display="none";
			}
			document.getElementById("addVerseCommentResponse").innerHTML = "";
			showcomments(chapter,book,verse);
		}
		function addVerseComment(theform)
		{
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() {
				document.getElementById("addVerseCommentResponse").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("addVerseCommentResponse").innerHTML = req.responseText;
				showcomments(document.forms['addversecomment'].chapter.value,document.forms['addversecomment'].book.value,document.forms['addversecomment'].verse.value);
			}
			}
			);
			return status;
		}
		function addPrayerWidget(theform)
		{
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() {
				document.getElementById("widget-response").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("widget-response").innerHTML = req.responseText;
				if (stristr(req.responseText,'successfully'))
				{
					window.location='http://www.churchtag.com/getwidgetcode.php';
				}
			}
			}
			);
			return status;
		}
		
		function getWidgetCode(theform)
		{
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() {
				document.getElementById("widget-code-response").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("widget-code-response").innerHTML = req.responseText;
				
			}
			}
			);
			return status;
		}
		function addEvent(theform)
		{
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() {
				document.getElementById("addEventLoading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("addEventResponse").innerHTML = req.responseText;
				document.getElementById("addEventLoading").innerHTML = '';
				if (stristr(req.responseText,"successfully"))
				{
					document.getElementById('addevent').style.display="none";
					document.getElementById('add-success').innerHTML = "<div class=\"alertsuccess\">You successfully added an event! <font color=\"red\"><a href=\"#delete\" name=\"#delete\" onclick=\"deletealert('add-success')\">[X]</a></font></div>";
				}
			}
			}
			);
			return status;
		}
		function messageMembers(theform)
		{
			var status = AjaxRequest.submit(
			theform
			,{
			'onLoading':function() {
				document.getElementById("messageMembers-response").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
			}
			,'onSuccess':function(req){
				document.getElementById("messageMembers-response").innerHTML = req.responseText;
			}
			}
			);
			return status;
		}

function confirmDeleteAlbum()
{
var agree=confirm("Are you sure you wish to delete this album?");
if (agree)
return true ;
else
return false ;
}
function find_churches(churchName)
{
	AjaxRequest.get(
	{
	'url':'http://www.churchtag.com/inc/php/find_churches.php?churchName=' + churchName
	,'onLoading':function() {
		document.getElementById("add-church-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	}
	,'onSuccess':function(req){
		document.getElementById("add-church-loading").innerHTML = req.responseText;
	}
	}
	)
}
function add_multiple_question(theform)
{
		var status = AjaxRequest.submit(
	theform
	,{
	'onLoading':function() { document.getElementById("question-loading").innerHTML = '<img src=http://www.churchtag.com/images/ajax-loader.gif>';
	}
	,'onSuccess':function(req){ document.getElementById("question-response").innerHTML = req.responseText;
	document.getElementById("question-loading").innerHTML = '';
	if (stristr(req.responseText,'form'))
	{
		//success, clear all fields
		document.forms['addmultiple'].question.value="";
		document.forms['addmultiple'].answer1.value="";
		document.forms['addmultiple'].answer2.value="";
		document.forms['addmultiple'].answer3.value="";
		document.forms['addmultiple'].answer4.value="";
		document.forms['addmultiple'].explanation.value="";
	}
	
	}
	}
	);
	return status;
}

