/* FUNCTIONS AND CLASSES */

/* FLASH ELEMENTS */
function createSectionHeader(){
	var objFlashProperties={
		src: strUrlHeaderNormalSwf,
		color: '#005AFF',
		width: 740,
		height: 25,
		content:'Annual Report 2008',
		fontsize:'21px',
		thickness:1,
		sharpness:-80
	}
	writeSifrElement(objFlashProperties);
}

function createGillSansHeader(objArguments){
	//get the correct color from the array
	//alert(objArguments.content);
	if(objArguments.content.contains('Lighting the National'))objArguments.content="Lighting the National - dramatic impact";

	if(objArguments.content==''){
		document.write('<img src="/imgs/syst/t.gif" width="1" height="1"/>')

	}else{

		var strColor=arrFarColors[objArguments.colorname];

		var objFlashProperties={
			src: strUrlHeaderNormalSwf,
			color: strColor,
			width: 500,
			height: 25,
			content:'Content',
			fontsize:'21px',
			thickness:1,
			sharpness:-80
		}
		//extend the default fash values with what has been passed to the function
		$extend(objFlashProperties, objArguments);

		if(!$defined(objArguments.returnhtml)){
			writeSifrElement(objFlashProperties);
		}else{
			return retrieveSifrElementHtml(objFlashProperties);
		}

	}

}

function createFarQuote(objArguments){
	//default values for the flashvars
	var objFlashVars={
		dataFile: '/imgs/user/swf/annualreport2008.xml',
		textcolor: '0x005aff',
		textsize: 18
	};
	//extend the default fashvars values with what has been passed to the function
	$extend(objFlashVars, objArguments);

	var strId=objArguments.id;

	intWidth=558;
	if(strId.contains('far-proofpoint'))intWidth=524;
	if($defined(objArguments.quotetype)){
		if(objArguments.quotetype=='proofpoint')intWidth=524;
	}

	var objFlashParams={
		src: '/imgs/user/swf/SubpageQuote.swf',
		width: intWidth,
		height: 75,
		version: 9,
		id: strId,
		params: {bgcolor:'#ffffff', allowScriptAccess: 'sameDomain'},
		vars: objFlashVars,
		align: 'middle',
		scale: 'noscale'
	}

	if(!$defined(objArguments.returnhtml)){
		writeFlashHtml(objFlashParams);
	}else{
		return createFlashHtml(objFlashParams);
	}

}

function createFarKpiElement(objArguments){
	var strTitle=escape(objArguments.title);
	var strText=objArguments.text;
	var strColorName=objArguments.colorname;

	var strColorHex=arrFarColors[objArguments.colorname];
	var intWidth=130;
	var intTitleHeight=36, intTextHeight=16;
	var strFontSizeTitle='30px', strFontSizeText='12px';

	//use a character count to calculate the height of the supporting title box
	if(unescape(strTitle).length>11)intTitleHeight=2*intTitleHeight;

	//use a character count to calculate the height of the supporting text box
	var strTextPlain=unescape(strText);
	if(strTextPlain.length>=24 && strTextPlain.length<46)intTextHeight=2*intTextHeight;
	if(strTextPlain.length>=46 && strTextPlain.length<68)intTextHeight=3*intTextHeight;
	if(strTextPlain.length>=68)intTextHeight=4*intTextHeight;

	//create the flash object for the title
	var objFlashProperties={
		src: strUrlHeaderSpecial1Swf,
		color: strColorHex,
		width: intWidth,
		height: intTitleHeight,
		content: strTitle,
		fontsize: strFontSizeTitle,
		thickness: 1,
		sharpness: -80
	};
	if(strTitle.charAt(0)=='1')objFlashProperties.paddingleft='-5px';
	var strFlashHtmlTitle=retrieveSifrElementHtml(objFlashProperties);

	//create the flash object for the text
	objFlashProperties={
		src: strUrlHeaderNormalSwf,
		color: strColorHex,
		width: intWidth,
		height: intTextHeight,
		content: strText,
		fontsize: strFontSizeText,
		thickness: 1,
		sharpness: -80
	}
	var strFlashHtmlText=retrieveSifrElementHtml(objFlashProperties);

	var objParam={
		height: intTitleHeight+intTextHeight,
		htmlflash: strFlashHtmlTitle+strFlashHtmlText
	}

	//base html for the kpi element
	strHtml='<div class="far-kpi_item_wrapper" style="height:{height}px">';
	strHtml+='	<div class="far-kpi_flash_mask" style="height:{height}px"></div>';
	strHtml+='	<div class="far-kpi_flash_wrapper" style="height:{height}px">{htmlflash}</div>';
	strHtml+='</div>';

	strHtml=strHtml.substitute(objParam);

	//alert(strHtml)
	if(!$defined(objArguments.returnhtml)){
		document.write(strHtml);
	}else{
		return strFlashHtmlTitle+strFlashHtmlText;
	}

}

function createFarKpiElementInline(objArguments){
	var strTitle=escape(objArguments.title);
	var strText=objArguments.text;
	var strColorName=objArguments.colorname;

	var strColorHex=arrFarColors[objArguments.colorname];
	var intWidth=130;
	var intTitleHeight=36, intTextHeight=15;
	var strFontSizeTitle='30px', strFontSizeText='12px';

	//use a character count to calculate the height of the supporting title box
	if(unescape(strTitle).length>11)intTitleHeight=2*intTitleHeight;

	//use a character count to calculate the height of the supporting text box
	var strTextPlain=unescape(strText);
	if(strTextPlain.length>=24 && strTextPlain.length<46)intTextHeight=2*intTextHeight;
	if(strTextPlain.length>=46 && strTextPlain.length<68)intTextHeight=3*intTextHeight;
	if(strTextPlain.length>=68)intTextHeight=4*intTextHeight;

	//create the flash object for the title
	var objFlashProperties={
		src: strUrlHeaderSpecial1Swf,
		color: strColorHex,
		width: intWidth,
		height: intTitleHeight,
		content: strTitle,
		fontsize: strFontSizeTitle,
		thickness: 1,
		sharpness: -80
	};
	if(strTitle.charAt(0)=='1')objFlashProperties.paddingleft='-5px';
	var strFlashHtmlTitle=retrieveSifrElementHtml(objFlashProperties);

	//create the flash object for the text
	objFlashProperties={
		src: strUrlHeaderNormalSwf,
		color: strColorHex,
		width: intWidth,
		height: intTextHeight,
		content: strText,
		fontsize: strFontSizeText,
		thickness: 1,
		sharpness: -80
	}
	var strFlashHtmlText=retrieveSifrElementHtml(objFlashProperties);

	document.write(strFlashHtmlTitle+strFlashHtmlText);
}

function animateFarKpiElements(){
	/*
	Animates the kpi elements into view
	*/
	var intDelayStart=600, intInterval=800, intDuration=1000, intDelay=0;
	var objEffectProperties={
		duration: intDuration,
		transition: Fx.Transitions.Cubic.easeInOut,
		link: 'chain'
	}
	if($defined(objPageElements.elrightcolumn)){
		var arrKpiWrappers=objPageElements.elrightcolumn.getElements('div.far-kpi_item_wrapper');

		intDelay=intDelayStart;
		arrKpiWrappers.each(function(elDivWrapper, index){
			var elDivMask=elDivWrapper.getElement('div.far-kpi_flash_mask');
			elDivMask.set('tween',objEffectProperties);
			elDivMask.tween.delay(intDelay, elDivMask, ['opacity', 0]);
			intDelay+=intInterval;
		})
	}
}


function leftNavigationRework(){
	/*
	Left navigation - add accordion effects
	*/
	//return true;
	var arrTr;
	//duration of each individual effect
	var intDuration=50;
	if(Browser.Engine.trident)intDuration=30;
	var elLeftNavigationTable=objPageElements.elleftnavtable;

	if(!$defined(elLeftNavigationTable))return false;

	if(strPageIdSystem=="ulogin_page"){
		//remove all rowws except the home page
		arrTr=elLeftNavigationTable.getElements("tr");
		arrTr.each(function(el, index){
			if(index > 0)el.dispose();
		});

	}else{
		var elLinkContainer1=elLeftNavigationTable.getElement("tr[class=leftnavtitlesect1] a");
		var elLinkContainer2=elLeftNavigationTable.getElement("tr[class=leftnavtitlesect2] a");
		var elLinkContainer3=elLeftNavigationTable.getElement("tr[class=leftnavtitlesect3] a");

		if($defined(elLinkContainer1) && $defined(elLinkContainer2) && $defined(elLinkContainer3)){


			elLinkContainer1.addEvent('click', function(event){
				event.preventDefault();
				leftNavigationSwapContainer(this, 1);
			});

			elLinkContainer2.addEvent('click', function(event){
				event.preventDefault();
				leftNavigationSwapContainer(this, 2);
			})

			elLinkContainer3.addEvent('click', function(event){
				event.preventDefault();
				leftNavigationSwapContainer(this, 3);
			})

			//apply tween effect to each row in the table
			var objTweenProperties={
				duration: intDuration,
				transition: Fx.Transitions.Elastic.easeOut,
				onComplete: function(el){
					if(el.get('style').contains('hidden')){
						el.setStyle('display', 'none');
					}else{
						el.removeProperty('style');
					}
				}
			}

			arrTr=elLeftNavigationTable.getElements("tr");
			arrTr.each(function(el, index){
				el.set('tween', objTweenProperties);
			});

		}
	}

 function leftNavigationSwapContainer(elContainer, intContainerNumber){

		var intContainerOpen=1;
		if(elLinkContainer2.getParent("tr").getNext().getStyle('display')!='none')intContainerOpen=2;
		if(elLinkContainer3.getParent("tr").getNext().getStyle('display')!='none')intContainerOpen=3;

		if(intContainerNumber==intContainerOpen)return;

		//alert('intContainerNumber:'+intContainerNumber+' - intContainerOpen:'+intContainerOpen)

		var elTr=elContainer.getParent("tr");
		var arrNextSiblings=elTr.getAllNext("tr.leftnavsect"+intContainerNumber);
		var arrOtherSectionTr=elLeftNavigationTable.getElements("tr.leftnavsect"+intContainerOpen);

		var objSequenceAccordion = new objSequentialFunctionExec();
		objSequenceAccordion.set('delay', intDuration);

		/*
		var objSequenceListUnhide = new objSequentialFunctionExec();
		objSequenceListUnhide.set('delay', intDuration);
		var objSequenceListHide = new objSequentialFunctionExec();
		objSequenceListHide.set('delay', intDuration);
		*/

		if(arrNextSiblings[0].get('style').contains('none')){
			//section is hidden - unhide current section and hide other section
			arrOtherSectionTr.each(function(el, index){
				objSequenceAccordion.add(function(){el.tween('opacity', 1, 0);})
			});

			arrNextSiblings.each(function(el, index){
				objSequenceAccordion.add(function(){el.tween('opacity', 0, 1);})
			});


		}else{
			arrNextSiblings.each(function(el, index){
				objSequenceAccordion.add(function(){el.tween('opacity', 1, 0);})
			});

			arrOtherSectionTr.each(function(el, index){
				objSequenceAccordion.add(function(){el.tween('opacity', 0, 1);})
			});
		}

		//objSequenceListHide.start();
		//objSequenceListUnhide.start();
		objSequenceAccordion.start();

	}

	return true;
}

/* Open new window */
function openNewWindow(url){
	window.open(url);
}



/* Calculate thie hierarchical position in the navigation array */
function linkLookup(){
	/*
	this function will find the correct number in the crsc array based on the url of the page
	*/
	var arrArguments=linkLookup.arguments;
	var intArguments=arrArguments.length;
	var arrTemp;

	if(retrieveQuerystringParameterValue(location.href, 'parentid')!='')return retrieveQuerystringParameterValue(location.href, 'parentid');

	var bolCheckNext=false, bolReturnValue=false;
	var strCurrentPath=document.location.pathname;
	if(intArguments>0)strCurrentPath=arrArguments[0];
	var strSearchString=document.location.search;
	var strTempId="";
	var strLeftNavPath;

	//rework the path so that it will match the string pattern in the site_structure.xml
	var re = new RegExp("(/|^\.asp|^\.html|^\.htm)$");
	if (strCurrentPath.match(re)) {
		//alert("Need to add the default document");
		strCurrentPath+="index.asp";
	}

	//build a string that will match the data in the array
	var strUniqueIdentifier=strCurrentPath;


	if(bolDebug)strLookupDebug="<b>Searching: strUniqueIdentifier="+strUniqueIdentifier+"</b><br/>";

	for(id in _page.leftNav){
		if($defined(_page.leftNav[id].link) && $defined(_page.leftNav[id].text)){

			strLeftNavPath=_page.leftNav[id].link;
			arrTemp=strLeftNavPath.split('?');
			if(arrTemp.length>0)strLeftNavPath=arrTemp[0]

			if(bolDebug)strLookupDebug+="-"+strLeftNavPath+"<br/>";

			if (strUniqueIdentifier == strLeftNavPath){
				strTempId=id;
				objPageAttributes.pagetitle=_page.leftNav[id].text;
				break;
			}
		}
	}

	return strTempId
}

/* Toolbar */
function pageFontEnlarge(){
	statsStorePageEvent({eventname: 'click', value1: 'font_enlarge'});
	_page.font_resize(1.2);
	if(bolStoreFontSizeInCookie){
		Cookie.write("fontsize", _page.articleCSSFontsizeCurrent);
	}
}
function pageFontReduce(){
	statsStorePageEvent({eventname: 'click', value1: 'font_reduce'});
	_page.font_resize(0.8);
	if(bolStoreFontSizeInCookie){
		Cookie.write("fontsize", _page.articleCSSFontsizeCurrent);
	}
}
function pagePrint(){
	statsStorePageEvent({eventname: 'click', value1: 'print_page'});
	_page.printVersionFar();
}
function pageSent(){
	statsStorePageEvent({eventname: 'click', value1: 'sent_page'});
	_page.email.delay(250);
}


/* STATISTICS */
function statsHitServer(strUrl){

}
function statsStorePageEvent(objArguments){

	var strEvent=($defined(objArguments.eventname))?objArguments.eventname:'';
	var strValue1=($defined(objArguments.value1))?objArguments.value1:'';
	var strValue2=($defined(objArguments.value2))?objArguments.value2:'';
	//alert(strValue1);

	if(strEvent=='' || strValue1=='')return;

	var objRequestParams={
		pageid: strPageIdSystem,
		eventname: strEvent,
		value1: strValue1,
		value2: strValue2,
		x: Math.random()
	};


	var objRequest = new Request.HTML({url: arrIdPage['statistics_add-event']}).get(objRequestParams);
}
function statsStorePageEventCssSelector(objArguments){

	var strEvent=($defined(objArguments.eventname))?objArguments.eventname:'';
	var elNode=($defined(objArguments.node))?objArguments.node:'';
	var strValue=($defined(objArguments.value))?objArguments.value:'';
	//alert('inn');
	if(elNode=='' || strEvent=='')return;

	var strCss=getCssSelector(elNode);
	statsStorePageEvent({eventname: strEvent, value1: strCss, value2: strValue});
}
function statsLinkSetEvent(elLink){
	//replaces the defailt action for a link with a statistics hit
	var strUrl=elLink.get('href');
	if(strUrl.contains('.asp')){
		elLink.addEvent('click', function(event){
			(new Event(event)).stop();
			//dumpLog(this.get('href'));
			navigateTo({el: this, url: this.get('href')})
		});
	}
	if(strUrl.contains('.zip') || strUrl.contains('.xls') || strUrl.contains('.pdf')){
		elLink.addEvent('click', function(event){
			(new Event(event)).stop();
			//dumpLog(this.get('href'));
			serveDownload(this.get('href'), elLink);
		});
	}	
}


/* LINKS AND DOWNLOADS */
function downloadFile(strUrl){
	//alert('in download file script '+strUrl);
	var strDownloadUrl="/tools/stream.asp?file=";
	var strFileName=strUrl.split('/').getLast();
	statsStorePageEvent({eventname: 'download', value1: strUrl, value2: strFileName})
	strDownloadUrl+=strUrl.split('?')[0];
	//location.href=strDownloadUrl;
}

function serveDownload(strUrl, strId){
	var strDownloadUrl=strUrl, strSelector;
	//on the https site the downloads need to be streamed to the client
	if(location.protocol=='https')strDownloadUrl="/tools/stream.asp?file="+strUrl;

	var strFileName=strUrl.split('/').getLast();
	if($type(strId)=='string'){
		strSelector=getCssSelector($(strId));
	}else{
		strSelector=getCssSelector(strId);
	}
	statsStorePageEvent({eventname: 'download', value1: strFileName, value2: strSelector});
	
	(function(){
		location.href=strDownloadUrl;
	}).delay(250);
}

function navigateTo(objArguments){
	var strSelector='', strText;
	var bolExecuteLocation=true;
	var strUrl=objArguments.url;
	var strId=($defined(objArguments.id))?objArguments.id:null;
	if(strId!=null){
		if(strId.contains('homepageanimation')){
			if(Browser.Engine.trident)strId+='_ie';
			objPageState.objClickedElement.selector='#'+strId;
			location.href=strUrl;
			return;
		}
	}

	var el=($defined(objArguments.el))?objArguments.el:$(strId);

	if($defined(el)){
		strSelector=getCssSelector(el);
		objPageState.objClickedElement.selector=strSelector
		strText=el.get('text');

		if(strText.contains('note (')){
			//attempt to locate the link in the page and fire the click event
			var strIdentifier=strText.replace(/^.*(\(.*\)).*$/, "$1");
			var arrLinks=objPageElements.elmaincolumn.getElements('a');
			arrLinks.each(function(elNested){
				if(elNested.get('text').contains(strIdentifier)){
					if(!elNested.get('href').contains('javascript')){
						elNested.fireEvent('click', elNested);
						bolExecuteLocation=false;
					}
				}
			})
		}
	};

	if(bolExecuteLocation){
		objPageAttributes.useonunload=false;

		//1) store the onuload event
		var strSelector=objPageState.objClickedElement.selector;
		var intVisible=objPageState.objScrollInfo.visiblecontentfactor;

		var objData={
			pageid: strPageIdSystem,
			eventname: 'onunload',
			value1: strSelector,
			value2: intVisible,
			x: Math.random()
		};

		var objRequest = new Request.HTML({
			method: 'get',
			url: arrIdPage['statistics_add-event'],
			data: objData,
			onComplete: function(responseTree, responseElements, responseHTML, responseJavaScript){
				//2) goto the requested url
				location.href=strUrl;
			}
		}).send();
	}
}


/* FAR SPECIAL FX - PROOFPOINT AND LIGHTBOX CONTENT */
function setupFinancialPopups(){

	var arrEl=[], arrLightboxContent=[], arrLightboxContentNotesOverview=[], arrLightboxContentAuditorsReport=[];
	var strType="regular";

	if(arguments.length>0){
		strType=arguments[0];
		switch(strType){
			case 'notes_overview':
				//the notes overview popup needs to be setup
				arrEl=objPageElements.elbody.getElements('.far-overview_number');
				break;
			case 'auditors_opinion':
				//auditors opinion button in the header
				arrEl=objPageElements.elbody.getElements('div.far-statements_header div.far-overlay');
				break;
		}
	}else{
		//regular inline popups (from the table or the notes landing page)
		var arrEl=objPageElements.elmaincolumn.getElements('.far-financial-statement .number');
		if(arrEl.length==0)arrEl=objPageElements.elmaincolumn.getElements('.far-single_number');
	}

	//check if we have the arrNotePopupData loaded
	if(typeof(arrNotePopupData)=='undefined'){
		var js = new Asset.javascript('/scripts/far_notes_data.js', {
			onload: setupFinancialPopups
		});
		return;
	}

	//1 - get lightbox content
	arrEl.each(function(el, index){
		//retrieves the url and title and returns this as an object
		var strId, strNoteUrl, strTag, strTitle, strTargetId, strLabel, strTargetTitle='';
		var strParentPageId, strPopupTitle
		var elSpan
		var objContent, objBody, objTitle;

		strLabel="";
		objPageState.objPageMask.type='regular';

		strTag=el.get('tag');
		//alert(strTag)
		switch(strType){
			case "notes_overview":
				//notes overview page and notes overview layer
				strNoteUrl=el.get('href');

				var strPageIdNote=linkLookup(strNoteUrl);
				strParentPageId=strPageIdNote.replace(/(\d+_\d+).*/,'$1');
				strPopupTitle="Notes to the "+_page.leftNav[strParentPageId].text;

				//retrieve the target page id
				for(strKey in arrNotePopupData){
					if($defined(arrNotePopupData[strKey].url)){
						if (arrNotePopupData[strKey].url==strNoteUrl){
							strTargetId=arrNotePopupData[strKey].id;
							strLabel=arrNotePopupData[strKey].label;
							strTargetTitle='Note '+strLabel+': '+arrNotePopupData[strKey].linkname
							break;
						}
					}
				}

				break;

			case "auditors_opinion":
				//auditors opinion
				var elLink=el.getParent().getElement('a');
				strNoteUrl=elLink.get('rel');
				strPopupTitle=elLink.get('text');
				if(strPopupTitle.contains('Assurance')){
					strNoteUrl='/pages/sustainability_report/assurance_report.asp';
				}
				if(strSectionType=="group_fin_statements")strNoteUrl='/pages/group_financial_statements/auditor_report.asp';

				//simulate the link mouseover events
				el.addEvent('mouseover', function(el){
					var elLink=this.getParent().getElement('a');
					elLink.setStyle('text-decoration', 'underline');
				});

				el.addEvent('mouseout', function(el){
					var elLink=this.getParent().getElement('a');
					elLink.setStyle('text-decoration', 'none');
				});

				break;
			default:
				//alert('using default');
				strId=el.get('id').split('-').getLast();
				strLabel=strId;
				var objNoteData=arrNotePopupData[strId];
				strNoteUrl=objNoteData.url;
				strTargetTitle='Note '+strLabel+': '+objNoteData.linkname;
				strParentPageId=strPageId.replace(/(\d+_\d+).*/,'$1');
				
				var strPopupTitle="US GAAP financial statements";
				if(strNoteUrl.contains('ifrs_financial_statements'))strPopupTitle="IFRS financial statements";
				if(strNoteUrl.contains('company_financial_statements'))strPopupTitle="Company financial statements";
				
				
				strPopupTitle="Notes to the "+strPopupTitle;
				
				
				//strPopupTitle="Notes to the "+_page.leftNav[strParentPageId].text;

		}


		var strUrl="/tools/retrieve_lightbox-content.asp?target="+encodeUrl(strNoteUrl)+"&label="+strLabel+"&color="+strColorGroupCurrent+"&type="+strType;
		objBody={content: strUrl, type: 'remote', notelabel: strLabel};

		strTitle=strPopupTitle;

		//determine title color (hard coded)
		var strColor="azure_base";
		if(strTitle.toLowerCase().contains('ifrs'))strColor="orange_base";
		if(strTitle.toLowerCase().contains('company'))strColor="purple_base";

		//var strColor=strColorGroupCurrent+'_base';

		var objSifrProperties={
			content: strTitle,
			src: strUrlHeaderNormalSwf,
			width: 500,
			height: 60,
			color: arrFarColors[strColor],
			fontsize: '24px',
			paddingtop: '-3px',
			thickness:1,
			sharpness:-80
		}
		strHtmlTitle=retrieveSifrElementHtml(objSifrProperties);
		objTitle={content: strHtmlTitle, type: 'html', label: strTargetTitle};

		var objLightboxContent={body: objBody, title: objTitle};

		//stick into array
		switch(strType){
			case "regular":
				arrLightboxContent.push(objLightboxContent);
				break;
			case "notes_overview":
				arrLightboxContentNotesOverview.push(objLightboxContent);
				break;
			case "auditors_opinion":
				arrLightboxContentAuditorsReport.push(objLightboxContent);
				break;
		}

	});


	//2 - apply click behavior
	arrEl.each(function(el, index) {

		el.addEvent('click', function(event){
			var strTitlePrevious, strTitleNext
			var objArguments;

			var strTag=el.get('tag');
			if(strTag=='a'){
				(new Event(event)).stop();
			}

			//store in statistics
			statsStorePageEventCssSelector({eventname: 'click', node: el, value: 'note_popup['+index+']'});

			//load the template for the lightbox
			objWidgetLightboxProperties.outerclick=true;
			objWidgetLightboxProperties.htmltemplate={content: strHtmlLightboxNotes, type: 'html'};
			objWidgetLightboxProperties.onloaded='lightboxJoesLoaded()';
			objWidgetLightboxProperties.elcontentwidth=700;
			objWidgetLightboxProperties.elcontentheight=380;

			switch(strType){
				case "regular":
					objPageState.objPageMask.type='regular';
					//the data for the lightbox
					widgetLightboxOpen({
						elsource: this,
						arrcontent: arrLightboxContent,
						start: index
					});
					break;
				case "notes_overview":
					objPageState.objPageMask.type='notes_overview';

					//the data for the lightbox
					widgetLightboxOpen({
						elsource: this,
						arrcontent: arrLightboxContentNotesOverview,
						start: index
					});

				case "auditors_opinion":
					objPageState.objPageMask.type='auditors_opinion';

					//the data for the lightbox
					widgetLightboxOpen({
						elsource: this,
						arrcontent: arrLightboxContentAuditorsReport,
						start: index
					});

					break;

			}



		})
		
		//check if we need to show a specific note "onload"
		if(index==arrEl.length-1 && strType=="regular"){
			if(document.location.search.indexOf('shownote')>0){
				var strNoteNr=retrieveQuerystringParameterValue(location.href, 'shownote');
				//find the associated element and fire the click event
				var el=objPageElements.elmaincolumn.getElement('a#far-single_number-'+strNoteNr);
				el.fireEvent('click', el);				
				
				//alert(strNoteNr);
			}
		}		
		
	});



}
function setupStatementsHeader(){
	/*
	Sets up the special header and the associated popup
	*/
	var elDivWrapper, elSpanNotes, elSpanAuditor, elLink, elPopup, elDivClose
	var intFadeDuration=300;


	elDivWrapper=objPageElements.elmaincolumn.getElement('div.far-statements_header');
	if($defined(elDivWrapper)){
		elSpanAuditor=elDivWrapper.getElement('span.far-statements_header_mark');
		elSpanNotes=elDivWrapper.getElement('span.far-statements_header_notes');
		elPopup=objPageElements.elbody.getElement('div.far-notesoverview');
		elPopup.set('tween', {duration: intFadeDuration});

		//accordion
		var intInitialActive=0;
		switch(strSectionType){
			case 'group_fin_statements':
				intInitialActive=0;
				break;
			case 'ifrs_fin_statements':
				intInitialActive=1;
				break;
			case 'company_fin_statements':
				intInitialActive=2;
				break;
		}
		var arrTogglers=elPopup.getElements('div.far-notesoverview_title');
		var arrElements=elPopup.getElements('div.far-notesoverview_links');
		var myAccordion = new Accordion(arrTogglers, arrElements, {
			display: false,
			alwaysHide: true,
			opacity: false,
			duration : 700,
			display: intInitialActive,
			onActive: function(eltoggler, eltarget){
				//elLi=eltoggler.getParent();
				eltoggler.addClass('open');
			},
			onBackground: function(eltoggler, eltarget){
				//elLi=eltoggler.getParent();
				eltoggler.removeClass('open');
			}
		});

		//link events
		setupFinancialPopups("notes_overview");

		//setup the events for the notes overview popup
		if($defined(elPopup)){
			//prepare the popup
			elPopup.set('opacity', 0);

			elDivClose=elPopup.getElement('div.close');
			elDivClose.addEvent('click', function(){
				//hide
				if(objPageState.objPopupNotesOverview.open){
					//ie fix to handle transparent png & opacity
					if(Browser.Engine.trident)elPopup.getElements('td.far-transparent').setStyle('visibility', 'hidden');
					elPopup.fade('out');
					objPageState.objPopupNotesOverview.open=false;
				}
			})
		}

		//setup auditors mark
		if($defined(elSpanAuditor)){
			elLink=elSpanAuditor.getElement('a');
			elLink.set('rel', elLink.get('href'));
			elLink.set('href', 'javascript:void(0);');
			elLink.addEvent('click', function(e){
				//(new Event(e)).stop();
				elSpanAuditor.fireEvent('click');
			})

			setupFinancialPopups("auditors_opinion");
		}

		if($defined(elSpanNotes)){
			elLink=elSpanNotes.getElement('a');
			elLink.addEvent('click', function(e){
				(new Event(e)).stop();
				elSpanNotes.fireEvent('click');
			})

			elSpanNotes.addEvent('click', function(event){

				if(objPageState.objPopupNotesOverview.open==false){
					var intPopupTop, intPopupLeft;
					var intPopupWidth=elPopup.getSize().x;
					var objPos=this.getPosition();
					intPopupTop=objPos.y+13;
					intPopupLeft=objPos.x-(intPopupWidth/2).round()-14;
					if(Browser.Engine.trident4)intPopupLeft=intPopupLeft+14;
					elPopup.setStyles({'left': intPopupLeft, 'top':intPopupTop});

					//ie fix to handle transparent png & opacity
					if(Browser.Engine.trident)elPopup.getElements('td.far-transparent').setStyle('visibility', 'hidden');

					elPopup.fade('in');

					(function(){
						objPageState.objPopupNotesOverview.open=true;
					}).delay(200);

					//ie fix to handle transparent png & opacity
					if(Browser.Engine.trident){
						(function(){
							elPopup.getElements('td.far-transparent').setStyle('visibility', 'visible');
						}).delay(intFadeDuration+50);
					}
				}

			})

		}

	}



}

//graph and keydata thumbnails and lightbox
function setupLightboxEvents(){
	var arrEl=[], arrLightboxContent=[]
	var elParent;
	var bolShowAsGallery=true;


	//find the snippets elements and stick into an array
	if($defined(objPageAttributes.use2008setup)){
		if(strPageIdSystem=="0")arrEl=objPageElements.elmaincolumn.getElements('div.far-homepage_perf_highl_item_link');
		if(arrEl.length==0)arrEl=objPageElements.elmaincolumn.getElements('div.far-graphthumbnail_item_link');
	}else{
		arrEl=objPageElements.elrightcolumn.getElements('ul.far-keydata-link')
	}



	//1) get the lightbox content
	arrEl.each(function(el, index) {
		var objLightboxContent=getLightboxContent(el, index)
		//stick into array
		arrLightboxContent.push(objLightboxContent);
	});


	//2) applying click behavior on the right column elements
	arrEl.each(function(el, index) {
		var objLightboxContent=arrLightboxContent[index];
		var strHtmlLightboxContent=objLightboxContent.body.content;

		//set the properties for the lightbox
		objWidgetLightboxProperties.outerclick=true;
		objWidgetLightboxProperties.onloaded='lightboxJoesLoaded()';
		objWidgetLightboxProperties.htmltemplate={content: strHtmlLightbox, type: 'html'}
		if(strPageIdSystem=="0"){
			objWidgetLightboxProperties.htmltemplate={content: strHtmlLightboxHome, type: 'html'}
		}

		if(strHtmlLightboxContent.length > 0){

			var elParent=el.getParents('div')[1];
			var elClick=elParent.getElement('div.far-w0')


			//dumpLog(convertHtmlForDisplay(getOuterHtml(elParent)));
			elClick.addEvent('click', function(){
				//alert('in click');
				//store in statistics
				statsStorePageEventCssSelector({eventname: 'click', node: el, value: 'graph_popup['+index+']'});

				widgetLightboxOpen({
					elsource: this,
					arrcontent: arrLightboxContent,
					start: index
				});

			});

			//simulate the link mouseover events
			elClick.addEvent('mouseover', function(el){
				var elLink=this.getParent().getElement('a');
				elLink.setStyle('text-decoration', 'underline');
			});

			elClick.addEvent('mouseout', function(el){
				var elLink=this.getParent().getElement('a');
				elLink.setStyle('text-decoration', 'none');
			});

			//reset the height of the element that contains the link <a> if it's over a specific amount of characters
			var elLink=elClick.getParent().getElement('a');
			var objSize=elLink.getSize();
			if(objSize.y > 30)elParent.getElement('div.far-w2').setStyle('height', objSize.y+5);

		}else{
			alert("no lightbox content can be found for "+el.get('html'));
		};
	})


	//helper function that will find the associated content of the right clolumn thumbnail in the main column
	function getLightboxContent(el, index){
		var elParentNode, elTargetNode;
		var elLightboxContent=null;
		var objBodyContent, objTitleContent;
		var strHtmlPopupContent='', strHtmlTitle;
		var strId = el.id;
		var strIdentifier=strId.replace(/popup-link-/,"");
		var intHeight=0;
		//alert(strIdentifier)

		var elLink=el.getElement('a');
		elLink.addEvent('click', function(event){
			event.preventDefault();
			//elParent=el.getParents('div')[2].fireEvent('click');
		})


		//1) get the lightbox title
		var strTitle=elLink.get('text');
		arrIdTitleSidebarGraphs.push([strIdentifier, strTitle])

		strTitle=objPageAttributes.pagetitle;

		//'convert' title to sifr-like element
		var objSifrProperties={
			content: strTitle,
			src: strUrlHeaderNormalSwf,
			width: 500,
			height: 40,
			color: arrFarColors['purple_base'],
			fontsize: '24px',
			paddingtop: '-3px',
			thickness:1,
			sharpness:-80
		}
		strHtmlTitle=retrieveSifrElementHtml(objSifrProperties);
		objTitleContent={content: strHtmlTitle, type: 'html', label: elLink.get('text')};


		//grab the html of the associated object (table or flash graph)
		var elContentWrapper=objPageElements.elmaincolumn.getElement('div.far-displayprint div.far-graph_container_'+strIdentifier)
		if($defined(elContentWrapper)){
			//flash or table object
			elTargetNode=elContentWrapper.getElement('div.far-graph_content');
			if(!$defined(elTargetNode))elTargetNode=elContentWrapper.getElement('div.far-table_content');
			strHtmlPopupContent=getOuterHtml(elTargetNode);

		}else{
			elContentWrapper=objPageElements.elmaincolumn.getElement('div.far-displayprint table#bigtable_'+strIdentifier)
			if($defined(elContentWrapper)){
				//table - the table may contain more than one element so we need to clone
				elParentNode=elContentWrapper.getParent('div.far-displayprint');
				elTargetNode=elContentWrapper.getElement('div.far-table_content');
				strHtmlPopupContent=getOuterHtml(elParentNode);
				intHeight=20;
			}else{
				//custom flash graph -> the id of the ul node does not match the number of the associated element in the content -> use wrapper div class instead
				//alert('3')
				elParentNode=el.getParent();
				var elDiv=elParentNode.getElement('div');
				var strClass=elDiv.get('class');
				strIdentifier=strClass.replace(/far-graph_container_/,"");
				elContentWrapper=objPageElements.elmaincolumn.getElement('div.far-displayprint div.far-graph_container_'+strIdentifier)
				if($defined(elContentWrapper)){
					elParentNode=elContentWrapper.getParent('div.far-displayprint');
					elTargetNode=elContentWrapper.getElement('div.far-graph_content');
					strHtmlPopupContent=getOuterHtml(elTargetNode);
				}else{
					alert("Cannot locate element with identifier "+strIdentifier);
				}

			}
		}

		//remove the script nodes from the lightbox content (safari will choke)
		strHtmlPopupContent=strHtmlPopupContent.stripScripts();

		objBodyContent={content: strHtmlPopupContent, type: 'html', height: intHeight};

		return {body: objBodyContent, title: objTitleContent}
	}

}

function setupProofpoints(){
	/*
	This function sets up the events and effects associated with proofpoints in the page
	*/

	var arrProofpoints=objPageElements.elmaincolumn.getElements('div.far-proofoint_wrapper');
	//alert(arrProofpoints.length);

	arrProofpoints.each(function(elDivWrapper, index){
		var elDivFullContentWrapper=elDivWrapper.getElement('div.far-proofpoint_content_wrapper');
		var elDivTitleWrapper=elDivFullContentWrapper.getElement('div.far-proofpoint_title');;
		var elDivContentWrapper=elDivFullContentWrapper.getElement('div.far-proofpoint_content');;
		var elDivContentLarge=elDivContentWrapper.getElement('div.far-proofpoint_content_large');
		var elDivContentSmall=elDivContentWrapper.getElement('div.far-proofpoint_content_small');
		var elDivImgMainWrapper=elDivWrapper.getElement('div.far-proofpoint_mainvisual');

		var elImgMainLarge=elDivImgMainWrapper.getElement('div.far-proofpoint_mainvisual_large img');
		var elImgMainSmall=elDivImgMainWrapper.getElement('div.far-proofpoint_mainvisual_small img');
		if(!$defined(elImgMainLarge)){
			var strHtml='<div class="far-proofpoint_mainvisual_small"><img src="/imgs/user/dummy/missing_proofpoint_main_small.jpg" alt="" width="558" height="125" /></div>';
			strHtml+='<div class="far-proofpoint_mainvisual_large"><img src="/imgs/user/dummy/missing_proofpoint_main_large.jpg" alt="" width="558" height="247" /></div>';
			elDivImgMainWrapper.set('html', strHtml);
			elImgMainLarge=elDivImgMainWrapper.getElement('div.far-proofpoint_mainvisual_large img');
			elImgMainSmall=elDivImgMainWrapper.getElement('div.far-proofpoint_mainvisual_small img');
		}

		//set the height of the initial div
		var objImgMainSmallSize=elImgMainSmall.getSize();
		var intHeight=125
		if($defined(objImgMainSmallSize) && $defined(objImgMainSmallSize.y)){
			if(objImgMainSmallSize.y >110)intHeight=objImgMainSmallSize.y;
		}
		elDivImgMainWrapper.setStyle('height', intHeight);

		var elDivShowProofpoint=elDivWrapper.getElement('div.far-proofpoint_plus');
		var elLinkShowProofpoint=elDivShowProofpoint.getElement('a');
		var elDivHideProofpoint=elDivWrapper.getElement('div.far-proofpoint_minus');
		var elLinkHideProofpoint=elDivHideProofpoint.getElement('a');


		//1) setup the condensed text in the small content layer (around 325 characters)
		var intMaxChars=325, intCharsPerLine=88;
		var arrSiblings=elDivContentLarge.getChildren();
		var intCharacterCount=0;
		var bolContinue=true;

		arrSiblings.each(function(elChild){
			var elClone=elChild.clone();

			var strText=elClone.get('text');
			var strTag=elClone.get('tag');
			var intLength=(strTag=='p')?strText.length:(intCharsPerLine*2);

			var strTextSmall='', strCharacter='';

			if(intLength > (intMaxChars-intCharacterCount) && bolContinue){
				bolContinue=false;
				strTextSmall=strText.substring(0, (intMaxChars-intCharacterCount));
				//find the next point or space
				for(x=(intMaxChars-intCharacterCount); x < strText.length; x++){
					strCharacter=strText.charAt(x);
					if(strCharacter==' ' || strCharacter=='.' || strCharacter==','){
						break;
					}else{
						strTextSmall+=strCharacter;
					}
				}

				//add the dots
				strTextSmall+='...';

				//insert the condensed text into the node
				elClone.set('text', strTextSmall);

				//inject the node into the small content div
				elDivContentSmall.grab(elClone);

			}else{

				//dump the cloned object into the layer and continue
				if(bolContinue){


					//use the character count to attempt to calculate the amount of characters that could fit into the small content layer
					//intCharacterCount=intCharacterCount+((intLength/intCharsPerLine).round()*intCharsPerLine);
					var intCeil=Math.ceil(intLength/intCharsPerLine);
					intCharacterCount+=intCeil*intCharsPerLine;

					if(intCharacterCount>intMaxChars && (arrSiblings.length-1)>index){
						elClone.appendText(' ...');
						elDivContentSmall.grab(elClone);
						bolContinue=false;
					}else{
						elDivContentSmall.grab(elClone);
					}
					//dumpLog(intCharacterCount+' - '+index+' - '+arrSiblings.length);

				}
			}

		})

		//show small layer and hide big layer
		elDivContentSmall.set('style', 'visibility:visible');
		elDivContentLarge.set('style', 'visibility:hidden');

		//2) setup the effects for the different elements
		elDivFullContentWrapper.set('tween',{
			duration: 800,
			transition: Fx.Transitions.Cubic.easeInOut,
			link: 'chain'
		});
		elDivImgMainWrapper.set('tween',{
			duration: 800,
			transition: Fx.Transitions.Cubic.easeInOut,
			link: 'chain'
		});
		elImgMainLarge.set('tween',{
			duration: 800,
			transition: Fx.Transitions.Cubic.easeInOut,
			link: 'chain'
		});
		elImgMainSmall.set('tween',{
			duration: 800,
			transition: Fx.Transitions.Cubic.easeInOut,
			link: 'chain'
		});

		var intHeightOriginalContent=elDivFullContentWrapper.getCoordinates().height-12;
		var intHeightOriginalImage=intHeight;

		//2) apply events to the show and hide proofpont links
		elLinkShowProofpoint.addEvent('click', function(event){
			event.preventDefault();
			//calculate the new height for the content wrapper
			var intHeight=elDivContentLarge.getCoordinates().height+elDivTitleWrapper.getCoordinates().height;

			//add 20 pixels per quote
			var arrQuotes=elDivContentLarge.getElements('div.far-quote_wrapper');
			if($type(arrQuotes)=='array'){
				intHeight+=arrQuotes.length*20;
			}

			//a) animate the content
			elDivContentLarge.setStyle.delay(400, elDivContentLarge, ['visibility', 'visible']);
			elDivContentSmall.setStyle.delay(400, elDivContentSmall, ['visibility', 'hidden']);
			elDivFullContentWrapper.tween.delay(400, elDivFullContentWrapper, ['height', intHeight]);

			//b) animate the images
			elImgMainLarge.set('opacity', 0);
			intHeight=elImgMainLarge.getCoordinates().height;
			elImgMainSmall.tween('opacity', 0);
			elDivImgMainWrapper.tween.delay(400, elDivImgMainWrapper, ['height', intHeight]);
			elImgMainLarge.tween.delay(400, elImgMainLarge, ['opacity', 1]);

			//c) swap show - hide controls
			elDivShowProofpoint.setStyle('display', 'none');
			elDivHideProofpoint.setStyle.delay(1200, elDivHideProofpoint, ['display', 'block']);

		})

		elLinkHideProofpoint.addEvent('click', function(event){
			event.preventDefault();

			//a) animate the content
			elDivContentLarge.setStyle.delay(800, elDivContentLarge, ['visibility', 'hidden']);
			elDivContentSmall.setStyle.delay(790, elDivContentSmall, ['visibility', 'visible']);
			elDivFullContentWrapper.tween.delay(1, elDivFullContentWrapper, ['height', intHeightOriginalContent]);

			//b) animate the images
			elImgMainLarge.tween('opacity', 0);
			elDivImgMainWrapper.tween.delay(1, elDivImgMainWrapper, ['height', intHeightOriginalImage]);
			elImgMainSmall.tween.delay(400, elImgMainSmall, ['opacity', 1]);

			//c) swap show - hide controls
			elDivShowProofpoint.setStyle.delay(1200, elDivShowProofpoint, ['display', 'block']);
			elDivHideProofpoint.setStyle('display', 'none');

		})

	});

}
function showLighboxVideoPlayer(strId){
	//alert(' in showLighboxVideoPlayer('+strId+')');
	var arrLightboxContent=[];

	//1) find the flash dom object
	var elClicked=objPageElements.elmaincolumn.getElement('div.far-video_'+strId)
	if(!$defined(elClicked))elClicked=null;

	//2) load the template
	objWidgetLightboxProperties.outerclick=true;
	objWidgetLightboxProperties.onloaded='lightboxVideoLoaded()';
	objWidgetLightboxProperties.htmltemplate={content: strHtmlLightboxVideo, type: 'html'}

	//3) the data required for the video player
	var objContent={
		body: {content: '<div style="width: 735px; height: 366px"></div>', type: 'html', videoid: strId},
		title: {content: 'titel1', type: 'html', label: 'title1'}
	};
	arrLightboxContent.push(objContent);

	//4) launch the player
	widgetLightboxOpen({
		elsource: elClicked,
		arrcontent: arrLightboxContent,
		start: 0
	});
}
/* WEB SURVEY */
function launchWebSurvey(el, strId){

	//alert(' in showLighboxVideoPlayer('+strId+')');
	var arrLightboxContent=[];

	//1) find the flash dom object
	var elClicked=null;

	if($type(el)=='element'){
		elClicked=el;
	}else{
		elClicked=objPageElements.elmaincolumn.getElement('div.far-video_'+el);
		if(!$defined(elClicked))objPageElements.elmaincolumn.getElement(el);
	}
	if(!$defined(elClicked))elClicked=null;
	elClicked=null;

	//2) load the template
	objWidgetLightboxProperties.outerclick=false;
	objWidgetLightboxProperties.onloaded='lightboxSurveyLoaded()';
	objWidgetLightboxProperties.htmltemplate={content: strHtmlLightboxWebform, type: 'html'}

	//3) the data required for the web survey
	var strTitle="Web survey";
	var objSifrProperties={
		content: strTitle,
		src: strUrlHeaderNormalSwf,
		width: 500,
		height: 40,
		color: arrFarColors['purple_base'],
		fontsize: '24px',
		paddingtop: '-3px',
		thickness:1,
		sharpness:-80
	}
	var strHtmlTitle=retrieveSifrElementHtml(objSifrProperties);
	var objTitle={content: strHtmlTitle, type: 'html', label: strTitle};
	var objContent={content: '/tools/survey_form.html', type: 'remote', surveyid: strId}
	//objContent={content: strSurveyForm, type: 'html', surveyid: strId}

	var objLbContent={
		body: objContent,
		title: objTitle
	};

	arrLightboxContent.push(objLbContent);

	//4) launch the player
	widgetLightboxOpen({
		elsource: elClicked,
		arrcontent: arrLightboxContent,
		start: 0
	});

}

function websurveyHandleFieldChange1(elFormField){
	var strValue=getFormFieldValue(elFormField);
	var elTarget=document.getElementById('email1');

	if(strValue=='other'){
		//elTarget.style.display="block";
	}else{
		//elTarget.style.display='none';
	}
}

function websurveyHandleFieldChange2(elFormField){
	var strValue=elFormField.value;
	var elTarget=document.getElementById('email2');

	if(strValue=='yes'){
		elTarget.style.display="block";
	}else{
		elTarget.style.display='none';
	}
}


function websurveySubmit(strFormId){
	var elForm=$(strFormId);
	var elMask=elForm.getElement('div.far-form_mask');
	var objSize=elForm.getSize();
	elMask.setStyles({
		'visibility':'hidden',
		'position':'absolute',
		'height':objSize.y,
		'width':objSize.x
	})
	var strUrl=elForm.get('action');

	var xhrForm=new Request.HTML({
		url:strUrl,
		onRequest: function(){
			// Show loading div.
			//fx.loading.start( 0,1 );
			elMask.tween('opacity', [0, 1]);
		},
		onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
			// Hide loading and show success for 3 seconds.
			//alert(responseHTML);
			if(responseHTML=="false"){
				alert("no rows inserted");
			}

			//set the cookie
			var hashSurvey=new Hash.Cookie('survey', {duration: 3600, path: '/'});
			hashSurvey.set('id', strFormId);

			//hide the button
			if(strFormId=='far_survey'){
				if($defined(objPageElements.elmaincolumn.getElement('div.far-orderform_tankyou_wrapper'))){
					objPageElements.elmaincolumn.getElement('div.far-orderform_tankyou_wrapper').setStyle('visibility', 'hidden');
				}else{
					objPageElements.elbody.getElement('div.far-survey_top_wrapper').setStyle('visibility', 'hidden');
				}
			};

			//end effect
			(function(){
				elMask.tween('opacity', [1, 0]);
			}).delay(400);

			//close the mask
			(function(){
				widgetLightboxClose();
			}).delay(1000);
		}
	}).post(elForm);

}

function websurveyClearCookie(){
	var hashSurvey=new Hash.Cookie('survey', {duration: 3600, path: '/'});
	hashSurvey.empty();

}

/* JOES LIGHTBOX FUNCTIONS */
function lightboxJoesOpen(){
	objPageState.objPageMask.bolMaskOpen=true;


}
function lightboxJoesClose(){
	objPageState.objPageMask.bolMaskOpen=false;
}
function lightboxJoesLoaded(){
	var elDivLbContent=objWidgetLightboxProperties.elcontent;

	if(objPageState.objPageMask.type=='auditors_opinion'){
		//hide the download manager add button
		var elLi=objPageElements.elbody.getElement('table.far-lightbox_wrapper ul li.far-download').setStyle('visibility', 'hidden');
	}

	if(strSectionType.contains('statements')){
		//set the title in the footer
		var elFooter=objPageElements.elbody.getElement('td.far-notes_lightbox_footer');

		if(objPageState.objPageMask.type=='auditors_opinion'){
			//disclaimer
			elFooter.setStyle('text-align', 'left')
			elFooter.getElement('div.link').setStyle('display', 'none')
			elFooter.getElement('div.disclaimer').setStyle('display', 'inline');


		}else{
			//var strParentPageId=strPageId.replace(/(\d+_\d+).*/,'$1');
			//var strParentPageLinkName=_page.leftNav[strParentPageId].text;

			elFooter.setStyle('text-align', 'center')
			elFooter.getElement('div.link').setStyle('display', 'none')
			elFooter.getElement('div.disclaimer').setStyle('display', 'none');
		};

		(function(){
			//deal with the correct setup of the downloadmanager icons
			var	hashDownloadManagerPages=new Hash.Cookie('downloadmanager', {duration: 3600, path: '/'});

			var objCurrentLightboxData=objWidgetLightboxProperties.arrcontent[objWidgetLightboxProperties.index];
			var strNoteNumber=objCurrentLightboxData.body.notelabel;
			//alert(objCurrentLightboxData.body.notelabel);

			//alert(hashDownloadManagerPages.toQueryString());
			if(strNoteNumber!=''){

				var strNotePageId='';
				if($defined(arrNotePopupData[strNoteNumber]))strNotePageId=arrNotePopupData[strNoteNumber].id;
				//store the current page id in the global object so that we can re-use
				objPageState.objPageMask.target=strNotePageId;
				if(strNotePageId!=''){
					//alert(strNotePageId);
					if(hashDownloadManagerPages.has(strNotePageId)){
						//this item is in the download manager basket
						var elLi=objPageElements.elbody.getElement('table.far-lightbox_wrapper ul li.far-download');
						if($defined(elLi)){
							elLi.addClass('selected');
							elSpan=elLi.getElement('span.far-add');
							if($defined(elSpan))elSpan.setStyle('display', 'none');
							elSpan=elLi.getElement('span.far-remove');
							if($defined(elSpan))elSpan.setStyle('display', 'inline');
						}
					}else{
						var elLi=objPageElements.elbody.getElement('table.far-lightbox_wrapper ul li.far-download');
						if($defined(elLi)){
							elLi.removeClass('selected');
							elSpan=elLi.getElement('span.far-add');
							if($defined(elSpan))elSpan.setStyle('display', 'inline');
							elSpan=elLi.getElement('span.far-remove');
							if($defined(elSpan))elSpan.setStyle('display', 'none');
						}
					};
				}
			}
		}).delay(10);

		//make the internal links to the notes work by firefing the click events from the note overview layer
		var arrEl=elDivLbContent.getElements('a')
		arrEl.each(function(el){

			el.addEvent('click', function(event){
				event.preventDefault();

				var strUrl=el.get('href');
				var strText=el.get('text');

				if(strText.contains('note (')){
					//attempt to locate the link in the page and fire the click event
					var strText=el.get('text');
					var bolFound=false;
					var strIdentifier=strText.replace(/^.*\((.*)\).*$/, "$1");

					var arrLinks=objPageElements.elbody.getElements('div.far-notesoverview td.far-popup_shadow_content li');
					arrLinks.each(function(elNested){

						if(elNested.get('class').contains('-')){
							var strNoteNumber=elNested.get('class').split('-')[1];

							if(strNoteNumber==strIdentifier){
								//now fire the event attached to the <a> node
								elNested.getFirst().fireEvent('click', elNested);
								bolFound=true;
							}
						}
					})
					if(!bolFound)location.href=strUrl;
				}else{
					location.href=strUrl;
				}
			})
		});



	};

	if(strPageIdSystem=='1153703'){
		//financial highlights page
		var arrEl=elDivLbContent.getElements('table.far-table-note td');
		arrEl.each(function(el, index){
			//alert(el.get('text'));
			if(el.get('text').toLowerCase().contains('results were 59%')){
				var elTarget=el.getParent().getElement('td');
				elTarget.dispose();
			}
		})


	}


}
function lightboxVideoLoaded(){
	var strVideoId=objWidgetLightboxProperties.arrcontent[0].body.videoid;

	var objFlashParams={
		src: '/imgs/user/swf/StandalonePlayer.swf',
		width: 735,
		height: 366,
		version: 9,
		id: 'arplayer',
		params: {bgcolor:'', FlashVars:'dataFile=/imgs/user/swf/annualreport2008.xml&quoteId='+strVideoId, allowScriptAccess: 'sameDomain'},
		align: 'middle',
		scale: 'noscale'
	}
	var strHtml=createFlashHtml(objFlashParams);

	objWidgetLightboxProperties.elcontent.set('html', strHtml);

}
function lightboxSurveyLoaded(){
	//stick the page id in the form
	document.getElementById('page_id').value=strPageIdSystem;
}

/* LEADERSHIP PAGES */
function setupBoardOfManagement(){
	var bolSetLinks=false;
	var arrEl=objPageElements.elmaincolumn.getElements('table.far-leadership table.p-secondaryfeature');
	arrEl.each(function(el, index){
		if(index==0){
			if(el.getElement('h2').get('text').contains('Gerard'))bolSetLinks=true;
		}

		var arrLinks=el.getElements('a');
		if(bolSetLinks){
			arrLinks.set('href', arrBomLinks[index]);
		}else{
			arrLinks.setStyle('cursor', 'default');
			arrLinks.removeProperty('href');
			arrLinks.each(function(elLink, index){
				//elLink.preventDefault();
			})

		}

	})

	arrEl=objPageElements.elmaincolumn.getElements('table.p-paragraph td');
	arrEl.each(function(el, index){
		//alert(el.get('html'));
		if(index==1){
			var strHtmlNew='<h3>Corporate Governance</h3><a name="section1"/><p>A full description of the Company\'s corporate governance structure is published in the chapter <a href="/pages/corporate_governance/corporate_governance_of_the_philips_group.asp">Corporate governance</a>.</p>';
			el.set('html', strHtmlNew);
		}

	});
}
function setupSupervisoryBoardNoteLinks(){
	/*
	Generates links from the asterixes to the descriptions
	*/
	var arrNodes=$$('h3');
	arrNodes.each(function(el){
		//alert(el.get('text'));
		var strNodeText=el.get('text');
		if(strNodeText.indexOf("*")>0){
			var strDivText="";

			if(strNodeText.indexOf("** ***")>0)strDivText="** ***";
			if(strDivText==""){
				if(strNodeText.indexOf("* ***")>0)strDivText="* ***";
			}
			if(strDivText==""){
				if(strNodeText.indexOf("* **")>0)strDivText="* **";
			}
			if(strDivText==""){
				if(strNodeText.indexOf("***")>0)strDivText="***";
			}
			if(strDivText==""){
				if(strNodeText.indexOf("**")>0)strDivText="**";
			}
			if(strDivText==""){
				if(strNodeText.indexOf("*")>0)strDivText="*";
			}

			var arrTemp=strNodeText.split("*");
			strNodeText=arrTemp[0];

			//set the text
			el.set('text', strNodeText);

			//create the div element
			var elSpan=new Element('span', {
				'styles': {
					'cursor': 'pointer',
					'padding-left': '7px'
				},
				'events': {
					'click': function(){
						scrollTo(0,10000000);
					}
				}
			});

			elSpan.set('text', strDivText);

			elSpan.injectInside(el);

		}

	});

	//fix a paragraph position
	var arrTable=objPageElements.elmaincolumn.getElements('table.p-paragraph');
	arrTable[1].inject(arrTable[0], 'after');
	var elTd=arrTable[1].getElement('td');
	var strHtml=elTd.get('text')
	strHtml=strHtml.replace(/the chapter Supervisory Board report of this Annual Report/, '<a href="/pages/supervisory_board_report.asp">Supervisory Board report</a>')
	elTd.set('html', strHtml);

	//typo in the bottom section
	elTd=arrTable[arrTable.length-1].getElement('td');
	strHtml=elTd.get('html').replace(/ncee/, 'nce');
	elTd.set('html', strHtml);

}


/* USE THIS LOGIC FOR THE "tooltips" */
var intAuditorsMarkTimerId;

function auditorsMarkPopupShow(){
	var objButton=$('far-auditors-mark-logo');
	var objPopup=$('far-auditors-mark-popup');

	objPopup.removeEvents('mouseleave')
	objPopup.removeEvents('mouseenter')
	objButton.removeEvents('mouseleave')

	objPopup.setStyle("display", "inline");
	bolPopupOpen=true;

	//calculate the position of the popup
	var objButtonPosition=objButton.getPosition();
	var intTop=objButtonPosition.y+27;
	var intLeft=objButtonPosition.x-10;
	objPopup.setStyles({
	   left: intLeft,
	   top: intTop
	});

	objPopup.addEvent('mouseleave', auditorsMarkPopupClose);
	objPopup.addEvent('mouseenter', function(){
		if($defined(intAuditorsMarkTimerId)){
			$clear(intAuditorsMarkTimerId);
		}
	});
	objButton.addEvent('mouseleave', function(){
		intAuditorsMarkTimerId=auditorsMarkPopupClose.delay(500)
	});
}


function auditorsMarkPopupClose(){
	$('far-auditors-mark-popup').setStyle("display", "none");
}


/* SEARCH */
function setupSearchForm(){
	//setup the autocomplete function for the search form
	var strLinkName;
	var arrTemp;
	var elInput=objPageElements.elsearchform.getElement('input#searchKey');

	//array with elements for the autocomplete search - based on the glossary and the left navigation items
	var arrSearchTokens=$A(arrDefinitions);
	//add left menu items
	for(id in _page.leftNav){
		if($defined(_page.leftNav[id].link) && $defined(_page.leftNav[id].text)){
			//dumpLog(_page.leftNav[id].text);
			strLinkName=_page.leftNav[id].text;
			//a) add the linkname itself
			arrSearchTokens.include(strLinkName);

			//b) optionally - add part of the linkname (to allow searching in the 'middle' of the string.
			arrTemp=strLinkName.split(" ");
			arrTemp.each(function(strWord){
				if(strWord.length>3){
					strWord=strWord.toLowerCase().capitalize();
					if(strWord!="Home")arrSearchTokens.include(strWord);
				}
			});
		}
	}

	//attach the autocomplete function to the search input form
	new Autocompleter.Local(elInput, arrSearchTokens, {
		'minLength': 1,
		'selectMode': 'pick',
		'multiple': false,
		'autoSubmit': true,
		'width': 235,
		onSelection: function(){
			//submit the search form
			//processSearchForm.delay(200);
			//alert('hello');
		}
	});

	return true;
}

function processSearchForm(){
	if (document.finderForm.searchKey.value == null || document.finderForm.searchKey.value == "" || document.finderForm.searchKey.value == "Enter name or keyword"){
		alert ("Please enter name or keyword.");
	}else{
		//fill the values from this form in the search form and submit this form
		document.searchForm.q.value=document.finderForm.searchKey.value;

		statsStorePageEvent({eventname: 'search', value1: document.searchForm.q.value});

		(function(){document.searchForm.submit();}).delay(400);

	}
	return false;
}

function setFieldValue(fieldRef, str) {
	// clears field when user clicks in,
	// and resets to default str when user clicks out
	// with no value in the field.
	obj = eval(fieldRef);
	if (obj.value == str) {
		obj.value = "";
	}
	else if (obj.value == "") {
		obj.value = str;
	}
}

function searchExecute(){
	//executes the search by performing an ajax request to a .NET module
	var arrFormData=new Array();
	var strHtml, strUrl="/tools/search_results.aspx";
	var strQueryString=Right(location.search, location.search.length-1);
	strQueryString=strQueryString.replace(/chapter/,"c");
	arrFormData['strQueryString']=strQueryString;

	strHtml=serverSideRequest({url: strUrl, callback: 'searchDisplayResults()', arrdata: arrFormData, method: 'post'});
}

function submitCorrected(strQuery){
	strUrl=replaceQuerystringParameter(location.href, "q", strQuery);
	location.replace(strUrl);
}

function searchDisplayResults(strHtml){
	//alert(strHtml)
	MM_setTextOfLayer('div_search_result','',strHtml);
}



/* VISIBLE CONTENT */
function calculateVisibleContentFactor(){

	if($defined(objPageElements.elcontent)){
		var intWindowHeight=window.getHeight();
		var intWindowScrollY=window.getScroll().y;

		var objContentCoordinates=objPageElements.elcontent.getCoordinates();
		var intContentTop=objContentCoordinates.top-intWindowScrollY;
		var intContentHeight=objContentCoordinates.height;


		var intContentVisible=intWindowHeight-intContentTop;
		var intContentVisibleFactor=(intContentVisible/intContentHeight).round(2);
		if(intContentVisibleFactor>1)intContentVisibleFactor=1;

		if(intContentVisibleFactor>objPageState.objScrollInfo.visiblecontentfactor)objPageState.objScrollInfo.visiblecontentfactor=intContentVisibleFactor;
	}

}

/* DEBUGGING */
function dumpLog(strText){

	if(bolUseDebugLayer){
		var currentTime = new Date()
	  var hours = currentTime.getHours()
	  var minutes = currentTime.getMinutes()
	  var seconds=currentTime.getSeconds()

	  if (minutes < 10)minutes = "0" + minutes
	  if (seconds < 10)seconds = "0" + seconds

	  strText=hours + ":" + minutes + ":"+seconds+" - "+strText;

	  var elDebugLayer=$('debug_layer');

	  if($defined(elDebugLayer)){
	  	if(intDebugCounter==0)elDebugLayer.style.visibility='visible';

		  elDebugLayer.innerHTML=elDebugLayer.innerHTML+"<br/>"+strText;
			elDebugLayer.scrollTop = elDebugLayer.scrollHeight;


		  if(intDebugCounter==0){
		  	var elDebugLayerHandle=$('debug_layer_handle')
		  	var objOptions={
					handle: elDebugLayerHandle
				}
		  	//alert(elDebugLayerHandle)
			  elDebugLayer.makeDraggable();
			}

			intDebugCounter++;
		}

	}
}

/* IN PAGE DOWNLOAD MANAGER */
function downloadManagerAdd(){
	//use a cookie to store the data
	var strStart, strEnd, strHashValue
	var hashDownloadManagerPages, strIdTarget, elLi;

	strStart=objPageElements.elbody.getElement('div.far-systemlayers div.far-page_numbers div.far-start').get('text');
	strEnd=objPageElements.elbody.getElement('div.far-systemlayers div.far-page_numbers div.far-end').get('text');
	strHashValue=strStart+'-'+strEnd;
	//alert(strStart+' - '+strEnd);
	//return;

	if(arguments.length==1){
		strIdTarget=objPageState.objPageMask.target;
		//alert(strIdTarget);
		elLi=objPageElements.elbody.getElement('table.far-lightbox_wrapper ul li.far-download');
	}else{
		strIdTarget=strPageIdSystem;
		elLi=objPageElements.elpagetools.getElement('li.far-download');
	}

	if($type(strIdTarget)=='string'){
		if(strIdTarget.length>0){
			hashDownloadManagerPages=new Hash.Cookie('downloadmanager', {duration: 3600, path: '/'});
			if(!hashDownloadManagerPages.has(strIdTarget)){
				hashDownloadManagerPages.set(strIdTarget, strHashValue);
			}
			//alert(hashDownloadManagerPages.toQueryString())

			//change the icon
			elLi.addClass('busy');

			statsStorePageEvent({eventname: 'download_add', value1: strPageIdSystem, value2: getCssSelector(elLi.getFirst())});

			//change it back
			(function(){
				elLi.getElement('.far-add').setStyle('display','none');
				elLi.getElement('.far-remove').setStyle('display','inline');
				elLi.removeClass('busy')
			}).delay(1000);
			//and then make it selected
			(function(){
				elLi.addClass('selected')
			}).delay(950);
		}
	}
}

function downloadManagerRemove(){
	var strStart, strEnd, strHashValue, strKey
	var hashDownloadManagerPages, strIdTarget, elLi;

	strStart=objPageElements.elbody.getElement('div.far-systemlayers div.far-page_numbers div.far-start').get('text');
	strEnd=objPageElements.elbody.getElement('div.far-systemlayers div.far-page_numbers div.far-end').get('text');
	strHashValue=strStart+'-'+strEnd;

	if(arguments.length==1){
		strIdTarget=objPageState.objPageMask.target;
		elLi=objPageElements.elbody.getElement('table.far-lightbox_wrapper ul li.far-download');
	}else{
		strIdTarget=strPageIdSystem;
		elLi=objPageElements.elpagetools.getElement('li.far-download');
	}


	hashDownloadManagerPages= new Hash.Cookie('downloadmanager', {duration: 3600, path: '/'});
	if(hashDownloadManagerPages.hasValue(strHashValue)){
		strKey=hashDownloadManagerPages.keyOf(strHashValue);
		hashDownloadManagerPages.erase(strKey);
	}
	//alert(JSON.encode(hashDownloadManagerPages))


	//change the icon
	elLi.addClass('busy');
	elLi.removeClass('selected');

	statsStorePageEvent({eventname: 'download_remove', value1: strPageIdSystem, value2: getCssSelector(elLi.getFirst())});

	//change it back
	(function(){
		elLi.getElement('.far-remove').setStyle('display','none');
		elLi.getElement('.far-add').setStyle('display','inline');
		elLi.removeClass('busy')
	}).delay(1000);

}

/* PRINT SCRIPTS */
function printLightboxGraph(){
	alert('still to be implemented');
}

_page.printVersionFar = function(print_type) {
	var printarea = document.getElementById("p-printarea");
	if (printarea == null) {
		alert("no print area defined");
		return;
	}

	/*
	FAR UNIQUE
	*/



	var printarea = document.getElementById("p-printarea");
	var strPageContent=printarea.innerHTML;
	//openDebugWindow(strPageContent);
	var strPageContentNew='', strPageFlashJavascriptParams;
	var strOnLoadScript='setTimeout(\'printThisPage()\', 2000);';
	strOnLoadScript='';

	//loop through the main column and copy what we need to copy
	var arrElements=objPageElements.elmaincolumn.getElement('td#p-center').getChildren();
	var strHtmlFooter=objPageElements.elbody.getElement('td.far-disclaimer').get('text');

	var strHtml='';


	arrElements.each(function(el, index){
		var strHtmlElement, strHtmlNewElement, strJs, strClass;
		var bolDefault, bolContinue;

		bolContinue=true;
		strClass=el.get('class');
		if(strClass=='far-pagenavigator_wrapper')bolContinue=false;
		if(strClass=='far-pagenavigator_wrapper_bottom')bolContinue=false;
		if(strClass=='far-anchorlist_wrapper')bolContinue=false;
		if(strClass=='far-finhigh_grid')bolContinue=false;

		if(bolContinue){
			bolDefault=true;

			//gillsans page header
			if(el.get('class')=='far-pagetitle_wrapper'){
				bolDefault=false;

				var strCss='color:#000000;'
				var objArguments={
					src: strUrlHeaderNormalSwf,
					paddingtop: '-5px',
					css: strCss,
					width: 560,
					height: 36
				}

				var objSifrObject=generateSifrFlashArgumentObject(objArguments);
				//debugObject({obj: objSifrObject});
				objSifrObject.content=_page.leftNav[strPageId].text;
				objSifrObject.fontsize=30;
				var strHtmlSifr=retrieveSifrElementHtml(objSifrObject);
				//alert(strHtmlSifr)
				strHtmlElement='<div class="far-pagetitle_wrapper"><h1>'+strHtmlSifr+'</h1></div>'

			}

			//kpi's
			if(index==0){
				var arrKpi=objPageElements.elbody.getElements('div.far-kpi_flash_wrapper');
				if(arrKpi.length>0){

					var elNodeScript;
					var strHtmlContent='';
					var intMod=-1;
					var strTr="<tr><td>{cell1}</td><td>{cell2}</td><td>{cell3}</td></tr>";

					var objTrContent={cell1: '', cell2: '', cell3: ''};
					var strHtmlKpi='<table class="far-print_kpi" cellpadding="0" cellspacing="0" width="100%">';

					arrKpi.each(function(el, index){
							//alert(index%3);
							intMod=index%3;

							if(index%3==0)objTrContent={cell1: '', cell2: '', cell3: ''};


							if(index%3==0){
								if(Browser.Engine.trident){
									elNodeScript=el.getParent('div.far-kpi_wrapper').getElements('script')[index];
									strJs=elNodeScript.get('html').clean();
									strJs=strJs.substring(0,strJs.length-3)+", returnhtml: true})";
									objTrContent.cell1=eval(strJs)
								}else{
									objTrContent.cell1=el.get('html');
								}

							}
							if(index%3==1){

								if(Browser.Engine.trident){
									elNodeScript=el.getParent('div.far-kpi_wrapper').getElements('script')[index];
									strJs=elNodeScript.get('html').clean();
									strJs=strJs.substring(0,strJs.length-3)+", returnhtml: true})";
									objTrContent.cell2=eval(strJs)
								}else{
									objTrContent.cell2=el.get('html');
								}

							}
							if(index%3==2){
								if(Browser.Engine.trident){
									elNodeScript=el.getParent('div.far-kpi_wrapper').getElements('script')[index];
									strJs=elNodeScript.get('html').clean();
									strJs=strJs.substring(0,strJs.length-3)+", returnhtml: true})";
									objTrContent.cell3=eval(strJs)
								}else{
									objTrContent.cell3=el.get('html');
								}
							}

							if(index%3==2){
								strHtmlContent+=strTr.substitute(objTrContent);
							};

					});


					if(intMod%3!=2){
						strHtmlContent+=strTr.substitute(objTrContent)
					}

					strHtmlKpi+=strHtmlContent+'</table>';
					strHtmlElement+=strHtmlKpi;
				}
			}


			//rework on the proofpoints
			if(strClass=='far-proofoint_wrapper'){
				el=el.clone();

				//alert(getOuterHtml(el).getFirst());

				el.getElement('div.far-proofpoint_mainvisual').erase('style');
				el.getElement('div.far-proofpoint_mainvisual_large').destroy();
				el.getElement('div.far-proofpoint_content_small').destroy();
				el.getElement('div.far-proofpoint_content_large').setStyle('visibility', 'visible');
				el.getElement('div.far-proofpoint_bottom').setStyle('visibility', 'hidden');
			}



			if(bolDefault){
				if(Browser.Engine.trident){
					var bolDefaultNested=true;

					//inpage quote
					if(el.get('class')=='far-quote_wrapper'){
						bolDefaultNested=false;
						//get the javascript
						strJs=el.getFirst().get('html').clean();
						strJs=strJs.substring(0,strJs.length-2)+", returnhtml: true})";
						strHtmlElement=eval(strJs)
						//alert(strJs+' - '+strHtmlElement);
					}

					//a highlightbox
					if(el.get('class')=='far-highlight_wrapper'){
						bolDefaultNested=false;

						strHtmlElement='<div class="far-highlight_wrapper">';

						var arrDiv=el.getChildren();
						arrDiv.each(function(elDiv){
							if(elDiv.get('class')=='far-highlight_content_wrapper'){

								var arrChilds=elDiv.getChildren()
								var strHtmlChild;
								strJs=arrChilds[0].getElement('script').get('html').clean();
								strJs=strJs.substring(0,strJs.length-3)+", returnhtml: true})";
								strHtmlChild='<div>'+eval(strJs)+'</div>';

								strHtmlChild+=getOuterHtml(arrChilds[1]);

								strHtmlElement+='<div class="far-highlight_content_wrapper"><div>'+strHtmlChild+'</div><div class="far-highlight_spacer"/></div></div>';
							}else{
								strHtmlElement+=getOuterHtml(elDiv);
							}

						});

						strHtmlElement+='</div>';
						//dumpLog(convertHtmlForDisplay(strHtmlElement));
					}

					if(bolDefaultNested)strHtmlElement=getOuterHtml(el);

				}else{
					strHtmlElement=getOuterHtml(el);

				}
			}


			strHtml+=strHtmlElement;
		}
		//alert(getOuterHtml(el))
		//return;
	})


	// Create privacy footer
	var crsc = _page.crsc_server;
	var privacy_footer = _page.text["footer"];
	privacy_footer = privacy_footer.replace("{BR}", "<br />");
	privacy_footer = privacy_footer.replace("{COPYRIGHT}", _page.text["copyright"]);
	privacy_footer = privacy_footer.replace("{PRIVACY}", "<a href=\""+_page.link["privacy"]+"\">"+_page.text["privacy"]+"</a>");
	privacy_footer = privacy_footer.replace("{OWNER}", "<a href=\""+_page.link["owner"]+"\">"+_page.text["owner"]+"</a>");
	privacy_footer = privacy_footer.replace("{TERMS}", "<a href=\""+_page.link["terms"]+"\">"+_page.text["terms"]+"</a>");
	privacy_footer = privacy_footer.replace("| {SITEMAP}", "");
	privacy_footer = privacy_footer.replace("{CAREERS} | ","");




	var print_body = '';
	print_body += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n';
	print_body += '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	print_body += '<html xmlns="http://www.w3.org/1999/xhtml">\n';
	print_body += '<head>\n';
	print_body += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n';
	if(_page.headerType == "external_extranet") {
		// No global stylesheet when using external extranet
		var stylesheet_externalextranet = "	<link rel=\"stylesheet\" type=\"text/css\" href=\""+_page.crsc_server+"/crsc/styles/external_extranet.css\" />\n";
		print_body += stylesheet_externalextranet;
	} else {
		print_body += '  <link href="'+_page.crsc_server + '/crsc/styles/global.css" type="text/css" rel="stylesheet" />\n';
	}
	print_body += '  <link href="'+_page.crsc_server + '/crsc/styles/components.css" type="text/css" rel="stylesheet" />\n';
	print_body += '  <link href="'+_page.crsc_server + '/crsc/styles/print.css" type="text/css" rel="stylesheet" />\n';
	if(_page.direction=="rtl"){
		print_body += '  <link href="'+_page.crsc_server + '/crsc/styles/rtl.css" type="text/css" rel="stylesheet" />\n';
	}
	print_body += '  <link media="print" href="'+_page.crsc_server + '/crsc/styles/printbrowser.css" type="text/css" rel="stylesheet" />\n';
	// Adjust styles of some locales
	if(_page.locale) {
		if(_page.locale.substring(3,5)=="zh" || _page.locale.substring(3,5)=="ja" || _page.locale.substring(3,5)=="ko"){
			// Add extra stylesheet for Chinese and Japanese and Korean locales
			print_body += "<link rel=\"stylesheet\" type=\"text/css\" href=\""+_page.crsc_server+"/crsc/styles/zh_ja.css\" />\n";
		}
		else if(_page.locale.substring(3,5)=="th"){
			// Add extra stylesheet for Thai locales
			print_body += "<link rel=\"stylesheet\" type=\"text/css\" href=\""+_page.crsc_server+"/crsc/styles/th.css\" />\n";
		}
		else if(_page.locale.substring(3,5)=="ru"){
			// Add extra stylesheet for russian locales
			print_body += "<link rel=\"stylesheet\" type=\"text/css\" href=\""+_page.crsc_server+"/crsc/styles/ru.css\" />\n";
		}
	}

	/*
	FAR UNIQUE
	*/
	print_body += '  <link href="/styles/far_styles-print_2008.css" media="screen" rel="stylesheet" type="text/css" />';
	print_body += '  <link href="/styles/dynamic_css.asp" media="screen" rel="stylesheet" type="text/css" />';
	if(Browser.Engine.trident){
		//print_body += '<style type="text/css" />';
		//print_body += ' div.far-quote_wrapper{display:none!};';
		//print_body += '</style>';


	}

	print_body += '	<title>'+document.title+'</title>';
	print_body += '</head>\n';
	print_body += '<body style="direction:'+_page.direction+'" onload="setTimeout(\'window.print()\', 1000);setTimeout(\'window.close()\', 5000);">\n';
	//print_body += '<body style="direction:'+_page.direction+'">\n';

	print_body += '	<div class="p-printcontainer">\n';
	print_body += '  	<div class="p-print-logo"><img alt="Philips" src="'+_page.crsc_server + '/crsc/images/mainlogo.gif" /></div>\n';
	if(print_type=='press'){
		print_body += '  	<div class="p-print-press"><img alt="Press information" src="'+_page.crsc_server + '/crsc/images/pressrelease_header.gif" /></div>\n';
	} else {
		print_body += '  	<div class="p-line"><img alt="" src="'+_page.crsc_server + '/crsc/images/solidline.gif" /></div>\n';
	}



	print_body += '  	<div id="p-grid-c">'+strHtml.stripScripts()+'</div>\n';



	print_body += '  	<div class="p-line" style="padding-top:10px; padding-bottom:10px"><img alt="" src="'+_page.crsc_server + '/crsc/images/solidline.gif" /></div>\n';

	print_body +=strHtmlFooter.split(' Information about:')[0];
	print_body += '  	<div class="p-line" style="padding-top:10px;"><img alt="" src="'+_page.crsc_server + '/crsc/images/solidline.gif" /></div>\n';
	print_body += '  	<div class="p-print-footer">\n';
	print_body += '  	  ' + privacy_footer +'\n';
	print_body += '		</div>\n';
	print_body += '	</div>\n';
	print_body += '</body></html>\n';
	// Create popup window
	var wHeight=500;
	var wWidth=700;
	var w=window.open('','','height='+wHeight+',width='+wWidth+',toolbar=yes,scrollbars=yes')
	// Center popup window
	var sWidth = parseInt(gsW());
	var sHeight = parseInt(gsH());
	if( sWidth>0&&sHeight>0 ){w.moveTo(Math.round((sWidth-wWidth)/2),Math.round((sHeight-wHeight)/2))};
	if( w.focus ) { w.focus(); }
	w.document.open();
	w.document.write(print_body);
	w.document.close();
};

/**
 * PopUp
 * - Needs an element to be connected with the PopUp
 * - Based on Mootools.v1.1
 *
 */

var currPopup;
var currPopupMouseOver = false;
var currPopupOpen = false;
var currPopupHandle;


function setPopup(handle, popup, offset, showEvent) {

	// Set events
	handle.addEvent(showEvent, function(){

		if (currPopupOpen){
			hidePopup();
			currPopupOpen = false;
		} else {
			// Retrieve positions
			var pos = {'x': handle.getPosition()['x'] + offset['x'], 'y': handle.getPosition()['y'] + offset['y']};
			//var pos = {'x': handle.getPosition()['x'] + offset['x'], 'y': handle.getPosition()['y'] - popup.getSize()['size']['y'] + offset['y']};

			//debugObject({obj: pos})

			// Set positions
			popup.setStyles({'top': pos['y'] + 'px','left': pos['x'] + 'px'}); // Assign the positions

			//alert(currPopup);
			if (currPopup != null) currPopup.setStyle('visibility', 'hidden');
			currPopup = popup;
			currPopupHandle = this.getElement('li');
			showPopup(); // Show the popup
			currPopupOpen = true;

			handle.addEvent('mouseleave', function(){ hidePopup.delay(500, this); });
		}
	});

	popup.addEvent('mouseenter', function() {
		currPopupMouseOver = true;
		popup.addEvent('mouseleave', function() {
			currPopupMouseOver = false;
			handle.removeEvents('mouseleave');
			hidePopup();
		});
	});
}

function showPopup() {
	if (currPopup != null) currPopup.setStyle('visibility', 'hidden');
	if (currPopupHandle != null) currPopupHandle.addClass('open');

	currPopup.setStyle('visibility','visible');
}

function hidePopup() {
	if (!currPopupMouseOver) {
		if (currPopupHandle != null) currPopupHandle.removeClass('open');
		currPopup.setStyle('visibility','hidden');
		currPopupOpen = false;
	}
}

/* ToolTip - static tooltip */

var currTooltip;
var currTooltipHandle;
var currTooltipMouseOver = false;

function setToolTips() {
	var el = $('far-toolbar');

	if (el)	{
		var arr = el.getElements('a');

		if (arr.length > 0) {
			var html, strId;
			var bPopup = false;

			var offset = {'x': -67, 'y': -1};
			if (Browser.Engine.trident) offset = {'x': -67, 'y': 30};
			if (Browser.Engine.webkit) offset = {'x': -67, 'y': 10};

			arr.each(function(item){
				strId=item.id;
				switch(strId){
					case "toolbar_fontenlarge":
						html = '<div class="far-popup-small-larger"></div>';
						break;
					case "toolbar_fontreduce":
						html = '<div class="far-popup-small-smaller"></div>';
						break;
					case "toolbar_print":
						html = '<div class="far-popup-small-print"></div>';
						break;
					case "toolbar_email":
						html = '<div class="far-popup-small-mail"></div>'
						break;
					case "toolbar_download":
						var downloadsHtml = $('far-toolbar-downloads').innerHTML;
						var html = '<div class="far-popup-large-wrapper"><div class="far-top-shadow-large"></div><table cellspacing="0" class="far-p-large-content" ><tr><td class="far-download-content"><p class="far-p-h-dl">Download</p>' + downloadsHtml + '</td></tr></table><div class="far-bottom-shadow-large"></div></div>';

						bPopup = true;
						offset =  {'x': -183, 'y': 1};
						if (Browser.Engine.trident) offset = {'x': -183, 'y': 24};
						if (Browser.Engine.webkit) offset = {'x': -183, 'y': 12};
						break;

				}
				setTooltip(item, html, offset, 'mouseenter', bPopup);

			});


		}
	}

	//var years = $('far-overview-table');
	var years = $('far-overview-container');
	if(years){
		years.getElements('.first-row').each(function(el){
			setFarToolTip(el);
		});

		years.getElements('.far-numeric-data').each(function(el){
			setFarToolTip(el);
		});
	}



	var tdInfo = $('far-overview-info');
	if(tdInfo){
		tdInfo.getElements('.info').each(function(el){
			setFarToolTip(el);
		});
	}
}

function setFarToolTip(el) {
	var innerHtml, html, strId, strNewCopy, elHandle, arrSups;
	var bPopup = false;

	strNewCopy = "";

	arrSups = el.getElements('sup.far-note');
	arrSups.each(function(el){
		strNewCopy = strNewCopy + '<span>' + el.getProperty('title') + '</span>';
		el.setProperty('title', '');
	});

	if(strNewCopy != "") {
		var popup = $('popup-10y');
		popup.getElement('.far-content-copy-10y').set('html', strNewCopy);
		html = popup.innerHTML;

		bPopup = false;
		var offset = {'x': -60, 'y': el.getSize().y};
		if(Browser.Engine.trident){
			offset = {'x': -60, 'y': el.getSize().y - 1};
		} else if (window.gecko)
		{
			offset = {'x': -60, 'y': el.getSize().y};
		}

		setTooltip(el, html, offset, 'mouseenter', bPopup);
	}
	strNewCopy = "";
}

function setTooltip(handle, html, offset, showEvent, popup) {
	// Set the html
	var tooltip = new Element('div').setStyles({
		'position': 'absolute',
		'z-index': '999',
		'visibility': 'hidden',
		'top': '0px',
		'height': '0px'
	}).set('html', html).injectInside(document.body);


	if (popup) {
		// Set events
		handle.addEvent(showEvent, function(){
			// Retrieve positions
			var pos = {'x': handle.getPosition()['x'] + offset['x'], 'y': handle.getPosition()['y'] + offset['y']};

			// Set positions
			tooltip.setStyles({'top': pos['y'] + 'px','left': pos['x'] + 'px'}); // Assign the positions

			if (currTooltip != null) currTooltip.setStyle('visibility', 'hidden');
			currTooltip = tooltip;
			currTooltipHandle = this;

			showTooltip(); // Show the popup

			handle.addEvent('mouseleave', function(){
				hideTooltip.delay(600, this);
			});
		});

		tooltip.addEvent('mouseenter', function() {
			currTooltipMouseOver = true;
			tooltip.addEvent('mouseleave', function() {
				currTooltipMouseOver = false;
				handle.removeEvents('mouseleave');
				hideTooltip();
			});
		});
	} else {
		// Set events
		handle.addEvent(showEvent, function(){
			// Retrieve positions
			var pos = {'x': handle.getPosition()['x'] + offset['x'], 'y': handle.getPosition()['y'] + offset['y']};

			// Set positions
			tooltip.setStyles({'top': pos['y'] + 'px','left': pos['x'] + 'px'}); // Assign the positions

			if (currTooltip != null) currTooltip.setStyle('visibility', 'hidden');
			currTooltip = tooltip;
			currTooltipHandle = this;
			showTooltip(); // Show the popup
		});

		handle.addEvent('mouseleave', function() {
			hideTooltip();
		});
	}
}

function showTooltip() {
	if (currTooltip != null) currTooltip.setStyle('visibility', 'hidden');
	if (currTooltipHandle != null) currTooltipHandle.addClass('open');

	currTooltip.setStyle('visibility','visible');
}

function hideTooltip() {
	if (!currTooltipMouseOver) {
		if (currTooltipHandle != null) currTooltipHandle.removeClass('open');
		if (currTooltip != null) currTooltip.setStyle('visibility','hidden');
	}
}

function hideEmptyParagraphTables(){
	var arrEl=objPageElements.elmaincolumn.getElements('td.p-article:empty');
	arrEl.each(function(el){
		el.getParent('table').setStyle('display', 'none');
	})
}

function setupArrowKeysEvents(){

	document.addEvent('keydown', function(event){
		var strStyle;
		var bolLightboxOpen=false;
		if($defined(objLightbox) && $type(objLightbox)=='object')if(objLightbox.getStatus()=='open')bolLightboxOpen=true;

		if(objPageState.objPageMask.bolMaskOpen){
			//arrow keys need to interact with the mask layer next and previous

		}else{
			if($defined(objPageElements.elpagenavigator_top_next)){
				if(event.key=="right" && !bolLightboxOpen){
					event.stop();
					objPageState.objPageNavigator.keydown=true;
					strStyle=objPageElements.elpagenavigator_top_next.get('style');
					if(!strStyle.contains('none')){
						objPageElements.elpagenavigator_top_next.fireEvent('click');
						if($defined(objPageElements.elpagenavigator_bottom_next))objPageElements.elpagenavigator_bottom_next.highlight(objPageAttributes.highlightcolor);
					}
				}
			}
			if($defined(objPageElements.elpagenavigator_top_prev)){
				if(event.key=="left" && !bolLightboxOpen){
					event.stop();
					objPageState.objPageNavigator.keydown=true;
					objPageElements.elpagenavigator_top_prev.fireEvent('click');
					if($defined(objPageElements.elpagenavigator_bottom_prev))objPageElements.elpagenavigator_bottom_prev.highlight(objPageAttributes.highlightcolor);
				}
			}
		}

	});

	return true;
}

function setupPageNavigatorElement(el){

	var objTweenEffect={
		duration: 500,
		transition: Fx.Transitions.Quad.easeOut,
		link: 'chain'
	}

	el.set('tween',objTweenEffect);
	//add event to the link inside the div
	el.getElement("a").addEvent('click', function(event){
		event.stop();
		el.fireEvent('click');
	});

	el.addEvent('click', function(){
		//for statistical event
		var strType=this.get('class').split('_')[1];
		var strClass=this.getParents('div')[0].get('class');
		var strNavigatorVariation="page-navigator_"+((strClass.contains('bottom'))?'bottom':'top');
		if(objPageState.objPageNavigator.keydown){
			statsStorePageEvent({eventname: 'keydown', value1: strType})
		}else{
			statsStorePageEvent({eventname: 'click', value1: strType, value2: strNavigatorVariation})
		}

		var strUrl=this.getElement("a").get('href');
		this.highlight(objPageAttributes.highlightcolor);
		var nextpage=function(){
			location.href=strUrl;
		}.delay(400);
	})

	return true;
}

function setupGlossaryElement(){
	var arrTogglers=objPageElements.elglossary.getElements('a');
	arrTogglers.addEvent('click', function(event){
		event.stop();
	});
	var arrElements=objPageElements.elglossary.getElements('div');
	var myAccordion = new Accordion(arrTogglers, arrElements, {
		display: false,
		alwaysHide: true,
		opacity: false,
		duration : 700,
		onActive: function(eltoggler, eltarget){
			elLi=eltoggler.getParent();
			elLi.set('class','open');
		},
		onBackground: function(eltoggler, eltarget){
			elLi=eltoggler.getParent();
			elLi.set('class','');
		}
	});
	objPageElements.elglossary.setStyle('display', 'block');
	return true;
}

function getDefaultPageElements(){
	//fills a global object with references to commonly used page DOM elements
	var o=objPageElements;
	var arrEl;

	o.elbody=$$('body')[0];
	o.elcontent=o.elbody.getElement('table#p-columns');
	o.elleftcolumn=o.elbody.getElement('td#p-leftnav');
	if($defined(o.elleftcolumn)){
		o.elleftnavtable=o.elleftcolumn.getElement('table#p-table-left');
	}
	o.elsearchform=o.elbody.getElement('form#far-search-field');
	o.eliconenlarge=o.elcontent.getElement('a#toolbar_fontenlarge');
	o.eliconreduce=o.elcontent.getElement('a#toolbar_fontreduce');
	o.eliconprint=o.elcontent.getElement('a#toolbar_print');
	o.eliconemail=o.elcontent.getElement('a#toolbar_email');
	o.elmaincolumn=$('p-maincontent');
	if(!$defined(o.elmaincolumn))o.elmaincolumn=$('p-main');
	if($defined(o.elmaincolumn)){
		arrEl=o.elmaincolumn.getElements('span.far-navigator_prev');
		if($defined(arrEl[0]))o.elpagenavigator_top_prev=arrEl[0];
		if($defined(arrEl[1]))o.elpagenavigator_bottom_prev=arrEl[1];
		arrEl=o.elmaincolumn.getElements('span.far-navigator_next');
		if($defined(arrEl[0]))o.elpagenavigator_top_next=arrEl[0];
		if($defined(arrEl[1]))o.elpagenavigator_bottom_next=arrEl[1];

		o.elrightcolumn=o.elmaincolumn.getElement('td.far-right-col');
		if(!$defined(o.elrightcolumn))o.elrightcolumn=o.elmaincolumn.getElement('td#p-right');
		if($defined(o.elrightcolumn)){
			o.elpagetools=o.elrightcolumn.getElement('table#far-pagetools');
		}

	}
	o.elglossary=o.elcontent.getElement('table#far-glossary_table');

	return true;
}

function onResize(){

	calculateVisibleContentFactor();
}

function onScroll(){

	calculateVisibleContentFactor();
}

function initPageDomReady(){
	/*
	Triggered on the dom ready event
	*/
	var bolTemp; //used to capture return vualues to prevent paraller execution of functions
	var objImage, objSpan;



	bolTemp=getDefaultPageElements();

	bolTemp=leftNavigationRework();
	//url specific functionality
	switch(strPageIdSystem){
		case "0":
			initHomePageDomReady();
		case "79288332467":
			//sectors landing page
			executeAdditionalSifrReplacements();
			break;
		case "93168837303":
			//financial highlights
			executeAdditionalSifrReplacements();
			break;
		case "4533956689":
			//ten year overview
			executeAdditionalSifrReplacements();
			break;
		case strPageIdDownloadManager:
			initDownloadManager();
			break;
		case "2039203":
			//people, partners and planet page
			if(document.location.search.indexOf('tofootprint')>0){
				//find the "footprint" proofpoint
				var arrEl=objPageElements.elmaincolumn.getElements("div.far-proofoint_wrapper")
				arrEl.each(function(el){
					var bolPocess=false;
					arrP=el.getElements("p");
					arrP.each(function(elP){
						if(elP.get('text').contains('continuously work on improving the environmental performance'))bolPocess=true;
					})

					if(bolPocess){
						//var intY=el.getPosition().y;
						var myFx = new Fx.Scroll(window, {duration: 800}).toElement(el);
					}
				})

			}

			break;

		case "2040697":
			//philips investment proposition
			var elTd=objPageElements.elmaincolumn.getElement('a[id=section2]').getParent();
			elTd.getElements('br').destroy();
			var arrUl=elTd.getElements('ul');
			arrUl[1].addClass('indent');

			break;
		case "1154067":
			//supervisory board page
			setupSupervisoryBoardNoteLinks();
			break;
		case '2040320':
			//our company page
			hideEmptyParagraphTables();
			break;
		case '2039313':
			//sustainability - align table
			var arrEl=objPageElements.elmaincolumn.getElements("table#bigtable_d9e54 tr td.far-numeric-data")
			arrEl.each(function(el, index){
				if(el.getParent().get('class')!='row_8')el.setStyle('vertical-align', 'top');
			})
			break;
		case '1162894':
			var arrEl=objPageElements.elmaincolumn.getElements("a");

			arrEl.each(function(el, index){
				if(el.get('text').toLowerCase().contains('auditor\'s repor')){
					var strHref=el.get('href');

						if(el.get('href').contains('ifrs')){
							el.set('html', 'Auditor\'s report (IFRS)');
						}else{
							el.set('html', 'Auditor\'s report (Company Financial Statements)');
						}

				}
			})
			break;
		case '2040342':
			var arrTable=objPageElements.elmaincolumn.getElements('table.p-paragraph');
			arrTable.each(function(elTable, index){
				var elTd=elTable.getElement('td');
				//alert(elTd.get('html'))

				var arrP=elTd.getElements('p');
				arrP.each(function(elP, indexnested){
					if(elP.get('html').contains('Royal Philips Electronics'))elP.setStyle('padding-top', 10);
					if(elP.get('html').contains('ABN AMRO'))elP.setStyle('padding-top', 5);
					if(elP.get('html').contains('Communications concerning share transfers'))elP.setStyle('padding-top', 10);
					if(elP.get('html').contains('Citibank Shareholder Service'))elP.setStyle('padding-top', 10);
				})
			})
			break;

	}



	//set the font size used in the page
	var intFontSizeCookie=Cookie.read("fontsize");
	if(intFontSizeCookie!=false && bolStoreFontSizeInCookie){
		//reset the fontsize in the page based on the factor stored
		intFontSizeCookie=intFontSizeCookie.toFloat();
		var intFontSizeFactor=intFontSizeCookie/100;
		//alert(intFontSizeFactorCookie);
		_page.font_resize(intFontSizeFactor);
	}

  //position the usgaap logo
  if(Browser.Engine.trident4){
	  var elTdBar=$('far-bar');
	  if($defined(elTdBar)){
	  	var elDivLogo=elTdBar.getElement('div.far-usgaap-logo');
	  	//alert(elDivLogo.getStyle('display'));
	  	if(elDivLogo.getStyle('display')!='none'){
		  	var objTdPosition=elTdBar.getPosition();
		  	var intTop=objTdPosition.y+5;
		  	var intLeft=objTdPosition.x+660;
		  	elDivLogo.setStyle('left', intLeft);
		  	elDivLogo.setStyle('top', intTop);
		  	elDivLogo.setStyle('display', 'inline');
		  }
	  }
	}

	//setup the page navigator (previous - next links)
	if($defined(objPageElements.elpagenavigator_top_next))bolTemp=setupPageNavigatorElement(objPageElements.elpagenavigator_top_next);
	if($defined(objPageElements.elpagenavigator_bottom_next))bolTemp=setupPageNavigatorElement(objPageElements.elpagenavigator_bottom_next);
	if($defined(objPageElements.elpagenavigator_top_prev))bolTemp=setupPageNavigatorElement(objPageElements.elpagenavigator_top_prev);
	if($defined(objPageElements.elpagenavigator_bottom_prev))bolTemp=setupPageNavigatorElement(objPageElements.elpagenavigator_bottom_prev);

	//script the arrow keys
	bolTemp=setupArrowKeysEvents();

	//setup the glossary element
	if($defined(objPageElements.elglossary))bolTemp=setupGlossaryElement();

	//setup search autocomplete
	if($defined(objPageElements.elsearchform))bolTemp=setupSearchForm();

	//setup proofpoints
	setupProofpoints();

	//animate kpi's into view
	animateFarKpiElements();

	//calculate the visible content
	calculateVisibleContentFactor();


  if($defined(objPageAttributes.usebom)){
		setupBoardOfManagement();
  }


}

function initPage(){
	/*
	Triggered on the onload event
	*/
	//setup the pagination component
  if($defined(objPageAttributes.usepagination) && $defined($('far-anchorlist'))){
  	new SmoothScroll({ duration: 1000 });
  }

	//setup the tool tips (print, email, etc)
	setToolTips.delay(4500);

  /*
  Page specific client side scripting
  Uses global objPageAttributes object to trigger functions
  */
  if($defined(objPageAttributes.usenotepopups || strSectionType.contains('statements'))){
  	setupStatementsHeader.delay(1000);
  	setupFinancialPopups.delay(300);
  }


	//set the default properties for the lightbox
	objWidgetLightboxProperties.outerclick=true;
	objWidgetLightboxProperties.onopen='lightboxJoesOpen()';
	objWidgetLightboxProperties.onclose='lightboxJoesClose()';
	objWidgetLightboxProperties.onloaded='lightboxJoesLoaded()';
	objWidgetLightboxProperties.widgetpath='/scripts/joes_lightbox';
	objWidgetLightboxProperties.imgpath='/imgs/syst/joes_lightbox';
	objWidgetLightboxProperties.positiontop=100;
	objWidgetLightboxProperties.hoverclass='hover';
	if(Browser.Engine.trident4)objWidgetLightboxProperties.hoverclass=null;

	objWidgetLightboxProperties.htmltemplate={content: strHtmlLightbox, type: 'html'}
	if(strPageIdSystem=="0"){
		objWidgetLightboxProperties.htmltemplate={content: strHtmlLightboxHome, type: 'html'}
	}

	//setup lightbox with graphs and tables (right column)
	if($defined(objPageAttributes.usesidebargraphs) || strSectionType.contains('statements') || strSectionType=="financial-highlights"){
		setupLightboxEvents.delay(300);
	}

	//ten year overview tables
	if(strPageIdSystem=="4533956689" || strPageIdSystem=="55986043686" || strPageIdSystem=="23358651642" || strPageIdSystem=="13874572099" || strPageIdSystem=="96903724863" || strPageIdSystem=="83491981930" || strPageIdSystem=="38890719333" || strPageIdSystem=="48078879263"){
		initTenYearOverview.delay(2000);

	}

	switch(strTemplateSystemId){
		case "grid-h":
			//full width page with a retractable navigation
			if(Browser.Engine.trident){
				initHomePage.delay(500);
			}else{
				initHomePage()
			}
			break;

	}

	//url specific functionality
	switch(strPageIdSystem){
		case "0":
			//homepage
			if(Browser.Engine.trident){
				initHomePage.delay(500);
			}else{
				initHomePage()
			}
			break;
		case "u93168837303":
			//financial highlights
			setSwapper(); // Set image-swapper events
			break;
		case "usearch-results":
			searchExecute();
			break;
		case strPageIdFactsAndFigures:
			//style this page by applying css classes to the paragraphs
			var arrEl=$$('#p-center table.p-paragraph');
			arrEl.each(function(el, index){
				switch(index){
					case 0:
						el.addClass('far-faf_introduction');
						break;
					case 1:
						el.addClass('far-faf_paragraph'+index);
						break;
					case 2:
						el.addClass('far-faf_paragraph'+index);
						el.getElement('h2').addClass('far-azure_base');
						break;
					case 3:
						el.addClass('far-faf_paragraph'+index);
						break;
					case 4:
						el.addClass('far-faf_paragraph'+index);
						el.getElement('h2').addClass('far-green_base');
						break;
				}

			})
			break;
		case strPageIdOurStrategy:
			//style the our strategy page
			var arrEl=$$('#p-center table.p-paragraph');
			arrEl.each(function(el, index){
				el.addClass('far-strategy_paragraph'+(index+1));
				if(index==0){
					var elLi=el.getElements('li')
					elLi.each(function(elnested, indexnested){
						elnested.addClass('far-'+(indexnested+1));

					})


				}
			})
			break;
	}
}

function beforeLoad(){

	if(strPageIdSystem=="48078879263"){
		//change the header (introduction)
		var el=$(document.body).getElement('div.far-introduction_wrapper p');
		var strText='All amounts based on US GAAP and in euros unless otherwise stated. Due to factors such as consolidations and divestments, the amounts, percentages and ratios are not directly comparable.';
		el.set('text', strText);
	}

	//execute default sifr replacements
	if($defined(objPageAttributes.use2008setup)){
		bolTemp=executeDefaultSifrReplacements2008();
	}else{
		bolTemp=executeDefaultSifrReplacements();
	}

}

function initUnload(){
	/*
	Fired when the user exits the page
	*/
	if(objPageAttributes.useonunload){
		//pass the selector of the clicked element
		var strSelector=objPageState.objClickedElement.selector;
		var intVisible=objPageState.objScrollInfo.visiblecontentfactor;
		statsStorePageEvent({eventname: 'onunload', value1: strSelector, value2: intVisible})
	}
}

/* Global settings */

//debug modus
var bolDebug = false;
var intDebugCounter=0;
var bolUseDebugLayer=true;
if(document.location.search.indexOf('debug')>0 && document.location.search.indexOf('cachedebug')<1)bolDebug=true;
var bla="jaa";


//crsc settings
_page.showStockQuotes = false;
if(location.hostname=='www.annualreport2008.philips.com')_page.showStockQuotes = true;
//_page.crsc_nav_server = location.protocol+"//"+location.hostname;
_page.hideFlashSectionBanner = true;
_page.sectionSpecial = ["Annual Report 2008","/index.asp"]; /* Enter title and url special section */
_page.sectionMain = ["Investor Relations","http://www.philips.com/about/investor/index.page?Int_origin=3_micro_others_slot1_global_en_annualreport2008"]; /* Optional: Enter title and url main section */
_page.leftNavOnload = false;
_page.loadSIFR = false;
_page.loadSIFRScript = false;
_page.loadSIFRConfig = false;
_page.loadESurvey = false;
_page.loadOmniture = false;
_page.showSearch = false;

//define the level1 id's that split the navigation into sections
var arrSeperatorLevel1ItemIds=[1,10,14,18];

/* Global variables */
var objPageAttributes={
	highlightcolor: '#ddf',
	pagetitle: '',
	useonunload: true
};
var objPageElements={};
var objPageState={
	objLeftNavigation: {
		bolSection1Open: true,
		bolSection2Open: false
	},
	objPageMask: {
		bolMaskOpen: false,
		type: 'regular',
		target: '',
		titlenext: '',
		titleprevious: ''
	},
	objPageNavigator: {
		clicked: false,
		keydown: false
	},
	objPopupNotesOverview: {
		open: false,
		setup: false
	},
	objClickedElement: {
		selector: "no_selector"
	},
	objScrollInfo: {
		visiblecontentfactor: 0
	}
};

var strCurrentPath = document.location.pathname;
var objLightbox;
var bolStoreFontSizeInCookie=false;
var intFontSize=100; //default to 100%
var arrIdTitleSidebarGraphs=[], arrIdTitleInlineNotes=[];
var arrQuoteClass=[], arrBomLinks=[];
arrBomLinks.push('http://www.philips.com/about/company/management/boardofmanagement/gerardkleisterlee/index.page');
arrBomLinks.push('http://www.philips.com/about/company/management/boardofmanagement/pierre-jeansivignon/index.page');
arrBomLinks.push('http://www.philips.com/about/company/management/boardofmanagement/gottfrieddutin/index.page');
arrBomLinks.push('http://www.philips.com/about/company/management/boardofmanagement/rudyprovoost/index.page');
arrBomLinks.push('http://www.philips.com/about/company/management/boardofmanagement/andrearagnetti/index.page');
arrBomLinks.push('http://www.philips.com/about/company/management/boardofmanagement/steverusckowski/index.page');

/*
Calculate hierarchical position
*/
var strPageId = linkLookup();

/*
Initiate page
*/
window.addEvent('domready', initPageDomReady);
window.addEvent('load', initPage);
window.addEvent("scroll", onScroll);
window.addEvent("resize", onResize);
window.onunload=initUnload;

