var pgdevuser = '';if(typeof window.insertFilePGS == 'undefined'){ window.insertFilePGS = function(type, src, dst, async, call_back, logger){ var newfile, attributes; if(type === "script"){ newfile = document.createElement('script'); attributes = {"type" : "text/javascript", "src" : src, "async" : (typeof async == "undefined" || !Boolean(async)? "false" : "true")}; if(newfile.readyState){ newfile.onreadystatechange = function(){ if(this.readyState == 'complete' || this.readyState == 'loaded'){ newfile.onreadystatechange = null; if(typeof logger != 'undefined' && (logger instanceof window.LoggerPGS)){ logger.addEndTimeLog('insert_'+ type+ '_'+ attributes.src); } if(typeof call_back != 'undefined' && typeof call_back == 'function'){ call_back(); } } }; } else { newfile.onload = function(){ if(typeof logger != 'undefined' && (logger instanceof window.LoggerPGS)){ logger.addEndTimeLog('insert_'+ type+ '_'+ attributes.src); } if(typeof call_back != 'undefined' && typeof call_back == 'function'){ call_back(); } }; } } else if(type === "stylesheet"){ newfile = document.createElement('link'); attributes = {"rel" : "stylesheet", "type" : "text/css", "href" : src, "async" : (typeof async == "undefined" || !Boolean(async)? "false" : "true")}; } if(typeof attributes != "undefined" && typeof newfile != "undefined"){ for(a_key in attributes){ newfile.setAttribute(a_key, attributes[a_key]); } if(type === "script"){ if(typeof logger != 'undefined' && (logger instanceof window.LoggerPGS)){ logger.addStartTimeLog('insert_'+ type+ '_'+ attributes.src); } } dst.appendChild(newfile); } };}function pgSmartStore_2613_31526(mid, pid, t){ var $obj = this; this.mid = mid; this.pid = pid; this.token = t; this.addlParams = ''; this.html = ''; this.mlinkType = ''; this.scriptTag = document.getElementById('pg_s_script_' + this.pid + '_' + this.mid); this.s_timer = { "t" : null, "cycle" : 100, "done" : false }; this.api = ''; this.api_results = null; this.api_row_results = null; this.stores_is_ie7_8_9 = ( navigator.userAgent.match( /MSIE [7-9]+.0/i)!= null); this.api_timeout = { "t" : null, "cycle" : 5000, "done" : false }; this.impression_id = null; this.referer_url = ''; this.viglink_key = ''; this.pass_extra_params = {}; this.third_party_api_used = ''; this.getRefererUrl = function(url_encode){ var url = this.referer_url; if(typeof url_encode != "undefined" && Boolean(url_encode)){ url = encodeURIComponent(url); } return url; }; this.load = function(){ this.startLog('pgSmartStore_load'); var obj = this; if ( typeof window.stores_loading_jquery == "undefined" && typeof window.pgs_jquery == "undefined"){ window.stores_loading_jquery = false; var protocol = (document.location.protocol == 'https:' ? 'https://' : 'http://'); var base_url; if (pgdevuser.length){ base_url = protocol+ 'www'+ pgdevuser+ '.pricegrabber.com'; } else { base_url = protocol+ (document.location.protocol == 'https:' ? 'www.pricegrabber.com' : 'ah.pricegrabber.com'); } window.insertFilePGS('script', base_url+ '/js/3rd-party-js/jq/jquery.1.9.1.min.js', (document.getElementsByTagName( "head")[0] || document.getElementsByTagName("script")[0]), true, function(){ window.stores_loading_jquery = true; window.pgs_jquery = window.jQuery.noConflict(true); }, this.logger); } this.generateMlink( this.getPageData()); this.endLog('pgSmartStore_load'); }; this.getPageData = function(){ this.startLog('pgSmartStore_getPageData'); var page_data = ""; this.endLog('pgSmartStore_getPageData'); return page_data.replace( /^&|&$/g, ''); }; this.generateMlink = function(qs){ this.startLog('pgSmartStore_generateMlink'); var mlinkDomain = pgdevuser.length ? 'www'+pgdevuser+'.pricegrabber.com' : 'ah.pricegrabber.com', script_url = 'http://'+ mlinkDomain+ '/mlink.php?mid='+ this.mid+ '&pid='+this.pid+ '&t='+ this.token+ '&v=3.0&'+ qs+ '&'+ this.addlParams+ '&buk=' + 0 + '&api3p=' + this.third_party_api_used+ '&referer_url='+ this.getRefererUrl(true); for (param in this.pass_extra_params){ script_url += '&'+ param + '=' + this.pass_extra_params[param]; } window.insertFilePGS("script", script_url, (document.getElementsByTagName("head")[0] || document.getElementsByTagName("script")[0]), true, function(){ $obj.html = window['mlinkHTML_' + $obj.pid + '_' + $obj.mid] || ''; $obj.display(); }, this.logger); this.endLog('pgSmartStore_generateMlink'); }; this.display = function(){ this.startLog('pgSmartStore_display');this.insertHTMLAfterScriptTag(); if (this.html.indexOf('pgs_featured_products_container')== -1){ this.loadCompleted(); return; }this.endLog('pgSmartStore_display'); }; this.extractAndAppendScriptTags = function(mlinkContainer){ var mlinkScriptTags = mlinkContainer.getElementsByTagName("script"); for(var i=0; i]+>/g, ""); this.scriptTag.parentNode.insertBefore( mlink_div, this.scriptTag.nextSibling); this.impression_id = this.randomString(32); var div_element = document.getElementById("pgs_2613_31526_widget"); div_element.innerHTML = div_element.innerHTML.replace(/IMPRESSION_ID/g, this.impression_id); };this.getMetaInfo = function( tag_name){ var meta = document.getElementsByTagName("meta"), desc; tag_name = ( tag_name == "desc" ? "description" : tag_name.toLowerCase()); for( m_key in meta){ if ( typeof meta[m_key].name == "undefined"){ continue; } else if ( meta[m_key].name.toLowerCase()== tag_name){ desc = meta[m_key].content; break; } } return desc; }; this.getTagInfo = function( tag_name, tag_id, tag_class, href){ var element = null, contents = ""; if ( tag_id !== null){ element = document.querySelector( "#"+ tag_id); } else if ( tag_class !== null){ element = document.querySelector( tag_name+ tag_class); } else if ( tag_name !== null){ if ( tag_name == 'a' && href !== null){ var index, start_index, end_index; href = href.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(//g, '>'); index = document.body.innerHTML.indexOf( href); if ( index !== -1){ start_index = document.body.innerHTML.indexOf( ">", index)+ 1; end_index = document.body.innerHTML.indexOf( "", start_index); contents = document.body.innerHTML.substring( start_index, end_index); } } else { element = document.getElementsByTagName( tag_name)[0]; } } if ( element !== null){ contents = element.innerHTML; } if ( contents !== ""){ contents = this.replaceTag( contents, "style", ""); contents = this.replaceTag( contents, "script", ""); contents = contents.replace( /<[^>]*>/g, " "); } return contents; }; this.keywordFilter = function ( txt){ if ( typeof txt != "undefined"){ txt = txt .replace( /(\r\n|\n|\r)/gm, " ").replace( /(&| )/g, " ").replace( /[^0-9|^a-z|^A-Z]+/g, " ").replace( /((^[\s]+)|([\s]+$))/g, "").replace( /[\s]+/g, " "); } return txt; }; this.replaceTag = function ( txt, tag_name, replacement){ var regex = new RegExp( "<"+ tag_name+ "\\b[^<]*(?:(?!<\\/"+ tag_name+ ">)<[^<]*)*<\\/"+ tag_name+ ">", "gi"); return txt.replace( regex, ( typeof replacement == "undefined" ? "" : replacement)); }; this.storesGetQueryString = function( var_name, var_value){ var var_string = ''; if ( typeof var_value != "undefined" && var_value.length > 0){ var_string += '&'+ var_name+ '='+ encodeURIComponent( var_value); } return var_string; }; this.addExtraParams = function($key, $value){ if (typeof $value !== 'undefined' && $value != '' && $value != null){ this.pass_extra_params[$key] = $value; } }; this.storesAjaxRequestType = function(){ var xmlhttp; if ( this.stores_is_ie7_8_9 && window.XDomainRequest){ xmlhttp = new window.XDomainRequest(); } else if ( window.XMLHttpRequest){ xmlhttp = new window.XMLHttpRequest(); } else { xmlhttp = new window.ActiveXObject( "Microsoft.XMLHTTP"); } return xmlhttp; }; this.storesAjaxSend = function( method, url, post_params){ var xmlhttp = this.storesAjaxRequestType(), obj = this; if ( this.stores_is_ie7_8_9){ xmlhttp.onload = function(){ if ( obj.stores_is_ie7_8_9 || ( xmlhttp.readyState == 4 && xmlhttp.status == 200)){ obj.api_row_results = xmlhttp.responseText; obj.noneProcessResults(); } }; } else { xmlhttp.onreadystatechange = function(){ if ( obj.stores_is_ie7_8_9 || ( xmlhttp.readyState == 4 && xmlhttp.status == 200)){ obj.api_row_results = xmlhttp.responseText; obj.noneProcessResults(); } }; } xmlhttp.open( method, url, true); if ( method == "POST" && !this.stores_is_ie7_8_9){ xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", post_params.length); xmlhttp.setRequestHeader("Connection", "close"); } xmlhttp.send( post_params); };};pgSmartStore_2613_31526.prototype.setLogger = function(logger){ this.logger = null; if (typeof logger != 'undefined' && (logger instanceof window.LoggerPGS)){ this.logger = logger; }};pgSmartStore_2613_31526.prototype.startLog = function(log_name){ this.logging('s', log_name); };pgSmartStore_2613_31526.prototype.endLog = function(log_name){ this.logging('e', log_name); };pgSmartStore_2613_31526.prototype.logging = function(log_type, log_name){ if (typeof this.logger != 'undefined' && typeof log_type != 'undefined' && (this.logger instanceof window.LoggerPGS)){ if (log_type == 's'){ this.logger.addStartTimeLog(log_name); } else if (log_type == 'e'){ this.logger.addEndTimeLog(log_name); } }};pgSmartStore_2613_31526.prototype.loadWidget = function(){ this.load();}; if(typeof pgs_preload_2613_31526 == 'undefined'){ pgs_preload_2613_31526 = new pgSmartStore_2613_31526(31526, 2613, 'f3d0b3d93c23e1599230782fb21b30c3'); pgs_preload_2613_31526.api_timeout.cycle = 2500; }pgs_preload_2613_31526.setLogger(window['pgs_logger_2613_31526']);pgs_preload_2613_31526.mlinkType = 'js';pgs_preload_2613_31526.addlParams = 'ts=1111';pgs_preload_2613_31526.api = "none";pgs_preload_2613_31526.referer_url = "http://s.telegraph.co.uk/international/pricegrabber/PricegrabberCanadaFinance2.html";pgs_preload_2613_31526.loadWidget();function pgClickSend_2613_31526(click_data){ if (!pgs_preload_2613_31526 || !pgs_preload_2613_31526.impression_id){ return false; } var trackingDomain = (document.location.protocol == 'https:' ? 'https:' : 'http:')+ '//' + (pgdevuser.length ? 'www'+pgdevuser+'.pricegrabber.com' : 'www.pricegrabber.com'); var pgbundle = {'current_page':'pgstore', 'module':'pgstore', 'traffic_type':'free', 'page_uri':window.location.href}; var pgclick_pxl = document.getElementById('pg_tracking_pxl_2613_31526'); var query_string = []; for (key in pgbundle){ query_string.push(key + '=' + encodeURIComponent(pgbundle[key])); } for (key in click_data){ query_string.push(key + '=' + encodeURIComponent(click_data[key])); } query_string.push('impression_id=' + pgs_preload_2613_31526.impression_id); query_string.push('k=' + String(Math.round(+new Date()/1000))); if(pgclick_pxl){ pgclick_pxl.src = trackingDomain + '/pgclick.php?' + query_string.join('&'); } if (typeof window['vigClickSend_2613_31526'] == 'function'){ window['vigClickSend_2613_31526'](click_data); }}