/*
 * Script: 	uksitewise.js
 * Version:	1.0
 * Author:	marissa
 * Date:	January 31, 2002
 * Purpose:	The JavaScript file will be included in the html pages of
 *		www.morganstanley.com/im/uk to define the content groups
 *		used by Akamai SiteWise.
 *
*/




var wtl_imgarray = new Array; 
var wtl_ptr = 0;
function wtl_Tag6(wtl_TagID,wtl_SID,wtl_URL,wtl_Title,CONTENTGROUP)
{

        function wtl_createImage(wtl_src)
        {
                wtl_imgarray[wtl_ptr] = new Image;
                wtl_imgarray[wtl_ptr].src = wtl_src;
                wtl_ptr++; 
        }
        
        function D8( d)
        {
                var fwd=1, seed= new Date('01/01/2000'), key= "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
                var s= key.charAt( d.getFullYear()-2000)+key.charAt( d.getMonth()+1)+key.charAt( d.getDate());
                s+= key.charAt( d.getHours())+key.charAt( d.getMinutes())+key.charAt( d.getSeconds());
                while( seed.getDay()!=fwd) seed= new Date(seed.getTime() + 86400000);
                var w= Math.floor( (d.getTime()-(seed.getTime()+86400000)) / 604800000 );
                s+= key.charAt( (w-(w%16))/16 );
                s+= key.charAt( w%16);
                return s;
        }

        function A( B, C)
        {
                W+="&"+B+"="+escape(C);
        }
        
        var t = new Date();
        var W="http"+(document.URL.indexOf('https:')==0?'s':'')+"://statse.webtrendslive.com/S" + wtl_SID + "/button6.asp?tagver=" + wtl_TagVer + "&si=" + wtl_TagID + "&offset=" + wtl_Offset + "&fw=" + wtl_FWD;
        A( "server", typeof(SERVER)== "string" ? SERVER : "");
        A( "order", typeof(ORDER)== "string" ? ORDER : "");
        A( "Group", typeof(CONTENTGROUP)== "string" ? CONTENTGROUP : "");
        A( "invoice", typeof(INVOICE)== "string" ? INVOICE : "");
        A( "cartview", typeof(CARTVIEW)== "string" ? CARTVIEW : "");
        A( "cartadd", typeof(CARTADD)== "string" ? CARTADD : "");
        A( "cartremove", typeof(CARTREMOVE)== "string" ? CARTREMOVE : "");
        A( "checkout", typeof(CHECKOUT)== "string" ? CHECKOUT : "");
        A( "cartbuy", typeof(CARTBUY)== "string" ? CARTBUY : "");
        A( "adcampaign", typeof(ADCAMPAIGN)== "string" ? ADCAMPAIGN : "");
        A( "tz", t.getTimezoneOffset());
        A( "ch", t.getHours());
        A( "cl", D8(t));
        A( "ti", wtl_Title);
        A( "url", wtl_URL);
        A( "rf", window.document.referrer);
        A( "js", "Yes");
        A( "ul", navigator.appName=="Netscape" ? navigator.language : navigator.userLanguage);
        if(typeof(screen)=="object")
        {
        A( "sr", screen.width+"x"+screen.height);
        A( "cd", screen.colorDepth);
        A( "jo", navigator.javaEnabled() ? "Yes" : "No");
        }

        if( W.length>2048 && navigator.userAgent.indexOf('MSIE')>=0)
                W= W.substring( 0, 2043)+"&tu=1";

        wtl_createImage(W);

}

var pattern = document.URL;
var group = '';
var url = /(\w+):\/\/([\w.]+)\/(\S*)/;
var result = pattern.match(url);
if (result != null) {
   var fullurl = result[0];
   var protocol = result[1];
   var host = result[2];
   var path = result[3];
}
var a = new Array();
var b = new Array();
var dgroup = '';
var pgroup = '';
var dgroup1 = new Array();
var dgroup2 = new Array();
var pgroup1 = new Array();
var pgroup2 = new Array();

if ( ((pattern.indexOf("pisas268")) == -1) && ((pattern.indexOf("sacore")) == -1) && ((pattern.indexOf("pisws1")) == -1) ){   //exclude staging areas

/*
 * Array a contains URL regular expression 
 * Array b contains corresponding content group
 * if a sub-directory has a different content group
 * than its parent, you must list the sub-directory
 * first in Array a or its parent's content group
 * will override it.
 */

 //PUT YOUR REGULAR EXPRESSIONS HERE
 a[0] = new RegExp("\/sitemap\/");			b[0] = "Site Map";
 a[1] = new RegExp("\/about\/");			b[1] = "About Morgan Stanley";
 a[2] = new RegExp("\/contact\/");			b[2] = "Contact Us";
 a[3] = new RegExp("\/literature\/");			b[3] = "Literature";
 a[4] = new RegExp("\/uk\/index");			b[4] = "Main Page";
 a[5] = new RegExp("\/uk\/legal");			b[5] = "Legal";
 a[6] = new RegExp("\/prices\/");			b[6] = "Dynamic Product Information";
 a[7] = new RegExp("\/products_uk\/.*\/commentary"); 	b[7] = "Dynamic Product Information";
 a[8] = new RegExp("\/products_uk\/.*\/performance");	b[8] = "Dynamic Product Information";
 a[9] = new RegExp("\/products_uk\/.*\/composition");	b[9] = "Dynamic Product Information";
 a[10] = new RegExp("\/products_uk\/.*\/c_p");		b[10] = "Dynamic Product Information";
 a[11] = new RegExp("\/invproducts\/");			b[11] = "Products";
 a[12] = new RegExp("\/products_uk\/.*\/team");		b[12] = "Products";
 a[13] = new RegExp("\/views\/");			b[13] = "Views";
 a[14] = new RegExp("\/offering\/");			b[14] = "Online Offering";
 a[15] = new RegExp("\/bios\/");			b[15] = "Manager Bios";
 a[16] = new RegExp("\/faq\/");				b[16] = "Frequently Asked Questions";
 a[17] = new RegExp("\/webcasts\/");			b[17] = "Webcasts";
 a[18] = new RegExp("\/press\/");			b[18] = "Press Release";



 //a[6] = new RegExp("\/products_uk\/.*\/overview");	b[6] = "Product Details";
 
 for (var element in a) {
  if (a[element].test(pattern)) { group = b[element] ; break; }
  else { group = "Miscellaneous"; }
 }
}


var wtl_TagVer = 6;
var wtl_FWD = 0;
var wtl_url = document.URL;
var wtl_title = document.title;
var wtl_Offset = "-500";
WTL_TAG = new Image;
WTL_TAG.ID = "WTL_TAG";
var CONTENTGROUP= group;

wtl_Tag6(94033,"005-01-8-2-233860-94033",wtl_url,wtl_title,"MorganStanley.com");
wtl_Tag6(93722,"005-01-8-1-233860-93722",wtl_url,wtl_title,"IIM UK");
wtl_Tag6(115196,"115196",wtl_url,wtl_title,CONTENTGROUP);

if (CONTENTGROUP == "Dynamic Product Information") {
 dgroup1[0] = new RegExp("\/prices\/");				dgroup2[0] = "Daily Prices";
 dgroup1[1] = new RegExp("\/products_uk\/.*\/commentary");	dgroup2[1] = "Commentary";
 dgroup1[2] = new RegExp("\/products_uk\/.*\/performance");	dgroup2[2] = "Performance";
 dgroup1[3] = new RegExp("\/products_uk\/.*\/composition");	dgroup2[3] = "Composition";
 dgroup1[4] = new RegExp("\/products_uk\/.*\/c_p");		dgroup2[4] = "Performance";

 for (var index in dgroup1) {
   if (dgroup1[index].test(pattern)) { dgroup = dgroup2[index]; break;}
   else { dgroup = "Miscellaneous"; }
 }
 wtl_Tag6(122441,"122441",wtl_url,wtl_title,dgroup);		//Pass in Dynamic Product Info content group
}
else if (CONTENTGROUP == "Products") {
 pgroup1[0] = new RegExp("\/invproducts\/");			pgroup2[0] = "Investment Products Page";
 pgroup1[1] = new RegExp("\/products_uk\/.*\/team");		pgroup2[1] = "Team Page";

 for (var index in pgroup1) {
   if (pgroup1[index].test(pattern)) {pgroup = pgroup2[index]; break;}
   else { pgroup = "Miscellaneous"; }
 }
 wtl_Tag6(122445,"122445",wtl_url,wtl_title,pgroup);		//Pass in Products Content group
}


//wtl_Tag6(122441,"122441",wtl_url,wtl_title,CONTENTGROUP);

