$(function(){

	initSwiper = function(){
		var mySwiper = new Swiper(".swiper-container", {
			pagination: '.swiper-pagination',
			speed: 400,
			spaceBetween: 100,
			mode:'horizontal',
			loop: true,
			grabCursor: true,
			autoplay: 3000
		});   
	};

	fetchAdvert = function(_target,postId){
		var _path=buildHTTP("/advertment/fetch.shtml");
		var params={
				postId:postId
		};
		$.ajax({
			url: _path, 
			type: "post", 
			dataType: "json",
			data:$.toJSON(params),   
			contentType:"application/json",
			success: function(data) { 
				if(data.code=='01'){
					var vhtml ="";
					$.each(data.content, function (i, adv) {
						vhtml += "<div class=\"swiper-slide\">";
						vhtml += "<img src='"+adv.fpath+"'>";
						vhtml += "</div>";
					}); 
					$(_target).html(vhtml);

					initSwiper(); // 广告轮播图

				}else{
					$.toast("获取轮播广告失败");
				}
			}
		});
	};

	fetchAdvert(".swiper-wrapper",2);



	fetchCity = function(){
		var user = fetchUSER();  // 提取用户信息
		if(user==null||user.hostId=='0'){
			$("#city").html("贵阳");
		}else{
			$("#city").html(user.city);
		}
	};
	
	$.init();
});