//Init elements - hide plus images from old browsers
function initElts(numElts)
{	
	if ( document.getElementById )
	{
	// standard browsers
	
		for (i = 1; i <= numElts; i++)
		{
			// Get the IDs we need
		    var eltID = 'info_' + i; // the element which gets toggled on and off
		    var toggleID = 'toggle_' + i; // clickable widget which toggles element on and off. It's a gif
			
			// start: show the toggle widget
			var widget = document.getElementById(toggleID); // the widget gif
			widget.height = 14; // swap in a replacement gif
			widget.width = 14; // swap in a replacement gif
			widget.src = '/nol/shared/spl/hi/uk/05/born_abroad/img/plus.gif'; // swap in a replacement gif	
			// end: show the toggle widget
		 }
	}  
	else return; // if getElementById is not supported then give up
}


//Toggle elements - show/hide top countries of birth  
function toggleElt(eltNum)
{	
	if (document.getElementById)
	{
		// Get the IDs we need
	    var eltID = 'info_' + eltNum; // the element which gets toggled on and off
	    var toggleID = 'toggle_' + eltNum; // clickable widget which toggles  element on and off. It's a gif
		
		// start: toggle the element
		var divState = document.getElementById(eltID).style; // the css style of the content block	
		
		// Code to toggle the content block on and off
		divState.display = divState.display == "none" ? "" : "none";
		// end: toggle the element
		
		// start: toggle the widget
		var widget = document.getElementById(toggleID); // the widget gif

		// If the image source matches plus.gif then change it to minus.gif
		if ( widget.src.match(/plus.gif/) )
		{
			widget.src = '/nol/shared/spl/hi/uk/05/born_abroad/img/minus.gif';
		}
		// and vice versa
		else
		{
			widget.src = '/nol/shared/spl/hi/uk/05/born_abroad/img/plus.gif';
		}
		//widget.src = widget.src == 'plus.gif' ? 'minus.gif' : 'plus.gif';	
		// end: toggle the widget
	} 
	else return; // if getElementById is not supported then give up
}
 
  
//Write in map overlay stuff for compatible browsers
function initMapLabels()
{	
	if ( document.getElementById )
	{
		var argv = initMapLabels.arguments;
  		var argc = argv.length;
  		for (var i = 0; i < argc; i++) 
		{
			var myLinkDiv = argv[i]+'Link';
			
			document.getElementById(myLinkDiv).innerHTML='<form><input type="checkbox" onclick="toggleOverlay(\''+argv[i]+'\');">Click to highlight key cities</form>'; // the css style of the content block
		}	
	}  
	else return; // if getElementById is not supported then give up
}  


//Toggle overlay map 
function toggleOverlay(overlayID)
{	
	if (document.getElementById)
	{
		var myDiv = document.getElementById(overlayID); // the css style of the content block	
		
		// Code to toggle the content block on and off
		if (myDiv.innerHTML == '')
		{
			myDiv.innerHTML =  '<img src="\/nol\/shared\/spl\/hi\/uk\/05\/born_abroad\/countries\/img\/city_labels.gif" width="416" height="353" border="0" alt="Map showing key cities in England, Scotland and Wales" \/>'; 
		}
		else
		{
			myDiv.innerHTML = '';
		}
	} 
	else return; // if getElementById is not supported then give up
}
