$(function() {
	'use strict';
	
	// 幻灯片效果
	$('.carousel').carousel({
		interval: 3000
	});
	
	// 通过哈希值切换幻灯片
	var onHashChange = function() {
		var hash = (window.location.hash && window.location.hash.substring(1)) || null;
		switch(hash) {
			case '/finance':
				$('.carousel').carousel(4); break;
			case '/public':
				$('.carousel').carousel(5); break;
			case '/member':
				$('.carousel').carousel(6); break;
			case '/help':
				$('.carousel').carousel(7); break;
		}
	};
	
	onHashChange();
	
	// 监听哈希值变化
	window.onhashchange = function() {
		onHashChange();
	};
	
	var tour = new Tour({
		template: "<div class='popover tour'>" +
					"<div class='arrow'></div>" + 
					"<div class='popover-title text-info'></div>" +
					"<div class='popover-content'></div>" +
					"<div class='popover-navigation'>" +
						"<button class='btn btn-default btn-sm' data-role='prev'>« 上一步</button>" +
						"<span data-role='separator'>&nbsp;</span>" +
						"<button class='btn btn-default btn-sm' data-role='next'>下一步 »</button>" +
						"<button class='btn btn-default btn-sm' data-role='end'>结束引导</button>" +
					"</div>" +
				"</div>",
		steps: [{
			element: '#logo',
			title: '这是优软云的新Logo哟',
			content: '点击这里可以返回到优软云首页',
			placement: 'bottom',
			backdrop: true
		}, {
			element: '.link-login',
			title: '点击这里去登录',
			content: '使用原有的优软商务平台的账号和密码就可以登录啦',
			placement: 'bottom',
			backdrop: true
		}, {
			element: '.link-b2b',
			title: '点击这里进入原先的优软商务平台',
			content: '优软商务平台搬到这里啦，点进去就能看到客户给你下的新的采购单咯',
			placement: 'bottom',
			backdrop: true
		}, {
			element: '.qrcode-uu',
			title: '手机UU客户端二维码',
			content: '扫描下载手机UU客户端，全新的移动办公体验',
			placement: 'top',
			backdrop: true
		}, {
			element: '.qrcode-uas',
			title: 'UAS公众号二维码',
			content: '扫描关注UAS微信公众号，掌握最新动态',
			placement: 'top',
			backdrop: true
		}],
		onEnd: function() {
			// 介绍滚动至页面最顶部
			$(document.body).animate({scrollTop: 0}, 300);
		}
	});
	
	// 引导提示
	tour.init();
	tour.start();
	
});