var swiper = new Swiper('.swiper-container', {
  	loop: true,
    speed:300,
    observer: true,	
    observerParents: true,
    autoplayDisableOnInteraction: false,
	  autoplay : {
	    delay:4000
	  },
	   onSlideChangeEnd: function(swipers){ 
        swipers.update(); //swiper更新
    },
    pagination: {
	    el: '.swiper-pagination',
	  },
});

var langList = [
	//中文 英文 阿拉伯文
	{
		foot1:'儲值',
		foot2:'https://footseen.com/img/animg1_cn.png',
		foot3:'https://footseen.com/img/animg2_cn.png',
		foot4:'https://footseen.com/img/animg3_cn.png',
		foot5:'下載APP',
		foot6:'Andorid安裝教學',
		foot7:'1 先至「設置」→「安全性與隱私權」',
		foot8:'2 開啟「從位置來源下載應用程式」,並執行「確定」',
		foot9:'3 在該頁面點擊「下載按鈕」並同意安裝即可',
		foot10:'',
		foot11:'注:請將你的手機版本更新至安卓5.0以上,獲得更好的',
		foot12:'Foot Seen體驗',
	},
	{
		foot1:'Top-up',
		foot2:'https://footseen.com/img/animg1_en.png',
		foot3:'https://footseen.com/img/animg2_en.png',
		foot4:'https://footseen.com/img/animg3_en.png',
		foot5:'Download APP',
		foot6:'Andorid download tutrial',
		foot7:'1.Enter Settings→Security&Privacy',
		foot8:'2.Choose More Settings',
		foot9:'3.Select Download apps from external sources',
		foot10:'4.Click Download and verify installing',
		foot11:'Note:Please upgrade your mobile to Android 5.0',
		foot12:'for a better experience',
	},
	{
		foot1:'العربية',
		foot2:'https://footseen.com/img/img1_ar.jpg',
		foot3:'https://footseen.com/img/img2_ar.jpg',
		foot4:'https://footseen.com/img/img3_ar.jpg',
		foot5:'تحميل التطبيق',
		foot6:'دليل تثبيت لنظام Android',
		foot7:'1. ابحث عن "الإعدادات" وإلى "الحماية والخصوصية"',
		foot8:'2. افعل "تشيت التطيقات من مصدر غير معروف"',
		foot9:'3. إعادة إلى الموقع وانقر على "تحميل التطبيق" وتثبيهه ',
		foot10:'',
		foot11:'تنبيه: يرجى تحديث نظام هاتفك إلى 5.0 أو أحدث منه للتمتع بالامتياز ',
		foot12:'',
	}
]
var langType = 0;
var langStr =(navigator.language || navigator.browserLanguage).toLowerCase();
if(sessionStorage.lang == undefined || sessionStorage.lang == 'undefined'){
	if(langStr.indexOf('ar')>=0){
		sessionStorage.lang = 7;
		$('.langTitle font').html('العربية');
		langType = 2;
		$('.langList p').eq(2).addClass('check');
	} else if(langStr.indexOf('zh')>=0){
		sessionStorage.lang = 2;
		$('.langTitle font').html('繁體中文');
		langType = 0;
		$('.langList p').eq(0).addClass('check');
	} else {
		sessionStorage.lang = 1;
		$('.langTitle font').html('English');
		langType = 1;
		$('.langList p').eq(1).addClass('check');
	}
} else {
	 if(sessionStorage.lang == 7){
		langType = 2;
		$('.langTitle font').html('العربية');
		$('.langList p').eq(2).addClass('check');
	} else if(sessionStorage.lang == 2){
		langType = 0;
		$('.langTitle font').html('繁體中文');
		$('.langList p').eq(0).addClass('check');
	} else {
		langType = 1;
		$('.langTitle font').html('English');
		$('.langList p').eq(1).addClass('check');
	}
}

$(function(){
	lang();
	$('.langTitle').on('click',function(e){
		$('.langList').show();
		$('.langTitle img').attr('src','https://footseen.com/img/up2.png');
		e.stopPropagation();
	})
	$('.langList p').on('click',function(e){
		$(this).addClass('check').siblings().removeClass('check');
		$('.langTitle font').html($(this).html());
		$('.langList').hide();
		$('.langTitle img').attr('src','https://footseen.com/img/down2.png');
		sessionStorage.lang = $(this).attr('data-lang');
		lang();
		e.stopPropagation();
	})
	$(document).on('click',function(e){
		$('.langList').hide();		
		$('.langTitle img').attr('src','https://footseen.com/img/down2.png');

		e.stopPropagation();
	})
})

function lang(){
	$('.main').removeClass('L_Ar');
	if(sessionStorage.lang == 1){
		langType = 1;
	} else if(sessionStorage.lang == 2){
		langType = 0;
	} else if(sessionStorage.lang == 7){
		langType = 2;
		$('.main').addClass('L_Ar');
	}
	$('.swiper-container').removeClass('hide');
	var str = '';
	str += '<div class="swiper-wrapper">';
	str += '	<div class="swiper-slide">';
	str += '		<img src="'+langList[langType].foot2+'"/>';
	str += '	</div>';
	str += '	<div class="swiper-slide">';
	str += '		<img src="'+langList[langType].foot3+'"/>';
	str += '	</div>';
	str += '	<div class="swiper-slide">';
	str += '		<img src="'+langList[langType].foot4+'"/>';
	str += '	</div>';
	str += '</div>';
	str += '<div class="swiper-pagination"></div>';
	$('.swiper-container').html(str);
		this.swiper.destroy(false);
		this.swiper = new Swiper('.swiper-container', {
	  	loop: true,
	    speed:300,
	    observer: true,	
	    observerParents: true,
	    autoplayDisableOnInteraction: false,
		  autoplay : {
		    delay:4000
		  },
		   onSlideChangeEnd: function(swipers){ 
	        swipers.update(); //swiper更新
	    },
	    pagination: {
		    el: '.swiper-pagination',
		  },
	});
	$('.topUp').html(langList[langType].foot1);
	$('.iosDown').html(langList[langType].foot5);
	var str2 = '';
	str2 += '<p class="andoridDescTitle"><img src="https://www.footseen.com/img/desc.png">'+langList[langType].foot6+'</p>';
	str2 += '<p class="andoridDescText andoridDescText1">'+langList[langType].foot7+'</p>';
	str2 += '<p class="andoridDescText1">'+langList[langType].foot8+'</p>';
	str2 += '<p class="andoridDescText1">'+langList[langType].foot9+'</p>';
	if(langType == 1){		
		str2 += '<p class="andoridDescText1">'+langList[langType].foot10+'</p>';
	}
	str2 += '<p class="andoridDescText andoridDescText2">'+langList[langType].foot11+'</p>';
	str2 += '<p class="andoridDescText2">'+langList[langType].foot12+'</p>';
	$('.andoridDesc').html(str2);
}