function MultiTab(DivArray, DivArrayLabel, DelayInMillisec, ShowTabs, MultiTabName, IsDivPositionRelative) {

    this.divArray = DivArray;
    this.delay = DelayInMillisec;
    this.divArrayLabel = DivArrayLabel;
    this.name = MultiTabName;

    this.currentIndex = -1;
    this.divSwap0 = null;
    this.divSwap1 = null;

    this.showTabs = ShowTabs;

    this.activeDivSwap = 0;

    this.canChange = true;

    this.isDivPositionRelative = IsDivPositionRelative;

    this.init = function() {

        if (this.showTabs) {
            document.write("<div class='" + this.name + "_tab' id='" + this.name + "wl_tabs'><div class='" + this.name + "_tab_bg'>");

            for (i in DivArrayLabel) {

                document.write("<div class='" + this.name + "_tabItem' id='" + this.name + "wl_tabs_" + i + "' onclick='" + this.name + ".start(" + i + ");'>");
                document.write(DivArrayLabel[i]);
                document.write("</div>");
            }

            document.write("<div style='clear: left;'></div></div><div style='clear: left;'></div></div>");
        }

       
        document.write("<div class='" + this.name + "_swapDiv1' id='" + this.name + "wl_div_1'></div>");
        document.write("<div class='" + this.name + "_swapDiv' id='" + this.name + "wl_div_0'></div>");
        this.divSwap0 = document.getElementById(this.name + 'wl_div_0');
        this.divSwap1 = document.getElementById(this.name + 'wl_div_1');



    };

    this.start = function(index) {
        if (this.currentIndex != index && this.canChange) {
            this.currentIndex = index;
            if (this.activeDivSwap == 0) {
                this.swapTo1(index);

            }
            else {

                this.swap(index);
            }
        }

    };


    this.goTo = function(index) {
        if (this.canChange) {
            this.currentIndex = index;
            if (this.activeDivSwap == 0) {
                this.swapTo1(index);

            }
            else {

                this.swap(index);
            }
        }

    };


    this.swap = function(nextIndex) {

        this.activeDivSwap = 0;
        this.setDivTrans(0, this.divSwap0.id);
        this.divSwap0.innerHTML = document.getElementById(this.name + nextIndex).innerHTML;
        //this.divSwap0.setAttribute('class', this.name + '_swapDiv ' + this.name + '_swapDivSelected');
        this.setTab(nextIndex);
        this.fadeInSlide(document.getElementById(this.name + 'wl_div_0'), document.getElementById(this.name + 'wl_div_1'));


    };

    this.swapTo1 = function(nextIndex) {


        this.activeDivSwap = 1;
        this.setDivTrans(0, this.divSwap1.id);
        this.divSwap1.innerHTML = document.getElementById(this.name + nextIndex).innerHTML;

        //this.divSwap1.setAttribute('class', this.name + '_swapDiv ' + this.name + '_swapDivSelected');
        this.setTab(nextIndex);
        this.fadeInSlide(document.getElementById(this.name + 'wl_div_1'), document.getElementById(this.name + 'wl_div_0'));


    };

    this.setTab = function(index) {
        if (this.showTabs) {
            document.getElementById(this.name + 'wl_tabs_' + index).setAttribute((document.all ? 'className' : 'class'), this.name + '_tabItem ' + this.name + '_tabItemSelected');
            try {
                document.getElementById(this.name + 'wl_tabs_' + index).setAttribute('class', this.name + '_tabItem ' + this.name + '_tabItemSelected');
            }
            catch (e) {
                alert(e);
            }

            for (i in DivArrayLabel) {
                if (i != index) {
                    document.getElementById(this.name + 'wl_tabs_' + i).setAttribute((document.all ? 'className' : 'class'), this.name + '_tabItem');

                    try {
                        document.getElementById(this.name + 'wl_tabs_' + i).setAttribute('class', this.name + '_tabItem');
                    }
                    catch (e) {
                        alert(e);
                    }

                }
            }
        }
    };


    this.resetAllOcapicty = function(opac) {

        for (i in DivArrayLabel) {
            document.getElementById(this.name + 'wl_tabs_' + i).style.opacity = opac;
        }

    };

    this.fadeInSlide = function(inDivObj, outDivObj) {

        var speed = Math.round(this.delay / 100);
        var tick = 0;
        this.setDivTrans(0, inDivObj.id);
        //inDivObj.style.visibility = "visible";

        if (1 == 2) {
            
            this.setDivTrans(100, inDivObj.id);
            this.setDivTrans(0, outDivObj.id);

        }
        else {
            this.setCanChange(false);

            setTimeout(this.name + ".setCanChange(true)", (100 * speed));

            for (i = 1; i <= 100; i++) {

                setTimeout(this.name + ".setDivTrans(" + i + ", '" + inDivObj.id + "')", (tick * speed));
                setTimeout(this.name + ".setDivTrans(" + (100 - i) + ", '" + outDivObj.id + "')", (tick * speed));
                tick++;


            }
        }

    };

    this.setHeight = function(obj, n) {
        obj.style.width = n + '%';
    };

    this.setCanChange = function(v) {
        this.canChange = v;

    };

    this.setDivTrans = function(n, divObjID) {

        try {
            //this.canChange = false;
            var divObj = getElement(divObjID);

            if (this.isDivPositionRelative) {
                if (n == 50) {
                    //divObj.style.visibility = "hidden";
                    divObj.style.display = "none";

                }
                else if (n == 51) {
					                      divObj.style.display = "block";
					                      //divObj.style.visibility = "visible";
					                  }
					             } else {
					                 if (n == 0) {
					                     divObj.style.visibility = "hidden";
					 
					                 }
					                 else if (n == 1) {
					                     divObj.style.visibility = "visible";
					                 }
					              }
					              divObj.style.opacity = n / 100;
					              divObj.style.MozOpacity = n / 100;
            divObj.style.KhtmlOpacity = n / 100;
            divObj.style.filter = "alpha(opacity=" + n + ")";
            divObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + n + ")";
           
        }
        catch (e) {
           
        }

    };



}

function getElement(theID) {
    return document.getElementById(theID);
}


var pauseAutoPlay = false;
function autoPlay() {

    setInterval(autoPlayLoop, 5000);
}

function autoPlayLoop() {
   
    if (!pauseAutoPlay) {
        var nextIndex = multiTab.currentIndex + 1;
       
        if (nextIndex >= multiTab.divArray.length) {
            nextIndex = 0;
        }
        multiTab.start(nextIndex);
    }
}

			function moveNext(){
				
 
					multiTab.goTo(getNextSlide());
					
				
			}
 
 
			function movePrev(){
				if(multiTab.canChange){
					multiTab.goTo(getPrevSlide());
					
					pauseAutoPlay = true;
					
				}
 
			}
 
 
 
			function getNextSlide(){
 
				var nextIndex = multiTab.currentIndex + 1;
    
        			if (nextIndex >= multiTab.divArray.length) {
            				nextIndex = 0;
        			}
 
				
				multiTab.currentIndex = nextIndex;
				return nextIndex;
			}
 
			function getPrevSlide(){
 
				var nextIndex = multiTab.currentIndex - 1;
    
        			if (nextIndex < 0) {
            				nextIndex = multiTab.divArray.length -1;
        			}
				
				multiTab.currentIndex = nextIndex;
				return nextIndex;
			}
			
                   

