/*******************************************************************************
 * @name    SIMPLE SLIDER CLASS
 * @autor   Stanislav Zorjan
 * @copy    www.symblaze.com
 */

function SimpleSlider(maskDiv, slidingDiv){
    var _this = this;
    this.maskDiv = document.getElementById(maskDiv);
    this.slidingDiv = document.getElementById(slidingDiv);
 
    /*sliding speed*/
    var slide_speed  = 5;
    /*sliding step*/
    var slide_step   = 5;
    if(navigator.appVersion.indexOf("MSIE 6.0")!= -1 && navigator.appName.indexOf("Explorer") != -1){
        slide_step   = 5;
        //alert(navigator.appVersion+"    "+navigator.appName+"   "+navigator.appVersion.indexOf("MSIE 6.0"));
    }
    
    /*calculated step of sliding*/
    var step         = 0;

    /*calculated _$count$_ of steps*/
    var _$count$_        = 0;
    
    /*width of visible area*/
    var visible_area = this.maskDiv.offsetHeight;

    /*string containing generated html*/
    var div           = "";

    /*start position of image_holder*/
    var startPosition = 0;

    /*_$count$_er*/
    var i             = 0;

    /*flag for sliding left or right*/
    var mod          = new Boolean();

    /*timer interval for storing timer variable*/
    var timerInterval;

    /*image holder initialisation width*/
    var image_holder_width = 0;
        
   

    /***************************************************************************
     * FUNCTION FOR START SLIDING
     * @param m <boolean> direction of sliding
     */
    this.start = function(m){
    
    if(this.slidingDiv.offsetHeight > this.maskDiv.offsetHeight){
        /*adding value to mod*/
        mod = m;
        /*first clears interval if some already egzists*/
        clearInterval(timerInterval)
        /*sets interval for sliding*/

        timerInterval = setInterval(function(){_this.slide();}, slide_speed);
        this.slide();
    }
    }

    this.stop = function(){
        clearInterval(timerInterval);
    }

    /***************************************************************************
     * SLIDING FUNCTION
     */
    this.slide = function(){
        
        /*depending on mod variable, calculates step (direction)*/
        if(mod){
            _$count$_--;
             if(_$count$_ < 0){
                 _$count$_ = 0;
                 return;
             }
            step += slide_step;

        }else{
            _$count$_++;
             if(_$count$_ >= this.maskDiv.offsetHeight){
                 _$count$_ = this.maskDiv.offsetHeight;
                 return;
             }
            step -= slide_step;

        }


        /*moves image_holder element left/right*/
        
           this.slidingDiv.style.top = step+'px';
        
        
        /*if image_holder element is out of bounds, places it inside bounds*/
        if(this.slidingDiv.style.top > startPosition){
            this.slidingDiv.style.top = startPosition+'px';
            //step = startPosition;
            //clearInterval(timerInterval);
            return;
        }
        /*if image_holder element is out of bounds, places it inside bounds*/
       if(step<(this.maskDiv.offsetHeight - this.slidingDiv.offsetHeight)){
            this.slidingDiv.style.top = this.maskDiv.offsetHeight - this.slidingDiv.offsetHeight+"px";
            //step += slide_step;
            clearInterval(timerInterval);
           // return;
       // }

    }
}
this.reset = function(){
    this.slidingDiv.style.top = "0px";
    _$count$_ = 0;
    step = 0;
}
}
