// JavaScript Document

if (typeof( window[ 'rssFeedNotAvailable' ] ) == "undefined") rssFeedNotAvailable = false;

if (typeof( window[ 'totalraised' ] ) == "undefined") {

	  totalraised = "";
	  totalonline = "";
	  totaloffline = "";
	  totalgiftaid = "0";
	  totaltarget = "";

}

if (typeof( window[ 'fill' ] ) == "undefined") fill = 4;
else if (fill < 4) fill = 4; // minimum 4 !!		

if (typeof( window[ 'pagewidth' ] ) == "undefined") pagewidth = 1000;
else if (pagewidth < 1000) pagewidth = 1000; // minimum 1000 !!		

if (typeof( window[ 'pageheight' ] ) == "undefined") pageheight = 800;
else if (pageheight < 800) pageheight = 800; // minimum 800 !!		

function FMNR_rssFeedConvertTotal(responseText) {
	var iPos = responseText.indexOf("Total raised:");
	  if (iPos >=8) return  responseText.substr(iPos+15, 6);
	  else return  "";
}

function FMNR_rssFeedConvertOnline(responseText) {
	var iPos = responseText.indexOf("online:");
	  if (iPos >=8) {
	    var iText = responseText.substr(iPos+9, 8);
		var jPos = iText.indexOf(".");
		if (jPos > 0) return  iText.substr(0, jPos);
		else return  "";
	  }
	  else return  "";
}

function FMNR_rssFeedConvertOffline(responseText) {
	var iPos = responseText.indexOf("offline:");
	  if (iPos >=8) return  responseText.substr(iPos+10, 6);
	  else return  "";
}

function FMNR_rssFeedConvertGiftaid(responseText) {
	var iPos = responseText.indexOf("total by");
	  if (iPos >=8) return  responseText.substr(iPos+10, 6);
	  else return  "";
}

function FMNR_rssFeedConvertTarget(responseText) {
	var iPos = responseText.indexOf("target:");
	  if (iPos >=8) return  responseText.substr(iPos+26, 7);
	  else return  "";
}

backgroundWidth=1000;
mainWidth=1000;
mainHeight=800;
mainLeft=parseInt((backgroundWidth-mainWidth)/2);
backgroundOffset=16;

function FMNR_pageStart() {
  NS6=false;
  IE4=(document.all);
  if (!IE4) {NS6=(document.getElementById);}
  NS4=(document.layers);

  backgroundWidth=FMNR_getWindowWidth()-backgroundOffset;
  mainLeft=(FMNR_getWindowWidth()-mainWidth)/2;
  if (mainLeft<backgroundOffset) mainLeft=0;
  else mainLeft=(backgroundWidth-mainWidth)/2;

// Start of Page Layer
  if (document.layers) {document.write('<LAYER NAME="PageLayer" LEFT="0px" WIDTH="'+mainWidth.toString()+'px">');}
  else {document.write('<div id="PageLayer" style="position:absolute; left: '+mainLeft.toString()+'px; width: '+mainWidth.toString()+'px; z-index:1;">');}
  document.write('<table><tr><td>');
}

function FMNR_getWindowHeight() 
{ 
    if (window.innerHeight) return window.innerHeight; 
    else if (document.all) return document.body.offsetHeight; 
    else return window.innerHeight; 
} 

function FMNR_getWindowWidth() 
{ 
    if (document.all) return document.body.offsetWidth; 
    else return window.innerWidth; 
} 

function FMNR_pageDefine() {
	backgroundWidth=FMNR_getWindowWidth()-backgroundOffset;
	mainLeft=(FMNR_getWindowWidth()-mainWidth)/2;
	if (mainLeft<backgroundOffset) mainLeft=0;
	else mainLeft=(backgroundWidth-mainWidth)/2;
	if ((NS4) || (NS6)) 
	{
		lastX=window.pageXOffset + mainLeft;
		if (NS4)
		{
			document.layers['PageLayer'].pageX=lastX;
			document.layers['rssLayer'].pageX=lastX;
		}
		if (NS6)
		{
			document.getElementById('PageLayer').style.left=lastX+"px";
			document.getElementById('rssLayer').style.left=lastX+"px";
		}
	} else if (IE4)
	{
		lastX=document.body.scrollLeft + mainLeft;
		document.all['PageLayer'].style.posLeft=lastX;
		document.all['rssLayer'].style.posLeft=lastX;
	}
}

function FMNR_pageEnd() {
  document.write('</td></tr></table>');
  if (document.layers) {document.write('</LAYER>');}
  else {document.write('</div>');}	
// End of Page Layer

}

function FMNR_rssFeedDisplayStart() {
// Start of rssFeed Layer
  if (document.layers) {document.write('<LAYER NAME="rssLayer"> LEFT="0" WIDTH="500">');}
  else {document.write('<div id="rssLayer" style="position:absolute; left: 200; width:500;  z-index:2; visibility:hidden;">');}
  rssFeedAvailable = 0;	
  document.write('<table><tr><td>');
}

function FMNR_rssFeedDisplayEnd() {
  document.write('</td></tr></table>');
  if (document.layers) {document.write('</LAYER>');}
  else {document.write('</div>');}	
// End of rssFeed Layer

FMNR_pageDefine();
window.onresize=FMNR_pageDefine;

}

function FMNR_rssFeed_Update() {
  if (rssFeedAvailable == 0) {
	rssFeedAvailable = 1;
	setTimeout('FMNR_rssFeed_Update()',50); // often
  } 
  else {	
	if (document.all['rssLayer']) {
	  totalraised = FMNR_rssFeedConvertTotal(document.all['rssLayer'].innerHTML);
	  totalonline = FMNR_rssFeedConvertOnline(document.all['rssLayer'].innerHTML);
	  totaloffline = FMNR_rssFeedConvertOffline(document.all['rssLayer'].innerHTML);
	  totalgiftaid = FMNR_rssFeedConvertGiftaid(document.all['rssLayer'].innerHTML);
	  totaltarget = FMNR_rssFeedConvertTarget(document.all['rssLayer'].innerHTML);
	  if ((totalraised != '') && (totalonline != '') && (totaloffline != '')) {
	    document.all['fmnr_2011_raised'].innerHTML = '&pound;'+totalraised;
	    document.all['fmnr_2011_target'].innerHTML = '&pound;'+totaltarget;
	    document.all['fmnr_2011_online'].innerHTML = '&pound;'+totalonline;
	    document.all['fmnr_2011_offline'].innerHTML = '&pound;'+totaloffline;
	  }
	  else setTimeout('FMNR_rssFeed_Update()',50); // often
	}
	else if (document.getElementById('rssLayer')) {
	  totalraised = FMNR_rssFeedConvertTotal(document.getElementById('rssLayer').innerHTML);
	  totalonline = FMNR_rssFeedConvertOnline(document.getElementById('rssLayer').innerHTML);
	  totaloffline = FMNR_rssFeedConvertOffline(document.getElementById('rssLayer').innerHTML);
	  totalgiftaid = FMNR_rssFeedConvertGiftaid(document.getElementById('rssLayer').innerHTML);
	  totaltarget = FMNR_rssFeedConvertTarget(document.getElementById('rssLayer').innerHTML);
	  if ((totalraised != '') && (raisedonline != '') && (totaloffline != '')) {
		document.getElementById('fmnr_2011_raised').innerHTML = '&pound;'+totalraised;
		document.getElementById('fmnr_2011_target').innerHTML = '&pound;'+totaltarget;
		document.getElementById('fmnr_2011_online').innerHTML = '&pound;'+totalonline;
		document.getElementById('fmnr_2011_offline').innerHTML = '&pound;'+totaloffline;
	  }
	  else setTimeout('FMNR_rssFeed_Update()',50); // often
	}
	setTimeout('FMNR_Update()', 5000); // five seconds
  }
}

if ((typeof( window[ 'picsImgId' ] ) == "undefined") && (typeof( window[ 'picsImgCycle' ] )) == "undefined") {
  picsImgCycle = new Array('left_1', 'right_2', 'right_1', 'right_inner');
  picsImgId = picsImgCycle[0];
}

else if (typeof( window[ 'picsImgId' ] ) == "undefined") picsImgId = picsImgCycle[0];

else if (typeof( window[ 'picsImgCycle' ] ) == "undefined") picsImgCycle = new Array(picsImgId);

if (typeof( window[ 'picsImgGroup' ] ) == "undefined") {
  picsImgGroup = new Array();
	picsImgGroup['left_1']		= 0;
	picsImgGroup['right_inner']	= 1;
	picsImgGroup['right_2']		= 2;
	picsImgGroup['left_2']		= 3;
	picsImgGroup['left_inner']	= 4;
	picsImgGroup['right_1']		= 5;
}

if (typeof( window[ 'picsImgPath' ] ) == "undefined") picsImgPath = "";

  picsImgUrl = new Array();
	picsImgUrl[0] = picsImgPath + "gallery/profile/";
	picsImgUrl[1] = picsImgPath + "gallery/eton/";
	picsImgUrl[2] = picsImgPath + "gallery/henley/";
	picsImgUrl[3] = picsImgPath + "gallery/marlow/";
	picsImgUrl[4] = picsImgPath + "gallery/maidenhead/";
	picsImgUrl[5] = picsImgPath + "gallery/team/";

  picsImgName = new Array();
	picsImgName[0] = new Array(
		'Personal_10th_June_2005',				// At niece's wedding, June 2005
		'Personal_Jamie_Guitar_1964',			// With Guitar, 1964
		'Personal_Jamie_PSHL_1965',				// PSH Lawrence's House 1965
		'Personal_Jamie_Ewan_Henley_1966',		// At Henley Royal Regatta 1966, with brother Ewan Graham
		'Personal_Jamie_and_Vicki_1972',		// Vicki and Jamie on their Engagement, November 1971
		'Personal_Jamie_Guitar_ship',			// With Guitar, at sea
		'Personal_Jamie_Guitar_singing',		// With Guitar, singing
		'Personal_Jamie_Hooch_1998',			// Jamie with Hooch, 1998
		'Personal_Comrie_Golf_Course_2004',		// Comrie golf course, 2004
		'Personal_Cruachan_mascot_of_Argyll_and_Sutherland_Highlanders',	// Cruachan, mascot of the Argyll & Sutherland Highlanders
		'Personal_D_Company_Stirling_Castle_October_2007',					// Marching with his 'D' company, Stirling Castle, October 2007
		'Personal_DSCF0012',					// Forget-Me-Not group canoe outing - How it all started ...
		'Personal_Jamie_Skiing_2009',			// Jamie skiing in February 2009
		'Personal_Beastie_Lea_Macnally_2009',	// 'Beastie' with Lea Macnally,2009
		'Personal_Bikeman_2009',				// Bikeman in the yard at Home Idover Farm, 2009
		'Personal_Jamie_Rowing_Machine_large',	// .. still putting in a few thousand metres on my rowing machine - just to keep my oar in ..
		'DSC01651',								// First Practice - 4,000 metres on Eton Dorney Lake
		'Vicki_0091',							// Wednesday before the row
		'Personal_P1010204',					// Jamie and brother Colin Graham
		'Calum_017',							// Before the Row at Eton
		'Calum_076',							// At the start of the regatta course
		'Andy_IMG_3145',						// Jamie on the raft at the end of his Forget-Me-Not Row
		'Vicki_P1010343',						// Magnus and Jamie Graham, Wargrave Meadows Car Park
		'Caroline_4221',						// After the Row at Henley
		'Christian_6244_We_done_it');			// Vicki and Jamie celebrate the End of an emotional day
	picsImgName[1] = new Array(
		'Caroline_4112',
		'Calum_008',
		'Caroline_0765',
		'Calum_019',
		'Calum_011',
		'Caroline_0775',
		'Caroline_0778',
		'Calum_020',
		'Calum_028',
		'Calum_029',
		'Calum_030',
		'Calum_031');
		
	picsImgName[2] = new Array(
		'Calum_064',
		'Vicki_P1010317',
		'Caroline_0811',
		'Caroline_4191',
		'Caroline_4192',
		'Vicki_P1010322',
		'Calum_068',
		'Calum_069',
		'Calum_070',
		'Calum_071',
		'Calum_072',
		'Calum_073',
		'Calum_074',
		'Calum_075',
		'Calum_076',
		'Calum_077',
		'Calum_078',
		'Calum_079',
		'Calum_080',
		'Calum_081',
		'Calum_082',
		'Caroline_4200',
		'Caroline_4202',
		'Calum_083',
		'Vicki_P1010323',
		'Caroline_4205',
		'Christian_6223_Rowathon_arrives_Henley',
		'Christian_6224_Into_View',
		'Christian_6225_To_the_bridge');

	picsImgName[3] = new Array(
		'Calum_031');
		
	picsImgName[4] = new Array(
		'Calum_031');
		
	picsImgName[5] = new Array(
		'Caroline_0804',						// Peregrine (Perry) Moncrieffe
		'Caroline_4196',						// Andrew Gordon
		'Christian_6209_Bride_Groom_behind',	// Jonathan Seddon-Brown (Chef d’Equipe)
		'Caroline_0772',						// Rory Mann
		'Calum_014',							// Michael Baines
		'Vicki_P1010261',						// Fergus Graham (nephew)
		'Calum_061',							// Jonathan Baines 
		'Calum_076',							// Jamie Graham
		'Christian_6170_Row_Papa', 				// Vicki Graham (Chief Fundraiser)
		'Vicki_P1010304',						// 
		'Andy_IMG_3149',
		'Calum_080',
		'Calum_013',
		'Caroline_4194',
		'Calum_060',
		'Calum_054',
		'Calum_074',
		'Andy_IMG_3068',
		'Jonathan_074',
		'Calum_023',
		'Christian_6239_Piper_for_a_dram',
		'Personal_P1010204',
		'Andy_IMG_3081');						// Jamie's Crew and Support Team
		

  if (typeof( window[ 'picsImgNo' ] ) == "undefined") picsImgNo = 0;		

  picsImgCount = 0;
  refreshCount = 0;
  refreshLength = picsImgName[0].length +
  					picsImgName[1].length +
  					picsImgName[2].length +
  					picsImgName[3].length +
  					picsImgName[4].length +
  					picsImgName[5].length;
  if (refreshLength < 119) refreshLength = 119;

/*
picsImgId = "right_1";
picsImgNo = 21;
picsImgUrl = "gallery/profile/pics/";
picsImgSlidesUrl = "gallery/profile/slides/";
*/
function FMNR_Update() {
  var picsImgGroupNo = picsImgGroup[picsImgId];
	MM_swapImage('Img_'+picsImgId, '', picsImgUrl[picsImgGroupNo] + 'pics/' + picsImgName[picsImgGroupNo][picsImgNo] + '.jpg', 1);
	if (document.getElementById('Addr_'+picsImgId)) {
	  document.getElementById('Addr_'+picsImgId).href = picsImgUrl[picsImgGroupNo] + 'slides/' + picsImgName[picsImgGroupNo][picsImgNo] + '.html';
	}
	if (document.all['Addr_'+picsImgId]) document.all['Addr_'+picsImgId].href = picsImgUrl[picsImgGroupNo] + 'slides/' + picsImgName[picsImgGroupNo][picsImgNo] + '.html';

	picsImgNo = picsImgNo + 1;
	if (picsImgNo >= picsImgName[picsImgGroupNo].length) {
	  picsImgNo = 0;
	  picsImgCount = picsImgCount + 1;
	  if (picsImgCount < picsImgCycle.length) picsImgId = picsImgCycle[picsImgCount];
	}
	
	FMNR_refresh();
}

function FMNR_refresh() { //v3.0
	refreshCount = refreshCount + 1;
	if (refreshCount >= refreshLength) location.reload(true); // 295 seconds
	else if (picsImgCount >= picsImgCycle.length) setTimeout('FMNR_refresh()', 5000); // five seconds
	else setTimeout('FMNR_Update()', 5000); // five seconds
}

function FMNR_money_raised() { //v3.0
      document.write('<td align="center"><h3>Total Raised:<br>&pound;'+totalraised+'</h3></td>');
}

function FMNR_online_cheques() { //v3.0
      document.write('<td align="left"><h4>Online:<br>Cheques:</h4></td><td align="right"><h4>&pound;'+raisedonline+'<br>&pound;'+cheques+'</h4></td>');
}

function FMNR_bar_filler(fill_height) { //v3.0
 if (fill_height > 0) {
	document.write('<tr>');
      document.write('<td><img src="images/spacer.gif" width="200" height="'+fill_height+'"></td>');
	document.write('</tr>');
 }
}

function FMNR_page_filler(fill_height) { //v3.0
 if (fill_height > 0) {
      document.write('<td width="10"><img src="images/spacer.gif" width="10" height="'+fill_height+'"></td>');
 }
}

function FMNR_page_length(fill_height) { //v3.0
 if (fill_height > 0) {
      document.write('</td><td align="center" height="'+fill_height+'">');
 }
}

function FMNR_margin_top_filler(fill_width, fill_height) { //v3.0
 if (fill_height > 0) {
      document.write('<td colspan="4" width="'+fill_width+'"><img src="images/spacer.gif" width="'+fill_width+'" height="'+fill_height+'"></td>');
 }
}

function FMNR_margin_bottom_filler(fill_width, fill_height) { //v3.0
 if (fill_height > 0) {
      document.write('<td colspan="4" width="'+fill_width+'"><img src="images/spacer.gif" width="'+fill_width+'" height="'+fill_height+'"></td>');
 }
}

function FMNR_margin_left_filler(fill_width, fill_height) { //v3.0
 if (fill_height > 0) {
      document.write('<td width="'+fill_width+'"><img src="images/spacer.gif" width="'+fill_width+'" height="'+fill_height+'"></td>');
 }
}

function FMNR_margin_right_filler(fill_width, fill_height) { //v3.0
 if (fill_height > 0) {
      document.write('<td width="'+fill_width+'"><img src="images/spacer.gif" width="'+fill_width+'" height="'+fill_height+'"></td>');
 }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
