/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
*/
var slideshowSpeed = 6000;
var photos = [ {
		"title" : "Clique aqui",
		"image" : "cloud.jpg",
		"url" : "http://www.alvo.com/software/software-cloud.asp",
		"firstline" : "Mais seguro e mais barato",
		"secondline" : "Software na Cloud"
	}, {
		"title" : "Alvo Connect",
		"image" : "connect.jpg",
		"url" : "http://www.alvo.com/servicos/planos-suporte.asp",
		"firstline" : "Suporte Primavera",
		"secondline" : "20€ por incidente"
	}, {
		"title" : "Gestão de Relacionamento com Clientes",
		"image" : "crm.jpg",
		"url" : "http://www.alvo.com/software/gestao-relacionamento-clientes-crm.asp",
		"firstline" : "Conheça bem os seus Clientes",
		"secondline" : "venda mais"
	}, {
		"title" : "Gestão Documental - Saiba mais",
		"image" : "documental.jpg",
		"url" : "http://www.alvo.com/software/gestao-documental.asp",
		"firstline" : "A CentralSeg poupou 50% com",
		"secondline" : "o Software da Alvo"
	}, {
		"title" : "Saiba como",
		"image" : "kpi.jpg",
		"url" : "http://www.alvo.com/software/indicadores-gestao-kpi.asp",
		"firstline" : "Tome decisões certas com",
		"secondline" : "indicadores de gestão"
	}, {
		"title" : "Saiba mais",
		"image" : "backups.jpg",
		"url" : "http://www.alvo.com/infraestrutura/backup.asp",
		"firstline" : "A Irrimac transferiu os Backups",
		"secondline" : "para a Cloud"
	}, {
		"title" : "Gestão de Obras e Contratos - Clique aqui",
		"image" : "obras.jpg",
		"url" : "http://www.alvo.com/software/gestao-obras-contratos.asp",
		"firstline" : "Software de gestão para o",
		"secondline" : "sector da construção"
	}, {
		"title" : "Clique aqui",
		"image" : "qualidade.jpg",
		"url" : "http://www.alvo.com/software/gestao-qualidade.asp",
		"firstline" : "Software de Gestão para",
		"secondline" : "processos da qualidade"
	}, {
		"title" : "Segurança",
		"image" : "seguranca.jpg",
		"url" : "http://www.alvo.com/infraestrutura/seguranca.asp",
		"firstline" : "Seja alertado de todas as",
		"secondline" : "ameaças à rede"
	}
];

$(document).ready(function() {
	$("#back").click(function() {stopAnimation();navigate("back");});
	$("#next").click(function() {stopAnimation();navigate("next");});
	var interval;
	$("#control").toggle(function(){stopAnimation();}, function() {$(this).css({ "background-image" : "url(images/frontpage/btn_pause.png)" });	navigate("next");interval = setInterval(function() {navigate("next");}, slideshowSpeed);});
	var activeContainer = 1;var currentImg = 0;	var animating = false;
	var navigate = function(direction) {if(animating) {return;}
		if(direction == "next") {currentImg++;if(currentImg == photos.length + 1) {currentImg = 1;}} else {currentImg--;if(currentImg == 0) {currentImg = photos.length;}}
		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(images/frontpage/" + photoObject.image + ")","display" : "block","z-index" : currentZindex});$("#headertxt").css({"display" : "none"});
		$("#firstline").html(photoObject.firstline);
		$("#secondline").attr("href", photoObject.url).html(photoObject.secondline);
		$("#pictureduri").attr("href", photoObject.url).html(photoObject.title);
		$("#headerimg" + currentContainer).fadeOut(function() {setTimeout(function() {$("#headertxt").css({"display" : "block"});animating = false;}, 600);});};
	var stopAnimation = function() {$("#control").css({ "background-image" : "url(images/frontpage/btn_play.png)" });clearInterval(interval);};navigate("next");interval = setInterval(function() {navigate("next");}, slideshowSpeed);});    

