/* ----------------------------------------------------------- **/


function PRU_hideText( iID )
{

/*

Function: Sets and resets visible elements to hidden

Input: ElementById

Output: style.display  = 'none';

**/

document.getElementById("1").style.display  = 'none';
document.getElementById("2").style.display  = 'none';
document.getElementById("3").style.display  = 'none';
document.getElementById("4").style.display  = 'none';

if (document.getElementById("5")!= null) {
	
document.getElementById("5").style.display  = 'none';
}
if (document.getElementById("6")!= null) {
	
document.getElementById("6").style.display  = 'none';

PRU_showText(iID);
}

else 
PRU_showText(iID)
}


/* ----------------------------------------------------------- **/


function PRU_showText( iID ) {

/*

Function: Displays and hides the content of an element

Input: iID - the ID of the element

Output: N/A

**/

	if ( document.all && document.getElementById ) {

		var oObject = document.getElementById( iID );
		if ( oObject != null ) {
			if ( oObject.style.display == 'none' ) { oObject.style.display = ''; } else { oObject.style.display  = 'none'; }
		}

	} else if ( ( ! document.all ) && document.getElementById ) {

		var oObject = document.getElementById( iID );
		if ( oObject != null ) {
			if ( oObject && oObject.style.display == 'none' ) { oObject.style.display = 'block'; } else { oObject.style.display  = 'none'; }
		}

	} else if ( document.all ) {

		var oObject = eval( "document.all." + iID );
		if ( oObject != null ) {
			if ( oObject && oObject.style.display == 'none' ) { oObject.style.display = ''; } else { oObject.style.display  = 'none'; }
		}	
	} 

}


/* ----------------------------------------------------------- **/


function PRU_getCookie( sCookieID )
{

/*

Function: Returns a cookie value given a name

Input: sCookieID - cookie name

Output: String; cookie value, or false if not found

**/


	var aCookieElements = document.cookie.toString().split( /;/ ); 

	for ( var i = 0; i < aCookieElements.length; i++ )
	{
		var aNameValue = aCookieElements[i].split( /\=/ );
		aNameValue[0]  = aNameValue[0].replace( /^\s*/, "" );
		if ( aNameValue[0] == sCookieID ) { return aNameValue[1]; }
	}

	return false;

}


/* ----------------------------------------------------------- **/


function PRU_setCookie( name, value, expires, path, domain, secure )
{

/*

Function: Set a cookie

Input:  name - name of cookie
	value - cookie value
	expires - date at which cookie should be removed
	path - directories from which cookie is accessible
	domain - host name
	secure - determines whether cookie is secure

Output: N/A

**/

    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toUTCString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");

}


/* ----------------------------------------------------------- **/


function PRU_getPathParameter( sName )
{

/*

Function: Retrieves a parameter from the Url

Input:  sName - name of parameter

Output: String; parameter name if found, or false

**/

		 var sParamString = location.search.toString();
		 sParamString     = sParamString.replace( /^\?/, "" );
		 var aParams      = sParamString.split( /\&/ );

		 for ( var i = 0; i < aParams.length; i++ )
		 {
		 		 var aNameValues = aParams[i].split( /\=/ );
		 		 if ( aNameValues[0] == sName ) { return aNameValues[1]; }
		 }

		 return false;

}


/* ----------------------------------------------------------- **/

function PRU_initialiseLeftMenu()
{

	var aSpanArray = document.getElementsByTagName( "span" );

	var sCookie = PRU_getCookie( 'PRU_KmId' );


	if ( sCookie ) 
	{
		for ( var i = 0; i < aSpanArray.length; i++ )
		{
			if ( ! aSpanArray[i].id.match( /^spnProd/i ) ) { continue; }
			aSpanArray[i].style.display =  ( eval ( "aSpanArray[i].id.search( /" + sCookie + "/ )" ) > -1 ) ? "": "none";
		}
	}


}


/* ----------------------------------------------------------- **/


var GsChildWin;

function PRU_JSopenUrl( sUrl, iWidth, iHeight, sParamaters )
{
	if ( GsChildWin ) { GsChildWin.close(); }

	if ( sParamaters ) { sParamaters = sParamaters + "," };

	GsChildWin = window.open( sUrl, '', sParamaters + "width=" + iWidth + ",height=" + iHeight + ", top=" + ( ( screen.availheight - iHeight ) / 2 ) + ", left=" + ( ( screen.availwidth  - iWidth  ) / 2 ) );

}

function PRU_JSopenExternalUrl( sPageName, iWidth, iHeight, sParameters )
{
	PRU_JSopenUrl( getURL( sPageName ), iWidth, iHeight, sParameters );
}

/* ----------------------------------------------------------- **/

var GsChildWin;

function PRU_JSopenUrl( sUrl, iWidth, iHeight, sParamaters )
{
	if ( GsChildWin ) { GsChildWin.close(); }

	if ( sParamaters ) { sParamaters = sParamaters + "," };

	GsChildWin = window.open( sUrl, '', sParamaters + "width=" + iWidth + ",height=" + iHeight + ", top=" + ( ( screen.availheight - iHeight ) / 2 ) + ", left=" + ( ( screen.availwidth  - iWidth  ) / 2 ) );

}

function PRU_ApplyOnline( sPageName, iWidth, iHeight, sParameters )
{	
	PRU_JSopenUrl(getURL( sPageName ), iWidth, iHeight, sParameters );
	dcsMultiTrack('DCS.dcsuri','/CTA','WT.ti','CTA: Apply Online', 'WT.z_cta', 'Apply Online');

}

/* ----------------------------------------------------------- **/


function PRU_autoSelect( oSelect )

{
	if ( oSelect.value != "" )
	{
		window.location = oSelect.value;
	}
}

/* ----------------------------------------------------------- **/

function PRU_replaceImage( oImg, sImagePath, sImageName )
{
	oImg.src = sImagePath + sImageName;
}

/* ----------------------------------------------------------- **/

function PRU_anchorTag( sName )
{
	location.hash = sName;
}

/* ----------------------------------------------------------- **/

function PRU_JSactionApplication( sPath )
{
	GsChildWin.close();
	PRU_JSopenUrl( sPath, 700, 800, 'resizable=yes, scrollbars=yes, toolbar=yes' );
}


function PRU_JSactionSmoothing( sPath )
{
	GsChildWin.close();
	PRU_JSopenUrl( sPath, 790, 540, 'resizable=yes, scrollbars=yes, toolbar=yes' );
}


function PRU_getApplicationForm( sPath, iMessageType )
{

	var iWidth = 350; var iHeight = 150;
	var sMessage  = "<span style='FONT-SIZE: x-small; COLOR: #003366; FONT-FAMILY: Arial, Helvetica, sans-serif'>Please ensure you have read the Key Features Document before you make your application.</span><a href='JavaScript:window.opener.PRU_JSactionApplication( \"" + sPath + "\" )'><br /><br /><img src='/images/adhoc/goblue.gif' border='0' /></a>";

	if ( iMessageType == 1 )
	{
		iWidth = 350; iHeight = 150;
		sMessage  = "<span style='FONT-SIZE: x-small; COLOR: #003366; FONT-FAMILY: Arial, Helvetica, sans-serif'><p>Don't forget, as there is no default fund, you must either: tick the box at the bottom of page 2 of the form to invest your transfer value into the same funds and in the same proportions as your current payments, or select a new fund or funds on page 3</p><p>The completed form should then be returned to:<br />Nortel Networks UK Pension Trust Ltd<br />5th Floor<br />Metropolitan House<br />Darkes Lane<br />Potters Bar<br />Hertfordshire<br />EN6 1AG</p></span><a href='JavaScript:window.opener.PRU_JSactionApplication( \"" + sPath + "\" )'><br /><br /><img src='/images/adhoc/goblue.gif' border='0' /></a>";
	}
	else if ( iMessageType == 2 )
	{
		iWidth = 350; iHeight = 150;
		sMessage  = "<span style='FONT-SIZE: x-small; COLOR: #003366; FONT-FAMILY: Arial, Helvetica, sans-serif'>Please read and keep a copy of the Key Features and the Technical Document before you make your application.</span><a href='JavaScript:window.opener.PRU_JSactionApplication( \"" + sPath + "\" )'><br /><br /><img src='/images/adhoc/goblue.gif' border='0' /></a>";
	}
	else if ( iMessageType == 3 )
	{
		iWidth = 350; iHeight = 150;
		sMessage  = "<span style='FONT-SIZE: x-small; COLOR: #003366; FONT-FAMILY: Arial, Helvetica, sans-serif'>Please read and keep a copy of the Key Features and the Customer Agreement before you make your application.</span><a href='JavaScript:window.opener.PRU_JSactionApplication( \"" + sPath + "\" )'><br /><br /><img src='/images/adhoc/goblue.gif' border='0' /></a>";
	}
	else if ( iMessageType == 4 )
	{
		iWidth = 350; iHeight = 150;
		sMessage  = "<span style='FONT-SIZE: x-small; COLOR: #003366; FONT-FAMILY: Arial, Helvetica, sans-serif'>Please read and keep a copy of the Key Features and Family Cover (Policy Sample) before you make your application.</span><a href='JavaScript:window.opener.PRU_JSactionApplication( \"" + sPath + "\" )'><br /><br /><img src='/images/adhoc/goblue.gif' border='0' /></a>";
	}
	else if ( iMessageType == 5 )
	{
		iWidth = 350; iHeight = 150;
		sMessage  = "<span style='FONT-SIZE: x-small; COLOR: #003366; FONT-FAMILY: Arial, Helvetica, sans-serif'>Please read and keep a copy of the Key Features and Critical Illness (Sample Policy) before you make your application.</span><a href='JavaScript:window.opener.PRU_JSactionApplication( \"" + sPath + "\" )'><br /><br /><img src='/images/adhoc/goblue.gif' border='0' /></a>";
	}
	else if ( iMessageType == 6 )
	{
		iWidth = 350; iHeight = 150;
		sMessage  = "<span style='FONT-SIZE: x-small; COLOR: #003366; FONT-FAMILY: Arial, Helvetica, sans-serif'>Please read and keep a copy of the Key Features and Mortgage Protection (Sample Policy) before you make your application.</span><a href='JavaScript:window.opener.PRU_JSactionApplication( \"" + sPath + "\" )'><br /><br /><img src='/images/adhoc/goblue.gif' border='0' /></a>";
	}
	else if ( iMessageType == 7 )
	{
		iWidth = 350; iHeight = 150;
		sMessage  = "<span style='FONT-SIZE: x-small; COLOR: #003366; FONT-FAMILY: Arial, Helvetica, sans-serif'>Please read and keep a copy of the Key Features and Sample Policy before you make your application.</span><a href='JavaScript:window.opener.PRU_JSactionApplication( \"" + sPath + "\" )'><br /><br /><img src='/images/adhoc/goblue.gif' border='0' /></a>";
	}
	else if ( iMessageType == 8 )
	{
		iWidth = 350; iHeight = 150;
		sMessage  = "<span style='FONT-SIZE: x-small; COLOR: #003366; FONT-FAMILY: Arial, Helvetica, sans-serif'>Please read and keep a copy of the Key Features and Policy Provisions before you make your application. </span><a href='JavaScript:window.opener.PRU_JSactionApplication( \"" + sPath + "\" )'><br /><br /><img src='/images/adhoc/goblue.gif' border='0' /></a>";
	}	

	var sTemplage = "<html><head><title>Application Form</title></head><body><table cellpadding='10' cellspacing='10' align='center'><tr><td>" + sMessage + "</td></tr></table></body></html>";

	PRU_JSopenUrl( '', iWidth, iHeight, 'scrollbars=yes, resizable=yes' );

	GsChildWin.document.open();
	GsChildWin.document.write(sTemplage);
	GsChildWin.document.close();

}

/* ----------------------------------------------------------- **/

function PRU_getSmoothing( sPath )
{

	var iWidth = 500; var iHeight = 350;
	var sMessage  = "<span style='FONT-SIZE: x-small; COLOR: #003366; FONT-FAMILY: Arial, Helvetica, sans-serif'>To protect your investment and ensure a fairer return to all investors, we have suspended smoothing on the PruFund Growth and Growth &amp; Income Funds. This will be effective for a minimum of 30 days, but may be longer.<br><br>During this time your plan fund value will fluctuate more as the unit price fund value will be the same as the actual fund value. For more information on this, please refer to your detailed fund guide. <br><br>Once smoothing restarts the unit price will increase at the Expected Growth Rate for the quarter and this notice will no longer appear.</span><br><a href='JavaScript:window.opener.PRU_JSactionSmoothing( \"" + sPath + "\" )'><br /><br /><img src='/images/adhoc/goblue.gif' border='0' /></a>";
	var sTemplate = "<html><head><title>PruFund Information</title></head><body><table cellpadding='10' cellspacing='10' align='center'><tr><td>" + sMessage + "</td></tr></table></body></html>";


	PRU_JSopenUrl( '', iWidth, iHeight, 'scrollbars=yes, resizable=yes' );

	GsChildWin.document.open();
	GsChildWin.document.write(sTemplate);
	GsChildWin.document.close();

}

/* ----------------------------------------------------------- **/

function PRU_getRequest()
{

/*

Function: Gets the parameters from the URL

Input:  N/A

Output: Returns array called collection

**/

var thisUrl = location.search;
var collection = new Array();

if (thisUrl.indexOf("=") > -1)
	{
	thisUrl = thisUrl.replace(/\?/g, "");
	if (thisUrl.indexOf("&") > -1) 
		{
		kvArray = thisUrl.split("&");
		for (i = 0; i < kvArray.length; i++) 
			{
			pairArray = kvArray[i].split("=")
			collection[pairArray[0]] = pairArray[1];
			}
		} else 
		{
		pairArray = thisUrl.split("=");
		collection[pairArray[0]] = pairArray[1];
		}
	}
return collection;
}

/* ----------------------------------------------------------- **/

function clearValue(field) {
	field.value="";
}


/* ----------------------------------------------------------- **/

/*

Function: Sets a persistent Cookie with a given name

Input:  N/A

Output: N/A

**/

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}

/* ----------------------------------------------------------- **/

function PRU_getExitSurvey(surl)
{
	var sCookie = PRU_getCookie("exitCode" );
	if ( ! sCookie ) 		
		{
		SetCookie("exitCode","Wibble",'30');
		PRU_JSopenUrl( surl, 700, 800, 'resizable=yes, scrollbars=yes, toolbar=yes' );		
		}
		
}

/* ----------------------------------------------------------- **/

function PRU_callCookie()
{
	var sCookie = PRU_getCookie( "COOKIE" );


	if  (sCookie == "Y" )
		{
		document.all.magazine.innerHTML = "<div id='backtomag'><a href='/content/ezine/'><img src='/images/ezine/backtonews.gif' alt='Back to newsletter'  border='0' align='right'></a></div>"; 
		}
}

/* ----------------------------------------------------------- **/


/* Ezine ShowHide Div **/


function showArticle(divID, blnTurnOff)
{
var vNum = navigator.appVersion;
var nsOnly = (vNum.indexOf("5.0") == -1 != vNum.indexOf("NT 5.0") == 1);

var holderDiv = 'multiarticle';

if (navigator.userAgent.indexOf("Mozilla") != -1)
	{
	// Mozilla Code
	if ((document.getElementById(divID).className ==  "articleOff") && (blnTurnOff != 1))
		{
		eval("document.getElementById('" + divID + "').className='articleOn';");
		}
	else
		{
		eval("document.getElementById('" + divID + "').className='articleOff';");
		}
	}
else if (navigator.appName.indexOf("Microsoft") == -1 && nsOnly)
	{
	// Netscape Code
	if ((document.getElementById(divID).className ==  "articleOff") && (blnTurnOff != 1))
		{
		eval("document." + holderLayer + ".layers['" + divID + "'].className='articleOn';");
		}
	else
		{
		eval("document." + holderLayer + ".layers['" + divID + "'].className='articleOff';");
		}
	}
}

function hideAllArticle(intArticleLength)
{
for (var loopArticle = 0; loopArticle < intArticleLength; loopArticle++)
	{
	showArticle("article" + (loopArticle + 1), 1);
	}
}

/* ----------------------------------------------------------- **/

	
	function addSheet(href)
	{
		var sheet = document.createElement("link");
		sheet.rel = "stylesheet";
		sheet.type = "text/css";
		sheet.href = href;
		sheet.media = "screen";
		document.getElementsByTagName("head")[0].appendChild(sheet);
		
		printPreviewTimer = setInterval(refreshPage, 5000);
		print();
	}
	
	function refreshPage()
	{
		clearInterval(printPreviewTimer);
		location.replace('');
		//
	}

