﻿// JScript File

        var index = 0;
        var rotatetime = 10; //seconds
        var timerid;
        var arAds = new Array();
	    var crossFadeDuration = 3;
	    var adpager;


//	    arAds[0] = new Advertisement(5, "images/ads/cessna_stars_alt2.png");
//	    arAds[1] = new Advertisement(5, "images/ads/phenom.png");
//	    arAds[2] = new Advertisement(5, "images/ads/mustang.png");
//	    arAds[3] = new Advertisement(18, "images/ads/cropdust.png");
//	    arAds[4] = new Advertisement(5, "images/ads/skies2.png");
	    //	    arAds[5] = new Advertisement(5, "images/ads/gill.png");


	    arAds[0] = new Advertisement(5, "images/ads/nowauthorized.png");
	    arAds[1] = new Advertisement(5, "images/ads/gill.png");
	    arAds[2] = new Advertisement(8, "images/ads/phenom.png");
	    arAds[3] = new Advertisement(8, "images/ads/copter.png");
	    arAds[4] = new Advertisement(5, "images/ads/stars.png");
	    arAds[5] = new Advertisement(8, "images/ads/mustang.png");
	    arAds[6] = new Advertisement(5, "images/ads/cropdust.png");
	    arAds[7] = new Advertisement(5, "images/ads/skies2.png");
        
        
//        var preLoad = new Array()
//        for (i=0;i<arImg.length;i++) {
////            preLoad[i] = new Image()
////            preLoad[i].src = arImg[i]
//        }

        function startrotator() {
            if (!timerid) {
                window.clearTimeout(timerid);
            }

            timerid = window.setTimeout("startrotator()", arAds[index].SecondDelay);

            RotateImage()    
            
        } // 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 = arAds[index].Image.src;
            imgHolder.alt = "";
            
            if (document.all){
                 imgHolder.filters.blendTrans.Play()
            }
                                                
            adpager.innerHTML = BuildPager()

            if (index < arAds.length - 1) {
                index++;
            }else{
                index = 0;
            }           
        
        } // end function RotateImage
        
        function BuildPager() {
            var output = "";
            for (i = 0; i < arAds.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 5: // Skies / Aircraft Batteries                    
                    document.location.href = "products.aspx";
                    break;
                case 0: // About Us
                    document.location.href = "about.aspx";
                    break;
   
            }
        
        } // end function InterpretLink
        
        function GetIndex(val) {
            var arraySrc;
            for (x = 0; arAds.length - 1; x++) {
                arraySrc = arAds[x].Image.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
