var tourContainer = null,
    lastLink = null,
    lastStop = null,
	testStops = [],
	scrollIndex = 0,
	scrollMax = 13;

window.addEvent('load', function() {

    tourContainer = $('tour');

    tourContainer.links = $ES('li','reason-menu');
    lastLink = $(tourContainer.links[0]);

    tourContainer.content = $ES('div','tour');
    lastStop = $(tourContainer.content[0]);

    lastStop.className = 'show';

    for (var i = 0; i < 6; i++) {
        var tour = $(tourContainer.content[i]);
        tour.outfx = tour.effects({duration: 1000, transition:
Fx.Transitions.Quart.easeOut});
        tour.infx = tour.effects({duration: 500, transition:
Fx.Transitions.Quart.easeIn});

        if (0 < i) {
            tour.outfx.start({
                'opacity': 0
            });
        }

        $(tourContainer.links[i]).addEvent('click', function() {
			if (lastLink == this) {return;}
            lastLink.className = '';
            this.className = 'current';

            var ltour = tourContainer.content[lastLink.id.replace('l','')],
                ntour = tourContainer.content[this.id.replace('l','')];
				if(this.id == "l0") {
					map = document.getElementById("Mapz");
					map.areas[0].coords = "22,222,122,249";
					map.areas[0].href = "apply.php?";
					map.areas[0].alt = "Apply Online";
					map.areas[1].coords = "129,231,200,240";
					map.areas[1].href = "howitworks.php";
					map.areas[1].alt = "See Details";
				}
				if(this.id == "l1") {
					map = document.getElementById("Mapz");
					map.areas[0].coords = "0,168,119,192";
					map.areas[0].href = "apply.php";
					map.areas[0].alt = "Apply Online";
					map.areas[1].coords = "124,174,199,188";
					map.areas[1].href = "howitworks.php";
					map.areas[1].alt = "See Details";
				}
				if(this.id == "l2") {
					map = document.getElementById("Mapz");
					map.areas[0].coords = "360,151,460,176";
					map.areas[0].href = "apply.php";
					map.areas[0].alt = "Apply Online";
					map.areas[1].coords = "465,157,539,170";
					map.areas[1].href = "howitworks.php";
					map.areas[1].alt = "See Details";
				}
				if(this.id == "l3") {
					map = document.getElementById("Mapz");
					map.areas[0].coords = "0,168,119,192";
					map.areas[0].href = "apply.php";
					map.areas[0].alt = "Apply Online";
					map.areas[1].coords = "124,174,199,188";
					map.areas[1].href = "howitworks.php";
					map.areas[1].alt = "See Details";
				}
				if(this.id == "l5") {
					map = document.getElementById("Mapz");
					map.areas[0].coords = "19,216,70,231";
					map.areas[0].href = "howitworks.php";
					map.areas[0].alt = "See Details";
					map.areas[1].coords = "160,216,211,231";
					map.areas[1].href = "howitworks.php";
					map.areas[1].alt = "See Details";
					map.areas[2].coords = "311,216,362,231";
					map.areas[2].href = "howitworks.php";
					map.areas[2].alt = "See Details";
					map.areas[3].coords = "461,216,512,231";
					map.areas[3].href = "howitworks.php";
					map.areas[3].alt = "See Details";  
				}				
            lastLink = this;

            ltour.outfx.start({
                'opacity': 0
            }).chain(function() {
                ntour.className = 'show';
                ltour.className = '';
                // executes immediately after completion of above effect
                ntour.infx.start({
                    'opacity': 1
                });
            });
        });
    }	
});
