function emailPage() {
		//mail_str ="mailto:?subject=Here's some information from St Paul Travelers";
		//mail_str +="&body=I thought you might be interested in this information from St Paul Travelers.  ";
 		//mail_str +="You can view it at: " + location.href;
 		//location.href=mail_str;
 		window.location = "mailto:"+"?subject=Information from Travelers " + "&body=I thought this information might interest you.  You can view it at: "+"  "+window.location+" ";
 
}

//	This javaScript file keeps all javascript used for web stats

function printerFriendly() {
	window.open(window.location+"?printerFriendly", window.title);
}

function pageStats() {
	
	var browser = "";
	var os = "";
	var osVer = "";
	var type = navigator.appVersion;
	var name = navigator.appName;
	var agent = navigator.userAgent;
	
	if (name.indexOf("Microsoft") >= 0)	{
		name = "MSIE";
	}
	else if (name.indexOf("Netscape") >= 0)	{
		name = "Netscape";
	}
	else {
		name = "Other";
	}
	
	var findIndex;
	var version = 0;
	if (name == "MSIE") {
		//version = navigator.userAgent;
		findIndex = agent.indexOf(name) + 5;
		version = (agent.substring(findIndex, findIndex + 3));
	}
	else {
		//version = parseInt(navigator.appVersion.substring(0,1));
		version = parseInt(type.substring(0,1));
	}
	
	var completeVer = name + version;
	if (agent.indexOf('Win') != -1) { 
	     os = "Windows"; 

		if (type.indexOf('95') != -1) { 
			osVer = "95"; 
		}
		else if(agent.indexOf('98') != -1) { 
			osVer = "98"; 
		}
		else if(agent.indexOf('ME') != -1) { 
			osVer = "ME"; 
		}
		else if(agent.indexOf('NT 4.0') != -1) { 
			osVer = "NT"; 
		}
		else if(agent.indexOf('NT 5.0') != -1) { 
			osVer = "2000"; 
		}
		else if(agent.indexOf('NT 5.1') != -1) { 
			osVer = "XP"; 
		}
		else if(agent.indexOf('NT 6.0') != -1) {
			osVer = "Vista";
		}
		
	}
	else if (agent.indexOf('Linux') != -1) { 
		os = "Linux"; 
	} 
	else if (agent.indexOf('Mac') != -1) { 
		os = "Macintosh"; 
	} 
	else if (agent.indexOf('SunOS') != -1) { 
		os = "UNIX"; 
		osVer = "SunOS"; 
	} 
	else {
		os = "Unknown";
		osVer = "Unknown";
	}
	
	var completeOs = os + osVer;
	var title = document.title;
	var remoteUser = "";
	if (document.forms[0] != undefined)	{
	
		remoteUser = document.forms[0].Remote_User;
		if (remoteUser != undefined) {
		
			remoteUser = remoteUser.value;
			while(remoteUser.indexOf(' ') != -1) {
			
				// replace any spaces in the username with underscores
				var index = remoteUser.indexOf(' ');
				var startString = remoteUser.substring(0, index) + '_';
				remoteUser = startString + remoteUser.substring(index + 1, remoteUser.length);
			}
		}
	}
	if (remoteUser == ""){
		remoteUser = "No User Signed in";
	}
	var product = "";
	var parentUrl = window.parent.location.href;
	if (parentUrl.indexOf('PRODUCT_CODE=') != -1)
	{ 
		var index = parentUrl.indexOf('PRODUCT_CODE=') + 13;
		var search = parentUrl.substring(index, index + 3);
		// check there is no '&' in the search string as there might not be a product yet
		if (search.indexOf('&') == -1) 
			product = search;
	} 
	var url = window.location.href;
	var urlIndex = url.indexOf('?');
	if (urlIndex != -1) { 
		// if there is a '?' just use the url up to that point
		url = url.substring(0, urlIndex);
	}
	
	
	var stats = document.getElementById("STATS");
	if ( stats ) {
		
		var host = this.location.hostname;
		var proto = this.location.protocol;
		// make sure it the appropriate route to the stats single
		
		if (host.indexOf('local') != -1 || host.indexOf('ukaswast01') != -1) {
			// alert("Local");
			stats.src = "/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
		}
		else if (host.indexOf('uspt') != -1 || host.indexOf('uspd') != -1 ) {
			// Dev and Test US Portal point to Test Web Hit Service
			// alert("Internal : Test or Dev");
			stats.src = "http://ukrhwast01.euprod.travp.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
			//stats.src = "http://ukaswast02.euprod.travp.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
			
		}
		else if (host.indexOf('uspp') != -1 || host.indexOf('inside-international') != -1) {
			// Production internal calls e.g. Intranet call internal production Web Hit Service cluster
			//stats.src = "http://sptservices.euprod.travp.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
			// alert("Internal : Prod");
			stats.src = "http://enterpriseapps.travp.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
		}
		else if(proto.indexOf('https:') != -1) {
		
			if (host.indexOf('test') != -1) {
				// alert("External : Secure : Test");
				stats.src = "https://www.test.internationalandlloyds.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
			}
			else {
				// alert("External : Secure : Prod");
				stats.src = "https://www.secure.internationalandlloyds.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
			}
			
		}
		else {
			// Public site
			if (host.indexOf('test') != -1) {
				// alert("External : Public : Test");
				stats.src = "https://www.test.internationalandlloyds.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
			}
			else {
				// alert("External : Public : Prod");
				stats.src = "http://www.internationalandlloyds.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
			}
		}
	}
	// alert("End of pageHits");
}

function openDoc() {

	var pageURL = this.location;
	var query = pageURL.search;
	var doc ="";
	var os = "";
	var osVer = "";
	var browser = "";
	var type = navigator.appVersion;
	var name = navigator.appName;
	var agent = navigator.userAgent;
	
	if (query != "") {
	
		// Get the document URL to be launched
		doc = query.substr(1,(query.length)-1);
		// launch a new window with the new document URL
		window.location=doc;
		
		if (name.indexOf("Microsoft") >= 0)	{
			name = "MSIE";
		}
		else if (name.indexOf("Netscape") >= 0) {
			name = "Netscape";
		}
		else {
			name = "Other";
		}
		
		var findIndex;
		var version = 0;
		if (name == "MSIE") {
			//version = navigator.userAgent;
			findIndex = agent.indexOf(name) + 5;
			version = (agent.substring(findIndex, findIndex + 3));
		}
		else {
			version = parseInt(type.substring(0,1));
		}
		
		var completeVer = name + version;
		if (agent.indexOf('Win') != -1) {
		
	     	os = "Windows";
			if (type.indexOf('95') != -1) { 
				osVer = "95"; 
			}
			else if(agent.indexOf('98') != -1) { 
				osVer = "98"; 
			}
			else if(agent.indexOf('ME') != -1) { 
				osVer = "ME"; 
			}
			else if(agent.indexOf('NT 4.0') != -1) { 
				osVer = "NT"; 
			}
			else if(agent.indexOf('NT 5.0') != -1) { 
				osVer = "2000"; 
			}
			else if(agent.indexOf('NT 5.1') != -1) { 
				osVer = "XP"; 
			}
			else if(agent.indexOf('NT 6.0') != -1) {
				osVer = "Vista";
			}
			
		}
		else if (agent.indexOf('Linux') != -1) { 
			os = "Linux"; 
		} 
		else if (agent.indexOf('Mac') != -1) { 
			os = "Macintosh"; 
		} 
		else if (agent.indexOf('SunOS') != -1) { 
			os = "UNIX"; 
			osVer = "SunOS"; 
		} 
		else {
			os = "Unknown";
			osVer = "Unknown";
		}
		
		var completeOs = os + osVer;
		var urlArray = doc.split("/");
		var urlArrayLength = urlArray.length;
		// alert(urlArrayLength);
		var title = urlArray[urlArrayLength-1];
		// alert(title);
		var remoteUser = "";
		if (document.forms[0] != undefined) {
		
			remoteUser = document.forms[0].Remote_User;
			if (remoteUser != undefined) {
			
				remoteUser = remoteUser.value;
				while(remoteUser.indexOf(' ') != -1) {
				
					// replace any spaces in the username with underscores
					var index = remoteUser.indexOf(' ');
					var startString = remoteUser.substring(0, index) + '_';
					remoteUser = startString + remoteUser.substring(index + 1, remoteUser.length);
				}
			}
		}
		if (remoteUser == ""){
			remoteUser = "No User Signed in";
		}
		var product = "";
		var parentUrl = window.parent.location.href;
		if (parentUrl.indexOf('PRODUCT_CODE=') != -1) { 
			var index = parentUrl.indexOf('PRODUCT_CODE=') + 13;
			var search = parentUrl.substring(index, index + 3);
			// check there is no '&' in the search string as there might not be a product yet
			if (search.indexOf('&') == -1) 
				product = search;
		} 
		var url = window.location.href;
		// url = doc;
		var urlIndex = url.indexOf('?');
		var urlSite = url.indexOf('/resources');
		if (urlIndex != -1) { 
			// if there is a '?' just use the url up to that point
			url = url.substring(0, urlSite)+url.substring(urlIndex+1, url.length);
			// url = url.substring(urlIndex+1, url.length);
			// alert(url);
		} 

		var stats = document.getElementById("STATS");
		if ( stats ) {
		
			var host = this.location.hostname;
			var proto = this.location.protocol;
			
			// make sure it the appropriate route to the stats single
			if (host.indexOf('local') != -1 || host.indexOf('ukaswast01') != -1) {
				// alert("Local");
				stats.src = "/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
			}
			else if (host.indexOf('uspt') !=-1 || host.indexOf('uspd') != -1 ) {
				// Dev and Test US Portal point to Test Web Hit Service
				// alert("Internal : Test or Dev");
				 stats.src = "http://ukrhwast01.euprod.travp.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
				//alert ("http://ukrhwast01.euprod.travp.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url);
				//stats.src = "http://ukaswast02.euprod.travp.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
			}
			else if (host.indexOf('uspp') !=-1 || host.indexOf('inside-international') != -1) {
				// Production internal calls e.g. Intranet call internal production Web Hit Service cluster
				//var sourceHost = (host.indexOf("test") > -1) ? "http://sptservices.euprod.travp.net" : "http://enterpriseapps.travp.net";
				//stats.src = sourceHost + "/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
				//stats.src = "http://sptservices.euprod.travp.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
				// alert("Internal : Prod");
				stats.src = "http://enterpriseapps.travp.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
			}
			else if(proto.indexOf('https:') != -1) {
			
				if (host.indexOf('test') != -1) {
					// alert("External : Secure : Test");
					stats.src = "https://www.test.internationalandlloyds.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
				}
				else {
					// alert("External : Secure : Prod");
					stats.src = "https://www.secure.internationalandlloyds.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
				}
				
			} else {
				// Public site
				if (host.indexOf('test') != -1) {
				// alert("External : Public : Test");
				stats.src = "http://www.test.internationalandlloyds.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
				}
				else {
					// alert("External : Public : Prod");
					stats.src = "http://www.internationalandlloyds.net/stats/statsSingle?BROWSER_TYPE="+completeVer+"&OPERATING_SYSTEM="+completeOs+"&PAGE_TITLE="+title+"&PRODUCT_CODE="+product+"&REMOTE_USER="+remoteUser+"&URL="+url;
				}				
			}
		}
	}
}

function accept(){
	var pageURL = this.location;
	var query = pageURL.search;
	var queryLength = query.length;
	var queryIndex = query.indexOf('&');
	var host = pageURL.hostname;
	//alert(queryIndex);
	//alert(query);
	if (queryIndex != -1) {
		var launchHost = (host.indexOf("test") > -1) ? "https://www.test.internationalandlloyds.net" : "https://www.secure.internationalandlloyds.net";
		var userreg = (host.indexOf("test") > -1) ? "/TeamStudio/CIAO/Project/userreg.nsf/UserRegOpenForm&" : "/webrealm/userreg.nsf/UserRegOpenForm&";
	
		// if there is a '&' just use the url from that point
		var queryType = query.substr(queryIndex+1,(query.length)-1);
		if (queryType == "login") {
			//window.open("https://www.secure.internationalandlloyds.net/wps/portal/trv", "Login");	
			window.open( launchHost+"/wps/portal/trv", "Login" );
		}
		else if (queryType.indexOf("register") != -1) {
			//var launchURL = "https://www.secure.internationalandlloyds.net/webrealm/userreg.nsf/UserRegOpenForm&"+queryType.substr((queryType.length)-3,(queryType.length)-1);
			var launchURL = launchHost + userreg + queryType.substr((queryType.length)-3,(queryType.length)-1);
			window.open(launchURL, "Register");
		}
	}
}


function launchDoc() 
{
	var pageURL = this.location;
	var query = pageURL.search;
	var doc ="";
	// alert(query);
	if (query != "")
	{
		doc = query.substr(1,(query.length)-1);
	//	alert(doc);
		window.open(doc);
		window.location="/iwcm/TRVUK/Home/index.shtm";
	}
}

function launchDocWith(aURL) 
{
	var pageURL = this.location;
	var query = pageURL.search;
	var doc ="";
	// alert(query);
	if (query != "")
	{
		doc = query.substr(1,(query.length)-1);
		// alert(doc);
		window.open(doc);
		window.location=aURL;
	}
}

function createRequestObject() 
	{
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer")
		{
		ro = new ActiveXObject("Microsoft.XMLHTTP");
		}
	else
		{
		ro = new XMLHttpRequest();
		}
	return ro;
	}

function refreshTimes() {
	getTimeList();
}

function getTimeList() 
	{
	http.open('get', '/resources/TimeService/TimeService.aspx');
	http.onreadystatechange = handleResponse;
	http.send(true);
	
	setTimeout("refreshTimes()",refreshInterval);
	}

function handleResponse() 
	{
	if(http.readyState == 4) 
		{
		var response = http.responseText;
		// update the page results
		document.getElementById("HTMLTimeResults").innerHTML = response;
		}
	}
	
function refreshStocks() {
	getStockList();
}
	
function getStockList() 
	{
	httpcurr.open('get', '/resources/StockService/StockService.aspx');
	httpcurr.onreadystatechange = handleStockResponse;
	httpcurr.send(true);
	
	setTimeout("refreshStocks()",refreshInterval);
	}

function handleStockResponse() 
	{
	if(httpcurr.readyState == 4) 
		{
		var response = httpcurr.responseText;
		// update the page results
		document.getElementById("HTMLCurrencyResults").innerHTML = response;
		}
	}
////////////////////////////////////

var msxmls = new Array( "Msxml2.XMLHTTP.5.0",
				        "Msxml2.XMLHTTP.4.0",
				        "Msxml2.XMLHTTP.3.0",
				        "Msxml2.XMLHTTP",
				        "Microsoft.XMLHTTP" );
var URL = "http://products.stockpoint.com/servlet/getQuotes?symbols=TRV";
var lookForStr = "new makeQuote(";
var lookForStrLen = lookForStr.length;

var refreshInterval = 60 * 1000;	// milliseconds

var xmlHttp;
var PRICE;
var CHANGE;

// Public method
function getCurrency()
{
	initXMLHttp();
	if (xmlHttp == null) {
		alert("Your browser does not support AJAX!");
		return null;
	}
	if (xmlHttp.readyState >0 && xmlHttp.readyState < 4) {
		alert("Processing previous request, please wait...");
		return;
	}
	//xmlHttp.onreadystatechange=parseCurrency;
	url = URL + "&dummy=" + new Date().getTime();
	try {
		if (navigator.appName == 'Netscape') {
			netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead UniversalBrowserWrite");
		}		
		xmlHttp.open("GET", url, false);
	} catch (e) {
		alert(e);
	}
	xmlHttp.send("");

	setTimeout("refreshCurrency()",refreshInterval);


	parseCurrency();
	
	if (CHANGE > 0) CHANGE = "+" + CHANGE;
	return "&nbsp;&nbsp; TRV   $" + PRICE + "<BR> &nbsp;&nbsp;&nbsp;(" + CHANGE + " Daily Change)";
	//return "TRV   $" + PRICE + ""
}

// Private method
function parseCurrency() {
	if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {	
		var response = xmlHttp.responseText;
		var i = response.indexOf(lookForStr) + lookForStrLen;
		response = response.substring(i);
		var values = response.split(",");

		try {
			PRICE = parseFloat(values[2]).toFixed(2);
		} catch (e) {
			PRICE = Math.round(values[2]*100)/100;
		}		
		try {
			CHANGE = parseFloat(values[3]).toFixed(2);
		} catch (e) {
			CHANGE = Math.round(values[3]*100)/100;
		}		
	}
}

function refreshCurrency() {
	document.getElementById("HTMLCurrencyResults").innerHTML = getCurrency();
}

// Private method
function initXMLHttp() {
	if (xmlHttp != null) {
		return xmlHttp;
	}
	if (window.XMLHttpRequest) {
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		// Internet Explorer
		for (var i = 0; i < msxmls.length; i++) {
			try {
				xmlHttp = new ActiveXObject(msxmls[i]);
				if (xmlHttp != null) break;
			} catch(e) {}
		}
	}
}
