var timer_3; 
var current_location_3 = 1;
var next_location_3 = 1; 
var pics_loaded_3 = 0;
var onoff = 0;
var direction_3 = 1;
var timeout_value_3;
var images_3 = new Array;
var photo_urls_3 = new Array;

var photo_count_3 = 23

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_3() {
//    changeElementText("stopOrStartText", "stop");

    onoff = 1;
//    status = "Slide show is running...";
    go_to_next_photo_3();
}

function change_transition_3() {
    current_transition = document.TopForm.transitionType.selectedIndex;
}

function preload_complete_3() {
}

function reset_timer_3() {
    clearTimeout(timer_3);
    if (onoff) {
	timeout_value_3 = 6000;
	timer_3 = setTimeout('go_to_next_photo_3()', timeout_value_3);
    }
}

function wait_for_current_photo_3() {

    /* Show the current photo */
    if (!show_current_photo_3()) {

	/*
	 * 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_3);
	timer_3 = setTimeout('wait_for_current_photo_3()', 4000);
	return 0;
    } else {
//	status = "Slide show is running...";
	preload_next_photo_3();
	reset_timer_3();
    }
}

function go_to_next_photo_3() {
    /* Go to the next location */
    current_location_3 = next_location_3;

    /* Show the current photo */
    if (!show_current_photo_3()) {
	wait_for_current_photo_3();
	return 0;
    }

    preload_next_photo_3();
    reset_timer_3();
}

function preload_next_photo_3() {
    
    /* Calculate the new next location */
    next_location_3 = (parseInt(current_location_3) + parseInt(direction_3));
    if (next_location_3 > photo_count_3) {
	next_location_3 = 1;
    }
    if (next_location_3 == 0) {
        next_location_3 = photo_count_3;
    }
    
    /* Preload the next photo */
    preload_photo_3(next_location_3);
}

function show_current_photo_3() {

    /*
     * If the current photo is not completely loaded don't display it.
     */
    if (!images_3[current_location_3] || !images_3[current_location_3].complete) {
	preload_photo_3(current_location_3);
	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_3.style.filter=transitions[do_transition];
	document.images.slide_3.filters[0].Apply();
    }
    document.slide_3.src = images_3[current_location_3].src;

    if (browserCanBlend) {
	document.images.slide_3.filters[0].Play();
    }

    return 1;
}

function preload_photo_3(index_3) {

    /* Load the next picture */
    if (pics_loaded_3 < photo_count_3) {

	/* not all the pics are loaded.  Is the next one loaded? */
	if (!images_3[index_3]) {
	    images_3[index_3] = new Image;
	    images_3[index_3].onLoad = preload_complete_3();
	    images_3[index_3].src = document.getElementById("photo_urls_3_" + index_3).href;
	    pics_loaded_3++;
	}
    } 
}