	IG.util.Site = {
			CalHeaders: ("Date,Heure,Pays,Annonce,Période,Estimations,Précédemment").split(","),
			CalWidths: ("50,25,143,120,95,95").split(","),
			Locale : (gE("locale"))?gE("locale").getAttribute("content").toLowerCase():'en_GB',
			CaseLocale : (gE("locale"))?gE("locale").getAttribute("content"):'en_GB',
			SoftId : (gE("softid"))?gE("softid").getAttribute("content").toLowerCase():null,
			DealerPath : (gE("dealer_path"))?gE("dealer_path").getAttribute("content").toLowerCase():null,
			DVer : (gE("dver"))?gE("dver").getAttribute("content").toLowerCase():null,
			Page : window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1),
			convertCode : function(s) { 
					s = s.replace(/&#(\d{3});/g,function(r,r1) {return String.fromCharCode(r1);});
					s = s.replace(/&#(\d{4});/g,function(r,r1) {return String.fromCharCode(r1);});
					return s.replace(/&#(\d{5});/g,function(r,r1) {return String.fromCharCode(r1);});
				},
			environment : ((/^http:\/\/([^.\/$]*)./.test(d.location.href)) && (RegExp.$1 == "net" || RegExp.$1 == "web" || RegExp.$1 == "new" || RegExp.$1 == "www" || RegExp.$1 == "staging"))? RegExp.$1 : null,
			goTo : function(s){
				if(document.selectLanguage){
					var of = document.selectLanguage;
					of.action = s;
					of.submit();
				} else {
					window.location.href = s;
				}
			},
			getEventTarget : function(e) {
				 e = e || window.event;
				 var targ = e.target || e.srcElement;
				 if (targ.nodeType == 3) { // defeat Safari bug
							targ = targ.parentNode;
				 }
				 return targ;
			},
			onload: function(){
				IG.util.Site.Id = gT("body")[0].id;
				IG.util.Site.Title = gT("title")[0].innerHTML;
				IG.util.Site.Body = gT("body")[0];
			}
	};

	/*
	   ********   			LOCAL SETTINGS 				********
		**																	**
		**			EVERYTHING BELOW NEEDS TO BE UPDATED 		**
		**																	**
	   ********   												********
	*/

    IG.util.slideImages = [["/img/puredeal_software_01.jpg", "", ""],["/img/puredeal_software_02.jpg", "", ""],["/img/puredeal_software_03.jpg", "", ""]];

	IG.util.TourPause  = function(strPage){
		switch(strPage){
			case 'customisable-interface.html' : 
			case 'market-leading-charts.html' :
			case 'price-improvement.html' :
			case 'reuters-news-service.html' :
			case 'customisable-interface-2.html' : 
			case 'customisable-interface-3.html' : 
			case 'deal-in-a-single-click.html' : 
			case 'find-your-market.html' :
			case 'find-your-market-2.html' :
			case 'flexible-ordering.html' :
			case 'market-leading-charts-2.html' :
			case 'market-leading-charts-3.html' :
			case 'market-leading-charts-4.html' :
			case 'market-leading-charts-5.html' :
			case 'market-leading-charts-6.html' :
			case 'market-leading-charts-7.html' :
			case 'phone-online-help.html' :
			case 'reuters-news-service-2.html' :
			case 'manage-your-account.html' :
			case 'quality-research.html' :
			case 'quality-research-2.html' :
				return 9000; 
				break;
			case 'deal-as-normal.html' : 
			case 'full-ordering-facility.html' :
			case 'full-range-of-markets.html' :
			case 'mobile-dealing-tour.html' :
			case 'monitor-your-portfolio.html' :
				return 10000;
				break;
		}
	};
	
	
	IG.util.TrackerCode = function(strLocale){
			switch (strLocale){
				case 'en_gb':
					return 'wwwlumenGB'; //en_gb
				 default:
					return 'wwwlumenGB';
			}
	};
	
	IG.util.InsertFlashSWF = function(strPage){
		var strLocale = gE("locale").getAttribute("content");
		IG.util.InsertFlash.height = 255;
		IG.util.InsertFlash.width = 480;
		switch (strPage){
			case 'online-dealing-tour.html':
			case 'at-a-glance.html':
			case 'quick-tour.html':
				IG.util.InsertFlash.get_gif = 'demo_flash_backup1.gif';
				return "intro.swf";
			case 'quick-tour-new.html':
				IG.util.InsertFlash.get_gif = 'demo_flash_backup1.gif';
				return "intro.swf";				
			case 'at-a-glance-1.html':
				IG.util.InsertFlash.get_gif = 'demo_flash_backup2.gif';
				return "price.swf";
			case 'at-a-glance-2.html':
				IG.util.InsertFlash.get_gif = 'demo_flash_backup3.gif';
				return "one_click.swf";
			case 'at-a-glance-3.html':
				IG.util.InsertFlash.get_gif = 'demo_flash_backup4.gif';
				return "finder3.swf";
			case 'at-a-glance-4.html':
				IG.util.InsertFlash.get_gif = 'demo_flash_backup5.gif';
				return "charts2.swf";
			case 'at-a-glance-5.html':
				IG.util.InsertFlash.get_gif = 'demo_flash_backup6.gif';
				return "reuters.swf";
			case 'at-a-glance-6.html':
				IG.util.InsertFlash.get_gif = 'demo_flash_backup7.gif';
				return "trading.swf";
		   case 'puredeal-resources.html':
				IG.util.InsertFlash.get_gif = 'bg_Resources_Home.jpg';
				IG.util.InsertFlash.width = 480;
				IG.util.InsertFlash.height = 230;
				return "resources-1.swf";
			case 'home.html':
				var gif='hp_banner.gif';
				var swf = 'lum_' + strLocale + '_banner.swf';
				var Link = '/cfd/at-a-glance.html';

				IG.util.InsertFlash.height = 173;
				IG.util.InsertFlash.get_gif = gif;
				IG.util.InsertFlash.get_link = Link;
				return swf;
		}
	};
	
	IG.util.OpenPopUp = 	function(s, t){
		var win;
		var pup = IG.util.PopUp;
		var browser = IG.util.Browser;
			switch(t) {
				case "help":
					win = pup.openWindow(s, "Help", 660, 500, 0, 0, 0);
					break;
		
				case "mmb":
					win = pup.openWindow(s, "MMB", 630, 529, 0, 0, 0);
					break;
		
				case "infotable":
					win = pup.openWindow(s, "infotable", 780, 520, 0, 0, 1);
					break;
				
				case "request_infopack":
					win = pup.openWindow(s, "request_infopack", 470, 670, 0, 0, 0);
					break;
					
				case "mobilePopup":
					win = pup.openWindow(s, "mobilePopup", 240, 374, 0, 0, 0);
					break;
		
				case "stock_listing":
					win = pup.openWindow(s, "stock_listing", 250, 529, 0, 0, 0);
					break;
				
				case "appform":
					if (s.indexOf('http://')>=0){
						s = s.replace("http://","https://") +"&secure=true";
					} else {
						s = "https://" + location.hostname + s +"&secure=true";
					}
					var safariChromeX = (browser.name == "safari") ? -1 : 0;
					var safariChromeY = (browser.name == "safari") ? 15 : 0;
					if(browser.op && browser.win) {
						if(window.innerHeight && window.innerHeight < 500) {
							win = pup.openWindow(s, "appform", 500, 410, 0, 0, 1);
						} else {
							win = pup.openWindow(s, "appform", 500, 520, 0, 0, 1);							
						}
					} else if(screen.availHeight > 600) {
						win = pup.openWindow(s, "appform", 500 +safariChromeX, 680 +safariChromeY, 0, 0, 1);
					} else {
						win = pup.openWindow(s, "appform", 500 +safariChromeX, 520 +safariChromeY, 0, 0, 1);					
					}
					break;
					
				case "appformSmall":
					win = pup.openWindow(s, "appform", 500, 520, 0, 0, 1);
					break;
				
				case "live_chat":
					win = pup.openWindow(s, "live_chat", 425, 385, 0, 0, 0);
					break;
				
				case "demo_form":
					win = pup.openWindow(s, "demo_form", 580, 580, 0, 0, 1);
					break;
				
				default:
					win = pup.openWindow(s, "Popup", 640, 480, 0, 0, 0);
					break;
			}
		};

// Override standard date parsing and formatting to process dates returned from SQL.
	YAHOO.util.DataSource.parseDate = function (oData)
	{
		if (oData === undefined || oData === null) return oData;
		var parts = oData.split(' ');
		var datePart = parts[0].split('/');
		if (parts.length > 1)
		{
			var timePart = parts[1].split(':');
			return new Date(datePart[2],datePart[1]-1,datePart[0],timePart[0],timePart[1],timePart[1]);
		}
		else
		{
			return new Date(datePart[2],datePart[1]-1,datePart[0]);
		}
	};
	
	
	//Custom format datetime
	YAHOO.widget.DataTable.formatDate = function(el, oRecord, oColumn, oData)
	{
		var oDate = oData;
		if(!isNaN(oDate))
		{
			switch (oDate.getHours())
			{
			case 0:
			  el.innerHTML = dateFormat(oDate, "dd/mm/yyyy");
			  break;
			default:
			  el.innerHTML = dateFormat(oDate, "dd/mm/yyyy HH:MM");
			}

		}
		else
		{
			//el.innerHTML = YAHOO.lang.isValue(oData) ? oData : "";
		}
	};

function pathToXml(){
	var path;
	//path = "/content/sites/lum/fr_LU/economic-calendar-xml.xml?sid="+Math.floor(Math.random()*999999991);
	path = "/igi/spread-betting/economic-calendar-xml.xml?sid="+Math.floor(Math.random()*999999991);
	return path;
}

var test = 0
// individual schema for the calendars
IG.util.XMLSchema_EconomicCalendar =  {
	//source: "/lib/xml/economic-calendar.xml", //LLoback changed the path
	//source: "/spread-betting/economic-calendar-xml.xml?sid="+Math.random(),
	source: pathToXml(), //updated to read specific xml path depending on domain visited
	resultsArea : 'EconomicCalendar_Data',
	resultNode: "Result",
	fields: [{key:"Date",parser:YAHOO.util.DataSource.parseDate},"Time","Country","Occurrence","Period","Survey","Prior"],
	columns : [
	  {key:"Date", label:IG.util.Site.CalHeaders[0], sortable:true, width:parseInt(IG.util.Site.CalWidths[0]), formatter:YAHOO.widget.DataTable.formatDate},
	  {key:"Time", label:IG.util.Site.CalHeaders[1], sortable:false, width:parseInt(IG.util.Site.CalWidths[1])},  
	  {key:"Country", label:IG.util.Site.CalHeaders[2], sortable:true},
	  {key:"Occurrence", label:IG.util.Site.CalHeaders[3], sortable:true, width:parseInt(IG.util.Site.CalWidths[2])},
	  {key:"Period", label:IG.util.Site.CalHeaders[4], sortable:true,width:parseInt(IG.util.Site.CalWidths[3])},
	  {key:"Survey", label:IG.util.Site.CalHeaders[5], sortable:true,width:parseInt(IG.util.Site.CalWidths[4])},
	  {key:"Prior", label:IG.util.Site.CalHeaders[6], sortable:true,width:parseInt(IG.util.Site.CalWidths[5])}
	],
	
	filter: function(xmlNodes){
		// Find where ie and firefox have put the text into the DOM
		var xmlOccurrence = (isIE)?xmlNodes.childNodes[3]:xmlNodes.childNodes[3];
		var xmlOccurrenceValue = xmlOccurrence.childNodes[0].nodeValue;
		var htmlOccurrence = gE("occurrence").value;
		var xmlDate = (isIE)?xmlNodes.childNodes[0]:xmlNodes.childNodes[0];
		var xmlDateValue = xmlDate.childNodes[0].nodeValue;		
		//xmlDateValue = xmlDateValue.substr(3,2) + '/' + xmlDateValue.substr(0,2) + '/' + xmlDateValue.substr(6)
		//22-01-09
		//fix date bug
		//reassemble string returned and convert to JS date object
		//then format for parsing
		if((xmlDateValue != '')&&(xmlDateValue!='N/A') && (xmlDateValue != null)){
			var arrxmlDateValue
			arrxmlDateValue = xmlDateValue.split("/");
			xmlDateValue = arrxmlDateValue[2] + "/" + arrxmlDateValue[1] + "/" + arrxmlDateValue[0];
			xmlDateValue = new Date(xmlDateValue)
			xmlDateValue = dateFormat(xmlDateValue, "mm/dd/yyyy");
		
			var htmlEDate = gE("dateFirst").value;
			var htmlLDate = gE("dateLast").value;
			
			//05-01-09
			//fix date bug
			//reassemble string returned and convert to JS date object
			//then format as month/day/year for parsing
			var arrHtmlEDate,
			arrHtmlLDate;
			if(htmlEDate!=''){
				arrHtmlEDate = htmlEDate.split("/");
				htmlEDate = arrHtmlEDate[2] + "/" + arrHtmlEDate[1] + "/" + arrHtmlEDate[0];
				htmlEDate = new Date(htmlEDate)
				htmlEDate = dateFormat(htmlEDate, "mm/dd/yyyy");		
			}
			
			if(htmlLDate!=''){
				arrHtmlLDate = htmlLDate.split("/");
				htmlLDate = arrHtmlLDate[2] + "/" + arrHtmlLDate[1] + "/" + arrHtmlLDate[0];
				htmlLDate = new Date(htmlLDate);
				htmlLDate = dateFormat(htmlLDate, "mm/dd/yyyy");
			}
			
			
			// set variables so if statement below is easier to read!!!
			var bolOccEmpty = htmlOccurrence.length===0;
			var bolEdateEmpty = htmlEDate.length===0;
			var bolLdateEmpty = htmlLDate.length===0;
			var xmlOccurrenceValueLcase = xmlOccurrenceValue.toLowerCase();
			var htmlOccurrenceLcase = htmlOccurrence.toLowerCase();
			var bolshowOcc = xmlOccurrenceValueLcase.indexOf(htmlOccurrenceLcase)>-1;
			var bolshowEdate = Date.parse(xmlDateValue) >= Date.parse(htmlEDate);
			var bolshowLdate = Date.parse(xmlDateValue) <= Date.parse(htmlLDate);
			
			// do the filter
			if ((bolOccEmpty && bolEdateEmpty && bolLdateEmpty) || 
				  (bolshowOcc && bolEdateEmpty && bolLdateEmpty) || 
				  (bolshowOcc && bolshowEdate && bolLdateEmpty) || 
				  (bolshowOcc && bolEdateEmpty && bolshowLdate) || 
				  (bolshowOcc && bolshowEdate && bolshowLdate) || 
				  (bolOccEmpty && bolshowEdate && bolLdateEmpty) || 
				  (bolOccEmpty && bolshowEdate && bolshowLdate) || 
				  (bolOccEmpty && bolEdateEmpty && bolshowLdate)){ 
				return true;
			} else {
				return false;
			}
		}else{
			return false;
		}
	},
	
	init: function(){
		var btn = gE("submitFilter");
		var but = gE("submitFilter"), onClick;
		if(typeof but.onclick=='function'){
			onClick = but.onclick;
		}
		but.onclick = function(){
			if(typeof onClick=='function'){
				onClick();
			}
			IG.util.XML.recreateXML(IG.util.XMLSchema_EconomicCalendar);
			return false;
		};

	}
};
IG.util.CalendarSchema_firstDate = {
	calButton: 'showFirst',
	calArea: 'calFirst',
	calCloser: 'calCloserFirst',
	inputField: 'dateFirst',
	container: 'containerFirst',
	weekdayString: 'WEEKDAYS_LONG',
	monthString: 'MONTHS_LONG',
	selectString: '', //there is no text here, so it wont be shown :)
	cancelString: 'Cancel',
	returnString : function(){
		var calendar = this.calendar;
		var selDate = calendar.getSelectedDates()[0];
		
		// Pretty Date Output, using Calendar's Locale values: Friday, 8 February 2008
		var wStr = calendar.cfg.getProperty(this.weekdayString)[selDate.getDay()];
		var dStr = selDate.getDate();
		var mStr = calendar.cfg.getProperty(this.monthString)[selDate.getMonth()];
		var yStr = selDate.getFullYear();

		//return wStr + ", " + dStr + " " + mStr + " " + yStr;
		var tempDate = wStr + ", " + dStr + " " + mStr + " " + yStr
		tempDate = dateFormat(tempDate, "dd/mm/yyyy");
		return tempDate;
	},
	
	
	ok:function(){
		this.dialog.hide();
	},
	// Any extra functions that need to be executed onLoad here
	extend: function(schema){
		// enable select on dateClick
		var inputField = this.inputField;
      schema.calendar.selectEvent.subscribe(function(){gE(inputField).value=schema.returnString();schema.dialog.hide();}, schema.calendar, true); 
	}
};
IG.util.CalendarSchema_lastDate = {
	calButton: 'showLast',
	calArea: 'calLast',
	calCloser: 'calCloserLast',
	inputField: 'dateLast',
	container: 'containerLast',
	weekdayString: 'WEEKDAYS_LONG',
	monthString: 'MONTHS_LONG',
	selectString: '', //there is no text here, so it wont be shown :)
	cancelString: 'Cancel',
	returnString : function(){
		var calendar = this.calendar;
		var selDate = calendar.getSelectedDates()[0];
		
		// Pretty Date Output, using Calendar's Locale values: Friday, 8 February 2008
		var wStr = calendar.cfg.getProperty(this.weekdayString)[selDate.getDay()];
		var dStr = selDate.getDate();
		var mStr = calendar.cfg.getProperty(this.monthString)[selDate.getMonth()];
		var yStr = selDate.getFullYear();

		//return wStr + ", " + dStr + " " + mStr + " " + yStr;
		var tempDate = wStr + ", " + dStr + " " + mStr + " " + yStr
		tempDate = dateFormat(tempDate, "dd/mm/yyyy");
		return tempDate
	},
	ok:function(){
		this.dialog.hide();
	},
	// Any extra functions that need to be executed onLoad here
	extend: function(schema){
		// enable select on dateClick 
		var inputField = this.inputField;
      schema.calendar.selectEvent.subscribe(function(){gE(inputField).value=schema.returnString();schema.dialog.hide();}, schema.calendar, true); 
	}
};

/* Created By Peter Mouland
   Put anything to do with individual schemas in here
	They will be initialised from ig_util.js onLoad
*/
IG.util.schemas = {
	
	init: function(){
		if (gE('EconomicCalendar_Data')){
			IG.util.XML.init(IG.util.XMLSchema_EconomicCalendar);  			
			IG.util.Calendar.init(IG.util.CalendarSchema_firstDate);
			IG.util.Calendar.init(IG.util.CalendarSchema_lastDate);
		}
	}
	
};

