function jumpMenu(selObj)
{
	var page = selObj[selObj.selectedIndex].value;
	if (page != 'NULL')
	{
		document.location.href = page;
	}
}

function previousSiblingByTagName( tagName, referenceElement )
{
	//goes through the previous siblings until it finds the node with the tag name specified
	while( referenceElement.previousSibling != null )
	{
		if( referenceElement.previousSibling.nodeName == tagName )
		{
			//return the node when we have found it
			return referenceElement.previousSibling;
		}
		referenceElement = referenceElement.previousSibling;
	}
	//if it cannot find a previous sibling that matches the tag name i.e. a previousSibling=null null is returned
	return null;		
}

function nextSiblingByTagName( tagName, referenceElement )
{
	//goes through the next siblings until it finds the node with the tag name specified
	while( referenceElement.nextSibling != null )
	{
		if( referenceElement.nextSibling.nodeName == tagName )
		{
			//return the node when we have found it
			return referenceElement.nextSibling;
		}
		referenceElement = referenceElement.nextSibling;
	}
	//if it cannot find a previous sibling that matches the tag name i.e. a previousSibling=null null is returned
	return null;		
}
function showPara( event )
{
	var thisNode = this;
	if( event.srcElement )
	{
		thisNode = 	event.srcElement;
	}
	if( thisNode.nodeName == "H2" )
	{
		for( var i = 0; i<hideShowParagraphList.length; i++ )
		{
			hideShowParagraphList[i].style.display = "none";
		}
	//window.alert( thisNode.tagName );
		var pToShow = nextSiblingByTagName( "P", thisNode );
		pToShow.style.display = "";
		pToShow.className = "jsParagraph";
	}
}
function showPara1( event )
{
	//window.alert("showPara1");
	for( var i = 0; i<hideShowParagraphList.length; i++ )
	{
		hideShowParagraphList[i].style.display = "none";
	}
	var thisNode = this;
	if( event.srcElement )
	{
		thisNode = 	event.srcElement;
	}
	if( thisNode.parentNode.nodeName != "H2" )
	{
		var pToShow = nextSiblingByTagName( "P", thisNode.parentNode.parentNode );
	}
	else
	{
		var pToShow = nextSiblingByTagName( "P", thisNode.parentNode );
	}
	//window.alert(thisNode.parentNode.tagName);
	pToShow.style.display = "";
	pToShow.className = "jsParagraph";
}
//not used
function hidePara( event )
{
	var thisNode = this;
	if( event.srcElement )
	{
		thisNode = 	event.srcElement;
	}
	//window.alert( "hi" );
	//window.alert( "mouse out: " + thisNode.tagName );
	//event.cancelBubble = false;
//	if( event.stopPropagation )
//	{
//		event.stopPropagation();
//	}
	if( thisNode.nodeName == "H2" )
	{
		var pToHide = nextSiblingByTagName( "P", thisNode )
		pToHide.style.display = "none";
		pToHide.className = "";
		hideShowParagraphList[0].style.display = "";
		hideShowParagraphList[0].className = "jsParagraph";
	}
}
function hidePara1( event )
{
	var thisNode = this;
	if( event.srcElement )
	{
		thisNode = 	event.srcElement;
	}
	
	if( thisNode.parentNode.nodeName != "H2" )
	{
		var pToHide = nextSiblingByTagName( "P", thisNode.parentNode.parentNode );
	}
	else
	{
		var pToHide = nextSiblingByTagName( "P", thisNode.parentNode )
	}
	
	pToHide.style.display = "none";
	pToHide.className = "";
	hideShowParagraphList[0].style.display = "";
	hideShowParagraphList[0].className = "jsParagraph";
}

//cls = class
//n = node
//t = tag
document.getElementsByClassName = function(cls,n,t)
{
	var rtn = [];
	n=n===null?document:n;
	t=t===null?'*':t;
	var els = n.getElementsByTagName ? n.getElementsByTagName(t) : document.all;
	els = (!els||!els.length ) && document.all ? document.all : els;
	if(cls==null){return els;}
	for (var i=0,j=0; i < els.length; i++)
	{
		if(els[i].className.match("(^|\\s)"+cls+"(\\s|$)"))
		{
			rtn[j++] = els[i];
		}
	}
	return rtn;
};

function jsfAttachEvent(obj,evt,fnc)
{
	if(window.addEventListener)
	{
		obj.addEventListener(evt, fnc, false);
	}
	else if(window.attachEvent)
	{
		obj.attachEvent('on'+evt, fnc);
	}
	else if (obj.getElementById && evt=='load')
	{
		obj.onload = fnc;
	}
}

jsfAttachEvent(window,'load',jsfOnLoad);

var hideShowParagraphList;

function jsfOnLoad()
{
	//window.alert(document.getElementsByClassName( "hsbcGP2007Ext1024", document.body, "DIV" ).length == 0);
	if( document.getElementById( "jsPresentationTransform01" ) && document.getElementsByClassName( "hsbcGP2007Ext1024", document.body, "DIV" ).length == 0 )//check to see if the element exists and make sure the script does not run on 1024 sites
	{
		//handle on the root node
		var rootNode = document.getElementById( "jsPresentationTransform01" );
		//hide all the p tags within the root node
		hideShowParagraphList = rootNode.getElementsByTagName( "P" );
		var h2List = rootNode.getElementsByTagName( "H2" );
		var colList = document.getElementsByClassName( "hsbcGP2007Column", rootNode, "DIV" );
		for( var i=0; i<hideShowParagraphList.length; i++ )/* There should always be as many paragraphs as there are columns and headings */
		{
			hideShowParagraphList[i].style.display = "none";				
		}
		for( var x=0; x<h2List.length; x++ )
		{
			h2List[x].className = "jsHeading";
			//jsfAttachEvent( h2List[x], "mouseover", showPara );
			//jsfAttachEvent( h2List[x], "mouseout", hidePara );
			jsfAttachEvent( h2List[x].getElementsByTagName( "A" )[0], "mouseover", showPara1 );//assign onhover event handlers
			jsfAttachEvent( h2List[x].getElementsByTagName( "A" )[0], "mouseout", hidePara1 );//assign onhover event handlers
		}
		for( var y=0; y<colList.length; y++ )
		{
			colList[y].className = "jsColumn"; 
		}
		//show the first one by default
		hideShowParagraphList[0].style.display = "";
		hideShowParagraphList[0].className = "jsParagraph";
		h2List[0].className = "jsHeading jsFirstAnchor";
	}
}