﻿function setMenu() {

    var locationString = window.location.toString().toLowerCase();

    if (locationString) {
        if (locationString.indexOf('/rooms') != -1) {
            $("#rooms").css({ backgroundColor: "#6c816b", color: "#FFF" });
        }
        else if (locationString.indexOf('/serviced-apartments') != -1) {
            $("#apartments").css({ backgroundColor: "#6c816b", color: "#FFF" });
        }
        else if (locationString.indexOf('/tariff') != -1) {
            $("#tariff").css({ backgroundColor: "#6c816b", color: "#FFF" });
        }
        else if (locationString.indexOf('/dining') != -1) {
            $("#dining").css({ backgroundColor: "#6c816b", color: "#FFF" });
        }
        else if (locationString.indexOf('/surrounding-area') != -1) {
            $("#area").css({ backgroundColor: "#6c816b", color: "#FFF" });
        }
        else if (locationString.indexOf('/history') != -1) {
            $("#history").css({ backgroundColor: "#6c816b", color: "#FFF" });
        }
        else if (locationString.indexOf('/contact') != -1) {
            $("#contact").css({ backgroundColor: "#6c816b", color: "#FFF" });
        }
        else {
            $("#home").css({ backgroundColor: "#6c816b", color: "#FFF" });
        }
    }
}

/********** Slide Show **************/
function slideShow() {

    //Set the opacity of all images to 0
    $('#slides_left img').css({ opacity: 0.0 });
    $('#slides_right img').css({ opacity: 0.0 });

    //Get the first image and display it (set it to full opacity)
    $('#slides_left img:first').css({ opacity: 1.0 });
    $('#slides_right img:first').css({ opacity: 1.0 }); 

    //Call the Transition function to run the slideshow, 6000 = change to next image after 6 seconds
    setInterval('transition()', 4000);

}

var slideToggle = 1;

function transition() {

    var selector;

    if (slideToggle) {
        selector = '#slides_left';
        slideToggle = null;
    }
    else {
        selector = '#slides_right'
        slideToggle = 1;
    }

    //if no IMGs have the show class, grab the first image
    var current = ($(selector + ' img.show') ? $(selector + ' img.show') : $(selector + ' img:first'));

    //alert(current);

    //Get next image, if it reached the end of the slideshow, rotate it back to the first image
    var next = ((current.next().length) ? current.next() : $(selector + ' img:first'));

    //alert(next);
    
    //Set the fade in effect for the next image, show class has higher z-index
    next.css({ opacity: 0.0 }).addClass('show').animate({ opacity: 1.0 }, 1000);

    //Hide the current image
    current.animate({ opacity: 0.0 }, 1000).removeClass('show');    

}

$(document).ready(function () {

    setMenu();
    slideShow();
});
