jumpPage();

function jumpPage() {
	//跳转页面
	var subpages = ['choiceness.html', 'dynamic.html', 'new_product.html'];
	var subpage_style = {
		top: '103px',
		bottom: '0px',
		scrollIndicator: 'none'
	};

	var aniShow = {}; //动画显示
	//当前激活选项
	var activeTab = subpages[0];
	//选项卡点击事件
	mui('.nav').on('tap', 'a', function(e) {
		var targetTab = this.getAttribute('href');
		if(targetTab == activeTab) {
			return;
		}
		//显示目标选项卡 
		//若为iOS平台或非首次显示，则直接显示
		if(mui.os.ios || aniShow[targetTab]) {
			plus.webview.show(targetTab);
		} else {
			//否则，使用fade-in动画，且保存变量
			var temp = {};
			temp[targetTab] = "true";
			mui.extend(aniShow, temp);
			plus.webview.show(targetTab, "fade-in", 300);
		}
		//隐藏当前;
		plus.webview.hide(activeTab);
		//更改当前活跃的选项卡
		activeTab = targetTab;

		if(targetTab == 'choiceness.html') {
			document.getElementsByClassName('p1')[1].classList.remove('on')
			document.getElementsByClassName('p1')[2].classList.remove('on')
			this.classList.add('on');
		}

		if(targetTab == 'dynamic.html') {
			document.getElementsByClassName('p1')[0].classList.remove('on')
			document.getElementsByClassName('p1')[2].classList.remove('on')
			this.classList.add('on');
		}

		if(targetTab == 'new_product.html') {
			document.getElementsByClassName('p1')[0].classList.remove('on')
			document.getElementsByClassName('p1')[1].classList.remove('on')
			this.classList.add('on');
		}

	});

	//首次启动切滑效果 

	mui.plusReady(function() {
		window.addEventListener('refresh', function(e) {
			location.reload();
		})
		//				launchScreen();
		//				plus.navigator.setStatusBarStyle('dark');
		//				//console.log(plus.navigator.getStatusBarStyle())
		var self = plus.webview.currentWebview();
		for(var i = 0; i < subpages.length; i++) {
			var temp = {};
			//http://www.html5plus.org/doc/zh_cn/webview.html#plus.webview.create
			var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);
			if(i > 0) {
				sub.hide();
			} else {
				temp[subpages[i]] = "true";
				mui.extend(aniShow, temp); //合并对象
			}
			self.append(sub);
		}
	});
}