﻿// Utility Function
function $(id){return document.getElementById(id);}
// END:Utility Function

// Extending js //
Array.prototype.max = function(){return Math.max.apply({},this)};
// END:Extending js //

function StandardizeHostName(hn)
{
    var hnpatterns = new RegExp("healthvault.com|microsofthealth.com","i");
    var standardizedhn = "www.healthvault.com";
    if (typeof(hn) == "string")
    {
        if (hn.match(hnpatterns))
        {
            hn = standardizedhn;
        }
    }
    return hn;
}


var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();




function HasWindowsMediaPlayerPlugin()
{
    //Windows Media Player
    var agt=navigator.userAgent.toLowerCase();
    var ie  = (agt.indexOf("msie") != -1);
    var ns  = (navigator.appName.indexOf("Netscape") != -1);
    var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
    var mac = (agt.indexOf("mac")!=-1);
    var returnValue = false;
    
    if (ie && win) 
    {	
        try 
        {
            var testObject = CreateObject("MediaPlayer.MediaPlayer.1");
            returnValue = IsObject(testObject);
        }
        catch (Err)
        {
            returnValue = false;
        }
    }
    if (ns || !win) 
    {
		if (navigator.mimeTypes["application/x-mplayer2"]) 
		{
            if (navigator.mimeTypes["application/x-mplayer2"].enabledPlugin != null) 
            {
                returnValue = true;
            }
        }
		if (navigator.mimeTypes["application/x-ms-wmp"]) 
		{
            if (navigator.mimeTypes["application/x-ms-wmp"].enabledPlugin != null) 
            {
                returnValue = true;
            }
        }
    }
    return returnValue;
}


function heightEqualizer(elementArray)
{
    var heights=[];
    for (var i=0;i<elementArray.length;i++)
    {
        heights.push(elementArray[i].offsetHeight);
    }
    applyChange("height",elementArray,heights.max());
}

function randomize(max,elementArray)
{
    var newArray = new Array();
    
    for (var i = 0; i < elementArray.length; i++)
        newArray[i] = i;
    
    for (var i = 0; i < max; i++)
    {
        var ri = -1;
        do
        {
            var n = Math.floor(Math.random() * newArray.length);
            ri = newArray[n];
            
            if (ri != -1)
                newArray[n] = -1;
        }
        while (ri == -1);
        
        elementArray[ri].style.display = "block";
    }
}

function applyChange(type,elementArray,value)
{
    var param = "";
    var unit = "";
    switch (type)
    {
        case "height":
            param = "height";
            unit = "em";
        break;
    }
    for (var i=0;i<elementArray.length;i++)
    {
        elementArray[i].style[param] = value/10 + unit;
    }
}

function getChildrenInParentByClassName(pID,cClass)
{
    var array = $(pID).getElementsByTagName("div");
    var newArray = [];
    for (var i=0;i<array.length;i++)
    {
        if (array[i].className == cClass)
        {
            newArray.push(array[i]);
        }
    }
    return(newArray);
}

function addToMyFavorite(url, title)
{
    if (document.all)
    {
        window.external.AddFavorite(url, title);
    }
    else if (window.sidebar)
    {
        window.sidebar.addPanel(title, url, "");
    }
}


// Redesign JS //


function audienceDirectory()
{
    if(readCookie("HealthVault"))
    {
        if (readCookie("HealthVault") == "organization")
        {
            document.getElementById("lnkPersonal").style.display = "none";
            document.getElementById("lnkIndustry").style.display = "block";
        }
    }     
}

function audienceDir()
{
    if(readCookie("HealthVault"))
    {
        if (readCookie("HealthVault") == "organization")
        {
            document.getElementById("channel").className = "indDir";
        }
    }     
}

function audienceHelp()
{
    if(readCookie("HealthVault"))
    {
        if (readCookie("HealthVault") == "organization")
        {
            document.getElementById("industry-help").style.display = "block";
        }
    }     
}


function lnkDevices()
{
    if(readCookie("HealthVault"))
    {
        if (readCookie("HealthVault") == "organization")
        {
            document.getElementById("lnkLD1Ind").style.display = "block";
            document.getElementById("lnkLD1Per").style.display = "none";
        }
    }     
}

function selectHome()
{
   if(readCookie("HealthVault"))
    {
        if (readCookie("HealthVault") == "organization")
        {
           window.location="/industry/index.html";
           return;
        }
      
    }
        window.location="/personal/index.html";  
}


function setSubnav()
{
	
	if(document.getElementById("nav-ind"))
	{
	    var nind =  document.getElementById("nav-ind");
	    var norg = document.getElementById("nav-org");
    
    	
	    if(readCookie("HealthVault"))
        {
            if (readCookie("HealthVault") == "individual")
            {
              nind.style.display = "block";
	          norg.style.display = "none";  
            }
            else if (readCookie("HealthVault") == "organization")
            {
              norg.style.display = "block";
	          nind.style.display = "none";   
            } 
        }
        else
        {
            norg.style.display = "none";
         }
    }
}


function setWTAudience()
{
	
	    if(readCookie("HealthVault"))
        {
            if (readCookie("HealthVault") == "individual")
            {  
	           document.write("<meta name=\"DCSext.www_rt\" content=\"" + "personal" + "\" />");
            }
            else if (readCookie("HealthVault") == "organization")
            {
    	      document.write("<meta name=\"DCSext.www_rt\" content=\"" + "industry" + "\" />");
            } 
        }
        else
        {
             document.write("<meta name=\"DCSext.www_rt\" content=\"" + "none" + "\" />");
        }
}



function startList() {
	if (document.all&&document.getElementById) 
	{
	    if(document.getElementById("nav"))
	    {
		    subnavRoot = document.getElementById("nav").getElementsByTagName("ul");
		    for (i=0; i<subnavRoot.length; i++){
		        for (j=0; j<subnavRoot[i].childNodes.length; j++) 
		        {
			        node = subnavRoot[i].childNodes[j];
			        if (node.nodeName=="LI") 
			        {
				        node.onmouseover=function() 
				        {
					        this.className+=" over";
				        }
				        node.onmouseout=function() 
				        {
					        this.className=this.className.replace(" over", "");
				        }
			        }
		        }
		    }
	    }
	}
}


function setCookie(name, value, expiration)
{
    var cookie = name + "=" + encodeURIComponent(value);
    var expires = new Date();
    expires.setFullYear(expires.getFullYear() + 1);   
    
    if(expiration != null)
    {
        if (expiration != 0)
            cookie += "; expires=" + expiration +"; path=/"; 
        else
          cookie += "; path=/"; 
    }
   else
    {
        cookie += "; expires=" + expires +"; path=/"; 
    }
    document.cookie = cookie;
   
}


function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function deleteCookie (name)
{
    setCookie(name, "", new Date(0));
}

function detect()
{
    if(readCookie("HealthVault"))
    {
        if (readCookie("HealthVault") == "individual")
        {
            document.location = "Personal/index.html";
        }
        else if (readCookie("HealthVault") == "organization")
        {
            document.location = "Industry/index.html";     
        }
    }
}


function setTabState()
{
    
        if(readCookie("HVFocus"))
        {
            if (readCookie("HVFocus") == "walking")
            {
                HRTabSelect("tab1");
            }
            else if (readCookie("HVFocus") == "diet")
            {
                HRTabSelect("tab2");    
            }
             else if (readCookie("HVFocus") == "comprehensive")
            {
                HRTabSelect("tab3");   
            }
        }
}

function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++)
    {
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className))
        {
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

function isPage(pageUrl)
{
    var currentUrl = document.URL;
    var re = new RegExp(pageUrl,"i");
    return (re.test(currentUrl));
}

function getPosition(element){   
     var left = 0;   
     var top  = 0;   
   
     while (element.offsetParent){   
         left += element.offsetLeft;   
         top  += element.offsetTop;   
         element = element.offsetParent;   
     }   
   
     left += element.offsetLeft;   
     top  += element.offsetTop;   
   
     return {x:left, y:top};   
 }  
 
function personalHomePageEqualizeHeights() 
{
     var elemA = document.getElementById("PersonalHomeBoxLeft");
     var elemB = document.getElementById("PersonalHomeBoxRight");
     if ((elemA) && (elemB))
     {
        // Equalize the heights
        var rightElemDelta = 81;
        var heightA = elemA.offsetHeight;
        var heightB = elemB.offsetHeight + rightElemDelta;
        var NewHeight = Math.max(heightA, heightB);
        elemA.style.height = NewHeight + "px";
        NewHeight -= rightElemDelta;
        elemB.style.height = NewHeight + "px";
      }
}
function personalHomePageOnFontResize(e,args) 
{
    personalHomePageEqualizeHeights();
}
function personalHomePageInit() 
{
    var iBase = TextResizeDetector.addEventListener(personalHomePageOnFontResize,null);
}

function correctNavigation() 
{
    var navObj = document.getElementById("nav");
    if (navObj) 
    {
        var navlistitemObjs = navObj.getElementsByTagName("LI");
        if (navlistitemObjs) 
        {
            var lastsubsubnavObj;
            var i = 0;
            var lastsubsubnavFound = false;
            while ((i < navlistitemObjs.length ) && (!lastsubsubnavFound))
            {
                lastsubsubnavObj = navlistitemObjs[i];
                if ((lastsubsubnavObj) && (lastsubsubnavObj.className))
                {
                    lastsubsubnavFound = (lastsubsubnavObj.className == "heightfix first");
                }
                if (!lastsubsubnavFound)
                {
                    i++;
                }
            }
            if (lastsubsubnavFound) 
            {
                if (BrowserDetect.browser == "Safari")
                {
                    // get the submenu
                    var submenuobjs = lastsubsubnavObj.getElementsByTagName("UL");
                    if (submenuobjs) 
                    {
                        var submenuobj = submenuobjs[0];
                        if (submenuobj)
                        {
                            // add a little to the left margin
                            submenuobj.style.marginLeft = "20px";
                        }
                    }
                }
            }
        }
    }
}
function init()
{
     appendFlip4MacText();
     startList(); 
     if (isPage("/ICE/HiMSS/index.html") || isPage("/ICE/HiMSS/index.aspx") || isPage("/ICE/HiMSS/"))
     {
        // Equalize the heights
        var elementA = document.getElementById("Metavante");
        var elementB = document.getElementById("MyVitalData");
        var heightA = elementA.offsetHeight;
        var heightB = elementB.offsetHeight;
        var NewHeight = Math.max(heightA, heightB);
        var deltaA = NewHeight - heightA;
        var deltaB = NewHeight - heightB;
        elementA.style.height = NewHeight + "px";
        elementB.style.height = NewHeight + "px";
        
        // Align the two offer blocks
        elementA = document.getElementById("MetavanteOffer");
        elementB = document.getElementById("MyVitalDataOffer");
        elementA.style.position = "relative";
        elementB.style.position = "relative";
        elementA.style.top = deltaA + "px";
        elementB.style.top = deltaB + "px";
        
        reTargetAllLinksOnPage("_target");
     }
     if (isPage("/Personal/devices-overview.") || isPage("/Personal/devicelogoprogram."))
     { 
        var HVCCInstallLink = document.getElementById("HVCCInstallLink");
        if (HVCCInstallLink)
        {        
            if (navigator.userAgent.toLowerCase().indexOf("windows nt 5.1")  == -1)
            {   
                HVCCInstallLink.href = "http://go.microsoft.com/fwlink/?LinkID=127972"; 
            }
        }
     }
     
     var elemA = document.getElementById("PersonalHomeBoxLeft");
     var elemB = document.getElementById("PersonalHomeBoxRight");
     if ((elemA) && (elemB))
     {
        personalHomePageEqualizeHeights();
     }
     correctNavigation();
}

function OSDetect()
{
    var platformOS;

    if (navigator.userAgent.indexOf("Windows NT 6.0") > -1) 
    { 
        document.getElementById("selectOS").style.display = "none";
        document.getElementById("vista").style.display = "block";
    }
    else if(navigator.userAgent.indexOf("Windows NT 5.1") > -1) 
    { 
         document.getElementById("selectOS").style.display = "none";
         document.getElementById("xp").style.display = "block";
    }	
}



function HRTabSelect(tab)
{
    for(var i=1;i < 4;i++)
    {
       document.getElementById("tab" + i + "Left").className = "tabLeftOff";
	   document.getElementById("tab" + i + "Middle").className = "tabMiddleOff";
	   document.getElementById("tab" + i + "Right").className = "tabRightOff";
	   document.getElementById("tab" + i + "Content").style.display = "none";
	   document.getElementById("tab" +i ).className = "tabNormal";
    }
    if(tab == "tab1")
	{
	   document.getElementById("tab1Left").className = "tabLeftOn";
	   document.getElementById("tab1Middle").className = "tabMiddleOn";
	   document.getElementById("tab1Right").className = "tabRightOn";
	   document.getElementById("tab2").className = "tabLeft";
	   document.getElementById("tab1Content").style.display = "block";
	}
	else if(tab == "tab2")
	{
	   document.getElementById("tab2Left").className = "tabLeftOn2";
	   document.getElementById("tab2Middle").className = "tabMiddleOn";
	   document.getElementById("tab2Right").className = "tabRightOn";
	   document.getElementById("tab3").className = "tabLeft";
	   document.getElementById("tab2Content").style.display = "block";
	}
	else if(tab == "tab3")
	{
	   document.getElementById("tab3Left").className = "tabLeftOn2";
	   document.getElementById("tab3Middle").className = "tabMiddleOn";
	   document.getElementById("tab3Right").className = "tabRightOn";
	   document.getElementById("tab3Content").style.display = "block";
    }
} 

function SmartBreadcrumb(name, section)
{
  url = window.location.search.substring(1); 
  
  if(url.length < 400)
  {
      param = url.split("&");   
       for (i=0;i<param.length;i++) 
       { 
            value = param[i].split("="); 
            if (value[0] == name) 
            { 
                switch(value[1])
                {
                    case "1":
                        document.write("<a href='/hrweb/lose-weight.html'>Back to Lose or maintain weight</a>");
                        break;
                    case "2":
                        document.write("<a href='/hrweb/stay-fit.html'>Back to Get fit, stay fit</a>");
                        break;    
                    case "3":
                        document.write("<a href='/hrweb/high-blood-pressure.html'>Back to Manage high blood pressure</a>");
                        break;    
                    case "4":
                        document.write("<a href='/hrweb/get-organized.html'>Back to Organize family health information</a>");
                        break;
                    case "5":
                       document.write("<a href='/hrweb/in-case-of-emergency.html'>Back to Prepare for emergency</a>");
                       break;  
                    case "6":
                        document.write("<a href='/personal/scenario/lose-weight.html'>Back to Lose or maintain weight</a>");
                        break;
                    case "7":
                        document.write("<a href='/personal/scenario/stay-fit.html'>Back to Get fit, stay fit</a>");
                        break;    
                    case "8":
                        document.write("<a href='/personal/scenario/high-blood-pressure.html'>Back to Manage high blood pressure</a>");
                        break;    
                    case "9":
                        document.write("<a href='/personal/scenario/get-organized.html'>Back to Organize family health information</a>");
                        break;
                    case "10":
                       document.write("<a href='/personal/scenario/in-case-of-emergency.html'>Back to Prepare for emergency</a>");
                       break;      
                    default:
                       document.write("<a href='/personal/scenario/index.html'>Back to HealthVault on HRWeb</a>");
                } 
                return;
           }
           else if(value[0] == "type")
           {
                switch(value[1])
                {
                 case "application":
                        document.write("<a href='/personal/websites.html'>See all applications</a>");
                        return;
                 case "device":
                        document.write("<a href='/personal/devices.html'>See all devices</a>");
                       return;   
                 }
           }
       }
   }
   
   if(section == "hrweb")
        document.write("<a href='/hrweb/websites.html'>Back to all featured applications</a>");
 }
 
function getViewportHeight() {
    var returnValue = -1;
	if (window.innerHeight!=window.undefined) 
	{
	    returnValue = window.innerHeight;
	}
	else 
	{
	    if (document.compatMode=='CSS1Compat') 
	    {
	        returnValue =  document.documentElement.clientHeight;
	    }
	    else 
	    {
	        if (document.body) 
	        {
	            returnValue =  document.body.clientHeight; 
	        }
        }
    }
	return returnValue;
}

function getViewportWidth() 
{
    var returnValue = -1;
	if (window.innerWidth!=window.undefined) 
	{
	    returnValue = window.innerWidth; 
	}
	else
	{
	    if (document.compatMode=='CSS1Compat') 
	    {
	        returnValue = document.documentElement.clientWidth; 
	    }
	    else
	    {
	        if (document.body) 
	        {
	            returnValue = document.body.clientWidth; 
	        }
        }
    }
	return returnValue;
}

function setFadeSize() 
{
	var body = document.getElementsByTagName("BODY")[0];
    var fade = document.getElementById("fade");
	var fullHeight = getViewportHeight();
	var fullWidth = getViewportWidth();
	
	// Determine what's bigger, scrollHeight or fullHeight / width
	if (fullHeight > body.scrollHeight) 
	{
		popHeight = fullHeight;
	}
	else 
	{
		popHeight = body.scrollHeight;
	}
	
	if (fullWidth > body.scrollWidth) 
	{
		popWidth = fullWidth;
	} 
	else 
	{
		popWidth = body.scrollWidth;
	}
	
	fade.style.height = popHeight + "px";
	fade.style.width = popWidth + "px";
}


function HRWebFirstVisit()
{
  if(!readCookie("HRWebHV"))
  {
      document.getElementById('light').style.display='block';
      document.getElementById('fade').style.display='block';
      setFadeSize();
      setCookie('WT.mc_id', 'hrweb', 0);
  }
}

function captureTab(e)
{
    var keynum;
    if(!readCookie("HRWebHV"))
    {
       if(window.event) // IE
       {
            keynum = e.keyCode;
       }
       else if(e.which) // Netscape/Firefox/Opera
       {
            keynum = e.which;
       } 
       if (keynum == 9)
            return false;
	}
}

function popUp(url,title, width, height)
{
    xPos = (screen.width) ? (screen.width - width)/2 : 0;
    yPos = (screen.height) ? (screen.height - height)/2 : 0;
    window.open(url, title, 'width=' + width + ',height=' + height + ',scrollbars=no,top=' + yPos + ',left=' + xPos, + ',location=no,resize=no');
}

function popUpWMPlayer(url, title, width, height)
{
    var onClickReturnValue = true;
    if (HasWindowsMediaPlayerPlugin())
    {
        if (url) 
        {
            if (!title)
            {
                title = "HealthVault Media";
            }
            if ((!width) || (!height))
            {
                height = 480;
                width = 640;
            }   
            url = "/player.html?v=" + url + "&h=" + height + "&w=" + width + "&t=" + title;
            var xPos = (screen.width) ? (screen.width - width)/2 : 0;
            var yPos = (screen.height) ? (screen.height - height)/2 : 0;
            var win = window.open(url, "popUpWMPlayer", 'width=' + width + ',height=' + height + ',scrollbars=no,top=' + yPos + ',left=' + xPos, + ',location=no,resize=no');
            if (win)
            {
                onClickReturnValue = false;
            }
        }
    }
    return onClickReturnValue;
}


function continueHRWeb()
{
   document.getElementById('light').style.display='none';
   document.getElementById('fade').style.display='none'; 
   setCookie('HRWebHV', 'true', 0);
   setCookie('WT.mc_id', 'hrweb', 0);
}

function setRefHRWeb()
{
     if(!readCookie("WT.mc_id"))
     {
        setCookie('WT.mc_id', 'hrweb', 0);
     }
     document.write("<meta name=\"WT.mc_id\" content=\"" + readCookie("WT.mc_id") + "\" />");
}   

function setHRCampaignId(mcid, ad)
{    
    if (document.referrer == '' && location.href.indexOf('WT.mc_id') < 0)
    {
        document.write("<meta name=\"WT.mc_id\" content=\"" + mcid + "\" />");
	    document.write("<meta name=\"WT.ad\" content=\"" + ad +"\" />");	    
    }
}

function setReferralSite()
{
    var RefererFound = false;
    var url = window.location.search.substring(1); 
    
    if (url.length < 1000) 
    {
        if(!readCookie("WT.mc_id"))
        {
            param = url.split("&"); 
            var i = 0;
            while ((i < param.length) && (!RefererFound)) ///  While
            { 
                value = param[i].split("="); 
                if ((value[0] == "ref"))
                { 
                    switch(value[1])
                    {
                         case "mshome": 
                         case "mshome1": 
                         case "mshome2": 
                         case "mshome3":
                         case "msoffice": 
                         case "msoffice1": 
                         case "msoffice2": 
                         case "msoffice3":  
                         case "mshealth":
                         case "mshealth1":
                         case "mshealth2":
                         case "mshealth3": 
                         case "mswork":
                         case "mswork1":
                         case "mswork2":
                         case "mswork3": 
                         case "msathome": 
                         case "msathome1": 
                         case "msathome2": 
                         case "msathome3": 
                         case "amazon":
                         case "amazon1":
                         case "amazon2":
                         case "amazon3":
                         case "discovery":
                         case "discovery1":
                         case "discovery2":
                         case "discovery3":
                         case "everyday":
                         case "everyday1":
                         case "everyday2":
                         case "everyday3":
                         case "everydayhome":
                         case "everydayhome1":
                         case "everydayhome2":
                         case "everydayhome3":
                         case "mayoclinic":
                         case "mayoclinic1":
                         case "mayoclinic2":
                         case "mayoclinic3":
                         case "msnlifestyles":
                         case "msnlifestyles1":
                         case "msnlifestyles2":
                         case "msnlifestyles3":
                         case "msnlifestyles4":
                         case "msnlifestyles5":
                         case "msnlifestyles6":
                         case "msnlifestyles7":
                         case "msnlifestyles8":
                         case "msnlifestyles9":
                         case "msnhealthfitness":
                         case "msnhealthfitness1":
                         case "msnhealthfitness2":
                         case "msnhealthfitness3":
                         case "msnhealthfitness4":
                         case "msnhealthfitness5":
                         case "msnhealthfitness6":
                         case "msnhealthfitness7":
                         case "msnhealthfitness8":
                         case "msnhealthfitness9":
                         case "msnwindows":
                         case "msnwindows1":
                         case "msnwindows2":
                         case "msnwindows3":
                         case "msnwindows4":
                         case "msnwindows5":
                         case "msnwindows6":
                         case "msnwindows7":
                         case "msnwindows8":
                         case "msnwindows9":
                         case "msnwindowstoday":
                         case "msnwindowstoday1":
                         case "msnwindowstoday2":
                         case "msnwindowstoday3":
                         case "msnwindowstoday4":
                         case "msnwindowstoday5":
                         case "msnwindowstoday6":
                         case "msnwindowstoday7":
                         case "msnwindowstoday8":
                         case "msnwindowstoday9":
                         case "msnmessenger":
                         case "msnmessenger1":
                         case "msnmessenger2":
                         case "msnmessenger3":
                         case "msnmessenger4":
                         case "msnmessenger5":
                         case "msnmessenger6":
                         case "msnmessenger7":
                         case "msnmessenger8":
                         case "msnmessenger9":
                         case "ivillagehealth":
                         case "ivillagehealth1":
                         case "ivillagehealth2":
                         case "ivillagehealth3":
                         case "ivillagestayinghealthy":
                         case "ivillagestayinghealthy1":
                         case "ivillagestayinghealthy2":
                         case "ivillagestayinghealthy3":
                         case "ivillage":
                         case "ivillage1":
                         case "ivillage2":
                         case "ivillage3":
                         case "diagnosis":
                         case "diagnosis1":
                         case "diagnosis2":
                         case "diagnosis3":
                         case "nytimes":
                         case "nytimes1":
                         case "nytimes2":
                         case "nytimes3":
                         case "nytimeshealth":
                         case "nytimeshealth1":
                         case "nytimeshealth2":
                         case "nytimeshealth3":
                         case "msnmain1":
                         case "msnmain2":
                         case "msnmain3":
                         case "msnmain4":
                         case "msnmain5":
                         case "msnmain6":
                         case "msnmain7": 
                         case "msnmain8": 
                         case "msnmain9":    
                         case "hardware": 
                         case "hardware1": 
                         case "hardware2": 
                         case "hardware3":
                         case "windowsvista":  
                         case "windowsvista1": 
                         case "windowsvista2": 
                         case "windowsvista3": 
                         case "windowsmobile": 
                         case "windowsmobile1": 
                         case "windowsmobile2": 
                         case "windowsmobile3": 
                         case "mscom2": 
                         case "test1":
                         case "test2":
                         case "160x600msngamesfl1":
                         case "728x90msngamesfl1":
                         case "300x250msngamesfl1":
                         case "160x600msngamessb1":
                         case "728x90msngamessb1":
                         case "300x250msngamessb1":
                         case "160x600msngamesfl2":
                         case "728x90msngamesfl2":
                         case "300x250msngamesfl2":
                         case "160x600msngamessb2":
                         case "728x90msngamessb2":
                         case "300x250msngamessb2":
                         case "160x600msngamesfl":
                         case "728x90msngamesfl":
                         case "300x250msngamesfl":
                         case "160x600msngamessb":
                         case "728x90msngamessb":
                         case "300x250msngamessb":
                         case "160x600msngameshp":
                         case "728x90msngameshp":
                         case "himss_vid":
                         case "himss_ice":
                         case "himss_mvd":
                         case "himss_acct":
                         case "himss_signin":
                         case "M09040301":
                         case "M09040302":
                         case "M09040303":
                         case "M09040304":
                         case "M09040305":
                         case "M09040306":
                         case "M09040307":
                         case "M09040308":
                         case "M09040309":
                         case "M09040310":
                         case "M09041501":
                         case "M09041502":
                         case "M09041503":
                         case "M09041504":
                         case "M09041505":
                         case "M09041506":
                         case "M09041507":
                         case "M09041508":
                         case "M09041509":
                         case "M09041510":
                         case "S09040301":
                         case "S09040302":
                         case "S09040303":
                         case "S09040304":
                         case "S09040305":
                         case "S09040306":
                         case "S09040307":
                         case "S09040308":
                         case "S09040309":
                         case "S09040310":
                         case "A09040301":
                         case "A09040302":
                         case "A09040303":
                         case "A09040304":
                         case "A09040305":
                         case "A09040306":
                         case "A09040307":
                         case "A09040308":
                         case "A09040309":
                         case "A09040310":
                             setCookie('WT.mc_id', value[1], 0);
                             document.write("<meta name=\"WT.mc_id\" content=\"" + value[1] + "\" />");
                             break;
                    }   // switch
                    RefererFound = true;                
               }    // if (value[0] == "ref")
               else if (value[0] == "WT.mc_id")
               {    
                   // Ensure it fits the pattern
                   var oRegExp = new RegExp("^[a-zA-Z0-9]+$");
                   if (value[1].match(oRegExp)) 
                   {
                        setCookie('WT.mc_id', value[1], 0);
                        document.write("<meta name=\"WT.mc_id\" content=\"" + value[1] + "\" />");
                        RefererFound = true; 
                   }
               }
               i++;
           }    // While loop
       }    // if(!readCookie("WT.mc_id"))
    }   // Length test
 }
 
function disableImage(e) 
{
    if (document.all) 
    {
        if (event.button==2||event.button==3) 
        {
            if (event.srcElement.tagName=="IMG")
            {
                alert(msg);
                return false;
            }
        }
    }
    else if (document.layers) 
    {
        if (e.which == 3) 
        {
            alert(msg);
            return false;
        }
    }
    else if (document.getElementById)
    {
        if (e.which==3&&e.target.tagName=="IMG")
        {
            alert(msg)
            return false;
        }
    }
}

function associateImages()
{
    for(i=0;i<document.images.length;i++)
        document.images[i].onmousedown=disableImage;
}

function isMac() 
{
    // returns True if client platform is a Mac
    return (navigator.appVersion.toLowerCase().indexOf("mac")!=-1);
}

function appendFlip4MacText() 
{
    if (isMac()) 
    {
        var FlipForMacElement = document.getElementById("FlipForMac");
        if (FlipForMacElement) {
            FlipForMacElement.style.display = "block";
            FlipForMacElement.style.visibility = "visible";
        }
        FlipForMacElement = document.getElementById("FlipForMac2");
        if (FlipForMacElement) {
            FlipForMacElement.style.display = "block";
            FlipForMacElement.style.visibility = "visible";
        }
    }
}        

function appendRef(objAnchor)
{   
    if(readCookie("WT.mc_id"))
    {
        var href = objAnchor.href;
        if (href.indexOf("?") < 1)
        {
            href = href + "?";
        } 
        else 
        {
            href = href + "&";
        }
        href = href + "WT.mc_id=" + readCookie("WT.mc_id");
        objAnchor.href = href;
    }
} 

function getRef() {
    return readCookie("WT.mc_id");
}

function reTargetAllLinksOnPage(newTarget)
{
    var anchorsCollection = document.getElementsByTagName('A');
    var anchorElement;
    var scratch = "";
    for (var i = 0; i < anchorsCollection.length; i++) 
    {
        anchorElement = anchorsCollection[i];
        scratch = anchorElement.href;
        scratch = scratch.substring(0,10);
        scratch = scratch.toLowerCase();
        if (scratch != "javascript")
        {
            anchorElement.setAttribute("target", newTarget);
        }
    }
}


/*****************************************************************************
    Text Resize Detector
*****************************************************************************/
TextResizeDetector = function() { 
    var el  = null;
	var iIntervalDelay  = 200;
	var iInterval = null;
	var iCurrSize = -1;
	var iBase = -1;
 	var aListeners = [];
 	var createControlElement = function() {
	 	el = document.createElement('span');
		el.id='textResizeControl';
		el.innerHTML='&nbsp;';
		el.style.position="absolute";
		el.style.left="-9999px";
		var elC = document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID);
		// insert before firstChild
		if (elC)
			elC.insertBefore(el,elC.firstChild);
		iBase = iCurrSize = TextResizeDetector.getSize();
 	};

 	function _stopDetector() {
		window.clearInterval(iInterval);
		iInterval=null;
	};
	function _startDetector() {
		if (!iInterval) {
			iInterval = window.setInterval('TextResizeDetector.detect()',iIntervalDelay);
		}
	};
 	
 	 function _detect() {
 		var iNewSize = TextResizeDetector.getSize();
 		if(iNewSize!== iCurrSize) {
			for (var 	i=0;i <aListeners.length;i++) {
				aListnr = aListeners[i];
				var oArgs = {  iBase: iBase,iDelta:((iCurrSize!=-1) ? iNewSize - iCurrSize + 'px' : "0px"),iSize:iCurrSize = iNewSize};
				if (!aListnr.obj) {
					aListnr.fn('textSizeChanged',[oArgs]);
				}
				else  {
					aListnr.fn.apply(aListnr.obj,['textSizeChanged',[oArgs]]);
				}
			}

 		}
 		return iCurrSize;
 	};
	var onAvailable = function() {
		if (!TextResizeDetector.onAvailableCount_i ) {
			TextResizeDetector.onAvailableCount_i =0;
		}

		if (document.getElementById(TextResizeDetector.TARGET_ELEMENT_ID)) {
			TextResizeDetector.init();
			if (TextResizeDetector.USER_INIT_FUNC){
				TextResizeDetector.USER_INIT_FUNC();
			}
			TextResizeDetector.onAvailableCount_i = null;
		}
		else {
			if (TextResizeDetector.onAvailableCount_i<600) {
	  	 	    TextResizeDetector.onAvailableCount_i++;
				setTimeout(onAvailable,200)
			}
		}
	};
	setTimeout(onAvailable,500);

 	return {
		 	 // Initialize the detector
		 	 //   @param {String} sId The id of the element in which to create the control element
		 	init: function() {
		 		createControlElement();		
				_startDetector();
 			},
			// Adds listeners to the ontextsizechange event. 
			// Returns the base font size
 			addEventListener:function(fn,obj,bScope) {
				aListeners[aListeners.length] = {
					fn: fn,
					obj: obj
				}
				return iBase;
			},
			// performs the detection and fires textSizeChanged event
			//   @return the current font size
			//   @type {integer}
 			detect:function() {
 				return _detect();
 			},
 			// Returns the height of the control element
 			//   @return the current height of control element
			//   @type {integer}
 			getSize:function() {
	 				var iSize;
			 		return el.offsetHeight;
		 		
		 		
 			},
 			// Stops the detector
 			stopDetector:function() {
				return _stopDetector();
			},
			// Starts the detector
 			startDetector:function() {
				return _startDetector();
			}
 	}
 }();

TextResizeDetector.TARGET_ELEMENT_ID = 'doc';
TextResizeDetector.USER_INIT_FUNC = null;
