function MainBody(bodystr,type,mnu)
{
	// This function is called when user clicks on a menu option 
	// It  sets up the 3 random images if we are processing Personal Details 
	// It sets up initial top image  in main page area
	//It cycles through all menu options to remove a previous logo marker, and then applies logo marker to the current selected menu item
	
	if (type==2)
	{
		//Code to select 2 portraits and 1 landscape in any order. Assumes s1.jpg and s2.jpg are landscape and s3,s4,s5 are portrait
		var pics = new Array(0,0,0,0); //Element for each 3 required picture, zero element not used
		var found = new Array (0,0,0,0,0,0) ; //Element to flag if a number already used
		lc = pc = 0 ; //Landscape and portrait counts
		var ppos = 1 ; //Count of picture position being looked for
		while (ppos < 4)
		{
			var rand=Math.floor(Math.random()*5)+1 ;
			if (found[rand] == 0)
			{
				// If landscape chosen, can use it as long as no landscapes already picked
				if (rand < 3 && lc == 0 )
					{lc++ ; pics[ppos] = rand ; ppos++ ; }
				else
				// If portrait chosen, can use it as long as 2 not already chosen
				if (rand > 2 && pc < 2 )
					{pc++ ; pics[ppos] = rand ; ppos++ ; }
				found[rand] = 1 ;
			}
		}
		var leg = 'Personal pictures' ;  var rpt = 'class="shdr" alt="'+leg+'" title="'+leg+'"' ;
		var picline = '<img src="/Personal/s'+pics[1]+'.jpg" '+rpt+' /><img src="/Personal/s'+pics[2]+'.jpg" '+rpt+' /><img src="/Personal/s'+pics[3]+'.jpg" '+rpt+' />' ;
		bodystr = picline+bodystr ;
	}
	//html5 does not like spaces in an href, so we were passed + signs, so change them back to spaces here.  Ditto with quotes from qq, £ from zx  and spaces from zz..
	bodystr=bodystr.replace(/\+/g,' ') ; bodystr=bodystr.replace(/\qq/g,'&rsquo;') ; bodystr=bodystr.replace(/\zz/g,'&nbsp; ') ; bodystr=bodystr.replace(/\zx/g,'&pound;') ;
	document.getElementById('mainpage').innerHTML='<div id="main'+type+'top">'+bodystr+'</div>' ;
	//Clear all menu marks and make show current menu mark (logo sign) . Code allows for up to 25 items - increase value here if necessary
	var ss = 1 ; 
	while (ss < 25) { idelement = document.getElementById('s'+ss) ; if (idelement) {idelement.innerHTML = '' ;  } ss++ ;}
	document.getElementById('s'+mnu).innerHTML='<img src="/images/logo_tiny.png" alt ="Menu item" class="logo" />' ;
}

function TopImg(img,leg,brs)
{
	// Function called when a thumbnail image is clicked
	// It ouputs required number of newlines and then inserts required image into main1top div.
	var br = '' ; var i=1;
	for (i=1;i<=brs;i++) {br = br+'<br />' ;} 
	document.getElementById('main1top').innerHTML=br+'<img class="mainpic" src="/'+img+'" /><p>'+leg+'</p>' ;
}
								
