function flashyslideshow(setting){

    this.wrapperid=setting.wrapperid
    this.imagearray=setting.imagearray
    this.pause=setting.pause
    this.transduration=setting.transduration/1000 //convert from miliseconds to seconds unit to pass into el.filters.play()
    this.currentimg=0

    var contentdiv=document.getElementById(this.wrapperid)
    var slideshow=this

    flashyslideshow.addEvent(contentdiv, function(){
        slideshow.isMouseover=1
    }, "mouseover")

    flashyslideshow.addEvent(contentdiv, function(){
        slideshow.isMouseover=0
    }, "mouseout")

    setInterval(function(){
        slideshow.rotate()
    }, this.pause)
}

flashyslideshow.addEvent=function(target, functionref, tasktype){
    if (target.addEventListener)
        target.addEventListener(tasktype, functionref, false);
    else if (target.attachEvent)
        target.attachEvent('on'+tasktype, function(){
            return functionref.call(target, window.event)
        });
},

flashyslideshow.setopacity=function(el, degree){ //sets opacity of an element (FF and non IE browsers only)
    if (typeof el.style.opacity!="undefined")
        el.style.opacity=degree
    else
        el.style.MozOpacity=degree
    el.currentopacity=degree
}


flashyslideshow.prototype.getSlideHTML=function(index){

    var html='<img id="rotating_image" src="' + this.imagearray[index][0] + '">'
    return html
}

flashyslideshow.prototype.rotate=function(){

    var contentdiv=document.getElementById(this.wrapperid)

    //  keep image displayed while mouse over
    this.currentimg=(this.currentimg<this.imagearray.length-1)? this.currentimg+1 : 0
    if (this.isMouseover){
        return
    }
    flashyslideshow.setopacity(contentdiv, 0)

    contentdiv.innerHTML=this.getSlideHTML(this.currentimg)
    contentdiv.fadetimer=setInterval(function(){
        if (contentdiv.currentopacity<1)
            flashyslideshow.setopacity(contentdiv, contentdiv.currentopacity+0.1)
        else
            clearInterval(contentdiv.fadetimer)
    }, 50) //end setInterval

}

function startSlideShow(){

    //create instance of slideshow
    new flashyslideshow({
        wrapperid: "slide_show_div", //unique div ID for this slideshow

        // where image array parameters are: ["image_path", "optional_image_link", "optional_link_target", "optional_text_description]
        imagearray: [
            ["img/slide_show/image9.jpg", "", "", ""],
            ["img/slide_show/image10.jpg", "", "", ""],
            ["img/slide_show/image1.jpg", "", "", ""],
            ["img/slide_show/image8.jpg", "", "", ""],
            ["img/slide_show/image2.jpg", "", "", ""],
            ["img/slide_show/image3.jpg", "", "", ""],
            ["img/slide_show/image4.jpg", "", "", ""],
            ["img/slide_show/image6.jpg", "", "", ""],
            ["img/slide_show/image7.jpg", "", "", ""]
            
        ],
        pause: 3500, //pause between content change (millisec)
        transduration: 2500 //duration of transition (affects only IE users)
    })
}

