function syncMessageNews(loginName) {
	$.ajax({
		url : '/column/queryBrandMessage.html',
		type : 'post',
		dataType : 'json', // returned data type
		data : 'brandId=' + loginName,
		success : function(data, stauts) {
			if (data.flag == 'success') {
				$("#newsBrandList").empty();
				var i = 0;
				$.each(data, function(n, value) {
					if (value != 'success') {
						var htmlTxt = "";
						htmlTxt = htmlTxt + '<div class="swiper-slide dy-list clearfix"><div class="dy-img">';
						var list = value.replace(/\'/g, "\"");
						var result = eval("("+list+")");	
						$.each(result, function(id, value) {
							if (id == 'brandNameEn') {
								if (value == 0) {
									htmlTxt = htmlTxt + '<img src="/resource/images/face-male.jpg" width="75" height="75">';
								} else if(value == 1) {
									htmlTxt = htmlTxt + '<img src="/resource/images/head-female.jpg" width="75" height="75">';
								} else {
									htmlTxt = htmlTxt + '<img src="/resource/images/face-male.jpg" width="75" height="75">';
								}
								htmlTxt = htmlTxt + '</div>';
							}
							if (id == 'messageContent') {
								htmlTxt = htmlTxt + '<div class="dy-con"><div class="tips">';
								if (null == value || value == 'null') {
									value = "我对此项目很感兴趣，请联系我。";
								}
								htmlTxt = htmlTxt + '<p>' + value + '</p>';
								htmlTxt = htmlTxt + '</div>';
							}
							if (id == 'auditTime') {
								htmlTxt = htmlTxt + '<div class="time">';
								htmlTxt = htmlTxt + '<span>' + value + '</span>';
							}
							if (id == 'addDetails') {
								if (value != 'null') {
									htmlTxt = htmlTxt + '<span>' + value + '</span>';
								}
								htmlTxt = htmlTxt + '</div></div></div>';
							}
						});
						$("#newsBrandList").append(htmlTxt);
						i++;
					}
				});
				var mySwiper = new Swiper('.swiper-container', {
					speed : 200, autoplay : true, direction : 'vertical',
					pagination : {
						el : '.swiper-pagination',
						clickable : true,
					},
				})
			} else {
				$("#newsBrandList").parent().parent().remove();
			}
		},
		error : function() {
			
		}
	});
}

function submitNewsMsg(msg) {
	var fileName = $(msg).parents("form").find("input[name='fileName']").val();
	var loginName = $(msg).parents("form").find("input[name='loginName']").val();
	var trueName = $(msg).parents("form").find("input[name='trueName']").val();
	var phone = $(msg).parents("form").find("input[name='phone']").val();
	var msgFlag = $(msg).parents("form").find("input[name='msgFlag']").val();
	var allowProtocol = $(msg).parents("form").find("input[name='allowProtocol']").attr('checked');
	var pageUrl = window.location.href;
	if (trueName.replace(/[ ]/g, "").length == 0) {
		alert("请输入您的称呼！");
		return false;
	}
	if (phone.replace(/[ ]/g, "").length == 0) {
		alert("请输入您的联系电话！");
		return false;
	}
	var myreg = /^1(3|4|5|6|7|8|9)\d{9}$/;
	if (!myreg.test(phone)) {
	    alert('您输入的联系电话格式不正确！');
	    return false; 
	}
	if ($(msg).parents("form").find("input[name='allowProtocol']").length > 0 && allowProtocol != "checked") {
		alert('请您阅读并同意服务条款！');
		return false;
	}
	$.ajax({
		url : '/column/submitNewsMsg.html',
		type : 'post',
		dataType : 'json',
		data : 'messageType=' + msgFlag + '&phone=' + encodeURIComponent(phone) + 
				'&trueName=' + encodeURIComponent(trueName) + '&brandId=' + encodeURIComponent(loginName) + 
				'&fileName=' + encodeURIComponent(fileName) + '&pageUrl=' + pageUrl,
		success : function(data, stauts) {
			if(data.flag == "ok") {
                if ($("#kfrwm").length > 0) {
                    $("#kfrwm").removeClass("hide");
                } else {
                    alert("恭喜留言成功，稍后我们招商经理会联系您，请保持电话通畅！");
                }
			} else if(data.flag == "same") {
				alert("请勿重复留言！");
			} else {
				alert("留言失败！");
			}
			$(".project-popup").addClass("hide")
			$(".cover").addClass("hide");
		},
		error : function() {
		}
	});
}

$(function() {
	if ($("#shangpuAd").length > 0) {
		$.ajax({
			url : '/column/queryShangpuAd.html',
			type : 'post',
			dataType : 'json',
			data : {adType:1},
			success : function(data) {
				var html = "";
				for (var p in data) {
					html += "<div class=\"li\"><a href=\"" + data[p].adUrl + "\" target=\"_blank\"><img src=\"" + data[p].adPath + "\" alt=\"\"></a></div>";
				}
				$("#shangpuAd").append(html);
			},
			error : function() {
			}
		});
	}
});
