// retrieves the machine information function MachineListingBanner_PreInit(linkPath) { if(!window.GetXmlDocument) { alert("Error: The script for the machine listing banner requires Ajax.js."); return; } var clientCallback = function(xmlDoc) { MachineListingBanner_Init(xmlDoc.getElementsByTagName("Machine"), linkPath); } GetXmlDocument("/Include/MachineListingBannerJS.aspx?getmachines=true&DivisionID=0", clientCallback); } // machines is an xml node list returned by getElementsByTagName(). function MachineListingBanner_Init(machines, linkPath) { var machinelistingbanner = document.getElementById("machinelistingbanner"); machinelistingbanner.DISPLAY_INTERVAL = 5000; machinelistingbanner.CurrentBannerIndex = 0; machinelistingbanner.Machines = machines; machinelistingbanner.LinkPath = linkPath; machinelistingbanner.Image = document.getElementById("imgEquipment"); machinelistingbanner.ProductName = document.getElementById("productname"); machinelistingbanner.SerialNumber = document.getElementById("serialnumber"); machinelistingbanner.Hours = document.getElementById("hours"); machinelistingbanner.Price = document.getElementById("price"); machinelistingbanner.ProductDescription = document.getElementById("productdescription"); machinelistingbanner.EquipmentLink = document.getElementById("lnkEquipment"); machinelistingbanner.EquipmentLink2 = document.getElementById("lnkEquipment2"); machinelistingbanner.CategoryLink = document.getElementById("lnkCategory"); machinelistingbanner.NextBanner = function() { if (this.Machines.length == 0 || this.Image == null) return ; this.CurrentBannerIndex = (this.CurrentBannerIndex + 1) % this.Machines.length; this.Image.src = this.GetCurrentValue("Image"); this.Image.alt = this.GetCurrentValue("Name"); this.ProductName.innerHTML = this.GetCurrentValue("Name"); this.SerialNumber.innerHTML = this.GetCurrentValue("SerialNum"); if(this.Hours) this.Hours.innerHTML = this.GetCurrentValue("Hours"); this.Price.innerHTML = this.GetCurrentValue("Price"); if(this.ProductDescription) this.ProductDescription.innerHTML = this.GetCurrentValue("Description"); this.EquipmentLink.href = this.LinkPath + "EquipmentDetails.aspx?EquipmentIDs=" + this.GetCurrentValue("EquipmentID"); this.EquipmentLink2.href = this.EquipmentLink.href; if(this.CategoryLink) this.CategoryLink.href = this.LinkPath + "SearchEquipment.aspx?Category=" + this.GetCurrentValue("CategoryID"); } machinelistingbanner.GetCurrentValue = function(tagName) { var element = this.Machines[this.CurrentBannerIndex].getElementsByTagName(tagName)[0].firstChild; return element != null ? element.nodeValue : ""; } machinelistingbanner.Start = function() { this.Stop(); this.IntervalID = window.setInterval("document.getElementById('machinelistingbanner').NextBanner()", this.DISPLAY_INTERVAL); } machinelistingbanner.Stop = function() { window.clearInterval(this.IntervalID); } machinelistingbanner.onmouseover = function() { this.Stop(); } machinelistingbanner.onmouseout = function() { this.Start(); } machinelistingbanner.Start(); }