// What's on next 2 weeks... Sunday = 0 ... Saturday = 6//
//"<a href='sundays.html'>10 am: Communion Service </br>11 am: Family Service</br>6.30 pm: Evening Service</br></a>",
//					"0",
//					"<a href='60plus.html'>1 pm: 60+ Group</br></a>",
//					"<a href='sunbeams.html'>9 am: Little Sunbeams Parent-Toddler Group</br></a> <a href='housegroups.html'>8 pm: House Groups</br></a>",
//					"<a href='sundays.html'>8 pm: Music Practice</br></a>",
//					"<a href='jam.html'>6.00 pm: Jam Club</br></a><a href='youth.html'>7.30 pm: Ignite</br></a>",
//					"0",
//					"<a href='sundays.html'>10 am: Communion Service </br>11 am: Family Service</br>6.30 pm: Evening Service</br></a>",
//					"0",
//					"0",
//					"<a href='sunbeams.html'>9 am: Little Sunbeams Parent-Toddler Group</br></a> <a href='housegroups.html'>8 pm: House Groups</br></a>",
//					"<a href='sundays.html'>8 pm: Music Practice</br></a>",
//					"<a href='jam.html'>6.00 pm: Jam Club</br></a><a href='youth.html'>7.30 pm: Youth Club</br></a>",
//					"0"


var WhatsOnArray = ["<a href='sundays.html'>10 am: Communion Service </br>11 am: Family Service</br>6.30 pm: Evening Service</br></a>",
					"0",
					"0",
					"<a href='sunbeams.html'>9 am: Little Sunbeams Parent-Toddler Group</br></a> <a href='housegroups.html'>8 pm: House Groups</br></a>",
					"0",
					"<a href='jam.html'>6.00 pm: Jam Club</br></a><a href='youth.html'>7.30 pm: Ignite</br></a>",
					"0",
					"<a href='sundays.html'>10 am: Communion Service </br>11 am: Family Service</br>6.30 pm: Evening Service</br></a>",
					"0",
					"0",
					"0",
					"0",
					"0",
					"0"];

//Notification at the top of the 'what's on page, to show some important reminder!//
var whatsonlatest = "";
//###########################################################################################//
//Write what's on over the next seven days. Array above defines meetings//
//###########################################################################################//

function WriteWhatsOn()
{
var now = new Date();
var today = now.getDay();
var i = today;
var activitytoday = 0;
var daynames = [ "<b>Sunday</b><br>",
					"<b>Monday</b><br>",
					"<b>Tuesday</b><br>",
					"<b>Wednesday</b><br>",
					"<b>Thursday</b><br>",
					"<b>Friday</b><br>",
					"<b>Saturday</b><br>"];
	if(WhatsOnArray[today] !="0")
	{
		activitytoday = 1;
		document.write("<b>Today</b></br>")
	}
while(i< (today+7))
{
	if(WhatsOnArray[i] !="0")
	{
		if((activitytoday == 0) || (i>today))
		{
			if(i>6)
			{
				document.write(daynames[i-7]);
			}
			else
			{
				document.write(daynames[i]);
			}
		}
			document.write(WhatsOnArray[i]);
	}
	i++;
}
}

//###########################################################################################//
//Write the latest single line notification (defined at the top)//
//###########################################################################################//
function WhatsOnLatest()
{
	document.write(whatsonlatest);
}

function activatePrayerForm()
{
	document.getElementById("centersection").innerHTML = '<form action="prayerphp.php" method="post">Name: <input type="text" name="name" size="30"/> <br/>Email (optional): <input type="text" name="email" size="30"/> <br/>Phone (optional): <input type="text" name="phone" size="30"/><br/>Please give as much information as you can, when done press the submit button <br /><textarea rows="10" cols="70" name="request" ></textarea> <br/><input type="submit" value="Submit"/></form>';
					
}
//###########################################################################################//
//Activate embedded google maps map//
//###########################################################################################//
function activateMap()
{
		document.getElementById("churchMap").innerHTML = "<iframe width='340' height='279' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.co.uk/maps/ms?hl=en&amp;gl=uk&amp;ptab=2&amp;ie=UTF8&amp;oe=UTF8&amp;source=embed&amp;msa=0&amp;msid=100724497454950512041.00047dd36b814df5a1fcd&amp;ll=52.45444,-2.083626&amp;spn=0.018307,0.036478&amp;z=14&amp;output=embed'></iframe><br />";

}

//###########################################################################################//
//Opacity stuff.//
//###########################################################################################//
var 	opValue=[0];
var     incTimer=[0];
var		decTimer=[0];
var        firstDec = [0];
var	imageArray = ["itemID0", "itemID1", "itemID2", "itemID3", "itemID4", "itemID5", "itemID6" , "itemID7"];
var	textArray = ["textID0", "textID1", "textID2", "textID3", "textID4", "textID5", "textID6" , "textID7"];
function ClearOpacity(thisID)
{
    document.getElementById(imageArray[thisID]).style.opacity = 0;
    opValue[thisID] = 0;
    document.getElementById(imageArray[thisID]).style.filter = 'alpha(opacity=0)';
}

function IncreaseOpacity(itemID)
{
	clearTimeout(decTimer[itemID]);
    if(opValue[itemID] <85)
    {
        opValue[itemID] +=4;
		if(opValue[itemID] <80)
        {
            document.getElementById(imageArray[itemID]).style.opacity = opValue[itemID]/100;
			document.getElementById(imageArray[itemID]).style.filter = 'alpha(opacity='+opValue[itemID]+')';
        }
            document.getElementById(textArray[itemID]).style.opacity = opValue[itemID]/100;
			document.getElementById(textArray[itemID]).style.filter = 'alpha(opacity='+opValue[itemID]+')';
        incTimer[itemID] = setTimeout('IncreaseOpacity('+itemID+')', 5);
    }
    firstDec[itemID] = 1;
}

function DecreaseOpacity(decItemID)
{
	clearTimeout(incTimer[decItemID]);
    if((firstDec[decItemID] == 1) && (opValue[decItemID] >=80))
    {
        firstDec[decItemID] = 0;
        decTimer[decItemID] = setTimeout('DecreaseOpacity('+decItemID+')', 300);
    }
    else if(opValue[decItemID] >0)
    {
        opValue[decItemID] -=4;
        {
            document.getElementById(imageArray[decItemID]).style.opacity = opValue[decItemID]/100;
			document.getElementById(imageArray[decItemID]).style.filter = 'alpha(opacity='+opValue[decItemID]+')';
        }
        decTimer[decItemID] = setTimeout('DecreaseOpacity('+decItemID+')', 5);
    }
}

//###########################################################################################//
//What's on static header.//
//###########################################################################################//
function showstaticheader()
{
	drawFbHeader("fb_whatson_static", "Whats On?");
}

//###########################################################################################//
//FB header.//
//###########################################################################################//
function drawFbHeader(flashlink, Title)
{
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// Version check based upon the values entered above in "Globals"
var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

// Check to see if the version meets the requirements for playback
if (hasReqestedVersion) {
	// if we've detected an acceptable version
	// embed the Flash Content SWF when all tests are passed
	AC_FL_RunContent(
				"src", flashlink,
				"width", "100%",
				"height", "125",
				"align", "middle",
				"id", "0",
				"quality", "high",
				"bgcolor", "#151515",
				"name", "detectionExample",
				"allowScriptAccess","sameDomain",
				"type", "application/x-shockwave-flash",
				'codebase', 'http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
				"pluginspage", "http://www.adobe.com/go/getflashplayer"
	);
} else {  // flash is too old or we can't detect the plugin
	var ap = "'";
	var alternateContent = '<table height="125" width="100%" bgcolor="#151515"><tr><td></td><td colspan = "6"><div class="noFlashHeader">'+Title+'</div></td><td></td></tr><tr class="noFlashLinks"><td bgcolor="#151515"></td><td><a href="fb_home.html">Home</a></td><td><a href="fb_whatson.html">What'+ap+'s On?</a></td><td><a href="fb_beliefs.html">Beliefs</a></td><td><a href="fb_leaders.html">Leaders</a></td><td><a href="fb_location.html">Location</a></td><td><a href="links.html">Links</a></td><td bgcolor="#151515"></td></tr></table>';
	
	document.write(alternateContent);  // insert non-flash content
}
}

//###########################################################################################//
//Set 1s timeout.//
//###########################################################################################//
function set1sTimeout(value)
{
	setTimeout('DecreaseTime('+value+')', 1000);
}

//###########################################################################################//
//Decrease Time.//
//###########################################################################################//
function DecreaseTime(time)
{
	time --;
	if(time > 0)
	{
		document.getElementById("wait_time").innerHTML = time;
		setTimeout('DecreaseTime('+time+')', 1000);
	}
	else
	{
		window.location.href="http://www.fb-church.org.uk/";
	}
}

//###########################################################################################//
//Show Popup in center of screen
//###########################################################################################//
function ShowPopMessage(width, height, message)
{
	var divLeft = ((screen.width-width)/2);
	var divTop = ((700-height)/2); 
	
	var text1 = "<div style='position:absolute;left:";
	var text2 ="px;top:";
	var text3 = "px; background-color:#ffffff; border-style:solid;border-width:1;border-color:#000000 #000000; width:";
	var text4 = "; height:";
	var text5 = "'>";
	var text6 = "</div>";
	document.getElementById("popupEdit").innerHTML = text1+divLeft+text2+divTop+text3+width+text4+height+text5+message+text6;
}

function PopupMessage(width, height)
{
	PopupMessageIntermediate( width, height, width/2, height/2);
}

function PopupMessageIntermediate( width, height, currentWidth, currentHeight)
{	
	var widthTemp = currentWidth;
	var heightTemp = currentHeight;
	if((currentWidth < width) || (currentHeight < height))
	{
		if(currentWidth < width)
		{
			widthTemp+=10;
		}
		if(currentHeight < height)
		{
			heightTemp+=10;
		}
		ShowPopMessage(currentWidth, currentHeight, "test message");
		setTimeout("PopupMessageIntermediate("+width+','+ height+','+ widthTemp+','+ heightTemp+")", 10);
	}
}





















