var timer_2; 
var current_location_2 = 1;
var next_location_2 = 1; 
var pics_loaded_2 = 0;
var onoff = 0;
var direction_2 = 1;
var timeout_value_2;
var images_2 = new Array;
var photo_urls_2 = new Array;

var photo_count_2 = 80

var transitionNames = new Array;
var transitions = new Array;
var current_transition = 0;

// - Define Transitions

transitions[0] = "progid:DXImageTransform.Microsoft.Fade(duration=1)";
transitions[1] = "progid:DXImageTransform.Microsoft.Blinds(Duration=1,bands=20)";
transitions[2] = "progid:DXImageTransform.Microsoft.Checkerboard(Duration=1,squaresX=20,squaresY=20)";
transitions[3] = "progid:DXImageTransform.Microsoft.Strips(Duration=1,motion=rightdown)";
transitions[4] = "progid:DXImageTransform.Microsoft.Barn(Duration=1,orientation=vertical)";
transitions[5] = "progid:DXImageTransform.Microsoft.GradientWipe(duration=1)";
transitions[6] = "progid:DXImageTransform.Microsoft.Iris(Duration=1,motion=out)";
transitions[7] = "progid:DXImageTransform.Microsoft.Wheel(Duration=1,spokes=12)";
transitions[8] = "progid:DXImageTransform.Microsoft.Pixelate(maxSquare=10,duration=1)";
transitions[9] = "progid:DXImageTransform.Microsoft.RadialWipe(Duration=1,wipeStyle=clock)";
transitions[10] = "progid:DXImageTransform.Microsoft.RandomBars(Duration=1,orientation=vertical)";
transitions[11] = "progid:DXImageTransform.Microsoft.Slide(Duration=1,slideStyle=push)";
transitions[12] = "progid:DXImageTransform.Microsoft.RandomDissolve(Duration=1,orientation=vertical)";
transitions[13] = "progid:DXImageTransform.Microsoft.Spiral(Duration=1,gridSizeX=40,gridSizeY=40)";
transitions[14] = "progid:DXImageTransform.Microsoft.Stretch(Duration=1,stretchStyle=push)";
transitions[15] = "special case";
var transition_count = 15;

var browserCanBlend = (is_ie5_5up);

function play_2() {
//    changeElementText("stopOrStartText", "stop");

    onoff = 1;
//    status = "Slide show is running...";
    go_to_next_photo_2();
}

function change_transition_2() {
    current_transition = document.TopForm.transitionType.selectedIndex;
}

function preload_complete_2() {
}

function reset_timer_2() {
    clearTimeout(timer_2);
    if (onoff) {
	timeout_value_2 = 6000;
	timer_2 = setTimeout('go_to_next_photo_2()', timeout_value_2);
    }
}

function wait_for_current_photo_2() {

    /* Show the current photo */
    if (!show_current_photo_2()) {

	/*
	 * The current photo isn't loaded yet.  Set a short timer just to wait
	 * until the current photo is loaded.
	 */
//	status = "Picture is loading...(" + current_location + " of " + photo_count + ").  Please Wait..." ;
	clearTimeout(timer_2);
	timer_2 = setTimeout('wait_for_current_photo_2()', 0);
	return 0;
    } else {
//	status = "Slide show is running...";
	preload_next_photo_2();
	reset_timer_2();
    }
}

function go_to_next_photo_2() {
    /* Go to the next location */
    current_location_2 = next_location_2;

    /* Show the current photo */
    if (!show_current_photo_2()) {
	wait_for_current_photo_2();
	return 0;
    }

    preload_next_photo_2();
    reset_timer_2();
}

function preload_next_photo_2() {
    
    /* Calculate the new next location */
    next_location_2 = (parseInt(current_location_2) + parseInt(direction_2));
    if (next_location_2 > photo_count_2) {
	next_location_2 = 1;
    }
    if (next_location_2 == 0) {
        next_location_2 = photo_count_2;
    }
    
    /* Preload the next photo */
    preload_photo_2(next_location_2);
}

function show_current_photo_2() {

    /*
     * If the current photo is not completely loaded don't display it.
     */
    if (!images_2[current_location_2] || !images_2[current_location_2].complete) {
	preload_photo_2(current_location_2);
	return 0;
    }
    
    /* transistion effects */
    if (browserCanBlend){
	var do_transition;
	if (current_transition == (transition_count)) {
	    do_transition = Math.floor(Math.random() * transition_count);
	} else {
	    do_transition = current_transition;
	}
	document.images.slide_2.style.filter=transitions[do_transition];
	document.images.slide_2.filters[0].Apply();
    }
    document.slide_2.src = images_2[current_location_2].src;

    if (browserCanBlend) {
	document.images.slide_2.filters[0].Play();
    }

    return 1;
}

function preload_photo_2(index_2) {

    /* Load the next picture */
    if (pics_loaded_2 < photo_count_2) {

	/* not all the pics are loaded.  Is the next one loaded? */
	if (!images_2[index_2]) {
	    images_2[index_2] = new Image;
	    images_2[index_2].onLoad = preload_complete_2();
	    images_2[index_2].src = document.getElementById("photo_urls_2_" + index_2).href;
	    pics_loaded_2++;
	}
    } 
}