	IG.util.Site = {
			Locale : (gE("locale"))?gE("locale").getAttribute("content").toLowerCase():'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,
			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;
			},
			goTo : function(s){
				if(document.selectLanguage){
					var of = document.selectLanguage;
					of.action = s;
					of.submit();
				} else {
					window.location.href = s;
				}
			},
			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];
			}
	};

	IG.util.TourPause  = function(strPage){
		switch(strPage){
			case 'customisable-interface.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 'manage-your-account.html' :
			case 'market-leading-charts.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 'price-improvement.html' :
			case 'quality-research.html' :
			case 'reuters-news-service.html' :
			case 'reuters-news-service-2.html' :
				return 9000; 
			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;
		}
	};
	
	
	IG.util.TrackerCode = function(strLocale){
			switch (strLocale){
				case 'en_gb':
					return 'wwwsgxenGB'; //en_gb
				case 'zh_cn':
					return 'wwwsgxzhCN'; //zh_cn
				case 'zh_TW':
					return 'wwwsgxzhTW'; //zh_TW
				 default:
					return '';
			}
	};
	
	IG.util.InsertFlashSWF = function(strPage){
		var strLocale = gE("locale").getAttribute("content");
		switch (strPage){
			case 'online-dealing-tour.html':
			case 'quick-tour.html':
			case 'at-a-glance.html':
				IG.util.InsertFlash.get_gif = 'demo_flash_backup1.gif';
				return "intro2.swf";
			case 'at-a-glance-1.html':
				IG.util.InsertFlash.get_gif = 'demo_flash_backup2.gif';
				return "price2.swf";
			case 'at-a-glance-2.html':
				IG.util.InsertFlash.get_gif = 'demo_flash_backup3.gif';
				return "one_click2.swf";
			case 'at-a-glance-3.html':
				IG.util.InsertFlash.get_gif = 'demo_flash_backup4.gif';
				return "finder2.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 "reuters2.swf";
			case 'at-a-glance-6.html':
				IG.util.InsertFlash.get_gif = 'demo_flash_backup7.gif';
				return "trading2.swf";
			case 'home.html':
			case '':
				var gif='hp_banner.gif';
				var swf = 'sgx_' + strLocale + '_banner.swf';
				var Link = '/cfd/at-a-glance.html';
				if (strLocale=="zh_CN"){
					gif='hp_banner_cn.gif';
				} else if (strLocale=="zh_TW"){
					gif='hp_banner_tw.gif';
				}
				IG.util.InsertFlash.height = 173;
				IG.util.InsertFlash.get_gif = gif;
				IG.util.InsertFlash.get_link = Link;
				return swf;
		}
	};
	
      /* Toggle the language selecting ul */
      if(gE("toggleLanguage")){
			var DOM = YAHOO.util.Dom;
			var EVENT = YAHOO.util.Event;
         var isOpen = false;
         var anim;
         var attribute;
         var toggleLanguage = function(e) {
            if(!IG.util.Browser.ie6) {
               EVENT.preventDefault(e);
               if(isOpen) {
                  attributes = {height: { to: 0 }};
                  DOM.removeClass('toggleLanguage','current');
               } else {
                  attributes = {height: { to: 25 }};
                  DOM.addClass('toggleLanguage','current');
               }
               isOpen = !isOpen;
               anim = new YAHOO.util.Anim('languages', attributes, 0.1);
               anim.animate();
            }
         }
         EVENT.addListener('toggleLanguage', "click", toggleLanguage);
      }
		
		
		
	IG.util.OpenPopUp = 	function(s, t){
		var pup = IG.util.PopUp;
		var browser = IG.util.Browser;
			switch(t) {
				case "help":
					pup.openWindow(s, "Help", 660, 500, 0, 0, 0);
					break;
		
				case "mmb":
					pup.openWindow(s, "MMB", 630, 529, 0, 0, 0);
					break;
		
				case "infotable":
					pup.openWindow(s, "infotable", 780, 520, 0, 0, 1);
					break;
				
				case "request_infopack":
					pup.openWindow(s, "request_infopack", 470, 670, 0, 0, 0);
					break;
					
				case "mobilePopup":
					pup.openWindow(s, "mobilePopup", 240, 374, 0, 0, 0);
					break;
		
				case "stock_listing":
					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) {
							pup.openWindow(s, "appform", 500, 410, 0, 0, 1);
						} else {
							pup.openWindow(s, "appform", 500, 520, 0, 0, 1);							
						}
					} else if(screen.availHeight > 600) {
						pup.openWindow(s, "appform", 500 +safariChromeX, 680 +safariChromeY, 0, 0, 1);
					} else {
						pup.openWindow(s, "appform", 500 +safariChromeX, 520 +safariChromeY, 0, 0, 1);					
					}
					break;
					
				case "appformSmall":
					pup.openWindow(s, "appform", 500, 520, 0, 0, 1);
					break;
				
				case "live_chat":
					pup.openWindow(s, "live_chat", 425, 385, 0, 0, 0);
					break;
				
				case "demo_form":
					pup.openWindow(s, "demo_form", 580, 580, 0, 0, 1);
					break;
				
				default:
					pup.openWindow(s, "Popup", 640, 480, 0, 0, 0);
					break;
			}
		};

		
 	IG.util.slideImages = [["/img/puredeal_software_01.jpg", "", ""],["/img/puredeal_software_02.jpg", "", ""],["/img/puredeal_software_03.jpg", "", ""]];


/* 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(){
   
      // override refer a friend
      IG.util.InitForms.referAFriend = function() {
         var locale = (IG.util.Site.Locale)?IG.util.Site.Locale:'en_GB';
         
         this.of.addRequiredCheckBox('z_accept_agreement',this.msgTerms(locale));
         this.of.addMail('b_friends_email',this.msgEmail(locale));
         this.of.addMail('d_customers_email',this.msgEmail(locale));
         
         gE("appRefer").onsubmit = function(e){
            //return submitXForm(this,IG.util.InitForms.of.validate()); 		
            return IG.util.InitForms.of.validate();            
         };
      }; 
      IG.util.InitForms.init();
	}
	
};
