﻿/*
    Project:	hoteltysandros
	Version: 	1.0.0
	Released:	23/05/2011
	Author:	    Dr. Domenico Mario Monte
	Company:	MdmSoft - Consulenza Sistemi Informatici
	Web:		http://www.mdmsoft.it
*/

// Set the speed of the automatic slideshow
var slideshowSpeed = 3000;

// Store the images we need to set as background
var photos = [ {
		"image" : "bg_hotel-villa-linda.jpg"
	}, {
		"image" : "bg_hotel-villa-linda-servizi.jpg"
	}, {
		"image" : "bg_hotel-villa-linda-tariffe.jpg"
	}, {
		"image" : "bg_hotel-villa-linda-camera-2.jpg"
	}, {
		"image" : "bg_hotel-villa-linda-camera-3.jpg"
	}
];

$(document).ready(function() {

	var activeContainer = 1;	
	var currentImg = 0;
	var animating = false;
	var navigate = function(direction) {
		if(animating) {
			return;
		}
		currentImg++;
		if(currentImg == photos.length + 1) {
			currentImg = 1;
		}
		var currentContainer = activeContainer;
		if(activeContainer == 1) {
			activeContainer = 2;
		} else {
			activeContainer = 1;
		}
		showImage(photos[currentImg - 1], currentContainer, activeContainer);
	};
	
	var currentZindex = -1;
	var showImage = function(photoObject, currentContainer, activeContainer) {
		animating = true;
		currentZindex--;
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(App_Themes/Tema/backgrounds/" + photoObject.image + ")",
			"display" : "block",
			"z-index" : currentZindex
		});
		
		$("#headerimg" + currentContainer).fadeOut(function() {
			setTimeout(function() {
				$("#headertxt").css({"display" : "block"});
				animating = false;
			}, 500);
		});
	};
	
	navigate("next");
	interval = setInterval(function() {
		navigate("next");
	}, slideshowSpeed);
});
