﻿// JavaScript Document

jQuery(document).ready(function() {
    //var hero = jQuery("#hero").children('img');
    var heroes = new Array("images/home_heroes/Bellagio_Conservatory.jpg", "images/home_heroes/Bellagio_Fountains.jpg", "images/home_heroes/Fremont_Street.jpg", "images/home_heroes/Hoover_Dam.jpg", "images/home_heroes/Lake_Mead.jpg", "images/home_heroes/Strip.jpg", "images/home_heroes/Strip_from_Bellagio_East.jpg", "images/home_heroes/Strip_from_Mandalay_Bay.jpg", "images/home_heroes/Welcome_to_Vegas_Sign.jpg");

    for (var i in heroes) {
        jQuery("#hero").prepend("<img src='" + heroes[i] + "' width='948' height='290' border='0' alt='' />");
    }
    /*	jQuery.ajax({
    type: "GET",
    url: "heroes.xml",
    dataType: "xml",
    success: function(xml) {
    jQuery(xml).find('hero').each(function() {
    var id = jQuery(this).attr("id");
    var name = jQuery(this).find('name').text();
    var src = jQuery(this).find('src').text();
    jQuery("#hero").prepend("<img src='"+src+"' width='948' height='290' border='0' alt='"+name+"' id='"+id+"' />");
    //alert(src);
    }); // close xml reading function
    } // close success function
    }); //close .ajax()*/
}); // close jQuery(document).ready()

function slideSwitch() {
    var $active = jQuery('#hero img.active');

    if ($active.length == 0) $active = jQuery('#hero IMG:last');

    var $next = $active.next().length ? $active.next() : jQuery('#hero IMG:first');

    $active.addClass('last-active');

    $next.css({ opacity: 0.0 })
		.addClass('active')
		.animate({ opacity: 1.0 }, 1000, function() {
		    $active.removeClass('active last-active');
		});

}

jQuery(function() {
    setInterval("slideSwitch()", 5000);
});
