﻿/* 
 * IMPORTANT
 *
 * This file has been minified using yuicompressor v.2.3.6, and put into the template JS-MIN in the CMS.
 * Changes should be made to this file, then minified and then both versions should be copied into
 * the CMS. The CMS should use the minified version.
 */
var lang = {
    langAbbr: "fr",
    langTxt: "francais",
    searchButtonImg: "/images/project/formButton_search_fr.gif",
    searchButtonAlt: "Recherche",
    viewButtonImg: "/images/project/view_fr.gif",
    viewButtonAlt: "Voir",
    showTxt: "Montrer",
    hideTxt: "Cacher",
    archiveTxt: "Archives ",
    closeTxt: "Quitter",
    externalLinkWarningTxt: "Vous quittez maintenant le site Web de la Compagnie des chemins de fer nationaux du Canada pour vous rendre au site d'un tiers. La Compagnie des chemins de fer nationaux du Canada n'exerce aucun contrôle sur les sites des tiers. Elle n'assume aucune responsabilité en ce qui a trait au contenu de ces sites et aux hyperliens qui peuvent s'y trouver. La Compagnie des chemins de fer nationaux du Canada offre des hyperliens entre son site et d'autres sites Web uniquement pour rendre service aux personnes intéressées et ce faisant, elle n'indique pas qu'elle approuve ces sites ni les renseignements qui s'y trouvent, ni qu'elle les a analysés ou vérifiés.",
    readStoryTxt: "Lisez l'article",
    eTools: {
        usernameImage: "/images/project/username_bg_fr.gif",
        passwordImage: "/images/project/password_bg_fr.gif",
        chooseToolTxt: "Choisir un outil",
        seeMoreToolsTxt: "Afficher les outils",
        greetingTxt: "Salut ",
        customizeTxt: "Personnaliser Mes favoris",
        toolsTxt: "Retour aux outils",
        toolsPopupTxt: "Cliquez sur <em>Retour aux outils</em> pour retourner au menu principal des Affaires &eacute;lectroniques",
        logoutTxt: "Fermer la session",
        missingUsernameOrPasswordTxt: "Veuillez inscrire votre nom d'usager et (ou) votre mot de passe."
    },
    priceCalendar: {
        orTxt: "- OU -",
        selectTxt: "Choisir dans la liste",
        listTxt: "Afficher toute la liste",
        searchTxt: "Afficher la recherche"
    },
    formMessages: {
        emptyTxt: "Ce champ ne peut pas &ecirc;tre vide",
        invalidEmailTxt: "Ce champ doit contenir une adresse courriel valide",
        nonMatchEmailTxt: "Ce champ doit corresponde au courriel"    
    }
};
var Loader = function() {
  return {
  
    headEl: null,
    yuiPath: null,
    
    getHeadEl: function() {
      if (!this.headEl) {
        this.headEl = document.getElementsByTagName("head")[0];
      }
      
      return this.headEl;
    },
    
    getYUIPath: function() {
      if (!this.yuiPath) {        
        var scripts = document.getElementsByTagName('script');
        for(var i = 0; i < scripts.length && !this.yuiPath; i++)
        {
            if (scripts[i].src.indexOf('yahoo-dom-event') != -1)
            {
                this.yuiPath = scripts[i].src.substring(0, scripts[i].src.indexOf("yahoo-dom-event"));
            }
        }
      }
      
      return this.yuiPath;    
    },
    insertYUIScript: function(path) {
      this.insertScript(this.getYUIPath() + path);
    },
    insertYUIStylesheet: function(path) {
      this.insertStylesheet(this.getYUIPath() + path);
    },
    
    insertSWFScript: function() {
      this.insertScript("common/swfobject/swfobject.js");
    },
    insertScript: function(path) {
      var headEl = this.getHeadEl(), scriptEl;
      var scripts = YAHOO.util.Dom.getElementsBy(function(s) {
        return s.src.indexOf(path) != -1; 
      }, "script", headEl);
      
      if(scripts.length == 0) {
        scriptEl = document.createElement("script");
        scriptEl.src = path;
        scriptEl.type = "text/javascript";
        headEl.appendChild(scriptEl);  
      }
    },
    
    insertStylesheet: function(path) {
      var headEl = this.getHeadEl(), linkEl;
      var links = YAHOO.util.Dom.getElementsBy(function(s) {
        return s.href.indexOf(path) != -1; 
      }, "link", headEl);
      
      if(links.length == 0) {
        linkEl = document.createElement("link");
        linkEl.rel = "stylesheet";
        linkEl.type = "text/css";
        linkEl.href = path;
        headEl.appendChild(linkEl);    
      }
    }
    
  }
  
}();
var VideoObject = function() {
  return {
    
    embedMPG: function(el, options) {
        var el = YAHOO.util.Dom.get(el);
        if (!el) {
            return;
        }
        
        el.innerHTML = "";
        
        if (YAHOO.env.ua.ie > 0) {
            this.createMPGObjectTag(el, options);
        }
        else {
            this.createMPGEmbedTag(el, options);
        }
    },
    
    createMPGObjectTag: function(el, options) {        
        var html = '<object class="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="video/mpeg"';
        if (options.width) {
            html += ' width="' + options.width + '"';
        }        
        
        if (options.height) {
            html += ' height="' + options.height + '"';
        }
        
        html += '><param name="filename" value="' + options.filename + '">'
        if (options.ShowStatusBar) {
            html += '<param name="ShowStatusBar" value="' + options.ShowStatusBar + '">';
        }        
        html += '</object>';
        el.innerHTML = html;
    },
    
    createMPGEmbedTag: function(el, options) {        
        var html = '<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="' + options.filename + '"';
        if (options.width) {
            html += ' width="' + options.width + '"';
        }        
        
        if(options.height) {
            html += ' height="' + options.height + '"';
        }
        
        if(options.ShowStatusBar) {
            html += ' ShowStatusBar="' + options.ShowStatusBar + '"';
        }        
        
        html += '></embed>';
        el.innerHTML = html;
    }    
  
  }
  
}();
/*    SWFObject v2.0 <http://code.google.com/p/swfobject/>
    Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
    This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var Z="undefined",P="object",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",W="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,T=null,S=false,C=false;var a=function(){var l=typeof g.getElementById!=Z&&typeof g.getElementsByTagName!=Z&&typeof g.createElement!=Z&&typeof g.appendChild!=Z&&typeof g.replaceChild!=Z&&typeof g.removeChild!=Z&&typeof g.cloneNode!=Z,t=[0,0,0],n=null;if(typeof N.plugins!=Z&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=Z){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var e=function(){if(!a.w3cdom){return }J(I);if(a.ie&&a.win){try{g.write("<script id=__ie_ondomload defer=true src=//:><\/script>");var i=c("__ie_ondomload");if(i){i.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);V()}}}}catch(j){}}if(a.webkit&&typeof g.readyState!=Z){Q=setInterval(function(){if(/loaded|complete/.test(g.readyState)){V()}},10)}if(typeof g.addEventListener!=Z){g.addEventListener("DOMContentLoaded",V,null)}M(V)}();function V(){if(S){return }if(a.ie&&a.win){var m=Y("span");try{var l=g.getElementsByTagName("body")[0].appendChild(m);l.parentNode.removeChild(l)}catch(n){return }}S=true;if(Q){clearInterval(Q);Q=null}var j=f.length;for(var k=0;k<j;k++){f[k]()}}function J(i){if(S){i()}else{f[f.length]=i}}function M(j){if(typeof G.addEventListener!=Z){G.addEventListener("load",j,false)}else{if(typeof g.addEventListener!=Z){g.addEventListener("load",j,false)}else{if(typeof G.attachEvent!=Z){G.attachEvent("onload",j)}else{if(typeof G.onload=="function"){var i=G.onload;G.onload=function(){i();j()}}else{G.onload=j}}}}}function I(){var l=H.length;for(var j=0;j<l;j++){var m=H[j].id;if(a.pv[0]>0){var k=c(m);if(k){H[j].width=k.getAttribute("width")?k.getAttribute("width"):"0";H[j].height=k.getAttribute("height")?k.getAttribute("height"):"0";if(O(H[j].swfVersion)){if(a.webkit&&a.webkit<312){U(k)}X(m,true)}else{if(H[j].expressInstall&&!C&&O("6.0.65")&&(a.win||a.mac)){D(H[j])}else{d(k)}}}}else{X(m,true)}}}function U(m){var k=m.getElementsByTagName(P)[0];if(k){var p=Y("embed"),r=k.attributes;if(r){var o=r.length;for(var n=0;n<o;n++){if(r[n].nodeName.toLowerCase()=="data"){p.setAttribute("src",r[n].nodeValue)}else{p.setAttribute(r[n].nodeName,r[n].nodeValue)}}}var q=k.childNodes;if(q){var s=q.length;for(var l=0;l<s;l++){if(q[l].nodeType==1&&q[l].nodeName.toLowerCase()=="param"){p.setAttribute(q[l].getAttribute("name"),q[l].getAttribute("value"))}}}m.parentNode.replaceChild(p,m)}}function F(i){if(a.ie&&a.win&&O("8.0.0")){G.attachEvent("onunload",function(){var k=c(i);if(k){for(var j in k){if(typeof k[j]=="function"){k[j]=function(){}}}k.parentNode.removeChild(k)}})}}function D(j){C=true;var o=c(j.id);if(o){if(j.altContentId){var l=c(j.altContentId);if(l){L=l;T=j.altContentId}}else{L=b(o)}if(!(/%$/.test(j.width))&&parseInt(j.width,10)<310){j.width="310"}if(!(/%$/.test(j.height))&&parseInt(j.height,10)<137){j.height="137"}g.title=g.title.slice(0,47)+" - Flash Player Installation";var n=a.ie&&a.win?"ActiveX":"PlugIn",k=g.title,m="MMredirectURL="+G.location+"&MMplayerType="+n+"&MMdoctitle="+k,p=j.id;if(a.ie&&a.win&&o.readyState!=4){var i=Y("div");p+="SWFObjectNew";i.setAttribute("id",p);o.parentNode.insertBefore(i,o);o.style.display="none";G.attachEvent("onload",function(){o.parentNode.removeChild(o)})}R({data:j.expressInstall,id:K,width:j.width,height:j.height},{flashvars:m},p)}}function d(j){if(a.ie&&a.win&&j.readyState!=4){var i=Y("div");j.parentNode.insertBefore(i,j);i.parentNode.replaceChild(b(j),i);j.style.display="none";G.attachEvent("onload",function(){j.parentNode.removeChild(j)})}else{j.parentNode.replaceChild(b(j),j)}}function b(n){var m=Y("div");if(a.win&&a.ie){m.innerHTML=n.innerHTML}else{var k=n.getElementsByTagName(P)[0];if(k){var o=k.childNodes;if(o){var j=o.length;for(var l=0;l<j;l++){if(!(o[l].nodeType==1&&o[l].nodeName.toLowerCase()=="param")&&!(o[l].nodeType==8)){m.appendChild(o[l].cloneNode(true))}}}}}return m}function R(AE,AC,q){var p,t=c(q);if(typeof AE.id==Z){AE.id=q}if(a.ie&&a.win){var AD="";for(var z in AE){if(AE[z]!=Object.prototype[z]){if(z=="data"){AC.movie=AE[z]}else{if(z.toLowerCase()=="styleclass"){AD+=' class="'+AE[z]+'"'}else{if(z!="classid"){AD+=" "+z+'="'+AE[z]+'"'}}}}}var AB="";for(var y in AC){if(AC[y]!=Object.prototype[y]){AB+='<param name="'+y+'" value="'+AC[y]+'" />'}}t.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AD+">"+AB+"</object>";F(AE.id);p=c(AE.id)}else{if(a.webkit&&a.webkit<312){var AA=Y("embed");AA.setAttribute("type",W);for(var x in AE){if(AE[x]!=Object.prototype[x]){if(x=="data"){AA.setAttribute("src",AE[x])}else{if(x.toLowerCase()=="styleclass"){AA.setAttribute("class",AE[x])}else{if(x!="classid"){AA.setAttribute(x,AE[x])}}}}}for(var w in AC){if(AC[w]!=Object.prototype[w]){if(w!="movie"){AA.setAttribute(w,AC[w])}}}t.parentNode.replaceChild(AA,t);p=AA}else{var s=Y(P);s.setAttribute("type",W);for(var v in AE){if(AE[v]!=Object.prototype[v]){if(v.toLowerCase()=="styleclass"){s.setAttribute("class",AE[v])}else{if(v!="classid"){s.setAttribute(v,AE[v])}}}}for(var u in AC){if(AC[u]!=Object.prototype[u]&&u!="movie"){E(s,u,AC[u])}}t.parentNode.replaceChild(s,t);p=s}}return p}function E(k,i,j){var l=Y("param");l.setAttribute("name",i);l.setAttribute("value",j);k.appendChild(l)}function c(i){return g.getElementById(i)}function Y(i){return g.createElement(i)}function O(k){var j=a.pv,i=k.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10);i[2]=parseInt(i[2],10);return(j[0]>i[0]||(j[0]==i[0]&&j[1]>i[1])||(j[0]==i[0]&&j[1]==i[1]&&j[2]>=i[2]))?true:false}function A(m,j){if(a.ie&&a.mac){return }var l=g.getElementsByTagName("head")[0],k=Y("style");k.setAttribute("type","text/css");k.setAttribute("media","screen");if(!(a.ie&&a.win)&&typeof g.createTextNode!=Z){k.appendChild(g.createTextNode(m+" {"+j+"}"))}l.appendChild(k);if(a.ie&&a.win&&typeof g.styleSheets!=Z&&g.styleSheets.length>0){var i=g.styleSheets[g.styleSheets.length-1];if(typeof i.addRule==P){i.addRule(m,j)}}}function X(k,i){var j=i?"visible":"hidden";if(S){c(k).style.visibility=j}else{A("#"+k,"visibility:"+j)}}return{registerObject:function(l,i,k){if(!a.w3cdom||!l||!i){return }var j={};j.id=l;j.swfVersion=i;j.expressInstall=k?k:false;H[H.length]=j;X(l,false)},getObjectById:function(l){var i=null;if(a.w3cdom&&S){var j=c(l);if(j){var k=j.getElementsByTagName(P)[0];if(!k||(k&&typeof j.SetVariable!=Z)){i=j}else{if(typeof k.SetVariable!=Z){i=k}}}}return i},embedSWF:function(n,u,r,t,j,m,k,p,s){if(!a.w3cdom||!n||!u||!r||!t||!j){return }r+="";t+="";if(O(j)){X(u,false);var q=(typeof s==P)?s:{};q.data=n;q.width=r;q.height=t;var o=(typeof p==P)?p:{};if(typeof k==P){for(var l in k){if(k[l]!=Object.prototype[l]){if(typeof o.flashvars!=Z){o.flashvars+="&"+l+"="+k[l]}else{o.flashvars=l+"="+k[l]}}}}J(function(){R(q,o,u);if(q.id==u){X(u,true)}})}else{if(m&&!C&&O("6.0.65")&&(a.win||a.mac)){X(u,false);J(function(){var i={};i.id=i.altContentId=u;i.width=r;i.height=t;i.expressInstall=m;D(i)})}}},getFlashPlayerVersion:function(){return{major:a.pv[0],minor:a.pv[1],release:a.pv[2]}},hasFlashPlayerVersion:O,createSWF:function(k,j,i){if(a.w3cdom&&S){return R(k,j,i)}else{return undefined}},createCSS:function(j,i){if(a.w3cdom){A(j,i)}},addDomLoadEvent:J,addLoadEvent:M,getQueryParamValue:function(m){var l=g.location.search||g.location.hash;if(m==null){return l}if(l){var k=l.substring(1).split("&");for(var j=0;j<k.length;j++){if(k[j].substring(0,k[j].indexOf("="))==m){return k[j].substring((k[j].indexOf("=")+1))}}}return""},expressInstallCallback:function(){if(C&&L){var i=c(K);if(i){i.parentNode.replaceChild(L,i);if(T){X(T,true);if(a.ie&&a.win){L.style.display="block"}}L=null;T=null;C=false}}}}}();
/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, days, path, domain, secure)
{ 
    if (days != 0) {
        var expdate = new Date(); 
        expdate.setTime(expdate.getTime() + days*24*60*60*1000); 
    }
    document.cookie= name + "=" + escape(value) + 
        ((expdate) ? "; expires=" + expdate.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix); // other than first position in cookie
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;  // if not at start of cookie then cookie not found and leave with nothing
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}
var UserMgr = function() {
        
    return {
        isLoggedIn: function() {
            if (getCookie("LOGIN") == "true" || (YAHOO.env.ua.ie >= 7 && self != top)) {
                return true;
            }
                        
            return false;
        },
        
        isSecure: function() {
            return false;
        },
        
        isKnown: function() {
            if (this.getUsername()) {
                return true;
            }
            
            return false;
        },
        
        logout: function() {
            setCookie("LOGIN", "false", false, "/");
        },
        
        setId: function(userId) {
            //setCookie("USER-ID", userId, false, "/");
        },
        
        getId: function() {
            var cookieid = getCookie("User-Id"); 
            if (cookieid == null || cookieid == "false") {
                return null;
            }
            var words = cookieid.split('a');
            if(words.length != 2) {
                return null;
            }
            
            var one = words[0]; 
            var two = words[1]; 
            var inc = (one.toString()).length 
            var i = 0; 
            var y =0; 
            for (i=0;i<inc;i++) 
            { 
                x = parseInt(one.charAt(i)); 
                y = x+y; 
            } 
            var id = two/y; 
            var idStr = id.toString(); 
            var zeros ="0"; 
            for(var j=0;j<7-idStr.length ;j++) 
            { 
                zeros = zeros + "0"; 
            } 
            return(zeros + id); 
        },
        
        deleteId: function() {
            //this.setId("false");
        },
                
        setUsername: function(username) {
            setCookie("USERNAME", username, 365, "/");
            setCookie("USERNAME-SESSION", username, false, "/");
        },
        
        getUsername: function() {
            var cookieValue = getCookie("USERNAME-SESSION");
            if(!cookieValue || cookieValue == "false") {
                cookieValue = getCookie("USERNAME");
                if(cookieValue && cookieValue != "false") {
                    setCookie("USERNAME-SESSION", cookieValue, false, "/");
                }
            }
            
            return cookieValue && cookieValue != "false" ? cookieValue : null; 
        },
        
        hasTools: function(lang) {
            var cookieName = lang == "fr" ? "TOOLS-FRENCH" : "TOOLS-ENGLISH";
            var cookieValue = getCookie(cookieName);
        
            return (cookieValue && cookieValue != "false") ? true : false;
        },
        
        setTools: function(tools, lang) {
            var cookieName = lang == "fr" ? "TOOLS-FRENCH" : "TOOLS-ENGLISH";
            
            var str = "";
            for(var i = 0; i < tools.length; i++) {
                if(i != 0) str += ",";
                str += tools[i][0] + ":" + escape(tools[i][1]);
            }
            
            setCookie(cookieName, str, false, "/");
        },
        
        deleteTools: function(lang) {
            var cookieName = lang == "fr" ? "TOOLS-FRENCH" : "TOOLS-ENGLISH";
            setCookie(cookieName, "false", false, "/");
        },
        
        getTools: function(lang) {
            var cookieName = lang == "fr" ? "TOOLS-FRENCH" : "TOOLS-ENGLISH";
            var cookieValue = getCookie(cookieName);
        
            if(!cookieValue && cookieValue == "false") {
                return [];
            }
        
            var tools = cookieValue.split(",");
            for(var i = 0; i < tools.length; i++) {
                tools[i] = tools[i].split(":");
                tools[i][1] = unescape(tools[i][1]);
            }
            
            return tools;
        },
        
        hasName: function() {
            var cookieValue = getCookie("CN_UFN");
            return (cookieValue && cookieValue != "false") ? true : false;
        },
        
        setName: function(name) {
        },
        
        deleteName: function() {
        },
        
        getName: function() {
            var cookieValue = getCookie("CN_UFN");
            return (cookieValue && cookieValue != "false") ? cookieValue : null;
        }
    }
}();
 
// for tracking
function omniture_getProp2Value() {
    return UserMgr.getId() ? UserMgr.getId() : "Anonymous";
}
function omniture_getProp7Value() {
    return UserMgr.isLoggedIn() ? "UserLoggedIn" : (UserMgr.isKnown() ? "UserKnown" : "UserUnknown");
}
function expandableContentClick(pageId) {
}
function recordRSSClick(obj, title) {
    if (title != "") {
        title = "RSS : " + title.replace(/&amp;/i, "&");
        var s=s_gi(s_account);
        s.linkTrackVars = "eVar7";
        s.eVar7 = title;
        s.tl(obj,"o",title);
    } 
}
function recordPDFClick(obj, cid) {
    if (cid != "") {
        var s=s_gi(s_account);
        s.linkTrackVars = "eVar3";
        s.eVar3 = cid;
        s.tl(obj,"o",cid);
    } 
}
// default favourite tools
var defaultTools = [];
defaultTools[defaultTools.length] = ["id5", "Rep&eacute;rage &eacute;clair"];defaultTools[defaultTools.length] = ["id14", "Sp&eacute;cifications du mat&eacute;riel"];defaultTools[defaultTools.length] = ["id11", "Calculateur de temps de parcours"];defaultTools[defaultTools.length] = ["id6", "Mon parc"];defaultTools[defaultTools.length] = ["id12", "Documents de tarification"];
/* for popup links */
var LinkFactory = function() {
    
    return {
        getLink: function(linkEl) {            
            if (YAHOO.util.Dom.hasClass(linkEl, 'close_window'))
            {
                return new CloseLink(linkEl);
            }
            else if (YAHOO.util.Dom.hasClass(linkEl, 'help'))
            {
                return new HelpLink(linkEl);
            }
            else if (YAHOO.util.Dom.hasClass(linkEl, 'print'))
            {
                return new PrintLink(linkEl);
            }    
            else if (linkEl.href.toLowerCase().indexOf("mailto:") != -1)
            {
                return new EmailLink(linkEl);
            }
            else if (linkEl.href.toLowerCase().indexOf("/external/marketing/mailsub.nsf/mailsub?openform&lang=") != -1)
            {
                return new ServiceSolutionsLink(linkEl);
            }
            else if (linkEl.rel != '' || linkEl.className != '')
            {
                return new PopupLink(linkEl);
            }
            
        }
    }
}
var LinkType = function(values) {
    this.init(values);
}
LinkType.prototype = {
    init: function(values) {
        this.values = values;
        this.rel = values.rel;
        this.options = values.options;
        this.newWindow = values.newWindow || false;
        this.windowName = values.windowName || false;
    },
    
    getRel: function() {
        return this.values.rel;
    },
    
    getOptionsString: function(options) {
        var str = '';
        var options = options || {};
    
        str += options.width || this.options.width ? ('width=' + (options.width || this.options.width)) : '';
        str += options.height || this.options.height ? ((str ? ',' : '') + 'height=' + (options.height || this.options.height)) : '';        str += this.options.menubar ? ((str ? ',' : '') + 'menubar=' + this.options.menubar) : '';
        str += this.options.toolbar ? ((str ? ',' : '') + 'toolbar=' + this.options.toolbar) : '';
        str += this.options.location ? ((str ? ',' : '') + 'location=' + this.options.location) : '';
        str += this.options.resizable ? ((str ? ',' : '') + 'resizable=' + this.options.resizable) : '';
        str += this.options.scrollbars ? ((str ? ',' : '') + 'scrollbars=' + this.options.scrollbars) : '';
        str += this.options.status ? ((str ? ',' : '') + 'status=' + this.options.status) : '';    
        
        return str;
    }    
}
var linkTypes = [
    new LinkType({rel: "catalogue", options: {menubar: "1", toolbar: "1", location: "1", resizable: "1", scrollbars: "1", status: "1"}}),
    new LinkType({rel: "demo", options: {width: "800", height: "550"}}),
    new LinkType({rel: "disclaimer", options: {width: "550", height: "350", resizable: "1", scrollbars: "1", status: "1"}}),
    new LinkType({rel: "email", options: {width: "500", height: "650", resizable: "1", scrollbars: "1"}}),
    new LinkType({rel: "simplifiedemail", options: {width: "500", height: "450", resizable: "1", scrollbars: "1"}}),
    new LinkType({rel: "etool", options: {width: "800", height: "550", resizable: "1", scrollbars: "1", status: "1"}}),
    new LinkType({rel: "external", options: {width: "640", height: "395", left: "10", top: "10", menubar: "1", toolbar: "1", location: "1", status: "1", scrollbars: "1", resizable: "1"}}),
    new LinkType({rel: "gallery_image", options: {width: "760", height: "550", resizable: "1"}}),
    new LinkType({rel: "get_a_price", options: {width: "965", height: "800", scrollbars: "1", resizable: "1"}}),
    new LinkType({rel: "ghg_graph1", options: {width: "435", height: "500", left: "190", top: "50", scrollbars: "0", resizable: "1"}}),
    new LinkType({rel: "ghg_graph2", options: {width: "435", height: "500", left: "230", top: "75", scrollbars: "0", resizable: "1"}}),
    new LinkType({rel: "help", newWindow: true, options: {width: "540", height: "115",left: "250", top: "150", scrollbars: "1", resizable: "1"}}),
    new LinkType({rel: "map", options: {width: "800", height: "600", scrollbars: "1", resizable: "1"}}),
    new LinkType({rel: "my_subscriptions", options: {width: "965", height: "800", scrollbars: "1", resizable: "1"}}),
    new LinkType({rel: "new_window", newWindow: true, options: {menubar: "1", toolbar: "1", location: "1", status: "1", scrollbars: "1", resizable: "1"}}),
    new LinkType({rel: "pdf", options: {menubar: "1", toolbar: "1", location: "1", status: "1", scrollbars: "1", resizable: "1"}}),
    new LinkType({rel: "popup", newWindow: true, options: {scrollbars: "1", resizable: "1"}}),
    new LinkType({rel: "price_documents", options: {width: "965", height: "800", scrollbars: "1", resizable: "1"}}),
    new LinkType({rel: "video", options: {width: "650", height: "580", scrollbars: "1", resizable: "1"}})        
];
var PopupLink = function(link)
{
    this.init(link);
}
PopupLink.prototype = {
    init: function(link) {
        this.link = link;
        this.rel = this.link.rel || this.link.className;    
        this.type = this.findType();            
        this.windowName = this.type && this.type.newWindow ? "_blank" : (this.type.windowName || this.type.rel);
        
        if (this.type) {
            this.addClickEventListener();
        }
    },
    
    findType: function() {
        for(var i = 0; i < linkTypes.length; i++) {
            type = linkTypes[i];
                                                            
            if(this.rel.substr(0, type.rel.length) == type.rel) {                    
                return type;
            }
        }
        return false;
    },
    
    addClickEventListener: function() {
        YAHOO.util.Event.on(this.link, "click", this.clickEventHandler, this, true);
    },
    
    clickEventHandler:  function(e) {            
        YAHOO.util.Event.stopEvent(e);
                                            
        if (this.isTrackedByOmniture()) {
            this.trackOmniture();
        }
        if (this.isConfirmedOrNeedsNoConfirmation()) {
            this.open();
        }
    },
    
    isTrackedByOmniture: function() {
        // track 'Get Carload Price' tool
        if (this.link.href.indexOf('GetCarloadPrice') !== -1)
        {
            return true;
        }

        // track 'Get Intermodal Price' tool
        if (this.link.href.indexOf('GetIntermodalPrice') !== -1)
        {
            return true;
        }

        // track 'Get Transit Time' tool
        if (this.link.href.indexOf('TransitCalculator') !== -1)
        {
            return true;
        }

        // track 'Get Route' tool
        if (this.link.href.indexOf('GET_ROUTE_FRAMESET') !== -1)
        {
            return true;
        }

        // track 'Price Documents' tool
        if (this.link.href.indexOf('PriceDocuments') !== -1)
        {
            return true;
        }

        return this.isExternal() && window.location.href.indexOf('.cn.ca') !== -1;
    },
    
    isExternal: function() {
        return this.type.rel=="external" || this.link.hostname.substring(this.link.hostname.length - 6) != ".cn.ca";
    },
    
    isConfirmedOrNeedsNoConfirmation: function() {
        return (this.type.rel == "external" && confirm(lang.externalLinkWarningTxt)) || this.type.rel != "external";
    },
    
    open: function() {    
        var popup = window.open(this.link.href, this.windowName, this.type.getOptionsString(this.getOptions()));
        popup.focus();
        YAHOO.util.Event.on(popup, "unload", function(e) {
            window.focus();
        });    
    },
    
    getOptions: function() {    
        var options = {};
        
        var underscorePos = this.rel.indexOf('_');
        var xPos = this.rel.indexOf('x');
        if (underscorePos != -1 && xPos != -1)
        {
            options.width = this.rel.substring(underscorePos + 1, xPos);
            options.height = this.rel.substring(xPos + 1);
        }
        
        return options;
    },
    
    trackOmniture: function() {
        var s=s_gi(s_account);
        s.tl(this.link, 'e', this.link.href);
    }    
};
var HelpLink = function(link) {
    this.init(link);
}
HelpLink.prototype = {
    init: function(link) {
        this.link = link;
        this.addClickEventListener();
    },
    
    addClickEventListener: function() {
        YAHOO.util.Event.on(this.link, 'click', this.clickEventListener, this, true);
    },
    
    clickEventListener: function(e) {
        YAHOO.util.Event.stopEvent(e);                
        var popup = window.open(this.link.href, "help", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=0,top=0,screenX=0,screenY=0,width=707,height=600");
        popup.focus();    
    }
}
var PrintLink = function(link) {
    this.init(link);
}
PrintLink.prototype = {
    init: function(link) {
        this.link = link;
        this.addClickEventListener();
    },
    
    addClickEventListener: function() {
        YAHOO.util.Event.on(this.link, 'click', this.clickEventListener, this, true);
    },
    
    clickEventListener: function(e) {
        YAHOO.util.Event.stopEvent(e);                
        window.print();    
    }
}
var CloseLink = function(link) {
    this.init(link);
}
CloseLink.prototype = {
    init: function(link) {
        this.link = link;
        this.addClickEventListener();
    },
    
    addClickEventListener: function() {
        YAHOO.util.Event.on(this.link, 'click', this.clickEventListener, this, true);
    },
    
    clickEventListener: function(e) {
        YAHOO.util.Event.stopEvent(e);
        if (window.opener) {
            window.opener.focus();
        }
        
        window.close();    
    }
}
var EmailLink = function(link) {
    this.init(link);
}
EmailLink.prototype = {
    init: function(link) {
        this.link = link;
        this.addClickEventListener();
    },
    
    addClickEventListener: function() {
        YAHOO.util.Event.on(this.link, 'click', this.clickEventListener, this, true);
    },
    
    clickEventListener: function(e) {
        var s=s_gi(s_account);
        s.linkTrackVars = "prop9,eVar12";            
        s.prop9 = s.eVar12 = this.link.href.substr(7);
        s.tl(this.link, 'o', this.link.href);      
    }
}
var ServiceSolutionsLink = function(link) {
    this.init(link);
}
ServiceSolutionsLink.prototype = {
    init: function(link) {
        this.link = link;
        this.addClickEventListener();
    },
    
    addClickEventListener: function() {
        YAHOO.util.Event.on(this.link, 'click', this.clickEventListener, this, true);
    },
    
    clickEventListener: function(e) {
        this.trackOmniture();
    },
    
    trackOmniture: function() {
        var s=s_gi(s_account);
        s.linkTrackVars = "eVar16,events";
        s.linkTrackEvents = "event11";
        s.eVar16 = "Service Solution";
        s.events="event11";
        s.tl(this.link,"o","Service Solution");      
    }
}
/* end for popup links */
