var photo_urls = new Array;
var photo_href = new Array;
var photo_title = new Array;
var photo_captions = new Array;


/*----------------------------------------------------------
					EDITAR AQUI 
------------------------------------------------------------*/
photo_urls[1] = "images/mol_night.jpg";
photo_title[1] = "<b>Monteverde Lodge & Gardens</b>";
photo_captions[1] = "<b>Located in the Tilarán Mountains at 4,600 ft on the edge of the world's best-known mid-elevation cloud forest, Monteverde Lodge was built for the discerning nature traveler.</b>";
photo_href[1] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=48";

photo_urls[2] = "images/room.jpg";
photo_title[2] = "<b>Accommodations</b>";
photo_captions[2] = "<b>Bay windows in every room offer views of the surrounding forest. Don’t forget your binoculars.</b>";
photo_href[2] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=43";

photo_urls[3] = "images/cloud_forest.jpg";
photo_title[3] = "<b>Monteverde Reserve</b>";
photo_captions[3] = "<b>Founded in 1972, Monteverde Reserve extends down both slopes of the Tilaran Mountains, encompassing 6 different ecological life zones with more than 400 species of birds.</b>";
photo_href[3] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=447";

photo_urls[4] = "images/morpho.jpg";
photo_title[4] = "<b>Monteverde</b>";
photo_captions[4] = "<b>The Morpho Butterfly’s beautiful metallic blue coloration and erratic flight most likely serve as mechanisms against predators, making it hard to pursue.</b>";
photo_href[4] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=129";

photo_urls[5] = "images/family_hike.jpg";
photo_title[5] = "<b>Cloud Forest Hike</b>";
photo_captions[5] = "<b>With luck and patience, from Jan. to July visitors may observe the Resplendent Quetzal in Monteverde Reserve.</b>";
photo_href[5] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=1262";

photo_urls[6] = "images/boy_w_frog.jpg";
photo_title[6] = "<b>Tree Frog</b>";
photo_captions[6] = "<b>Eye-to-eye with a Red-eyed Tree Frog.</b>";
photo_href[6] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=1301";

photo_urls[7] = "images/hummer.jpg";
photo_title[7] = "<b>Hummingbird</b>";
photo_captions[7] = "<b>This tiny Green Violet-ear Hummingbird is a common highland resident.</b>";
photo_href[7] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=130";

photo_urls[8] = "images/lookout.jpg";
photo_title[8] = "<b>Lookout</b>";
photo_captions[8] = "<b>The lookout at Monteverde Lodge offers good vistas for viewing wildlife.</b>";
photo_href[8] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=90";

photo_urls[9] = "images/lookout.jpg";
photo_title[9] = "<b>Lookout</b>";
photo_captions[9] = "<b>The lookout at Monteverde Lodge offers good vistas for viewing wildlife.</b>";
photo_href[9] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=90";

photo_urls[10] = "images/mol_bar_350x245.jpg";
photo_title[10] = "<b>Monteverde Lodge</b>";
photo_captions[10] = "<b>Bar and lounge.</b>";
photo_href[10] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=124";

photo_urls[11] = "images/mol(1).jpg";
photo_title[11] = "<b>Monteverde Lodge & Gardens</b>";
photo_captions[11] = "";
photo_href[11] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=131";

photo_urls[12] = "images/guided_tour.jpg";
photo_title[12] = "<b>Guided Tours</b>";
photo_captions[12] = "<b>While you hike in the cloud forest, we strongly recommended going with a guide. Many stunning birds, including the Quetzal, are surprisingly inconspicuous when perched quietly in the shade.</b>";
photo_href[12] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=128";

photo_urls[13] = "images/quetzal(2).jpg";
photo_title[13] = "<b>Resplendent Quetzal</b>";
photo_captions[13] = "<b>Without a doubt, the male Quetzal is one of the most beautiful birds in the world. From Jan. to July, he is the main attraction of the Monteverde Cloud Forest.</b>";
photo_href[13] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=131";

photo_urls[14] = "images/jacuzzi_350x245.jpg";
photo_title[14] = "<b>Monteverde Lodge</b>";
photo_captions[14] = "<b>Jacuzzi</b>";
photo_href[14] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=664";

photo_urls[15] = "images/garden.jpg";
photo_title[15] = "<b>The Gardens</b>";
photo_captions[15] = "<b>Many of our guests find that among their most enjoyable time spent in Costa Rica is in the Monteverde Lodge Gardens. We have chosen native plant species that replicate the natural cloud forest and attract its fauna.</b>";
photo_href[15] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=1024";

photo_urls[16] = "images/breakfast.jpg";
photo_title[16] = "<b>The Gardens</b>";
photo_captions[16] = "<b>Breakfast with bromeliads in the Lodge's garden.</b>";
photo_href[16] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=1456";

photo_urls[17] = "images/horseback.jpg";
photo_title[17] = "<b>Horseback Riding</b>";
photo_captions[17] = "<b>The Sunset Ride in Monteverde takes you through open fields and forests and offers fine views of the Gulf of Nicoya.</b>";
photo_href[17] = "http://www.costaricaexpeditions.com/Gallery/singlepicture.php?pic=225";

var photo_count = 17; 

/*----------------------------------------------------------
					HASTA AQUI 
------------------------------------------------------------*/



var timer; 
var current_location = 1;
var next_location = 1; 
var pics_loaded = 0;
var onoff = 0;
var direction = 1;
var timeout_value;
var images = new Array;
var transitionNames = new Array;
var transitions = new Array;
var current_transition = 0;
var loop = 0;


transitions[0] = "progid:DXImageTransform.Microsoft.Fade(duration=1)";
var transition_count = 15;




// Browser capabilities detection ---
// - assume only IE4+ and NAV6+ can do image resizing, others redirect to low 
if (is_ie4up || is_nav6up) {
    //-- it's all good ---
} else {
    //-- any other browser we go low-tech ---
    document.location = slideShowLow;
}

// - IE5.5 and up can do the blending transition.
var browserCanBlend = (is_ie5_5up);

function stopOrStart() {
    if (onoff) {
	stop();
    } else {
	play();
    }
}



function changeElementText(id, newText) {
    element = document.getElementById(id);
    element.innerHTML = newText;
}

function stop() {

    onoff = 0;
    status = "The slide show is stopped, Click [play] to continue.";
    clearTimeout(timer);

}

function play() {

    onoff = 1;
    status = "Slide show is running...";
	
    go_to_next_photo();
	  
}

function preload_complete() {
}

function reset_timer() {
    clearTimeout(timer);
   
	timeout_value = 8000;
	timer = setTimeout('go_to_next_photo()', timeout_value);
   
}

function wait_for_current_photo() {

    /* Show the current photo */
    if (!show_current_photo()) {

	/*
	 * 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);
	timer = setTimeout('wait_for_current_photo()', 500);
	return 0;
    } else {
	status = "Slide show is running...";
	preload_next_photo();
	reset_timer();
    }
}

function go_to_next_photo() {
    /* Go to the next location */
    current_location = next_location;

    /* Show the current photo */
    if (!show_current_photo()) {
	wait_for_current_photo();
	return 0;
    }

    preload_next_photo();
    reset_timer();
}

function preload_next_photo() {
    
    /* Calculate the new next location */
    next_location = (parseInt(current_location) + 1);
    if (next_location > photo_count) {
	next_location = 1;
	preload_photo(next_location);
    }
    /* Preload the next photo */
    preload_photo(next_location);
}

function preload_back_photo() {
    
    /* Calculate the new next location */
	
    next_location = (parseInt(current_location) - 1);
	stopOrStart();
    if (next_location < 0) {
	next_location = photo_count;
    }
    if (next_location == 0) {
        next_location = photo_count;
	if (!loop) {
	    stop();
	stopOrStart();
	}
    }
    
    /* Preload the next photo */
    preload_photo(next_location);
	stopOrStart();
}

function next() {
    
    /* Calculate the new next location */
	
    next_location = (parseInt(current_location) + 1);
	 if (next_location > photo_count) {
	next_location = 1;
	preload_photo(next_location);
    }
	stopOrStart();
   
    if (next_location == 0) {
        next_location = photo_count;
	if (!loop) {
	    stop();
	stopOrStart();
	}
    }
    
    /* Preload the next photo */
    preload_photo(next_location);
	stopOrStart();
}

function show_current_photo() {

    /*
     * If the current photo is not completely loaded don't display it.
     */
    if (!images[current_location] || !images[current_location].complete) {
	preload_photo(current_location);
	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.style.filter=transitions[do_transition];
	document.images.slide.filters[0].Apply();
    }
    document.slide.src = images[current_location].src;
	//Cambio url para redireccion on click de fotos
	//document.links['slide_href'].href = photo_href[current_location]; 
	//Cabio Para que el caption sea mas facil de poner
	var buh_caption = "<font color='#A46F47' size='3'>" + photo_title[current_location] + "</font>";
	buh_caption += "<p>" + photo_captions[current_location] + "</p>";
	setCaption( buh_caption );

    if (browserCanBlend) {
	document.images.slide.filters[0].Play();
    }

    return 1;
}

function preload_photo(index) {

    /* Load the next picture */
    if (pics_loaded < photo_count) {

	/* not all the pics are loaded.  Is the next one loaded? */
	if (!images[index]) {
	    images[index] = new Image;
	    images[index].onLoad = preload_complete();
	    images[index].src = photo_urls[index];
	    pics_loaded++;
	}
    } 
}

function setCaption(text) {
    changeElementText("caption", "" + text);
}