﻿// JScript File

        var index = 0;
        var rotatetime = 10; //seconds
        var timerid;
        var arImg = new Array();
	    var crossFadeDuration = 3;
	    var adpager; 
	   	    	       
        arImg[0] = "images/ads/skies2.png";
        arImg[1] = "images/ads/gill.png";
        //arImg[2] = "images/ads/gill2.png";
        arImg[2] = "images/ads/gill3.png";
        
        var preLoad = new Array()
        for (i=0;i<arImg.length;i++) {
            preLoad[i] = new Image()
            preLoad[i].src = arImg[i]
        }
        
        function startrotator() {
            RotateImage()           
            timerid = window.setTimeout("startrotator()", rotatetime*1000);            
        } // end function startrotator
        
        function RotateImage() {
        
            adpager = document.getElementById("adpager");
            var imgHolder = document.getElementById("imgAd");
        
            if (document.all){
              imgHolder.style.filter="blendTrans(duration=2)"
              imgHolder.style.filter="blendTrans(duration=crossFadeDuration)"
              imgHolder.filters.blendTrans.Apply()      
            }     
                        
            imgHolder.src = preLoad[index].src;
            imgHolder.alt = "";
            
            if (document.all){
                 imgHolder.filters.blendTrans.Play()
            }
                                                
            adpager.innerHTML = BuildPager()
           
            if (index < arImg.length -1) {
                index++;
            }else{
                index = 0;
            }           
        
        } // end function RotateImage
        
        function BuildPager() {
            var output = "";
            for (i=0;i<preLoad.length;i++) {
                if (i==index) {
                 output += "<span>" +eval(i+1) + "</span>"
                }else{
                 output += "<a href=\"javascript:void(0);\" onclick=\"GoTo("+i+");\">" + (i+1) + "</a>"
                }                           
            }
            return output;
        } // end function BuildPager
        
        function GoTo(idx) {
            index = idx;
            window.clearTimeout(timerid);
            startrotator()
        } // end function GoTo
        
        function InterpretLink() {
            var imgHolder = document.getElementById("imgAd");
            
            var curIndex;                      
            curIndex = GetIndex(imgHolder.src);  
                      
            switch (curIndex) {
                case 0: // Skies / Aircraft Batteries                    
                    document.location.href = "products.aspx";
                    break;
                case 1: // About Us
                    document.location.href = "about.aspx";
                    break;
//                case 2: // Office Prof - Office Misc
//                    document.location.href = "#";
//                    break;
                case 2: // Capacity Tester
                    document.location.href = "capacitytesters.aspx";
                    break;      
            }
        
        } // end function InterpretLink
        
        function GetIndex(val) {
            var arraySrc;
            for (x=0;preLoad.length-1;x++) {
                arraySrc = preLoad[x].src;
                
                if (arraySrc == val) {
                   return x;                    
                }
            }
                    
        } // end function GetIndex
        
        function Zoom(e, imgname, raw) {
            //alert(imgname);
            var zPnl = document.getElementById("ZoomPanel")
            zPnl.style.left = e.clientX;
            zPnl.style.top = e.clientY;
            zPnl.style.display = "block";
            zPnl.style.visibility = "visible";
            
            if (imgname == '00000') {
                //alert(document.getElementById("ctl00_ContentPlaceHolder1_imgBig").src.replace('&t=3', ''));
                zPnl.innerHTML = "<img src=\"" + document.getElementById("ctl00_ContentPlaceHolder1_imgBig").src.replace('&t=3', '') + "\"/>";
            }else{            
                if (raw) {
                    zPnl.innerHTML = "<img src=\"processimage.ashx?src="+imgname+"\"/>";
                }else{
                    zPnl.innerHTML = "<img src=\"processimage.ashx?src="+imgname+"&t=3\"/>";
                }
            }
            
            
        } // end function Zoom
        
        function HideZoom() {
            var zPnl = document.getElementById("ZoomPanel")
            zPnl.style.display = "none";
            zPnl.style.visibility = "hidden";
        } // end function HideZoom