﻿function adjustBehaviour()
    {
        writeImgProp(this.I);
        addImagesToDropDownList(this.A);
        setText("count", this.A.length);
        
        this.I['onload'] = function(){
            writeImgProp(this);
        }

        var oldPlayFunc = this.Pl;
        this.Pl = function(){
            oldPlayFunc.call(this);
            this.GE('spinner').style.visibility = "visible";
        }

        var oldStopFunc = this.St;
        this.St = function(){
            oldStopFunc.call(this);
            this.GE('spinner').style.visibility = "hidden";
        }

        var oldSSFunc = this.SS;
        this.SS = function(){
            oldSSFunc.call(this);
            this.GE('ddlSelectImage').selectedIndex = this.C;
        }

        function writeImgProp(img)
        {
            var imgName = stripFileName(img.src);
            var imgSize = (img.fileSize)? " " + (Math.round(100*(img.fileSize/1024))/100) + "kB":"";
            setText("imgprop", "...........");
        }

        function stripFileName(src)
        {
            var indexofSlash = src.lastIndexOf("%2f");
            
            if(indexofSlash > 0)
                indexofSlash += 3;
            
            var indexofHash = src.indexOf("\&",indexofSlash);
            return src.substring(indexofSlash,indexofHash);
        }

        function setText(objId, text)
        {
            var obj = document.getElementById(objId);
            var textNode = document.createTextNode(text);

            (obj.firstChild)?obj.replaceChild(textNode, obj.firstChild):obj.appendChild(textNode);
        }
        
        function addImagesToDropDownList(imgs)
        {
            var ddl = document.getElementById("ddlSelectImage");
            for(i=0;i<imgs.length;i++)
	        {
		        ddl.options[i] = new Option(i+1,i);
	        }
        }
    }

    function setSpeed(sender)
    {
        AutoSlideshow1.M = sender.value;
    }
    
    function setSlide(sender)
    {
        AutoSlideshow1.C = parseInt(sender.value);
        AutoSlideshow1.SS();
    }