var timer_1; 
var current_location_1 = 1;
var next_location_1 = 1; 
var pics_loaded_1 = 0;
var onoff = 0;
var direction_1 = 1;
var timeout_value_1;
var images_1 = new Array;
var photo_urls_1 = new Array;

var photo_count_1 = 18

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_1() {
//    changeElementText("stopOrStartText", "stop");

    onoff = 1;
//    status = "Slide show is running...";
    go_to_next_photo_1();
}

function change_transition_1() {
    current_transition = document.TopForm.transitionType.selectedIndex;
}

function preload_complete_1() {
}

function reset_timer_1() {
    clearTimeout(timer_1);
    if (onoff) {
	timeout_value_1 = 3000;
	timer_1 = setTimeout('go_to_next_photo_1()', timeout_value_1);
    }
}

function wait_for_current_photo_1() {

    /* Show the current photo */
    if (!show_current_photo_1()) {

	/*
	 * 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_1);
	timer_1 = setTimeout('wait_for_current_photo_1()', 3000);
	return 0;
    } else {
//	status = "Slide show is running...";
	preload_next_photo_1();
	reset_timer_1();
    }
}

function go_to_next_photo_1() {
    /* Go to the next location */
    current_location_1 = next_location_1;

    /* Show the current photo */
    if (!show_current_photo_1()) {
	wait_for_current_photo_1();
	return 0;
    }

    preload_next_photo_1();
    reset_timer_1();
}

function preload_next_photo_1() {
    
    /* Calculate the new next location */
    next_location_1 = (parseInt(current_location_1) + parseInt(direction_1));
    if (next_location_1 > photo_count_1) {
	next_location_1 = 1;
    }
    if (next_location_1 == 0) {
        next_location_1 = photo_count_1;
    }
    
    /* Preload the next photo */
    preload_photo_1(next_location_1);
}

function show_current_photo_1() {

    /*
     * If the current photo is not completely loaded don't display it.
     */
    if (!images_1[current_location_1] || !images_1[current_location_1].complete) {
	preload_photo_1(current_location_1);
	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_1.style.filter=transitions[do_transition];
	document.images.slide_1.filters[0].Apply();
    }
    document.slide_1.src = images_1[current_location_1].src;

    if (browserCanBlend) {
	document.images.slide_1.filters[0].Play();
    }

    return 1;
}

function preload_photo_1(index_1) {

    /* Load the next picture */
    if (pics_loaded_1 < photo_count_1) {

	/* not all the pics are loaded.  Is the next one loaded? */
	if (!images_1[index_1]) {
	    images_1[index_1] = new Image;
	    images_1[index_1].onLoad = preload_complete_1();
	    images_1[index_1].src = document.getElementById("photo_urls_1_" + index_1).href;
	    pics_loaded_1++;
	}
    } 
}
