var delay = 1000;

function bereanpopup() 
{
	if (getCookie("popup") != "popped") {
		var expire = new Date((new Date()).getTime() + 1000 * 24 * 3600000);
		setCookie("accept", "oreo", expire, "/", "", false); 
	
		if (getCookie("accept")) {
			if(typeof showAd != "undefined") {
				showAd();
				setCookie("popup", "popped", expire, "/", "", false);
			}
		}
	}
	return true;
}
function closeKeywords() {
	$("div#sermonKeywords").hide();
}
function closeShareThis() {
	$("div#akst_form").hide();
}
function closeDIV(DIVid) {
	$("div#" + DIVid).hide();
}
function emailPage() {
	$('div#responseContainer').html('');
	var tsTimeStamp= new Date().getTime();
	loading();
	jQuery.post("http://biblicaljesus.org/index.cfm?fuseaction=Email.ThisPage", {toAddress: $("#toAddress").val(), fromAddress: $("#fromAddress").val(), efa: $("#efa").val(), CT: $("#CT").val(), k: $("#k").val(), ID: $("#ID").val(), time: tsTimeStamp, comments: escape($("#emailComments").val())}, function(r) { $('div#responseContainer').html(r); });
	setTimeout("loaded()", delay);
	setCookie("email", $("#fromAddress").val(), "", "/", "", false);
}
function getCookie(name) {
	var dc = document.cookie;
	
	// find beginning of cookie value in document.cookie
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	else begin += 2;
	
	// find end of cookie value
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;
	
	// return cookie value
	return unescape(dc.substring(begin + prefix.length, end));
}
function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + '=' + escape(value) + ((expires) ? '; expires=' + expires.toGMTString() : '') + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + ((secure) ? '; secure' : '');
	document.cookie = curCookie;
}
function setClickPath() {
}

function loadPageJS()
{
	bereanpopup();
}
function loaded() {
	$("#ajaxWorkingEmail").removeClass("ac_loading");
}
function loading() {
	$("#ajaxWorkingEmail").addClass("ac_loading");
}
function chanout() {
}
function showAd() {
	document.getElementById('bereanad').style.visibility = 'visible';
}

function hideAd() {
	document.getElementById('bereanad').style.visibility = 'hidden';
}
function showEmailFriendAJAX() {
	var elem = document.getElementById('emailPageContainer');
	document.getElementById('responseContainer').innerHTML = '';
	elem.style.display = 'block';
    elem.style.visibility = 'visible';
	document.getElementById('toAddress').value = '';
	document.getElementById('emailComments').value = '';
	if (getCookie("email") != ("" || null))
	{
		document.getElementById('fromAddress').value = getCookie("email");
	}
	document.getElementById('toAddress').focus();

}
function hideEmailFriendAJAX() {
	var elem = document.getElementById('emailPageContainer');
	elem.style.display = 'none';
    elem.style.visibility = 'hidden';
}
function showKeywords() {
	$("div#sermonKeywords").show();
}
function toggleDescription() {
	if ($('#descriptionLink').html() == 'show') {
		$("div#sermonDescription").show();
		$('#descriptionLink').html('hide');
	}
	else {
		$("div#sermonDescription").hide();
		$('#descriptionLink').html('show');
	}
}
function toggleKeywords() {
	if ($('#keywordsLink').html() == 'show') {
		$("div#sermonKeywords").show();
		$('#keywordsLink').html('hide');
	}
	else {
		$("div#sermonKeywords").hide();
		$('#keywordsLink').html('show');
	}
}
