
function SetPageVariables() {

	// set the following variables :
	// this.IE50  - browser = IE 5.0 - 5.49
	// this.IE55up - browser = IE 5.5+
	// this.Mozzies - browser = netscape 7+ and mozilla family
	// this.BrowserIsCompatible - Site is designed for IE 5+ & Netscape 7+ & Mozillas
	// this.PageMode - what mode is this page? G = Graphic, P = Printer Friendly, T = Text

	// browser compatibility ...
	// only intersted in IE 5+, NS7+ and Mozzie family.

	var agent = navigator.userAgent.toLowerCase();
	var version = parseInt(navigator.appVersion);
	var appVer = navigator.appVersion.toLowerCase();
	var iePos  = appVer.indexOf('msie');
	var ieVer = appVer.substring(iePos+5,appVer.indexOf(';',iePos)) ;

	Opera = (agent.indexOf('opera') != -1) ;

	this.IE50 = ( ( iePos !=-1 ) && ( ( parseFloat(ieVer) >=5.0 ) &&  ( parseFloat(ieVer) <5.5 ) ) && !( Opera ) ) ;
	this.IE55up = ( ( iePos !=-1 ) && ( parseFloat(ieVer) >=5.5 ) && !( Opera ) ) ;

	NS6 = (agent.indexOf('netscape/6') !=-1 ) || (agent.indexOf('netscape6') !=-1 ) ;
	NSC = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)) && (version >=5 ) );
	
	this.Mozzies = ( NSC && !( NS6 || Opera ) ) ;

	this.BrowserIsCompatible = ( IE50 || IE55up || Mozzies ) ;


	// set PageMode for the menu hover mimic code and text-only code.
	var cookieName = 'Euro_ViewMode' ;
	var pmvalue = ( BrowserIsCompatible ) ? 'G' : 'T' ;


	var docloc = window.location.href.toLowerCase() ;
	var ppf = ( docloc.indexOf('&ppf') != -1 ) ;

	if ( ppf )
	{
		pmvalue = 'P' ;
	}
	else if ( document.cookie )
	{
		index = document.cookie.indexOf(cookieName);
		if ( index >=0 ) 
		{
			pmvalue = document.cookie.substr( index + cookieName.length +1 , 1 ) ;
		}
	} 


	this.PageMode = pmvalue ;

	return true ;
}

// set global variables ..
SetPageVariables() ;


// load in another stylesheet - customised for certain browsers .. - this is for the drop-down menus
if ( PageMode == "G" ) {

	if ( IE50 ) {
		document.write( '<LINK REL=STYLESHEET TYPE="text/css" HREF = "/Sectors/EURO/webeuro.nsf/vLA/css_extra/$File/common_IE50_style.css">' ) ;
	}
	else if ( IE55up )
	{
		document.write( '<LINK REL=STYLESHEET TYPE="text/css" HREF = "/Sectors/EURO/webeuro.nsf/vLA/css_extra/$File/common_IE55_style.css">' ) ;
	}
	else if ( Mozzies )
	{
		document.write( '<LINK REL=STYLESHEET TYPE="text/css" HREF = "/Sectors/EURO/webeuro.nsf/vLA/css_extra/$File/common_MOZ_style.css">' ) ;
	}
}


// mimic the hover behaviour for the top menu bar 
// for use with IE flavour browsers
// - when PageMode != G, it stops the mimic hover menu and prevents js error messages

startList = function() {
if (document.all&&document.getElementById) 
{
	if ( PageMode == 'G' ) 
	{
		navRoot = document.getElementById('nav');
		for (i=0; i<navRoot.childNodes.length; i++) 
		{
			node = navRoot.childNodes[i];
			if (node.nodeName=='LI') 
			{
				node.onmouseover=function() 
				{
					this.className+=' over';
				}
				node.onmouseout=function() 
				{
					this.className=this.className.replace(' over', '');
				}
			}
		}
	}
}
}
window.onload=startList;


// switch page mode .. for switching between graphic and text mode ..
function SwitchPageMode( pmode ) {

	var cookieName = 'Euro_ViewMode' ; 
	var cexpire = new Date() ;
	cexpire.setFullYear( cexpire.getFullYear() +1 ) ; 

	pgmode = ( BrowserIsCompatible ) ? pmode : 'T' ;

	document.cookie = cookieName + '=' + pgmode + '; expires=' + cexpire.toGMTString() + '; path=/;' ; 
	window.location.reload( true )

}

/* search submission code */
function trimspaces(aStr) {
	return aStr.replace(/^\s{1,}/, "").replace(/\s{1,}$/, "")
}


function SearchTermOk( qstr ) {

	var regExp1 = /\bfield\b/i; 		//used to test for reserved word field in query string
	var regExp2 = /[(,),<,>,\[,\]]/; 	//used to test for reserved char(s) in the query string

	var str = trimspaces( qstr );

	if ( str == "" )
	{
		alert("Please be sure to enter something to search for.");
		return 1 ;
	} 
	else 
	{
	if ( typeof regExp1.source != 'undefined' ) 
	{ 	//supports regular expression testing
		if ( regExp1.test( str ) || regExp2.test( str ) ) 
		{
			var alrt = "Please note that you can not include:\n";
			alrt += "\nThe reserved word 'field'\n";
			alrt += "The characters comma, [, ], (, ), < or >\n";
			alrt += "\nin your search query!";
			alert( alrt );
			return 2 ;
		}
		else
		{
			// search term is reasonably ok ...
			return 0 ;
		}
	}
	else
	{
		alert( "Unsupported browser function - search cannot proceed.\n\nPlease use a different browser." ) ;
		return 3 ;
	
	}
	}

}



function doSearch( qf ) {

	var doc = document.forms[0] ;

	if ( qf == '2' )   
	{
		qfield = doc.sQuery ;
		doc.Query.value = '' ;
	}
	else
	{
		qfield = doc.Query ;
	}

	var qr = SearchTermOk( qfield.value ) ;

	if ( qr == 0 ) {
		qfield.value = trimspaces( qfield.value ) ;
		doc.submit() ;  // submitting the form causes the search engine to run.
	} 
	else 
	{
		qfield.focus();
		return false;
	} 
}

function callSiteSearch() {

	var doc = document.forms[0] ;

	var qr = SearchTermOk( doc.Query.value ) ;

	if ( qr == 0 ) {
		// document.location = '/Sectors/EURO/webeuro.nsf/SearchSite?OpenAgent&Query=' + escape( str ) ;
		document.location = '/Sectors/EURO/webeuro.nsf/SearchSite?OpenAgent&Query=' + trimspaces( doc.Query.value ) ;
	}
	else
	{
		doc.Query.focus();
		// return false;
	} 
}

function OpenPrintPreviewWindow() {
	// open the current page in another window and strip off the skin - making the page printer friendly ..
	// window.open( location.pathname + location.search + '&PPF' + location.hash , '_blank' ) ;
	window.open( location.pathname + location.search + '&PPF', '_blank' ) ;
}

