﻿
    
    var imageIndex=1;
    var toggle=true;
    var timerID = 0;
    var animationSeconds = 5;
    
    function nextImage(){
        clearTimeout(timerID);
        timerID  = 0;
    
	    document.getElementById("left").style.cursor="wait";
	    document.getElementById("left").onclick=null;
	    if(toggle){
		    opacityTween = new OpacityTween(document.getElementById('img_1'),Tween.regularEaseOut, 100, 0, 1);
	    }else{
		    opacityTween = new OpacityTween(document.getElementById('img_2'),Tween.regularEaseOut, 100, 0, 1);	
	    }
	    opacityTween.onMotionFinished = function(){popNextImage()};
	    opacityTween.start();
	    imageIndex++;
    	
	    if(imageIndex>=nArr.length)imageIndex=0;	
    }

    function popNextImage(){
	    document.getElementById("left").style.cursor="pointer";
	    document.getElementById("left").onclick=nextImage;
	    var d = document.getElementById("div1");
	    var img;
	    if(toggle){
		    img = document.getElementById("img_1");
		    d.style.zIndex = "0";
		    toggle=false;	
	    }else{
		    img = document.getElementById("img_2");
		    d.style.zIndex = "2";
		    toggle=true;
	    }
	    img.src = "images/"+m+"/"+nArr[imageIndex];	
	    img.style['opacity'] = 100;
	    img.style['-moz-opacity'] = 100;
	    img.onload = function(){
	        timerID  = setTimeout("nextImage()", animationSeconds*1000);
	    }
	    if(img.filters) img.filters.alpha['opacity'] = 100;	
    }
    
    function goToPage(obj){
        window.location.href=obj.value;
    }
    
    window.onload = function(){
        document.getElementById("content").style.display="block";
        timerID  = setTimeout("nextImage()", animationSeconds*1000);
    }