

    var PREFIX = "images/"; // folder where images are stored
	var timeout = 0; // used in case we want to stop the timer
    var TIME_DELAY = 2000; // how long before the picture changes
    var leftState = 0; // which state we are on
    var rightState = 1; // which state we are on
    var done = "false";   // set when both animations are done
    // Preload arrays with sponsorship logos and websites
    var images = new Array();
    images.push("cpu.jpg", "pownz.jpg", "thermaltake.jpg");
    
    var url = new Array();
    url.push("http://www.computerpoweruser.com/", "http://www.pownz.com", "http://www.thermaltakeusa.com");
    
    //alert("length:"+images.length); // debug
    
    var MAX = images.length; // how many images we have
    
    // add folder path to image sources
    for (var index in images){
        images[index] = PREFIX+images[index];
    }
    
    
    function cycleLeft (){
        //alert("left");
        done = "false";
        $("#leftImg").show(2000, function(){
            if (done=="true") 
                timeout = setTimeout(cycleRight,TIME_DELAY);
            else 
                done="true";
        });    
        $("#rightImg").hide(2000, function(){
            if (done=="true") 
                timeout = setTimeout(cycleRight,TIME_DELAY);
            else 
                done="true";
            rightState ++;
            rightState = rightState % MAX;
            document.getElementById("rightURL").setAttribute("href",url[rightState]);
            document.getElementById("rightImg").setAttribute("src",images[rightState]);
        });                 
    }
    
    function cycleRight (){
        //alert("right");
        done = "false";
        $("#leftImg").hide(2000, function(){
            if (done=="true") 
                timeout = setTimeout(cycleLeft,TIME_DELAY);
            else 
                done="true";
            leftState ++;
            leftState = leftState % MAX;
            document.getElementById("leftURL").setAttribute("href",url[leftState]);
            document.getElementById("leftImg").setAttribute("src",images[leftState]);
        });    
        $("#rightImg").show(2000, function(){
            if (done=="true") 
                timeout = setTimeout(cycleLeft,TIME_DELAY);
            else 
                done="true";
        });    
    }
        
    
    function stopTimer (hoverSide){
        clearTimeout(timeout);
    }
    
    function resumeTimer (hoverSide){
        if (hoverSide == "right")
            timeout = setTimeout(cycleLeft,TIME_DELAY);
        else
            timeout = setTimeout(cycleRight,TIME_DELAY);
    }
    
    
    
    window.onload = function (){
        document.getElementById("leftImg").setAttribute("src",images[leftState]);
        document.getElementById("rightImg").setAttribute("src",images[rightState]);
        document.getElementById("leftURL").setAttribute("href",url[leftState]);
        document.getElementById("rightURL").setAttribute("href",url[rightState]);
        
        //alert("left:"+document.getElementById("leftURL").getAttribute("href"));
        $("#rightImg").hide();

        timeout = setTimeout(cycleRight,TIME_DELAY);      
        
    }