﻿// This code gets used by the Ad-Rotator control

//---**************    HIMSS Marquee functionality   **************---//
function HIMSSMarquee(ctrlId, startDelay, scrollDelay, scrollAmount, direction, bMouseOverStop, 
                        bMouseOverScroll, width, height, presentationStyle, contentUpdateUrl,
                        contentUpdateInterval, entriesCount, contentRotateInterval)
{
    this.CtrlID = ctrlId;
    this.StartDelay     = startDelay;       // Number of milliseconds to wait before start scrolling
    this.ScrollDelay    = scrollDelay;     // Number of milliseconds between frames
    this.ScrollAmount   = scrollAmount;   // Number of pixels to scroll on each move
    this.Direction  = direction;         // 0 - left, 1 - right, 2 - up, 3 - down
    this.Width      = (parseInt(width) > 0) ? parseInt(width) : 300;
    this.Height     = (parseInt(height) > 0) ? parseInt(height) : 300;
    this.StopOnMouseOver = bMouseOverStop;
    this.ShowScrollOnMouseOver = bMouseOverScroll;
    this.bSliding   = false;
    this.jqCtrl     = $('#' + ctrlId);
    this.jqMarquee  = null;
    this.xDown  = 0;
    this.yDown  = 0;
    this.xUp    = 0;
    this.yUp    = 0;
    this.xDownDrag = 0;
    this.yDownDrag = 0;
    this.Decelleration = -700;          // Number of pixels per second
    this.SlideRefreshInterval   = 100;  // Milliseconds between re-calculation of slide speed
    this.PresentationType       = presentationStyle;    // 0 - scrolls the content; 1 - rotates single items
    this.ContentUpdateURL       = contentUpdateUrl;
    this.ContentUpdateInterval  = contentUpdateInterval;  // This value is in seconds
    this.ContentRotateInterval  = contentRotateInterval;   // This value is in seconds
    this.ContentEntryCount      = entriesCount;   // Number of entries to download from server
    this.XmlContents            = null;
    this.XslContents            = null;
    this.CurrentItem            = -1;
    this.contentRotateTimer     = null;
    
    this.Init = function()
    {        
        if(this.jqCtrl.length == 0)
        {   alert("Could not find marquee control"); return; }
        
        var jqDivParent = this.jqCtrl.children("div:eq(1)");
        this.jqMarquee = jqDivParent.children("marquee");
       
        this.jqCtrl.css("width", this.Width);
        this.jqCtrl.css("height", this.Height);
        
        this.jqMarquee[0].direction = this.Direction;
        this.jqMarquee[0].scrollDelay = this.ScrollDelay;
        this.jqMarquee[0].scrollAmount = this.ScrollAmount;
        
        this.bMoving = true;
        var oThis = this; 
        
        if(this.StopOnMouseOver)
        {
            this.jqMarquee.bind('mouseover', function(e) {oThis.MouseOverHandler(e);});
            this.jqMarquee.bind('mouseout', function(e) {oThis.MouseOutHandler(e);});
            this.jqMarquee.bind('mousedown', function(e) {oThis.MouseDownHandler(e);});
            this.jqMarquee.bind('mouseup', function(e) {oThis.MouseUpHandler(e);});
            //this.jqMarquee.bind('mousemove', function(e) {oThis.MouseMoveHandler(e);});
            this.jqMarquee.bind('selectstart', function() { return false; });
        }
        $.get(this.ContentUpdateURL, function(data) { oThis.UploadXmlContentSuccess(data);});
        $.get("corpSupporters.xsl", function(data) { oThis.UploadXslContentSuccess(data);});
        if(this.PresentationType == 1)
        {
            this.jqMarquee[0].stop();
            alert("stopped");
        }
    }
    
    this.MouseDownHandler = function(e)
    {
        var evt = window.event || e;
        this.xDown = evt.clientX;
        this.yDown = evt.clientY;
        this.xDownDrag = this.xDown;
        this.yDownDrag = this.yDown;
        this.mouseDownTime = new Date();
        this.jqMarquee[0].stop();
        this.jqMarquee[0].setCapture();
    }
    
    this.MouseUpHandler = function(e)
    {
        var evt = window.event || e;
        this.xUp = evt.clientX;
        this.yUp= evt.clientY;
        this.mouseUpTime = new Date();
        
        if(this.xDown != 0 && this.yDown != 0)
        {
            if(parseInt((this.mouseUpTime - this.mouseDownTime).valueOf()) < 1000 && !this.bSliding)
            {
                var dx = (this.xUp - this.xDown);
                var dy = (this.yUp - this.yDown);
                
                var velX = Math.abs((this.xUp - this.xDown)*1000/parseInt((this.mouseUpTime - this.mouseDownTime).valueOf()));
                var velY = Math.abs((this.yUp - this.yDown)*1000/parseInt((this.mouseUpTime - this.mouseDownTime).valueOf()));
                
                this.xDown = 0; this.yDown = 0;
                if(Math.abs(dx) > Math.abs(dy))
                    if(dx < 0)
                        this.Slide(2*velX, "LEFT");
                    else
                        this.Slide(2*velX, "RIGHT");
                else
                    if(dy < 0)
                        this.Slide(2*velY, "UP");
                    else
                        this.Slide(2*velY, "DOWN");
            }
        }
        this.jqMarquee[0].releaseCapture();
    }
    
    this.MouseOverHandler = function(e)
    {
        this.jqMarquee[0].style.cursor = "hand";
        if(this.StopOnMouseOver && !this.bSliding)
            this.jqMarquee[0].stop();
    }
    
    this.MouseOutHandler = function(e)
    {
        this.jqMarquee[0].style.cursor = "default";
        this.jqMarquee[0].start();
    }
    
    this.MouseMoveHandler = function(e)
    {
        var evt = window.event || e;
        var btnPressed;
        
        if(evt.which)
            btnPressed = evt.which;
        else
            btnPressed = evt.button;
        
        if(!this.bSliding && btnPressed == 1 && this.xDown != 0 && this.yDown != 0)
        {
            var dx = (evt.clientX - this.xDownDrag);
            var dy = (evt.clientY - this.yDownDrag);
            
            this.jqMarquee[0].stop();
            
            this.xDownDrag = evt.clientX;
            this.yDownDrag = evt.clientY;
            
            if(this.jqMarquee[0].direction.toUpperCase() == "LEFT" || this.jqMarquee[0].direction.toUpperCase() == "RIGHT")
            {
                this.jqMarquee[0].scrollLeft = this.jqMarquee[0].scrollLeft - dx;
            }
        }
    }
    
    this.Slide = function(velocity, dir)
    {
        var oThis = this;
        
        if(!this.bSliding)
        {
            //--* Initialize the slide motion
            switch(this.Direction.toUpperCase())
            {
                case "LEFT":
                case "RIGHT":
                        if(dir == "UP" || dir == "DOWN")
                            return;
                        break;
                case "UP":
                case "DOWN":
                        if(dir == "LEFT" || dir == "RIGHT")
                            return;
                        break;
                default:
                        return;
            }
            this.SlideStartTime = new Date();
            this.jqMarquee[0].scrollDelay = 20;
            this.jqMarquee[0].scrollAmount = velocity * 20 / 1000;
            this.jqMarquee[0].direction = dir;
            this.bSliding = true;
            this.jqMarquee[0].start();
            setTimeout(function() {oThis.Slide(velocity);}, this.SlideRefreshInterval);
        }
        else
        {
            var curV    = 1000/this.jqMarquee[0].scrollDelay * this.jqMarquee[0].scrollAmount;
            var curTime = new Date();
            var newV    = velocity + this.Decelleration*parseInt((curTime - this.SlideStartTime).valueOf())/1000;
            var baseV   = 1000/this.ScrollDelay * this.ScrollAmount;
            if(newV < baseV)
            {
                this.bSliding = false;
                this.jqMarquee[0].scrollDelay = this.ScrollDelay;
                this.jqMarquee[0].scrollAmount = this.ScrollAmount;
                this.jqMarquee[0].direction = this.Direction;
            }
            else
            {
                this.jqMarquee[0].scrollAmount = parseInt(newV * this.jqMarquee[0].scrollDelay / 1000);
                setTimeout(function() { oThis.Slide(velocity);}, this.SlideRefreshInterval);
            }
        }
    }
    
    this.ShowNextItem = function()
    {
        if(this.XmlContents != null)
        {
            var itemList = this.XmlContents.selectNodes("/root/item")
            var curItem;
            
            if(itemList.length == 0)
                alert("Number of items is zero.");
            else
            {
                this.CurrentItem = (this.CurrentItem + 1) % itemList.length;
                curItem = itemList.item(this.CurrentItem);
                var htmlContent = curItem.transformNode(this.XslContents);
                //alert(htmlContent);
                this.jqMarquee[0].innerHTML = htmlContent;
            }
            
        }
    }
    
    this.UploadXmlContentSuccess = function(data)
    {
        this.XmlContents = data;
        if(this.XslContents != null)
            this.ShowNextItem();
    }
    
    this.UploadXslContentSuccess = function(data)
    {
        this.XslContents = data;
        if(this.XmlContents != null)
            this.ShowNextItem();
    }
}
     
//*************************************************************************************************//
//Description:  Provides 'Ad' control functionality through nested DIVs.
//
//Notes:        1. If content is loaded dynamically, the XML should have the following required elements:
//                  <root>
//                      <item> ... </item> <item> ... </item>
//                      <result>...</result>
//                      <xslURL>...</xslURL>
//                  </root>
//
//              2. <result></result> element is needed in the root of the XML during AJAX-based refresh.
//                  AJAX-based refresh will be enabled if the 'contentUpdateUrl' parameter is non-empty.
//                  The server method that returns XML data must add <result>update</result> if 
//                  the returned XML document is valid and should be loaded into the control.
//          
//              3. During AJAX-based refresh, the control will look for <xslURL></xslURL> entry in 
//                  the XML stream and will use the value for downloading the stylesheet. 
//*************************************************************************************************//
function HIMSSDivMarquee(ctrlId, startDelay, scrollDelay, scrollAmount, direction, bMouseOverStop, 
                        bMouseOverScroll, width, height, presentationStyle, contentUpdateUrl,
                        contentUpdateInterval, entriesCount, contentRotateInterval)
{
    this.CtrlID = ctrlId;
    this.StartDelay     = startDelay;       // Number of milliseconds to wait before start scrolling
    this.ScrollDelay    = scrollDelay;      // Number of milliseconds between frames
    this.ScrollAmount   = scrollAmount;     // Number of pixels to scroll on each move
    this.Direction  = direction.toLowerCase();         // left, right, up, down
    this.Width      = (parseInt(width) > 0) ? parseInt(width) : 300;
    this.Height     = (parseInt(height) > 0) ? parseInt(height) : 300;
    this.StopOnMouseOver        = bMouseOverStop;
    this.ShowScrollOnMouseOver  = bMouseOverScroll;
    this.bSliding       = false;
    this.jqCtrl         = $('#' + ctrlId);
    this.jqDivContent   = null;
    this.xDown  = 0;
    this.yDown  = 0;
    this.xUp    = 0;
    this.yUp    = 0;
    this.xDownDrag = 0;
    this.yDownDrag = 0;
    this.Decelleration = -700;           // Number of pixels per second
    this.SlideRefreshSpeed   = 100;      // Milliseconds between re-calculation of slide speed
    this.PresentationType       = presentationStyle;    // 0 - scrolls the content; 1 - rotates single items
    this.ContentUpdateURL       = contentUpdateUrl;
    this.ContentUpdateInterval  = contentUpdateInterval;  // This value is in seconds
    this.ContentRotateInterval  = contentRotateInterval;   // This value is in seconds
    this.ContentEntryCount      = entriesCount;   // Number of entries to download from server
    this.XmlContents            = null;
    this.XslContents            = null;
    this.CurrentItem            = -1;
    this.SLIDE_SCROLL_DELAY     = 20;             // Refresh rate during 'sliding' (in milliseconds)   
    
    this.Init = function()
    {        
        if(this.jqCtrl.length == 0)
        {   alert("Could not find marquee control"); return; }
        
        var jqDivParent     = this.jqCtrl.children("div:eq(1)");
        this.jqDivContent   = jqDivParent.children("div:first-child");
       
        this.jqCtrl.css("width", this.Width);
        this.jqCtrl.css("height", this.Height);
        
        var oThis = this; 
        
        if(this.ContentUpdateURL != "")
        {
            this.UploadContentFromServer();
            if(this.ContentUpdateInterval > 0)
                window.setInterval(function() { oThis.UploadContentFromServer(); }, this.ContentUpdateInterval * 1000);
        }
        
        if(this.PresentationType == 0)
        {
            switch(this.Direction)
            {
            case "left": 
                this.jqDivContent.css("left", this.Width);
                break;
            case "right": 
                this.jqDivContent.css("left", -this.jqDivContent.width());
                break;
            case "up": 
                this.jqDivContent.css("top", this.Height);
                break;
            case "down": 
                this.jqDivContent.css("top", -this.jqDivContent.height());
                break;
            }
            this.bMoving = true;
            window.setTimeout(function() { oThis.refreshTimer = window.setInterval(function() { oThis.ScrollMarquee();}, oThis.ScrollDelay);}, this.StartDelay);
            
            jqDivParent.bind('mousedown', function(e) {oThis.MouseDownHandler(e);});
            jqDivParent.bind('mouseup', function(e) {oThis.MouseUpHandler(e);});
            jqDivParent.bind('mousemove', function(e) {oThis.MouseMoveHandler(e);});
            //this.jqMarquee.bind('selectstart', function() { return false; });
        }
        else
        {
            this.bMoving = false;
        }
        
        if(this.StopOnMouseOver)
        {
            jqDivParent.bind('mouseover', function() { oThis.bMoving = false; });
            jqDivParent.bind('mouseout', function() { oThis.bMoving = true; });
        }
    }
    
    //--* Moves the contents of the control in the desired direction (called on regular intervals)
    this.ScrollMarquee = function()
    {
        var strLeft, strTop;
        var jqParent = this.jqCtrl.children("div:eq(1)");
        
        if(jqParent.css("overflow") == 'hidden')
        {
            if(this.bMoving)
            {
                switch(this.Direction)
                {
                case "left":  
                    if(this.jqDivContent.position().left > this.jqDivContent.width()*(-1))
                        strLeft = "" + (this.jqDivContent.position().left - this.ScrollAmount) + "px";
                    else
                        strLeft = jqParent.width() + "px";
                    break;
                case "right": 
                    if(this.jqDivContent.position().left < jqParent.width())
                        strLeft = "" + (this.jqDivContent.position().left + this.ScrollAmount) + "px";
                    else
                        strLeft = "-" + this.jqDivContent.width() + "px";
                    break;
                case "up":  
                    if(this.jqDivContent.position().top > this.jqDivContent.height()*(-1))
                        strTop = "" + (this.jqDivContent.position().top - this.ScrollAmount) + "px";
                    else
                        strTop = jqParent.height() + "px";
                    break;
                case "down": 
                    if(this.jqDivContent.position().top < jqParent.height())
                        strTop = "" + (this.jqDivContent.position().top + this.ScrollAmount) + "px";
                    else
                        strTop = "-" + this.jqDivContent.height() + "px";
                    break;
                default:
                    strLeft = "0px"; strTop= "0px";
                }
                this.jqDivContent.css('left', strLeft);
                this.jqDivContent.css('top', strTop);
            }
//            else
//                jqParent.css("overflow",'auto');
        }
        else
            if(this.bMoving)
                jqParent.css("overflow", 'hidden');
    }
    
    
    this.MouseDownHandler = function(e)
    {
        var evt = window.event || e;
        this.xDown = evt.clientX;
        this.yDown = evt.clientY;
        this.xDownDrag = this.xDown;
        this.yDownDrag = this.yDown;
        this.mouseDownTime = new Date();
        this.bMovind = false;
        this.jqDivContent[0].setCapture();
    }
    
    
    this.MouseUpHandler = function(e)
    {
        var evt = window.event || e;
        this.xUp = evt.clientX;
        this.yUp= evt.clientY;
        this.mouseUpTime = new Date();
        
        if(this.xDown != 0 && this.yDown != 0)
        {
            if(parseInt((this.mouseUpTime - this.mouseDownTime).valueOf()) < 1000 && !this.bSliding)
            {
                var dx = (this.xUp - this.xDown);
                var dy = (this.yUp - this.yDown);
                
                //--* Get some idea of the velocity of mouse movement
                var velX = Math.abs((this.xUp - this.xDown)*1000/parseInt((this.mouseUpTime - this.mouseDownTime).valueOf()));
                var velY = Math.abs((this.yUp - this.yDown)*1000/parseInt((this.mouseUpTime - this.mouseDownTime).valueOf()));
                
                this.xDown = 0; this.yDown = 0;
                
                if(this.PresentationType == 0)
                {
                    if(Math.abs(dx) > Math.abs(dy))
                        if(dx < 0)
                            this.Slide(2*velX, "left");
                        else
                            this.Slide(2*velX, "right");
                    else
                        if(dy < 0)
                            this.Slide(2*velY, "up");
                        else
                            this.Slide(2*velY, "down");
                }
            }
            this.bMoving = true;
        }
        this.jqDivContent[0].releaseCapture();
    }
    
    
    this.MouseOverHandler = function(e)
    {
    }
    
    
    this.MouseOutHandler = function(e)
    {
        this.jqDivContent[0].style.cursor = "default";
    }
    
    
    this.MouseMoveHandler = function(e)
    {
        var evt = window.event || e;
        var btnPressed;
        
        if(evt.which)
            btnPressed = evt.which;
        else
            btnPressed = evt.button;
        
        if(!this.bSliding && btnPressed == 1 && this.xDown != 0 && this.yDown != 0)
        {
            var dx = (evt.clientX - this.xDownDrag);
            var dy = (evt.clientY - this.yDownDrag);
            
            this.bMoving = false;
            
            this.xDownDrag = evt.clientX;
            this.yDownDrag = evt.clientY;
            
            var offset = this.jqDivContent.offset();
            
            if(this.Direction == "left" || this.Direction == "right")
                offset.left += dx;
            if(this.Direction == "up" || this.Direction == "down")
                offset.top += dy;    
            
            this.jqDivContent.offset(offset);
        }
    }
    
    
    this.Slide = function(velocity, dir)
    {
        var oThis = this;
        
        if(this.PresentationType == 1) 
            return;
            
        if(!this.bSliding)
        {
            //--* Initialize the slide motion
            switch(this.Direction)
            {
                case "left":
                case "right":
                        if(dir == "up" || dir == "down")
                            return;
                        break;
                case "up":
                case "down":
                        if(dir == "left" || dir == "right")
                            return;
                        break;
                default:
                        return;
            }
            this.SlideStartTime = new Date();
            this.orgScrollDelay = this.ScrollDelay;
            this.ScrollDelay = this.SLIDE_SCROLL_DELAY;
            
            this.orgScrollAmount = this.ScrollAmount;
            this.ScrollAmount = velocity * this.SLIDE_SCROLL_DELAY / 1000;
            
            this.orgDirection = this.Direction;
            this.Direction = dir;
            this.bSliding = true;
            
            clearInterval(this.refreshTimer);
            this.refreshTimer = window.setInterval(function() { oThis.ScrollMarquee();}, this.ScrollDelay);
            
            setTimeout(function() {oThis.Slide(velocity);}, this.SlideRefreshSpeed);
        }
        else
        {
            var curV    = 1000/this.ScrollDelay * this.ScrollAmount;
            var curTime = new Date();
            var newV    = velocity + this.Decelleration*parseInt((curTime - this.SlideStartTime).valueOf())/1000;
            var baseV   = 1000/this.orgScrollDelay * this.orgScrollAmount;
            if(newV < baseV)
            {
                this.bSliding = false;
                this.ScrollDelay = this.orgScrollDelay;
                this.ScrollAmount = this.orgScrollAmount;
                this.Direction = this.orgDirection;
                clearInterval(this.refreshTimer);
                this.refreshTimer = window.setInterval(function() { oThis.ScrollMarquee();}, this.ScrollDelay);
            }
            else
            {
                this.ScrollAmount = parseInt(newV * this.ScrollDelay / 1000);
                setTimeout(function() { oThis.Slide(velocity);}, this.SlideRefreshSpeed);
            }
        }
    }
    
    
    //--* Initiates a call to the server requesting the next 'portion' of the content
    this.UploadContentFromServer = function()
    {
        var strQuery;
        if(this.ContentUpdateURL.indexOf("?") == -1)
            strQuery = this.ContentUpdateURL + "?";
        else
            strQuery = this.ContentUpdateURL + "&";
        
        strQuery = strQuery + "name=" + this.CtrlID + "&ni=" + this.ContentEntryCount + "&rs=" +  
                    this.ContentUpdateInterval + "&liid=";
        if(this.XmlContents != null)
        {
            var arrItems = this.SelectNodes(this.XmlContents, "/root/item");
            var idNode = this.SelectSingleNode(arrItems[arrItems.length - 1], "name")
            strQuery = strQuery  + idNode.text;
        }
        else
            strQuery += "-1";  
            
        var oThis = this;
        $.get(strQuery, function(data) { oThis.UploadXmlContentSuccess(data, oThis);}); 
    }
    
    
    //--* Updates the contents of the Ad-control in the browser
    this.LoadContent = function()
    {
        if(window.ActiveXObject)
            this.jqDivContent[0].innerHTML = this.XmlContents.transformNode(this.XslContents);
        else
        {
            var xsltProcessor = new XSLTProcessor();
            xsltProcessor.importStylesheet(this.XslContents);
            var htmlContent = xsltProcessor.transformToFragment(this.XmlContents, document);
            this.jqDivContent[0].innerHTML = "";
            this.jqDivContent[0].appendChild(htmlContent);
        }
    }
    
    
    this.ShowNextItem = function()
    {
        if(this.XmlContents != null)
        {
            var itemList = this.SelectNodes(this.XmlContents, "/root/item");
            
            if(itemList.length == 0)
                ;//alert("Number of items is zero.");
            else
            {
                this.CurrentItem = (this.CurrentItem + 1) % itemList.length;
               
                if(window.ActiveXObject)
                {
                    this.jqDivContent[0].innerHTML = itemList[this.CurrentItem].transformNode(this.XslContents);
                }
                else
                {
                    var xsltProcessor = new XSLTProcessor();
                    try
                    {
                        xsltProcessor.importStylesheet(this.XslContents);
                        var htmlContent = xsltProcessor.transformToFragment(itemList[this.CurrentItem], document);
                        this.jqDivContent[0].innerHTML = "";
                        this.jqDivContent[0].appendChild(htmlContent);
                    }
                    catch(ex)
                    {
                        alert("XSL import failed: " + ex.message);
                    }
                }
            }
        }
    }
    
    
    this.UploadXmlContentSuccess = function(data, oThis)
    {
        var nodeItem;
        
        nodeItem = this.SelectSingleNode(data, "/root/result");
        if(nodeItem == null || ((nodeItem.text == null || nodeItem.text == '') &&
                          (nodeItem.textContent == null || nodeItem.textContent == '')))
            return true;
        
        var strRes = nodeItem.text || nodeItem.textContent;
        if(strRes != "update")
            return true;
                
        this.XmlContents = data;
        
        nodeItem = this.SelectSingleNode(this.XmlContents, "/root/xslURL");
       
        if(nodeItem == null || nodeItem.text == '')
            alert("XML style-sheet is missing in data stream. Make sure xslURL element is defined.");
        else
            if(nodeItem.text) // Browser crap
                $.get(nodeItem.text, function(data) { oThis.UploadXslContentSuccess(data, oThis);});
            else
                $.get(nodeItem.textContent, function(data) { oThis.UploadXslContentSuccess(data, oThis);});
    }
    
    
    this.UploadXslContentSuccess = function(data, oThis)
    {
        this.XslContents = data;
        
        if(this.XmlContents != null)
            if(this.PresentationType == 1)  // 'rotator'
            {
                if(this.contentRotateTimer == null)
                {
                    this.ShowNextItem();
                    this.contentRotateTimer = window.setInterval(function() { oThis.ShowNextItem(); }, oThis.ContentRotateInterval * 1000);
                }
            }
            else                            
                this.LoadContent();         // 'slider'
    }
    
    
    //--* Cross-browser utility function for XML xpath node selection
    this.SelectSingleNode = function (xmlDoc, elementPath)
    {
        if(window.ActiveXObject)
        {
            return xmlDoc.selectSingleNode(elementPath);
        }
        else
        {
           var xpe = new XPathEvaluator();
           var nsResolver = xpe.createNSResolver( xmlDoc.ownerDocument == null ? xmlDoc.documentElement : xmlDoc.ownerDocument.documentElement);
           var results = xpe.evaluate(elementPath,xmlDoc,nsResolver,XPathResult.FIRST_ORDERED_NODE_TYPE, null);
           
           return results.singleNodeValue; 
        }
    }


    //--* Cross-browser utility function for XML xpath node selection - selects multiple nodes
    this.SelectNodes = function (xmlDoc, elementPath)
    {
        if(window.ActiveXObject)
        {
            return xmlDoc.selectNodes(elementPath);
        }
        else
        {
           var xpe = new XPathEvaluator();
           var nsResolver = xpe.createNSResolver( xmlDoc.ownerDocument == null ? xmlDoc.documentElement : xmlDoc.ownerDocument.documentElement);
           var results = xpe.evaluate(elementPath, xmlDoc, null, 
                                        XPathResult.FIRST_ORDERED_NODE_ITERATOR_TYPE, null);
           
           var aNodes = new Array();

           if (results != null) 
           {
                var oElement = results.iterateNext();
                while(oElement) 
                {
                    aNodes.push(oElement);
                    oElement = results.iterateNext();
                }
            }

            return aNodes;
        }
    }

}
     

function InitMarquee(marqueeCtrlId, startDelay, scrollDelay, scrollAmount, direction, 
                        bMouseOverStop, bMouseOverShowScroll, width, height,
                        implementationStyle, presentationStyle, contentUpdateUrl,
                        contentUpdateInterval, entriesCount, contentRotateInterval)
{
    var oMarquee;
                        
    if(implementationStyle == 0)
        oMarquee = new HIMSSMarquee(marqueeCtrlId, startDelay, scrollDelay, scrollAmount, direction, 
                        bMouseOverStop, bMouseOverShowScroll, width, height, presentationStyle, contentUpdateUrl,
                        contentUpdateInterval, entriesCount, contentRotateInterval);
    else
        oMarquee = new HIMSSDivMarquee(marqueeCtrlId, startDelay, scrollDelay, scrollAmount, direction, 
                        bMouseOverStop, bMouseOverShowScroll, width, height, presentationStyle, contentUpdateUrl,
                        contentUpdateInterval, entriesCount, contentRotateInterval);
    oMarquee.Init();
}


