﻿//overlay sutff. There is one main overlay function that will make the div in the _header visible and set the background and such....It's all in a style on screen.css named overlay and overlayinside. 
//Each action such as AddToFavorites, SuggestKeyword, ScriptureSearchHelp, etc. is simply loaded into an iframe. To add more overlay features in the future just create a function for it, set
//the iframe url and then call the ShowOverlay() function. The timeout is included to give the iframe some time to load before it's displayed.
function ShowOverlay(){
	//document.documentElement.scrollTop work on all browsers on the PC. Macs will have a value of 0.
    var scrollTop1 = document.documentElement.scrollTop;
    //document.body.scrollTop works on all browsers on the MAC. PCs will have a value of 0.
    var scrollTop2 = document.body.scrollTop;
    
    var useScrollTop = scrollTop1; 
    if(scrollTop2 > scrollTop1) //set useScrollTop equal to whichever scrollTop has a value that isn't 0.
    {
        useScrollTop = scrollTop2;
    }
	
	document.getElementById("Overlay").style.top = useScrollTop + "px";
	document.getElementById("Overlay").style.display = "";
	
	document.getElementById("OverlayInside").style.top = (useScrollTop + 10) + "px";
	document.getElementById("OverlayInside").style.display = "";
	
    window.onscroll = closeOverlay;
    document.body.onscroll = closeOverlay;
}

function LargerImage(imagename){
	document.getElementById("OverlayIFrame").src = "/Overlay/LargerImage.aspx?Identifier=" + imagename;
	document.getElementById("OverlayIFrame").style.height = "400px";
	document.getElementById("OverlayIFrame").style.width = "400px";
	//document.getElementById("OverlayIFrame").style.marginLeft = "-50px";
	//the timeout is here to give the new page in the iframe time to reload the new page.
	window.setTimeout("ShowOverlay()", 300);	
}


function showRSVPLogin(EventID){
	document.getElementById("OverlayIFrame").src = "/Overlay/EnterPassword2Rsvp.aspx?Event_ID=" + EventID;
	document.getElementById("OverlayIFrame").style.height = "350px";
	document.getElementById("OverlayIFrame").style.width = "450px";
	//document.getElementById("OverlayIFrame").style.marginLeft = "-250px";
	//the timeout is here to give the new page in the iframe time to reload the new page.
	window.setTimeout("ShowOverlay()", 300);	
}

function showSpaEvent_Large(){
	document.getElementById("OverlayIFrame").src = "/Overlay/SpaDay_Large.aspx"
	document.getElementById("OverlayIFrame").style.height = "730px";
	document.getElementById("OverlayIFrame").style.width = "900px";
	document.getElementById("OverlayIFrame").style.marginLeft = "-250px";
	//the timeout is here to give the new page in the iframe time to reload the new page.
	window.setTimeout("ShowOverlay()", 300);	
}

function Add2PayPalCart(Product_ID, Amount, ItemName){
	document.getElementById("OverlayIFrame").src = "/Overlay/PayPalCart.aspx?Product_ID=" + Product_ID + "&Amount=" + Amount + "&ItemName=" + ItemName;
	document.getElementById("OverlayIFrame").style.height = "730px";
	document.getElementById("OverlayIFrame").style.width = "900px";
	document.getElementById("OverlayIFrame").style.marginLeft = "-250px";
	//the timeout is here to give the new page in the iframe time to reload the new page.
	window.setTimeout("ShowOverlay()", 300);	
}

function addNewsletterSignup(){
	document.getElementById("OverlayIFrame").src = "/Overlay/AddNewsletterSignup.aspx"
	document.getElementById("OverlayIFrame").style.height = "600px";
	document.getElementById("OverlayIFrame").style.width = "600px";
	document.getElementById("OverlayIFrame").style.marginLeft = "-100px";
	//the timeout is here to give the new page in the iframe time to reload the new page.
	window.setTimeout("ShowOverlay()", 300);	
}

function closeOverlay(){
    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;
}

////////////////////////////////////////////////////////////////////////////////////////
//////////////////End OVERLAY STUFF/////////////////////////////////////////////////////
//////////////////////////////////