betfair = top.betfair || {};
betfair.header = {};

top.constants_OPEN_SUB_MENU				="OpenSubMenu";
top.constants_MARKET_TYPE_COUPON_3RUNNER="Coupon_3Runner";
top.constants_MARKET_TYPE_COUPON_2RUNNER="Coupon_2Runner";
top.constants_MARKET_TYPE_ASIAN_COUPON	="Asian_Coupon";
top.constants_MARKET_TYPE_ASIAN			="Asian";
top.constants_MARKET_TYPE_LINE			="Line";
top.constants_MARKET_TYPE_RANGE			="Range";
top.constants_MARKET_TYPE_ODDS			="Odds";
top.constants_MINI_GAMES_MIN_MAX		="miniGamesCarouselMinMax";
top.constants_DISPLAY_MINI_GAMES_YN		="miniGamesDisplayCarousel";
top.constants_MINI_GAMES_ENABLED_YN		="miniGamesEnabled";
top.constants_SHOW_DEMO_HELP			="ShowDemoHelp";
top.constants_LAY_COLOUR_COOKIE			="LayColour";
top.constants_AUTO_REFRESH_COOKIE		="AutoRefresh";
top.constants_SHOW_HELP_COOKIE			="ShowHelp";
top.constants_USER_HISTORY_COOKIE		="userhistory";
top.constants_UI_VIEW_COMPACT			="COMPACT";
top.constants_UI_VIEW_EXCHANGE			="EXCHANGE";
top.constants_BSP_MD_COOKIE				="bspMD";
top.constants_BSP_LP_COOKIE				="bspLP";
top.constants_UI_VIEW_COOKIE			="UIView";
// copied from http://content-cache.betfair.com/scripts/launchDefinitions.js, required by subnav
betfair.header.launchDefs = {	
	"portal":			{frame: "Content",	url: "http://www.betfair.com/Frameset.do?target=portal"},
	"sports":			{frame: "Content",	url: "http://site.sports.betfair.com"},
	"games":			{frame: "Content",	url: "http://site.games.betfair.com"},
	"arcade":			{frame: "Content",	url: "http://site.arcade.betfair.com"},
	"poker":			{frame: "Content",	url: "http://site.poker.betfair.com"},
	"casino":			{frame: "Content",	url: "http://site.casino.betfair.com"},
	"forum":			{frame: "Content",	url: "http://www.betfair.com/Frameset.do?target=forum"},
	"extras":			{frame: "Content",	url: "http://www.betfair.com/Frameset.do?target=extras"},
	"financials":		{frame: "Content",	url: "http://www.betfair.com/Frameset.do?target=financials"},
	"financials_DE":	{frame: "Content",	url: "http://content.betfair.com/content/de/exchange/misc/financials.homepage.html"},
	"tote":				{frame: "Content",	url: "http://site.sports.betfair.com/?toteID=AUS",  search_crit: [{id: "toteID"}]},
	"multiplesaus":		{frame: "Content",	url: "http://site.multiples.au.betfair.com"},
	"soccer":			{frame: "top",		url: "http://soccer.betfair.com", primary_id: 1, secondary_id: 14},
	"tennis":			{frame: "top",		url: "http://tennis.betfair.com", primary_id: 2},
	"golf":				{frame: "top",		url: "http://golf.betfair.com", primary_id: 3},
	"cricket":			{frame: "top",		url: "http://cricket.betfair.com", primary_id: 4},
	"horseracing":		{frame: "top",		url: "http://horseracing.betfair.com", primary_id: 7, secondary_id: 13},
	"motorsport":		{frame: "top",		url: "http://motorsport.betfair.com", primary_id: 8},
	"greyhounds":		{frame: "top",		url: "http://greyhounds.betfair.com", primary_id: 4339, secondary_id: 15},
	"americanfootball":	{frame: "top",		url: "http://americanfootball.betfair.com", primary_id: 6423},
	"basketball":		{frame: "top",		url: "http://basketball.betfair.com", primary_id: 7522},
	"icehockey":		{frame: "top",		url: "http://icehockey.betfair.com", primary_id: 7524},
	"australianrules":	{frame: "top",		url: "http://australianrules.betfair.com", primary_id: 61420},
	"gaelicgames":		{frame: "top",		url: "http://gaelicgames.betfair.com", primary_id: 2152880},
	"multiples":		{frame: "top",		url: "http://multiples.betfair.com", search_crit: [{id: "mHome"}, {id: "mGID"}, {id: "mDID"}]}
};
// This file is a munge of window-popup spawn config data from
// http://content-cache.betfair.com/scripts/spawn_setup.js
// in order to assist backwards-compatibility temporarily
betfair.header.spawn_setup = (function() {
		
	var strCmsUrl 	= "http://"+betfair.defaults.contentDomain+"/",
		strPortalUrl= "http://"+betfair.defaults.topDomain+"/"+betfair.defaults.dimensionPath,
		strBrand 	= betfair.getBetexCompatibleDefaults().brandId,
		strRegion 	= betfair.getBetexCompatibleDefaults().regionId,
		strLocale 	= betfair.getBetexCompatibleDefaults().localeId;
			
	function getLanguage() {
		if (strLocale) {
			return "&" + "locale=" + strLocale + "&" + "region=" + strRegion + "&" + "brand=" + strBrand;
		} else {
			return "&" + "locale=" + parent.strLocale + "&" + "region=" + parent.strRegion + "&" + "brand=" + parent.strBrand;
		}
	}
	
	// "url" is used by old spawn component (from aspcms)  and "urlWM" by betfair.WindowManager
	var spawnWindowConfigs = {
		aboutUs: {
			url: strPortalUrl + "/aboutUs/",
			autoScroll: 0,
			height: 500,
			width: 788
		},
		affiliateScheme: {
			url: "http://affiliates."+document.domain+"/", 
			autoScroll: 1,
			height: 744,
			width: 1024
		},
		affiliateScheme_it: {
			url: "http://affiliates."+document.domain+"/", 
			autoScroll: 1,
			height: 744,
			width: 1024
		},
		affiliateScheme_zh: {
			url: "http://affiliates."+document.domain+"/", 
			autoScroll: 1,
			height: 744,
			width: 1024
		},
		affiliateScheme_zh_tw: {
			url: "http://affiliates."+document.domain+"/", 
			autoScroll: 1,
			height: 744,
			width: 1024
		},
		bigBrother: {
			url: "http://promo.betfair.com/bb/index.html",
			autoScroll: 1,
			height: 600,
			width: 800
		},
		betting: {
			url: "http://betting.betfair.com",
			autoScroll: 1,
			height: 650,
			width: 1000
		},
		brooke: {
			url: "http://www.thebrooke.org", 
			autoScroll: 1,
			height: 640,
			width: 800
		},
		calendar: {
			url: "http://tvguide.betfair.com/", 
			autoScroll: 1,
			height: 640,
			width: 1024
		},
		callback: {
			url: "http://promo.betfair.com/callback/comparison.asp", 
			autoScroll: 1,
			height: 600,
			width: 800
		},
		callback_zh: {
			url: "http://promo.betfair.com/callback/comparison_simp.asp", 
			autoScroll: 1,
			height: 600,
			width: 800
		},
		callback_zh_tw: {
			url: "http://promo.betfair.com/callback/comparison_trad.asp", 
			autoScroll: 1,
			height: 600,
			width: 800
		},
		casino: {
			constructUrl: {
				appName: "casino"
			},
		autoScroll: 1,
			height: 600,
			width: 800,
			statusBar: 1,
			menuBar: 1,
			toolbar: 1,
			locationBar: 1
		},
		championsLeagueMS_es: {
			url: "http://promo.betfair.com/ligadecampeones/", 
			autoScroll: 0,
			height: 600,
			width: 800
		},
		charity: {
			url: strPortalUrl + "/aboutUs/Charity.of.the.Year/", 
			autoScroll: 0,
			height: 500,
			width: 788
		},
		chineseForums: {
			url: "http://www.zzbf88.com/", 
			autoScroll: 1,
			height: 600,
			width: 800
		},
		cricketSC: {
			url: "http://scorecard.cricket.betfair.com/betfair/",
			autoScroll: 1,
			height: 600,
			width: 900
		},
		contactUs: {
			url: strPortalUrl + "/aboutUs/Contact.Us/", 
			autoScroll: 0,
			height: 500,
			width: 788
		},
		cyberPatrol: {
			url: "http://www.cyberpatrol.com", 
			autoScroll: 0,
			height: 768,
			width: 1024
		},
		demo: {
			url: "http://promo.betfair.com/learnbetfair?test=CMS",
			autoScroll:  1,
			height:  581,
			width:  650
		},
		demo_bg: {
			url: "http://promo.betfair.com/demo/index.asp?locale=bg&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_cz: {
			url: "http://promo.betfair.com/demo/index.asp?locale=cz&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_da: {
			url: "http://promo.betfair.com/demo/index.asp?locale=da&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_de: {
			url: "http://promo.betfair.com/demo/index.asp?locale=de&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_el: {
			url: "http://promo.betfair.com/demo/index.asp?locale=el&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_es: {
			url: "http://promo.betfair.com/demo/index.asp?locale=es&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_fi: {
			url: "http://promo.betfair.com/demo/index.asp?locale=fi&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_fr: {
			url: "http://promo.betfair.com/demo/index.asp?locale=fr&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_it: {
			url: "http://promo.betfair.com/demo/index.asp?locale=it&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_no: {
			url: "http://promo.betfair.com/demo/index.asp?locale=no&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_pl: {
			url: "http://promo.betfair.com/demo/index.asp?locale=pl&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_pt: {
			url: "http://promo.betfair.com/demo/index.asp?locale=pt&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_ru: {
			url: "http://promo.betfair.com/demo/index.asp?locale=ru&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_sv: {
			url: "http://promo.betfair.com/demo/index.asp?locale=se&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_tr: {
			url: "http://promo.betfair.com/demo/index.asp?locale=tr&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_zh: {
			url: "http://promo.betfair.com/demo/index.asp?locale=zh&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		demo_zh_tw: {
			url: "http://promo.betfair.com/demo/index.asp?locale=cn&test=CMS",
			autoScroll:  1,
			height:  460,
			width:  727
		},
		developers: {
			url: "http://bdp.betfair.com/", 
			autoScroll: 1,
			height: 640,
			width: 820
		},
		disclosure: {
			url: "http://promo.betfair.com/crm/disclosure.html", 
			autoScroll: 1,
			height: 640,
			width: 800
		},
		dsg: {
			url: strCmsUrl + "misc/?product=exchange&sWhichKey=DSG" + getLanguage(), 
			autoScroll: 0,
			height: 400,
			width: 440
		},
		dvd_el: {
			url: "http://promo.betfair.com/greek/greek.html",
			autoScroll:  0,
			height:  600,
			width:  800
		},
		faqs: {
			url: strCmsUrl + "faqs/?product=exchange" + getLanguage(),
			urlWM: "[[contentURL]]faqs/?product=exchange[[cookieInfo]]",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		football: {
			url: "http://football.betfair.com", 
			autoScroll: 1,
			height:  600,
			width:  800
		},
		gamCare: {
			url: strCmsUrl + "misc/?product=portal&sWhichKey=gamCare" + getLanguage(), 
			urlWM: "[[contentURL]]misc/?product=portal&sWhichKey=GamCare[[cookieInfo]]",
			autoScroll: 0,
			height: 500,
			width: 788
		},
		games: {
			constructUrl: {
				appName: "games"
			},
			autoScroll: 1,
			height: 600,
			width: 800,
			statusBar: 1,
			menuBar: 1,
			toolbar: 1,
			locationBar: 1
		},
		gba: {
			url: "http://www.growingbusinessawards.co.uk", 
			autoScroll: 0,
			height: 600,
			width: 800
		},
		greyhoundTV: {
			url: "http://form.greyhounds.betfair.com/racingform", 
			autoScroll: 1,
			height: 600,
			width: 840
		},
		help: {
			url: strPortalUrl + "/help/",
			autoScroll: 0,
			height: 500,
			width: 788
		},
		horseRacingAU: {
			url: "http://racing.betfair.com.au", 
			autoScroll: 1,
			height: 600,
			width: 840
		},
		ibas: {
			url: "http://www.ibas-uk.com/",
			autoScroll: 0,
			height: 600,
			width: 800
		},
		icra: {
			url: "http://www.icra.org/parents/", 
			autoScroll: 0,
			height: 640,
			width: 800
		},
		inPlayNews: {
			url: "http://promo.betfair.com/inplay/",
			autoScroll: 1,
			height: 600,
			width: 800
		},
		inPlayNews_bg: {
			url: "http://promo.betfair.com/cee/newsletter/bgindex.htm",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		inPlayNews_cz: {
			url: "http://promo.betfair.com/cee/newsletter/czindex.htm",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		inPlayNews_pl: {
			url: "http://promo.betfair.com/cee/newsletter/poindex.htm",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		jobs: {
			url: strPortalUrl + "/aboutUs/Jobs/",
			autoScroll: 0,
			height: 600,
			width: 788
		},
		joinNow: {
			constructUrlWithPath: {
				appName: "account",
				pathName: "openaccount",
				isSecure: true
			},
			extraParams: "?origin=[[1]][[2]]",
			autoScroll: 1,
			height: 700,
			width: 738
		},
		JoinNow: {
			constructUrlWithPath: {
				appName: "account",
				pathName: "openaccount",
				isSecure: true
			},
			extraParams: "?origin=[[1]][[2]]",
			autoScroll: 1,
			height: 700,
			width: 738
		},
		knowledge: {
			url: "http://betting.betfair.com.au",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		knowledge_pl: {
			url: "http://www.betfairinfo.pl",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		kycBetfair: {
			url: "http://kyc.betfair.com",
			autoScroll: 0,
			height: 500,
			width: 788
		},
		labs: {
			url: "http://labs.betfair.com/labs.aspx",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		lba_malta: {
			url:"http://www.lga.org.mt/lga/home.aspx",
			autoScroll: 1,
			height: 600,
			width: 800
		},
		livescore: {
			url: "http://www.livescore.betradar.com/?alias=betfair",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		livescore_el: {
            url: "http://stoixhma.betfair.gr/live-scores",
            autoScroll: 1,
            height:  600,
            width:  800
		},
		livescore_bg: {
            url: "http://www.livescore.betradar.com/multicast/?alias=betfair&language=bg",
            autoScroll: 1,
            height:  600,
            width:  800
        },
		"Betfairfootball": {
			"url": "http://www.betfairfootball.com", 
			"autoScroll": 1,
			"height":  640,
			"width":  1024
		},
		"livescore": {
			"url": "http://www.livescore.betradar.com/?alias=betfair&language=" + ("zh" == "cz" ? "cs" : "zh"),
			"autoScroll": 1,
			"height":  600,
			"width":  800
		},
		"betfairRadio": {
			"url": "http://radio.betfair.com",
			"autoscroll": false,
			"dimensions": {"X": 405, "Y": 480}
		},
		"footballForm": {
			"url": "http://www.stats.betradar.com/statistics/betfaircom/?language=" + ("zh" == "cz" ? "cs" : "zh"),
			"autoscroll": false,
			"dimensions": {"X": 405, "Y": 480}
		},
		"footballForm_zh": {
			"url": "http://www.stats.betradar.com/statistics/betfaircom/?language=zh",
			"autoscroll": false,
			"dimensions": {"X": 405, "Y": 480}
		},
		"footballForm_zhtw": {
			"url": "http://www.stats.betradar.com/statistics/betfaircom/?language=zht",
			"autoscroll": false,
			"dimensions": {"X": 405, "Y": 480}
		},
		liveStreaming: {
			url: "http://livevideo.betfair.com/",
			autoScroll: 1,
			height: 670,
			width: 950
		},
		marketResults: {
			url: "http://www.betfair.com/",
			autoScroll: 0,
			height: 600,
			width: 800
		},
		microsite_bg: {
			url: "http://promo.betfair.com/bulgaria/",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		microsite_cz: {
			url: "http://www.betfairinfo.cz/",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		microsite_pl: {
			url: "http://promo.betfair.com/polish/",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		minigamesHelp: {
			url: strCmsUrl + "minigames/frameset.asp?product=exchange" + getLanguage(),
			autoScroll: 1,
			height: 500,
			width: 788
		},
		minigamesRules: {
			url: strCmsUrl + "minigames/frameset.asp?sWhichKey=${sWhichKey}&product=exchange" + getLanguage(),
			autoScroll: 1,
			height: 500,
			width: 788
		},
		mobile: {
			url: "http://mobile.betfair.com/",
			autoScroll: 1,
			height: 650,
			width: 800
		},
		mobile_tr: {
			url: "http://promo.betfair.com/turkey/mobile/", 
			autoScroll: 0,
			height: 600,
			width: 800
		},
		netNanny: {
			url: "http://www.netnanny.com",
			autoScroll: 1,
			height: 768,
			width: 1024
		},
		payments: {
			url: "http://payments.betfair.com",
			autoScroll: 1,
			height: 600,
			width: 800
		},
		payments_bg: {
			url: "http://promo.betfair.com/cee/payments/bgpayment.html",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		payments_cz: {
			url: "http://promo.betfair.com/CEE/payments/czpayment.html",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		payments_da: {
			url: "http://promo.betfair.com/intpayments/payment_dk.htm",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		payments_de: {
			url: "http://promo.betfair.com/sports/de/payments/index.htm",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		payments_el: {
			url: "http://promo.betfair.com/greece/payment/",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		payments_es: {
			url: "http://promo.betfair.com/intpayments/payment_sp.htm",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		payments_fi: {
			url: "http://promo.betfair.com/intpayments/payment_fin.htm",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		payments_it: {
			url: "http://promo.betfair.com/italia/payment.aspx?norfr=1&mID=2",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		payments_no: {
			url: "http://promo.betfair.com/intpayments/payment_no.htm",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		payments_pl: {
			url: "http://promo.betfair.com/CEE/payments/popayment.html",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		payments_pt: {
		    url: "http://promo.betfair.com/promocao/payment.html",
		    autoScroll:  1,
		    height:  600,
		    width:  800                                          
		},
		payments_ru: {
			url: "http://promo.betfair.com/CEE/payments/rupayment.html",
			autoScroll:  1,
			height:  500,
			width:  860			
		},
		payments_sv: {
			url: "http://promo.betfair.com/intpayments/payment_sw.htm",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		payments_tr: {
			url: "http://promo.betfair.com/season06/turkishb/payment.html",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		payments_zh: {
			url: "http://promo.betfair.com/Payment_Asia88_SC.htm",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		payments_zh_TW: {
			url: "http://promo.betfair.com/Payment_Asia88_tC.htm",
			autoScroll:  1,
			height:  600,
			width:  800			
		},
		playForFun: {
			url: "http://www.playbetfair.com/",
			autoScroll: 0,
			height: 620,
			width: 800
		},
		playForFun_de: {
			url: "http://www.playbetfair.com/?_lang=gm",
			autoScroll:  0,
			height:  620,
			width:  800
		},
		playForFun_it: {
			url: "http://www.playbetfair.com/?_lang=it",
			autoScroll:  0,
			height:  620,
			width:  800
		},
		playForFun_tr: {
			url: "http://www.playbetfair.com/?_lang=tk",
			autoScroll:  0,
			height:  620,
			width:  800
		},
		playForFun_zh: {
			url: "http://www.playbf88.com",
			autoScroll:  0,
			height:  620,
			width:  800
		},
		poker: {
			constructUrl: {
				appName: "poker"
			},
		autoScroll: 1,
			height:  600,
			width:  800,
			statusBar: 1,
			menuBar: 1,
			toolbar: 1,
			locationBar: 1
		},
		preview: {
			url: "http://preview.betfair.com/",
			autoScroll: 1,
			height: 700,
			width: 960
		},
		priceComparison: {
			url: "/PriceComparisonTop100.do?origin=news",
			autoScroll: 1,
			height:  600,
			width:  800,
			statusBar: 1
		},
		privacyPolicy: {
			url: strPortalUrl + "/aboutUs/Privacy.Policy/",
			autoScroll: 0,
			height: 600,
			width: 788
		},
		queens: {
			url: strPortalUrl + "/aboutUs/", 
			autoScroll: 0,
			height: 600,
			width: 788
		},
		quickbet: {
			url: "http://altfarm.mediaplex.com/ad/ck/7778-42351-16606-59", 
			autoScroll: 1,
			height: 750,
			width: 850
		},
		racing: {
			url: "http://racing.betfair.com", 
			autoScroll: 1,
			height:  600,
			width:  800
		},
		racingForm: {
			url: "http://horseracing.betfair.com/form", 
			autoScroll: 1,
			height:  768,
			width:  1024
		},
		racingpost: {
			url: "http://www.racingpost.co.uk",
			menuBar: 1,
			toolbar: 1,
			autoScroll: 1,
			locationBar: 1,
			height: 600,
			width: 800
		},
		radio: {
			url: "http://betfair.mediaondemand.net/",
			urlWM: "[[radioURL]]",
			autoScroll: 0,
			height: 480,
			width: 405
		},
		referAFriend: {
			url: "http://www.referandearn.com/",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		referAndEarn: {
			url: "http://www.referandearn.com/",
			autoScroll:  1,
			height:  600,
			width:  850
		},
		referAndEarn_bg: {
			url: "http://referandearn.betfair.com/sports/index.html?language=bg",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		referAndEarn_cz: {
			url: "http://www.referandearn.com/index.cz.html",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		referAndEarn_de: {
			url: "http://www.referandearn.com/index.de.html",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		referAndEarn_es: {
			url: "http://www.referandearn.com/index.es.html",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		referAndEarn_it: {
			url: "http://www.referandearn.com/index.it.html",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		referAndEarn_no: {
			url: "http://www.referandearn.com/index.no.html",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		referAndEarn_pl: {
			url: "http://www.referandearn.com/index.pl.html",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		referAndEarn_pt: {
			url: "http://www.referandearn.com/index.pt.html",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		referAndEarn_ru: {
			url: "http://www.referandearn.com/index.ru.html",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		referAndEarn_sv: {
			url: "http://www.referandearn.com/index.sv.html",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		referAndEarn_tr: {
			url: "http://www.referandearn.com/index.tr.html",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		referAndEarn_zh: {
			url: "http://www.referandearn.com/index.zh.html",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		referAndEarn_zh_tw: {
			url: "http://www.referandearn.com/index.zh_TW.html",
			autoScroll:  1,
			height:  600,
			width:  800
		},
		responsibleGambling: {
			url: strCmsUrl + "misc/?product=portal&sWhichKey=ResponsibleGambling" + getLanguage(),
			urlWM: "[[contentURL]]misc/?product=portal&sWhichKey=ResponsibleGambling[[cookieInfo]]",
			autoScroll: 1,
			height: 650,
			width: 640
		},
		safeSecure: {
			url: "http://promo.betfair.com/php/secure.htm",
			autoScroll: 1,
			height: 500,
			width: 400
		},
		soccerMS_de: {
			url: "http://betting.betfair.com/de/fussball", 
			autoScroll: 1,
			height: 600,
			width: 800
		},
		solutions: {
			url: "http://solutions.betfair.com/", 
			autoScroll: 1,
			height: 600,
			width: 800
		},
		sportsNews: {
			url: "http://www.betfair.com/", 
			autoScroll: 1,
			height: 600,
			width: 800
		},
		sun: {
			url: "http://uk.sun.com/",
			autoScroll: 1,
			height: 640,
			width: 860
		},
		taikai: {
			url: "http://taikai.betfair.com/",
	                     locationBar: 1,
	                     menuBar: 1,
	                     toolbar: 1,
			autoScroll: 1,
			height: 768,
			width: 1024
		},
		tennisZone: {
			url: "http://form.tennis.betfair.com/tennis",
			autoScroll: 1,
			height: 600,
			width: 900
		},
		terms: {
			url: strPortalUrl + "/aboutUs/Terms.and.Conditions/",
			autoScroll: 0,
			height: 500,
			width: 788
		},
		termsArcade: {
			url: strPortalUrl + "/aboutUs/Terms.and.Conditions/#arcade",
			autoScroll: 0,
			height: 500,
			width: 788
		},
		tgc: {
			url: strPortalUrl + "/aboutUs/Dispute.Resolution/",
			autoScroll: 1,
			height: 500,
			width: 788
		},
		tradingMS_es: {
			url: "http://promo.betfair.com/apuestas/", 
			autoScroll: 1,
			height: 600,
			width: 800
		},
		turftrax: {
			url: "http://www.turftrax.com",
			autoScroll: 0,
			menuBar: 1,
			toolbar: 1,
			autoScroll: 1,
			locationBar: 1,
			height: 600,
			width: 800
		},
		tv: {
			url: "http://www.betfair.tv/",
			autoScroll: 1,
			height: 600,
			width: 820
		},
		tv_bg: {
			url: "http://www.betfair.tv/region/bulgaria",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_cz: {
			url: "http://www.betfair.tv/region/czech",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_da: {
			url: "http://www.betfair.tv/region/denmark",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_de: {
			url: "http://www.betfair.tv/region/germany",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_el: {
			url: "http://www.betfair.tv/region/greece",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_es: {
			url: "http://www.betfair.tv/region/es",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_fi: {
			url: "http://www.betfair.tv/region/finland",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_irl: {
			url: "http://www.betfair.tv/region/ireland",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_it: {
			url: "http://www.betfair.tv/region/italy",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_na: {
			url: "http://www.betfair.tv/region/canada",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_new: {
			url: "http://tvguide.betfair.com/",
			autoScroll: 1,
			height: 640,
			width: 1024
		},
		tv_no: {
			url: "http://www.betfair.tv/region/norway",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_pl: {
			url: "http://www.betfair.tv/region/poland",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_pt: {
			url: "http://www.betfair.tv/region/portugal",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_ru: {
			url: "http://www.betfair.tv/region/russia",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_sv: {
			url: "http://www.betfair.tv/region/sweden",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_tr: {
			url: "http://www.betfair.tv/region/tr",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_zaf: {
			url: "http://www.betfair.tv/region/rsa",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_zh: {
			url: "http://www.betfair.tv/region/seasiazh/?origin=H",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		tv_zh_tw: {
			url: "http://www.betfair.tv/region/seasiazhtw",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		uktote: {
			url: "http://uktotezone.betfair.com/tote/",
			autoScroll: 1,
			height:  600,
			width:  800
		},
		verisign: {
			url: "https://seal.verisign.com/splash?form_file=fdf/splash.fdf&dn=www.betfair.com",
			autoScroll: 1,
			height: 450,
			width: 540
		},
		eighteenPlus: {
			url: strCmsUrl + "misc/?product=portal&sWhichKey=gamCare&locale=en_GB",
			autoscroll: 0,
			height: 500,
			width: 788
		},
		gamCare: {
			url: "http://www.gamcare.org.uk/",
			autoscroll: 0,
			height: 720,
			width: 870
		},
		gamTherapy: {
			url: "http://www.gamblingtherapy.org/?ReferrerID=103",
			autoscroll: 0,
			height: 640,
			width: 1024
		},
		lga: {
			url:"http://www.lga.org.mt/lga/home.aspx",
			autoScroll: 1,
			height: 600,
			width: 800
		},
		
		//new configs migrated from window manager
		"aboutUsTermsAndConditions": {
			"urlWM": "[[portalDomain]]/aboutUs/Terms.and.Conditions/",
			"autoscroll": false,
			"dimensions": {"X": 788, "Y": 500}
		},
		"ageRestriction": {
			"urlWM": "[[myaccountDomain]]/account/registration/AgeRestriction.do",
			"autoscroll": false,
			"dimensions": {"X": 300, "Y": 250}
		},
		"betfairOverview": {
			"urlWM": "http://promo.betfair.com/demo/index.asp?locale=[[1]]",
			"autoscroll": true,
			"dimensions": {"X": 730, "Y": 480}
		},
		"bettingGuide": {
			"urlWM": "[[contentURL]]downloads/[[locale]]/Betfair_Guide_to_Betting.pdf",
			"autoscroll": false,
			"dimensions": {"X": 800, "Y": 600}
		},
		"cardCountries": {
			"urlWM": "[[myaccountDomain]]/myaccount/payment/CardCountries.do",
			"autoscroll": false,
			"dimensions": {"X": 270, "Y": 420}
		},
		"cmsContactUs": {
			"urlWM": "[[portalDomain]]/aboutUs/Contact.Us/",
			"autoscroll": false,
			"dimensions": {"X": 788, "Y": 500}
		},
		"commission": {
			"urlWM": "[[portalDomain]]/help/Help.Managing.Account/#CommissionPoints",
			"autoscroll": false,
			"dimensions": {"X": 788, "Y": 500}
		},
		"cvv2": {
			"urlWM": "[[myaccountDomain]]/myaccount/payment/Cv2.do",
			"autoscroll": false,
			"dimensions": {"X": 470, "Y": 380}
		},
		"deepMarketLink": {
			"urlWM": "http://[[singlesDomain]][[1]]",
			"autoscroll": false,
			"dimensions": {"X": 788, "Y": 500}
		},
		"deposit": {
			"urlWM": "[[myaccountDomain]]/myaccount/payment/CardDeposit.do?formaction=form",
			"autoscroll": false,
			"dimensions": {"X": 788, "Y": 500}
		},
		"exchangePokerGameHistory": {
			"urlWM": "[[myaccountDomain]]/exchangepoker/LoadExchangePokerHistoryAction.do[[1]]",
			"autoscroll": false,
			"dimensions": {"X": 788, "Y": 500}
		},
		"exchangeWebHomePage": {
			"urlWM": "[[singlesDomain]]",
			"autoscroll": false,
			"dimensions": {"X": 800, "Y": 600},
			"statusBar": true,
			"menuBar": true,
			"toolbar": true
		},			
		"forum": {
			"url": "http://community."+document.domain+"/go/forum/popup?output_method=iframe&base_url=http://community."+document.domain+"/service&type=forum&category=94166&xref=165814", 
			"autoscroll": true,
			"dimensions": {"X": 788, "Y": 500}
		},
		"forgottenPassword": {
			"constructUrlWithPath": {
				"appName": "portal",
				"pathName": "lostpasswd"
			},
			"autoscroll": false,
			"dimensions": {"X": 788, "Y": 500}
		},
		"marketUnavailable": {
			"url": "/MarketUnavailable.do",
			"autoscroll": false,
			"dimensions": {"X": 600, "Y": 400}
		},
		"myAccountHeader": {
			"constructUrlWithPath": {
				"appName": "portal",
				"pathName": "myaccount"
			},
			"autoscroll": false,
			"dimensions": {"X": 788, "Y": 575},
			"statusBar": false
		},
		"myAccount": {
			"urlWM": "[[myaccountDomain]]/myaccount/account/MyAccount.do[[1]][[2]][[3]]",
			"autoscroll": false,
			"dimensions": {"X": 788, "Y": 575},
			"statusBar": false
		},
		"myAccountAgeVerification": {
			"constructUrlWithPath": {
				"appName": "portal",
				"pathName": "myaccount",
				"isSecure": true
			},
			"extraParams": "?tabID=15",
			"autoscroll": false,
			"dimensions": {"X": 788, "Y": 575},
			"statusBar": false
		},
		"myAccountFromRegistration": {
			"urlWM": "[[1]][[2]]",
			"autoscroll": false,
			"dimensions": {"X": 788, "Y": 575},
			"statusBar": false
		},
		"myCasinoAcc": {
			"constructUrlWithPath": {
				"appName": "casino",
				"pathName": "mycasinoaccount"
			},
			"autoscroll": true,
			"dimensions": {"X": 700, "Y": 535}
		},
		"myCasinoAccTransfer": {
			"constructUrlWithPath": {
				"appName": "casino",
				"pathName": "popLogoutTx"
			},
			"autoscroll": true,
			"dimensions": {"X": 800, "Y": 600}
		},
		"myGamesAcc": {
			"constructUrlWithPath": {
				"appName": "games",
				"pathName": "mygamesaccount"
			},
			"autoscroll": false,
			"dimensions": {"X": 700, "Y": 535}
		},
		"netellerWithdrawalHelp": {
			"urlWM": "[[myaccountDomain]]/myaccount/payment/netellerWithdrawalHelp.do",
			"autoscroll": false,
			"dimensions": {"X": 470, "Y": 280}
		},
		"newHelp": {
			"urlWM": "[[1]]",
			"autoscroll": false,
			"dimensions": {"X": 788, "Y": 500}
		},
		"oddsEquivalent": {
			"urlWM": "[[1]]",
			"autoscroll": false,
			"dimensions": {"X": 700, "Y": 500}
		},
		/* similar with joinNow*/
		"openAcc": {
			"constructUrlWithPath": {
				"appName": "account",
				"pathName": "openaccount",
				"isSecure": true
			},
			"extraParams": "?origin=[[1]][[2]]",
			"autoscroll": true,
			"dimensions": {"X": 738, "Y": 700}
		},
		"securityMsg": {
			"urlWM": "[[contentURL]]misc/?product=portal&sWhichKey=Security[[cookieInfo]]",
			"autoscroll": 0,
			"dimensions": { "X": 400, "Y": 350}
		},
		"timeform": {
			"urlWM": "[[timeFormURL]]",
			"autoscroll": true,
			"dimensions": {"X": 800, "Y": 600}
		},
		"trustDeed": {
			"urlWM": "[[portalDomain]]/aboutUs/Trust.Deed/",
			"autoscroll": false,
			"dimensions": {"X": 788, "Y": 500 }
		},
		"video": {
			"urlWM": "[[videoURL]]",
			"extraParams": "?Default.do?eID=[[2]]",
			"autoscroll": true,
			"dimensions": {"X": 920, "Y": 650 }
		},			
		"walletTransfer": {
			"urlWM": "[[1]]?transfer=1",
			"autoscroll": true,
			"dimensions": {"X": 520, "Y": 420 }
		}
	};
	
	function spawnWindowNames() {
		var mockWindow 	= { close: function() { } },
			windowNames = {};			
		for (var swn in spawnWindowConfigs) {
			windowNames[swn] = mockWindow;
		}
		return windowNames;
	}
	
	return {
		"spawnWindowConfigs": spawnWindowConfigs,
		"spawnWindowNames": spawnWindowNames()
	};
})();

betfair.header.FunctionMappings = (function() {
	
	function logoutMapping() {
		if (window.parent) {
			try {				 
				window.parent.betfair.Account.Logout.finalise();
			} catch (e) {
				var iframe = document.createElement("iframe");
				iframe.src = "http://"+betfair.defaults.myaccountDomain+"/account/login/Logout.do";	// force logout server-side
				document.body.appendChild(iframe);
			}
			betfair.Events.custom.Navigation.logoutRedirect.fire(true);
		}
	}
	
	function getWindow(popupName, url, autoScroll, height, width, statusBar, menuBar, toolbar, locationBar) {
		var windowConfig = {
			autoscroll: autoScroll,
			dimensions: { X : width, Y: height },
			statusBar: statusBar,
			menuBar: menuBar,
			toolbar: toolbar,
			locationBar: locationBar
		};
		return betfair.WindowManager.getWindow(popupName, url, windowConfig);
	};
	
	function getCollecton() {
		return betfair.header.spawn_setup.spawnWindowNames;
	}
	
	function displayMoreInfo(eventId, selectionId, asianLineId, exchangeID, sOrigin) {
		var baseURL = "http://"+betfair.Config.products[exchangeID].subdomain;
		var params = [
			"marketId=" + eventId,
			"selectionId=" + selectionId
		];
		if (asianLineId) {
			params.push("asianLineId=" + asianLineId);
		}
		if (sOrigin) {
			params.push("origin=" + sOrigin);
		}
		spawn('moreInfoChart', '?'+params.join('&'), baseURL);
	}
	
	function getContentFrame() {
		return top.frames['Content'];
	}
	
	function getSubNavFrame() {
		try {
			return getContentFrame().frames['SubNav'];
		}
		catch(x) {

		}
	}
		
	function getSubNavCmsFrame(){
		try {
			return getSubNavFrame().frames['SubNavCMS'];
		}
		catch(x) {

		}
	}
	
	function getCurrentUser() {
		// user now as sparse as possible see old Portal-Web: var oUser = interfaces_getNewUser
		var userLoginState = betfair.User.getLoginState();
		return {
			'loggedIn': (userLoginState === "loggedIn"),
			'preferences': { "displayMyMarketsDefault" : betfair.User.getData("preferences.displayMyMarketsDefault") || false } 
		}; // known uses
	}
	
	function getUserState(user) {
		if (user) {
			return user.loggedIn;
		}
		return null;
	}

	function changeLanguage(e) {
		if(!e) {e = this;}
		var target = e.target || e; // e for sports.
		var value = target.options[target.selectedIndex].value;
		if (!value || value === "") { return; }
		value = value.replace(/en_[a-zA-Z]+,/, betfair.getBetexPtkDefaults().localeId+',')
					 .replace(','+betfair.getBetexPtkDefaults().regionId, '')
					 .replace(betfair.getBetexPtkDefaults().localeId+',', '');
		betfair.Events.custom.Navigation.changeLocalisation.fire(value);
	}
	
	function getHelpKey(key, sAnchor) {
		spawn('help', key, sAnchor);
	}
	
	function launchMyAccount(iTabID, bLogOutOption, productId) {
		var sArgument1 = "";
		var sArgument2 = "";
		var sArgument3 = "";
		if (iTabID && iTabID!=null && iTabID!="") {
			sArgument2 = "?tabID="+iTabID;
			if (productId && ((productId % 1) === 0)) { // is a number
			    sArgument2 += "&ex=" + productId;
			}
		}
		
		if (bLogOutOption && bLogOutOption!=null && bLogOutOption!="") {
			sArgument3 = "&logout="+bLogOutOption;
			spawn('myAccount', sArgument1, sArgument2, sArgument3);
		} else if (spawn('myAccount', sArgument1, sArgument2, sArgument3)) {
			try {
	            spawn('myAccount', sArgument1, sArgument2, sArgument3).switchTabs(iTabID);
			}
			catch(x){}
		}
	}
	
	function sessionTimeOut(localisedMessage) {
		if (localisedMessage && (typeof localisedMessage === "string")) {
			alert(localisedMessage);
			logoutMapping();
		}
	}
	
	function fireWalletRefreshRequest() {
		try{
			betfair.Events.custom.Wallet.refresh.fire();
		} catch(e) {
		}
	}
	
	// SFE-435
	function setTargets(target) {
		if (!target) { return; }
		if (!betfair.header.launchDefs[target]) {
			var sportLocated = false;
			var launchDefs = betfair.header.launchDefs;
			for (var i in launchDefs) {
				if ((launchDefs[i].primary_id != null && launchDefs[i].primary_id === target) || (launchDefs[i].secondary_id != null && launchDefs[i].secondary_id === target)) {
					target = i;
					sportLocated = true;
					break;
				}
			}
			if (!sportLocated) {
				target = "sports";
			}
		}
		top.header.setSubnav(target);
		//top.betfair.Navigation.subNav.setSubNavVisibility(target);
	}
	
	return {
		"refreshFunds":					fireWalletRefreshRequest,
		"displayMoreInfo": 				displayMoreInfo,
		"logoutFunction": 				logoutMapping,		
		"getHelpKey":					getHelpKey,
		"launchMyAccount":				launchMyAccount,
		"sessionTimeOut":				sessionTimeOut,
		"interfaces_changeLanguage":	changeLanguage,
		"interfaces_getWindow": 		getWindow,
		"interfaces_getCollection": 	getCollecton,
		"interfaces_getContentFrame": 	getContentFrame,
		"interfaces_getSubNavFrame": 	getSubNavFrame,
		"interfaces_getSubNavCmsFrame": getSubNavCmsFrame,
		"interfaces_getCurrentUser": 	getCurrentUser,
		"interfaces_getUserState":		getUserState,
		"Nav": {
			"popupWindowConfig": betfair.header.spawn_setup.spawnWindowConfigs,
			"setTargets": setTargets,
			"launchDefs": betfair.header.launchDefs
			// more functions might go here
		},
		"interfaces_switchProduct":	betfair.Wallet.updateWalletDisplay
	};
})(); 