// 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: Youth Club</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",
					"0",
					"0",
					"0",
					"<b>4-6pm: Summer BBQ for All Ages</b></br>",
					"<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 whatsonlink = "http://www.quinta.org/ target='blank'";
var whatsonlatest = "Don't forget the church weekend away at <a href ="+whatsonlink+">the Quinta</a> June 2011";

//###########################################################################################//
//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>"];
					document.write('<a href="kids.html"><img src="images/kidsbanner.JPG"></img></a></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);
}

//###########################################################################################//
//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/";
	}
}

