
var objToUpdate;var rating;var xmlHttp;var thisResourceID;function createXMLHttpRequestObject()
{try
{xmlHttp=new XMLHttpRequest();}
catch(e)
{try
{xmlHttp=new ActiveXObject("Microsoft.XMLHttp");}
catch(e){}}
if(!xmlHttp)
alert("Error creating the XMLHttpRequest object.");else
return xmlHttp;}
function rateResource(resourceType,thisObj,thisRating,resourceID)
{objToUpdate=thisObj;rating=thisRating;thisResourceID=resourceID;var url="/includes/ajax/RateResource.asp?ResourceType="+resourceType+"&Rating="+rating+"&ResourceID="+resourceID;try{xmlHttp=createXMLHttpRequestObject();xmlHttp.onreadystatechange=callback;var browser=navigator.appName
var b_version=navigator.appVersion
var version=parseFloat(b_version)
if(b_version.indexOf("Safari")>0){xmlHttp.open("get",url,false);}
else{xmlHttp.open("get",url,true);}
xmlHttp.send(null);
} catch (e) { } 
}

function callback(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){adjustRatingStars();}}}
function adjustRatingStars() {
    var obj=document.getElementById(objToUpdate);switch(rating)
    {case.5:obj.className="rating halfstar";obj.style.backgroundPosition="0px -272px";break;case 1:obj.className="rating onestar";obj.style.backgroundPosition="0px -96px";break;case 1.5:obj.className="rating onehalfstar";obj.style.backgroundPosition="0px -288px";break;case 2:obj.className="rating twostar";obj.style.backgroundPosition="0px -112px";break;case 2.5:obj.className="rating twohalfstar";obj.style.backgroundPosition="0px -304px";break;case 3:obj.className="rating threestar";obj.style.backgroundPosition="0px -128px";break;case 3.5:obj.className="rating threehalfstar";obj.style.backgroundPosition="0px -320px";break;case 4:obj.className="rating fourstar";obj.style.backgroundPosition="0px -144px";break;case 4.5:obj.className="rating fourhalfstar";obj.style.backgroundPosition="0px -336px";break;case 5:obj.className="rating fivestar";obj.style.backgroundPosition="0px -160px";break;default:obj.className="rating nostar";obj.style.backgroundPosition="0px 0px";}


if(document.getElementById('ratedtext_'+thisResourceID)!=null)
{document.getElementById('ratedtext_'+thisResourceID).innerHTML="(Thanks for rating!)"}
/*
if(document.getElementById('ratedtext2_'+thisResourceID)!=null)
{ document.getElementById('ratedtext2_' + thisResourceID).innerHTML = "(Thanks for rating!)" }
*/

}


function updateCommentPreview(o)
{
    var comment = document.forms["commentform"].comment.value;
    comment = comment.replace("\n"," ")
    comment = comment.replace("  "," ")
    document.forms["commentform"].comment.value = comment;
    
    //var preview=document.getElementById("commentpreview");
    //if(preview!=null){
    //    preview.innerHTML=o.value;
    //}
}

function toggleMenuSection(s,force){var section=document.getElementById(s);var button=document.getElementById(s+'_button');if(section!=null){if(section.style.display=="none"||force==1){section.style.display="block";if(button!=null){button.src='/images/seccol_arrow_con_d.gif';}}else{section.style.display="none";if(button!=null){button.src='/images/seccol_arrow_con_r.gif';}}}}
function submitMainForm(v){var mainform=document.getElementById("mainform");if(mainform!=null){if(v!=null){var action=mainform.action;if(action!=null){action.value=v;}}
mainform.submit();return(false);}}
function confirmChoice(question,href){if(confirm(question)){document.location=href}}
function show2(id,layout){var e=document.getElementById(id);if(e!=null){if(layout==null){e.style.display="block";}else{e.style.display=layout;}}}
function hide2(id) { var e = document.getElementById(id); if (e != null) { e.style.display = "none"; } }
function hide(id) { var e = document.getElementById(id); if (e != null) { e.style.display = "none"; } }
function bodyLoaded(){}
function ValidateNumeric(FormName,FieldName,FieldValue){len=FieldValue.length;nums="0123456789";for(i=0;i<len;i++){if(nums.indexOf(FieldValue.charAt(i))<0){alert('Please enter only numbers!');document[FormName][FieldName].focus();document[FormName][FieldName].select();return false;}}
return true;}
function ShowOverlay(){
    var scrollTop1=document.documentElement.scrollTop;
    var scrollTop2=document.body.scrollTop;
    var useScrollTop=scrollTop1;
    if(scrollTop2>scrollTop1)
    {
        useScrollTop=scrollTop2;
    }
    document.getElementById("Overlay").style.top=useScrollTop+"px";
    document.getElementById("Overlay").style.display="";
    if(screen.height>769)
    {
        document.getElementById("OverlayInside").style.top=(useScrollTop+120)+"px";
    }
    else
    {
        document.getElementById("OverlayInside").style.top=(useScrollTop)+"px";
    }
    document.getElementById("OverlayInside").style.display="";
    window.onscroll=resetOverlay;
    document.body.onscroll=resetOverlay;
}
function resetOverlay() {
    closeOverlay;
    ShowOverlay();
}
function SuggestKeyword(ResourceTypeID,ResourceID,Title,Topic)
    {
        document.getElementById("OverlayIFrame").src="/Overlays/KeywordSuggestion.asp?ResourceID="+ResourceID+"&ResourceTypeID="+ResourceTypeID
        document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="540px";
        if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
        window.setTimeout("ShowOverlay()",400);
}
function ShareWithFriend(ResourceID,ResourceTypeID){document.getElementById("OverlayIFrame").src="/Overlays/ShareWithFriend.asp?ResourceID="+ResourceID+"&ResourceTypeID="+ResourceTypeID;document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="540px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",400);}
function AddResourceToCalendar(Item_ID,Type_ID){document.getElementById("OverlayIFrame").src="/Overlays/AddToCalendar.asp?Item_ID="+Item_ID+"&Type_ID="+Type_ID;document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="540px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",400);}
function AddResourceToFavorites(Item_ID,Type_ID){document.getElementById("OverlayIFrame").src="/Overlays/AddToFavorites.asp?Item_ID="+Item_ID+"&Type_ID="+Type_ID;document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="540px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",400);}
function EmailSearch(SearchURL){document.getElementById("OverlayIFrame").src="/Overlays/EmailSearch.asp?SearchURL="+SearchURL;document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="540px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",400);}
function NewsletterSignup(LYRIS_Email,MoreInfo){document.getElementById("OverlayIFrame").src="/Overlays/NewsletterSignup.asp?MoreInfo="+MoreInfo+"&LYRIS_Email="+LYRIS_Email;document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="540px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",400);}

function MarketingOverlay_Favorites(){window.location = "http://www.sermoncentral.com/cms/landing-page/articlec.asp?article=Add-To-Favorites-PRO";}
function MarketingOverlay_Series() {document.getElementById("OverlayIFrame").src = "/Overlays/MarketingOverlay_Series.asp"; document.getElementById("OverlayIFrame").style.width = "620px"; document.getElementById("OverlayIFrame").style.height = "470px"; if (navigator.appVersion.indexOf("MSIE 6.") < 0) { document.getElementById("OverlayInside").style.left = "-120px"; }window.setTimeout("ShowOverlay()", 300);}
function MarketingOverlay_FullPageSermon(){window.location = "http://www.sermoncentral.com/cms/landing-page/articlec.asp?article=View-On-One-Page-Sermons-PRO";}
function MarketingOverlay_MyCalendar(){window.location = "http://www.sermoncentral.com/cms/landing-page/articlec.asp?article=Add-To-Calendar-PRO";}
function MarketingOverlay_Illustrations(){window.location="/cms/landing-page/articlec.asp?article=Pro-Signup-Simple-List-Illustrations&utm_source=internal&utm_medium=banner&utm_content=Unlock5Star&utm_campaign=IllustrationSERP";}
function MarketingOverlay_PowerPoints(){window.location = "http://www.sermoncentral.com/cms/landing-page/articlec.asp?article=Get-Free-PowerPoints-PRO";}

function DownloadVideoOfTheWeek(){document.getElementById("OverlayIFrame").src="/Overlays/DownloadVideoOfTheWeek.asp";document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="215px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",300);}

function PreviewVideoFromFeed(VideoFeedProductGroup_ID){document.getElementById("OverlayIFrame").src="/Overlays/PreviewVideoFromFeed.asp?VideoFeedProductGroup_ID="+VideoFeedProductGroup_ID;document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="490px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",300);}

function PreviewVideoFromFeed_Test(VideoPreviewURL){document.getElementById("OverlayIFrame").src="/Overlays/PreviewVideoFromFeed_Test.asp?VideoPreviewURL="+VideoPreviewURL;document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="388px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",300);}

function ReportProblemWithVideoFeed(VideoFeedProductGroup_ID){document.getElementById("OverlayIFrame").src="/Overlays/ReportProblemWithVideoFeed.asp?VideoFeedProductGroup_ID="+VideoFeedProductGroup_ID;document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="460px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",300);}

function ReportComment(Comment_ID){document.getElementById("OverlayIFrame").src="/Overlays/ReportComment.asp?Comment_ID="+Comment_ID;document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="460px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",300);}

function ReportAbuse(Contributor_ID){document.getElementById("OverlayIFrame").src="/Overlays/ReportAbuse.asp?Contributor_ID="+Contributor_ID;document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="460px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",300);}

function ProvideSiteFeedback(){document.getElementById("OverlayIFrame").src="/Overlays/ProvideSiteFeedback.asp"
document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="460px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",300);}
function LoginOverlay(){
    document.getElementById("OverlayIFrame").src="/Overlays/Login.asp"
    document.getElementById("OverlayIFrame").style.width="610px";
    document.getElementById("OverlayIFrame").style.height="405px";
    document.getElementById("OverlayInside").style.left="-100px";
    window.setTimeout("ShowOverlay()",300);
}
function LoginOverlayWithReturnUrl(returnurl){document.getElementById("OverlayIFrame").src="/Overlays/Login.asp?ReturnUrl="+returnurl;document.getElementById("OverlayIFrame").style.width="610px";document.getElementById("OverlayIFrame").style.height="405px";document.getElementById("OverlayInside").style.left="-100px";window.setTimeout("ShowOverlay()",300);}
function CreateBasicOverlay(email,CreateContributor){document.getElementById("OverlayIFrame").src="/Overlays/createbasic.asp?email="+email+"&CreateContributor="+CreateContributor;document.getElementById("OverlayIFrame").style.width="600px";document.getElementById("OverlayIFrame").style.height="405px";document.getElementById("OverlayInside").style.left="-100px";window.setTimeout("ShowOverlay()",300);}
function LogoutOverlay(){document.getElementById("OverlayIFrame").src="/Overlays/Logout.asp"
document.getElementById("OverlayIFrame").style.width="480px";document.getElementById("OverlayIFrame").style.height="405px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",300);}
function LinkToThis(VideoFeedProductGroup_ID){document.getElementById("OverlayIFrame").src="/Overlays/LinkToThis.asp?VideoFeedProductGroup_ID="+VideoFeedProductGroup_ID;document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="460px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",300);}
function LinkToThisPowerPoint(PowerPoint_ID){document.getElementById("OverlayIFrame").src="/Overlays/LinkToThis.asp?PowerPoint_ID="+PowerPoint_ID;document.getElementById("OverlayIFrame").style.width="464px";document.getElementById("OverlayIFrame").style.height="460px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-45px";}
window.setTimeout("ShowOverlay()",300);}
function PowerPointPreview(root,image1,image2,image3,PowerPointID){var url="/Overlays/PreviewPowerpoint.asp?root="+root+"&image1="+image1+"&image2="+image2+"&image3="+image3+"&PowerPointID="+PowerPointID;document.getElementById("OverlayIFrame").src=url;document.getElementById("OverlayIFrame").style.width="512px";document.getElementById("OverlayIFrame").style.height="430px";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-70px";}
window.setTimeout("ShowOverlay()",400);}
function SuggestScripture(url){document.getElementById("OverlayIFrame").src=url;document.getElementById("OverlayIFrame").style.width="650px";document.getElementById("OverlayIFrame").style.height="500px";document.getElementById("OverlayInside").style.overflow="auto";if(navigator.appVersion.indexOf("MSIE 6.")<0){document.getElementById("OverlayInside").style.left="-150px";}
window.setTimeout("ShowOverlay()",400);}
function closeOverlay() {
    document.getElementById("OverlayIFrame").src = "";
    document.getElementById("Overlay").style.display = "none";
    document.getElementById("OverlayInside").style.display = "none";
    document.getElementById("OverlayIFrame").style.height = "240px";
    document.getElementById("OverlayIFrame").style.width = "400px";
    window.onscroll = null; 
    document.body.onscroll = null;
}

function toggleVideoFeedScriptureSuggestions(id)
{if(document.getElementById("divScripture"+id).style.display=='none')
{document.getElementById("divScripture"+id).style.display='';document.getElementById("a"+id).style.display='none';}else
{document.getElementById("divScripture"+id).style.display='none';document.getElementById("a"+id).style.display='';}}
function toggleKeywordSuggestions(id)
{if(document.getElementById("div"+id).style.display=='none')
{document.getElementById("div"+id).style.display='';document.getElementById("a"+id).style.display='none';}
else{document.getElementById("div"+id).style.display='none';document.getElementById("a"+id).style.display='';}}
function toggleDescription(id)
{if(document.getElementById("DescDiv"+id).style.display=='none')
{document.getElementById("DescDiv"+id).style.display='';document.getElementById("DescA"+id).style.display='none';}
else{document.getElementById("DescDiv"+id).style.display='none';document.getElementById("DescA"+id).style.display='';}}
function ShowAltTextOnRating(obj,altText)
{document.getElementById(obj).innerHTML="("+altText+")"}
var timeout;function ScrollContributors(direction){var obj=document.getElementById('FeaturedContributors');var currentOffset=obj.style.marginLeft;currentOffset=parseInt(currentOffset.replace("px",""));var newOffset;var offsetIncrement=parseInt(500);if(direction=='right')
{if(currentOffset>=-1475)
{newOffset=eval(currentOffset+-(offsetIncrement));obj.style.marginLeft=newOffset+"px";}
else { newOffset = 0; obj.style.marginLeft = newOffset + "px"; } }
else{if(currentOffset<0)
{newOffset=eval(currentOffset+offsetIncrement);obj.style.marginLeft=newOffset+"px";}
else{newOffset=-1500;obj.style.marginLeft=newOffset+"px";}}clearTimeout(timeout);}
function toggleMoreResources()
{if(document.getElementById('MoreResourcesMenu').style.display=="")
{document.getElementById('MoreResourcesMenu').style.display="none";}
else{document.getElementById('MoreResourcesMenu').style.display="";}}
function showSPM(section)
{UnSelectAllSPM();if(section=='scripture'){document.getElementById('SPMNav1').style.backgroundImage='url(/images/40/btn_spm_selected.jpg)';document.getElementById('SPMNav1').style.backgroundPosition='right';document.getElementById('SPMNav1').style.backgroundRepeat='no-repeat';document.getElementById('SPM_Scripture').style.display='block';document.getElementById('SPM_A1').style.fontWeight='bold';}
if(section=='sermons'){document.getElementById('SPMNav2').style.backgroundImage='url(/images/40/btn_spm_selected.jpg)';document.getElementById('SPMNav2').style.backgroundPosition='right';document.getElementById('SPMNav2').style.backgroundRepeat='no-repeat';document.getElementById('SPM_Sermons').style.display='block';document.getElementById('SPM_A2').style.fontWeight='bold';}
if(section=='illustrations'){document.getElementById('SPMNav3').style.backgroundImage='url(/images/40/btn_spm_selected.jpg)';document.getElementById('SPMNav3').style.backgroundPosition='right';document.getElementById('SPMNav3').style.backgroundRepeat='no-repeat';document.getElementById('SPM_Illustrations').style.display='block';document.getElementById('SPM_A3').style.fontWeight='bold';}
if(section=='videos'){document.getElementById('SPMNav4').style.backgroundImage='url(/images/40/btn_spm_selected.jpg)';document.getElementById('SPMNav4').style.backgroundPosition='right';document.getElementById('SPMNav4').style.backgroundRepeat='no-repeat';document.getElementById('SPM_Videos').style.display='block';document.getElementById('SPM_A4').style.fontWeight='bold';}
if(section=='powerpoints'){document.getElementById('SPMNav5').style.backgroundImage='url(/images/40/btn_spm_selected.jpg)';document.getElementById('SPMNav5').style.backgroundPosition='right';document.getElementById('SPMNav5').style.backgroundRepeat='no-repeat';document.getElementById('SPM_PowerPoints').style.display='block';document.getElementById('SPM_A5').style.fontWeight='bold';}
if(section=='more'){ document.getElementById('SPMNav6').style.backgroundImage = 'url(/images/40/btn_spm_selected.jpg)'; document.getElementById('SPMNav6').style.backgroundPosition = 'right'; document.getElementById('SPMNav6').style.backgroundRepeat = 'no-repeat'; document.getElementById('SPM_More').style.display = 'block'; document.getElementById('SPM_A6').style.fontWeight = 'bold'; }}
function UnSelectAllSPM()
{document.getElementById('SPMNav1').style.backgroundImage='url(/images/40/btn_spm_not_selected.jpg)';document.getElementById('SPMNav2').style.backgroundImage='url(/images/40/btn_spm_not_selected.jpg)';document.getElementById('SPMNav3').style.backgroundImage='url(/images/40/btn_spm_not_selected.jpg)';document.getElementById('SPMNav4').style.backgroundImage='url(/images/40/btn_spm_not_selected.jpg)';document.getElementById('SPMNav5').style.backgroundImage='url(/images/40/btn_spm_not_selected.jpg)';document.getElementById('SPMNav6').style.backgroundImage='url(/images/40/btn_spm_not_selected.jpg)';document.getElementById('SPM_Scripture').style.display='none';document.getElementById('SPM_Sermons').style.display='none';document.getElementById('SPM_Illustrations').style.display='none';document.getElementById('SPM_Videos').style.display='none';document.getElementById('SPM_PowerPoints').style.display='none';document.getElementById('SPM_More').style.display='none';document.getElementById('SPM_A1').style.textDecoration='none';document.getElementById('SPM_A2').style.textDecoration='none';document.getElementById('SPM_A3').style.textDecoration='none';document.getElementById('SPM_A4').style.textDecoration='none';document.getElementById('SPM_A5').style.textDecoration='none';document.getElementById('SPM_A6').style.textDecoration='none';document.getElementById('SPM_A1').style.fontWeight='normal';document.getElementById('SPM_A2').style.fontWeight='normal';document.getElementById('SPM_A3').style.fontWeight='normal';document.getElementById('SPM_A4').style.fontWeight='normal';document.getElementById('SPM_A5').style.fontWeight='normal';document.getElementById('SPM_A6').style.fontWeight='normal';}
function toggleSermonPageRateThis()
{if(document.getElementById('SermonPageRateThis').style.display=="none")
{document.getElementById('SermonPageRateThis').style.display="block";}
else{document.getElementById('SermonPageRateThis').style.display="none";}}
function togglePowerPointPageRateThis()
{if(document.getElementById('PowerPointPageRateThis').style.display=="none")
{document.getElementById('PowerPointPageRateThis').style.display="block";}
else{document.getElementById('PowerPointPageRateThis').style.display="none";}}
function toggleContributorMenu()
{document.getElementById('ProMenu').style.display="none";if(document.getElementById('ContributorMenu').style.display=="none")
{document.getElementById('ContributorMenu').style.display="block";}
else{document.getElementById('ContributorMenu').style.display="none";}}
function toggleProMenu()
{document.getElementById('ContributorMenu').style.display="none";if(document.getElementById('ProMenu').style.display=="none")
{document.getElementById('ProMenu').style.display="block";}
else{document.getElementById('ProMenu').style.display="none";}}
function isMouseLeaveOrEnter(e,handler)
{if(e.type!='mouseout'&&e.type!='mouseover')return false;var reltg=e.relatedTarget?e.relatedTarget:e.type=='mouseout'?e.toElement:e.fromElement;while(reltg&&reltg!=handler)reltg=reltg.parentNode;return(reltg!=handler);}
function toggleScripturePageResources(id)
{if(document.getElementById(id).style.display=="none")
{document.getElementById(id).style.display="block";document.getElementById('scripturemoreresources').src="/images/40/uparrow.gif";}
else{document.getElementById(id).style.display="none";document.getElementById('scripturemoreresources').src="/images/40/downarrow.gif";}}
function toggleBibleChapterList(id)
{if(document.getElementById(id).style.display=="none")
{document.getElementById(id).style.display="block";}
else{ document.getElementById(id).style.display = "none";}}
function redirectMobile(ReturnUrl) { window.location = "/overlays/login.asp?ReturnUrl=" + ReturnUrl; }

function ClearBlankFields() {
    if (document.getElementById("keyword") != null) {
        if (document.getElementById("keyword").value.toLowerCase() == "enter your keyword search") { document.getElementById("keyword").value = ""; }
    }
    
    if (document.getElementById("SPMAllResources_Keyword") != null) {
        if (document.getElementById("SPMAllResources_Keyword").value.toLowerCase() == "enter your keyword search") { document.getElementById("SPMAllResources_Keyword").value = ""; }
    }
    
    if (document.getElementById("ScriptureVerseAll") != null) {
        if (document.getElementById("ScriptureVerseAll").value.toLowerCase() == "chapter:verse") { document.getElementById("ScriptureVerseAll").value = ""; }
    }
    
    if (document.getElementById("ScriptureVerse") != null) {
        if (document.getElementById("ScriptureVerse").value.toLowerCase() == "chapter:verse") { document.getElementById("ScriptureVerse").value = ""; } 
    }
}
function closeStarArea(id) {
    document.getElementById("RatableArea" + id).style.display = "none";
    document.getElementById("NonRatableArea" + id).style.display = "";
}
function openStarArea(id) {
    document.getElementById("RatableArea" + id).style.display = "";
    document.getElementById("NonRatableArea" + id).style.display = "none";
}

function SetSearchKeepOpenCookie() {
    if (document.getElementById("KeepSearchesOpen").checked == true) {
        document.cookie = "KeepSearchBoxesOpen=1;expires=Fri, 3 Aug 2100 20:47:11 UTC; path=/; domain=sermoncentral.com;";
    }
    else {
        document.cookie = "KeepSearchBoxesOpen=0;expires=Fri, 3 Aug 2100 20:47:11 UTC; path=/; domain=sermoncentral.com;";
    }
}

function GetCookieValue(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

var theScriptureWindow;
function openWinQuestionForScripture(URL) {
    if (theScriptureWindow != null) {
        //theScriptureWindow.close();
    }
    theScriptureWindow = window.open(URL, "thewindow", "width=680,height=300,top=50,left=50,status=yes, menubar=no, resizable=yes, scrollbars=yes,");
    theScriptureWindow.focus();
}


function UpdateSiteSearch(SiteSearchPrefix) {
    
    var SiteSearchString = "";
    
    if (document.getElementById('keyword') != null) {
        var keyword = document.getElementById("keyword").value;
        keyword = keyword.toLowerCase();
        keyword = keyword.replace("enter your keyword search", "");
        if (keyword != "") {SiteSearchString = SiteSearchString + "-keyword--" + keyword}
    }

    if (document.getElementById('TopicID') != null) {
        var TopicName = document.getElementById('TopicID').options[document.getElementById('TopicID').selectedIndex].text;
        TopicName = TopicName.toLowerCase();
        TopicName = TopicName.replace("search all topics", "");
        if (TopicName != "") {SiteSearchString = SiteSearchString + "-topic--" + TopicName}
    }

    if (document.getElementById('ScriptureBookA') != null) {
        var ScriptureBook = document.getElementById('ScriptureBookA').value;
        if (ScriptureBook != "") {SiteSearchString = SiteSearchString + "-book--" + ScriptureBook}
    }
    
    if(document.getElementById('ScriptureVerse')!=null){
        var ScriptureVerse = document.getElementById('ScriptureVerse').value;
        ScriptureVerse = ScriptureVerse.toLowerCase();
        ScriptureVerse = ScriptureVerse.replace("chapter:verse", "");
        if(ScriptureVerse != "" && ScriptureVerse != "chapter:verse"){SiteSearchString = SiteSearchString + "-verse--" + ScriptureVerse}
    }

    if(document.getElementById('denomination')!=null){
        var Denomination = document.getElementById('denomination').value;
        if(Denomination != ""){SiteSearchString = SiteSearchString + "-denom--" + Denomination}
    }

    //look for Audience Age
    if(document.getElementById('audienceage')!=null){
        var Age = document.getElementById('audienceage').value;
        if(Age != ""){SiteSearchString = SiteSearchString + "-age--" + Age}
    }

    if(document.getElementById('VideoProviders')!=null){
        var VideoProvider = document.getElementById('VideoProviders').options[document.getElementById('VideoProviders').selectedIndex].text;
        VideoProvider = VideoProvider.toLowerCase();
        VideoProvider = VideoProvider.replace("search all video providers", "");
        if (VideoProvider != "") {SiteSearchString = SiteSearchString + "-videoprovider--" + VideoProvider}
    }

    if(document.getElementById('since')!=null){
        var Date = document.getElementById('since').value;
        if(Date != "0"){SiteSearchString = SiteSearchString + "-date--" + Date}
    }

    if (document.getElementById('AuthorID') != null) {
        var AuthorName = document.getElementById('AuthorID').options[document.getElementById('AuthorID').selectedIndex].text;
        AuthorName = AuthorName.toLowerCase();
        AuthorName = AuthorName.replace("search all authors", "");
        if (AuthorName != "") {SiteSearchString = SiteSearchString + "-author--" + AuthorName;}
    }

    document.getElementById('sitesearch').value = SiteSearchPrefix + SiteSearchString;
}


function UpdateSiteCspSearch(SiteSearchPrefix, FormName) {

    var frm = document.forms[FormName];
    var SiteSearchString = "";

    if (frm.keyword != null) {
        var keyword = frm.keyword.value;
        keyword = keyword.toLowerCase();
        keyword = keyword.replace("enter your keyword search", "");
        if(keyword != ""){SiteSearchString = SiteSearchString + "-keyword--" + keyword}
    }

    if (frm.TopicID != null) {
        var TopicName = frm.TopicID.options[frm.TopicID.selectedIndex].text;
        TopicName = TopicName.toLowerCase();
        TopicName = TopicName.replace("search all topics", "");
        TopicName = TopicName.replace("all topics", "");
        if (TopicName != "") {SiteSearchString = SiteSearchString + "-topic--" + TopicName} 
    }
    
    if(frm.ScriptureBookA !=null){
        var ScriptureBook = frm.ScriptureBookA.value;
        if(ScriptureBook != ""){SiteSearchString = SiteSearchString + "-book--" + ScriptureBook}
    }

    if(frm.ScriptureVerse !=null){
        var ScriptureVerse = frm.ScriptureVerse.value;
        ScriptureVerse = ScriptureVerse.toLowerCase();
        ScriptureVerse = ScriptureVerse.replace("chapter:verse", "");
        if(ScriptureVerse != "" && ScriptureVerse != "chapter:verse"){SiteSearchString = SiteSearchString + "-verse--" + ScriptureVers}
    }

    if(frm.denomination !=null){
        var Denomination = frm.denomination.value;
        if(Denomination != ""){SiteSearchString = SiteSearchString + "-denom--" + Denomination}
    }

    if(frm.audienceage !=null){
        var Age = frm.audienceage.value;
        if(Age != ""){SiteSearchString = SiteSearchString + "-age--" + Age}
    }

    if (frm.since != null) {
        var Date = frm.since.value;
        if (Date != "0") {SiteSearchString = SiteSearchString + "-date--" + Date}
    }
//alert("SiteSearchString: " + SiteSearchString);
    frm.sitesearch.value = SiteSearchPrefix + SiteSearchString;
}

function newCookie(name,value,days) {
    var days = 60;   // the number at the left reflects the number of days for the cookie to last
                 // modify it according to your needs
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString(); 
    } else var expires = "";
    
    document.cookie = name+"="+value+expires+"; path=/"; 
}

function readCookie(name) {
    var nameSG = name + "=";
    var nuller = '';
    if (document.cookie.indexOf(nameSG) == -1)
    return nuller;

    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameSG) == 0) return c.substring(nameSG.length,c.length); 
    }
    return null; 
}

function eraseCookie(name) {
  newCookie(name,"",1); }

function toMem(a, f) {
    var frm = document.forms[f];
    newCookie('aEmail', frm.email.value);
    newCookie('aPassword', frm.password.value);
}

function delMem(a,f) {
    
    eraseCookie('aEmail');   // make sure to add the eraseCookie function for every field
    eraseCookie('aPassword');

    //var frm = document.forms[f];
    //frm.email.value = '';   // add a line for every field
    //frm.password.value = ''; 
}
