function append(id, newsId, typeid) {
	curNewsListId = id;
	
	if(id%10 == 0){
		topValue = (10-1)*43;
	} else {
		topValue = (id%10-1)*43;
	}
	$("#top_content_mask").show("fade", 300);
	$("#top_content_close").css("display","block");
	$("#top_content").css("top", topValue);
	$("#top_content").show("clip",{ direction: "horizontal" }, 300 ,function() {append1(id, newsId,typeid);});
}
function append1(id, newsId,typeid) {
	topValue = (id-1)*43;
	$("#top_news_float").animate({top:43-topValue},300);
	$("#top_news_"+id).animate({height:"344px"},300);
	$("#top_content").animate({top:43,height:"344px"},300, function() {getNewsById(newsId,typeid);});
	$("#top_content_close").click(function() {
			shousuo(id);
		});
}
function shousuo(id) {
	curNewsListId = 0;
	
	if(id%10 == 0){
		topValue = (10-1)*43;
	} else {
		topValue = (id%10-1)*43;
	}
	$("#top_news_float").animate({top:Math.floor((id-1)/10)*(-430)},300);
	$("#top_news_"+id).animate({height:"43px"},300);

	$("#top_content").animate({top:topValue,height:"43px"},300,function(){shousuo1();});
	$("#top_content_mask").hide("fade", 300);
	$("#top_content_loading").show(0);
	$("#top_content_close").css("display","none");
	$("#top_content_close").unbind("click");
	$("#top_content_news_img").attr("src", "");
}
function shousuo1() {
	$("#top_content").hide("clip",{ direction: "horizontal" }, 300 );
}
function getNewsById(newsId,typeid) {
	$.ajax({
		url : "ajax/getIndexNews.php",
		type : "POST",
		dataType : "json",
		cache:false,
		data : {newsId:newsId,date:new Date(),"typeid":typeid},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			//alert("获取失败");
			},
		success : function(json, textStatus, XMLHttpRequest) {
				if(null != json) {
					$("#top_content_news_img").attr("src", json["thumbPath"]);
					$("#news_type").html("");
					if(json["subtype"] == 2) {
						if(json["catid"] == 1 || json["catId"] == 3) {
							$("#news_type").html("<a href='news.php?mainType=2&type=-98' class='black_link'>奥迪发声 Audi News</a>");
						} else if(json["catid"] == 2) {
							$("#news_type").html("<a href='news.php?mainType=2&type=2' class='black_link'>媒体聚焦 Media Focus</a>");
						} else if(json["catid"] == 4) {
							$("#news_type").html("<a href='news.php?mainType=2&type=4' class='black_link'>独家头条 Exclusive News</a>");
						} else if(json["catid"] == 6) {
							$("#news_type").html("<a href='news.php?mainType=2&type=6' class='black_link'>博文颂 Audi Blogs</a>");
						}
					} else if(json["subtype"] == 3){
						if(json["catid"] == 521) {
							$("#news_type").html("<a href='events.php?mainType=3&type=521' class='black_link'>奥迪活动 Audi Event</a>");
						} else if(json["catid"] == 522) {
							$("#news_type").html("<a href='events.php?mainType=3&type=522' class='black_link'>英杰汇活动 A.V.C Event</a>");
						} else if(json["catid"] == 523) {
							$("#news_type").html("<a href='events.php?mainType=3&type=523' class='black_link'>经销商活动 Dealership Event</a>");
						} else if(json["catid"] == 524) {
							$("#news_type").html("<a href='events.php?mainType=3&type=524' class='black_link'>圈层活动 Audi Circles</a>");
						}
					} else if(json["subtype"] == 4) {
						$("#news_type").html("<a href='lives.php' class='black_link'>奢适生活 Audi Life</a>");
					} else if(json["subtype"] == 7) {
						if(json["catid"] == 601||json["catid"] == 600) {
							$("#news_type").html("<a href='service_cat_2.php' class='black_link'>奥迪经销商 Dealership</a>");
						} else if(json["catid"] == 602||json["catid"] == 603) {
							$("#news_type").html("<a href='service_cat_3.php' class='black_link'>驾驶学堂 Driving Tips</a>");
						}
					}else if(json["subtype"]==9){
						if(json['catid']==513)
							$("#news_type").html("<a href='news_list.php?mainType=5&avcType=news' class='black_link'>英杰汇动态 A.V.C News</a>");
						else
							$("#news_type").html("<a href='avc.php' class='black_link'>英杰汇 A.V.C</a>");
					}else if(json["subtype"]==8){
						switch(json['catid']){
							case "571":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>车系视频 Models Channies</a>");
								break;
							case "572":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>活动视频 Events Videos</a>");
								break;
							case "573":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>节目视频 Audi Shows</a>");
								break;
							case "574":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>赛车视频 Audi Speed</a>");
								break;
							case "575":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>其他视频 Others</a>");
								break;
							case "577":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>精美大片 Audi Galleries</a>");
								break;
							case "578":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>最佳现场 Site Photos</a>");
								break;
							case "579":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>创意无限 Audi Posters</a>");
								break;
							case "586":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>赛车图集 MotorSport Atlas</a>");
								break;
							case "580":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>其他图集 Others</a>");
								break;
							case "582":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>时尚壁纸 Audi Wallpapers</a>");
								break;
							case "583":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>个性屏保 Audi Screensavers</a>");
								break;
							case "584":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>其他壁纸屏保 Others</a>");
								break;
							case "610":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>奥迪新闻月刊 News Audios</a>");
								break;
							case "611":
								$("#news_type").html("<a href='news_list.php?mainType=8&type="+json['catid']+"' class='black_link'>英杰汇电子杂志 A.V.C E-zine</a>");
								break;
						}
					}
					$("#news_title").html(json["subject"]);
					$("#news_subtitle").html(json["ensubject"]);
					$("#news_intro").html(json["intro"]);
					$("#news_url").unbind("click");
					$("#news_url").click(function() {
						window.open(json['url']);
					});
					
					$("#top_content_loading").hide("fade", 1000);
				} else {
					alert("没有内容");
					//hideTopContent();
				}
			}
	});
}
$(function(){
	$(".topnewsitem").mouseover(function(){
		if(typeof(postop)=='undefined'||postop=='')
			postop=421;
		$("#top_content_loading").css("opacity", 1);
		$("#top_content_loading").show(0);
		$("#top_content").css("top", $(this).position().top%postop);
		$("#top_content").css("left", $(this).position().left);
		$("#top_content").show(0);
		subtype=$(this).attr("subtype");
		gtype=$(this).attr("gtype");
		catid=$(this).attr("catid");
		url=$(this).attr("url");
		if(subtype == 2) {
			if(catid == 1 || catid == 3) {
				$("#news_type").html("<a href='news.php?mainType=2&type=-98' class='white_link' title='Audi News'>奥迪发声</a>");
			} else if(catid == 2) {
				$("#news_type").html("<a href='news.php?mainType=2&type=2' class='white_link' title='Media Focus'>媒体聚焦</a>");
			} else if(catid) {
				$("#news_type").html("<a href='news.php?mainType=2&type=4' class='white_link' title='Exclusive News'>独家头条</a>");
			} else if(catid) {
				$("#news_type").html("<a href='news.php?mainType=2&type=6' class='white_link' title='Audi Blogs'>博文颂</a>");
			}
		} else if(subtype == 3) {
			if(catid== 521) {
				$("#news_type").html("<a href='news_list.php?mainType=3&type=521' class='white_link'>奥迪活动</a>");
			} else if(catid == 522) {
				$("#news_type").html("<a href='news_list.php?mainType=3&type=522' class='white_link'>英杰汇活动</a>");
			} else if(catid == 523) {
				$("#news_type").html("<a href='news_list.php?mainType=3&type=523' class='white_link'>经销商活动</a>");
			} else if(catid== 524) {
				$("#news_type").html("<a href='news_list.php?mainType=3&type=524' class='white_link'>圈层活动</a>");
			}
		} else if(subtype == 4) {
			$("#news_type").html("<a href='lives.php' class='white_link' title='Audi Life'>奢适生活</a>");
		} else if(subtype == 7) {
			if(catid== 601) {
				$("#news_type").html("<a href='service_cat_2.php' class='white_link'>热点推荐</a>");
			} else if(catid == 602) {
				$("#news_type").html("<a href='service_cat_3.php' class='white_link'>驾驶技巧</a>");
			} else if(catid == 603) {
				$("#news_type").html("<a href='service_cat_3.php' class='white_link'>生活小贴士</a>");
			}
		}else if(subtype==9){
			if(catid== 532) {
				$("#news_type").html("<a href='news_list.php?mainType=3&type=532' class='white_link'>英杰汇专访</a>");
			}
		}else if(subtype==8){
			switch(catid){
				case "571":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>车系视频</a>");
					break;
				case "572":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>活动视频</a>");
					break;
				case "573":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>节目视频</a>");
					break;
				case "574":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>赛车视频</a>");
					break;
				case "575":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>其他视频</a>");
					break;
				case "577":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>精美大片</a>");
					break;
				case "578":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>最佳现场</a>");
					break;
				case "579":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>创意无限</a>");
					break;
				case "586":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>赛车图集</a>");
					break;
				case "580":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>其他图集</a>");
					break;
				case "582":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>时尚壁纸</a>");
					break;
				case "583":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>个性屏保</a>");
					break;
				case "584":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>其他壁纸屏保</a>");
					break;
				case "610":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>奥迪新闻月刊</a>");
					break;
				case "611":
					$("#news_type").html("<a href='news_list.php?mainType=8&type="+catid+"' class='white_link'>英杰汇电子杂志</a>");
					break;
			}
		}
		title = $(this).attr("alt");
		itemid=$(this).attr("itemid");
		gid=$(this).attr("gid");
		ensubject=$(this).attr("ensubject");
		styletitle=$(this).attr("styletitle");
		var maxwidth=26;
		if(title.length>maxwidth) title = title.substring(0,maxwidth)+"...";
		$("#news_title").html("<a href='"+url+"' class='white_link' target='_blank' title='"+ensubject+"'>"+title+"</a>");
		$("#news_dateline").html($(this).attr('dateline'));
		$("#top_content_loading").animate({opacity:0}, {duration:300,queue:false,complete:function(){
			$("#top_content_loading").hide(0);}});
	});
});
function prevPageNews() {
	if(curPage > 1) {
		if(0 != curNewsListId) {
			shousuo(curNewsListId);
		}
		$("#top_news_page > img").attr("src", "view/image/page"+(curPage-1)*10+".gif");
		$("#top_news_float").animate({top:"+=430"},1600);
		curPage--;
	}
}
function nextPageNews($totalPage) {
	if(curPage < $totalPage) {
		if(0 != curNewsListId) {
			shousuo(curNewsListId);
		}
		$("#top_news_page > img").attr("src", "view/image/page"+(curPage+1)*10+".gif");
		$("#top_news_float").animate({top:"-=430"},1600);
		curPage++;
	}
}
function prevPageNews1() {
	if(curPage > 1) {
		imgHideContent();
		$("#top_news_page > img").attr("src", "view/image/page"+(curPage-1)*15+".gif");
		$("#top_news_float").animate({top:"+=421"},1600);
		curPage--;
	}
}
function nextPageNews1($totalPage) {
	if(curPage < $totalPage) {
		imgHideContent();
		$("#top_news_page > img").attr("src", "view/image/page"+(curPage+1)*15+".gif");
		$("#top_news_float").animate({top:"-=421"},1600);
		curPage++;
	}
}
function imgHideContent() {
	$("#top_content").hide(0);
}

function englistTitleSwitch(isShow) {
	if(isShow) {
		$("#news_dateline").hide(0);
		$(".news_subtitle2").show(0);
	}
	else {
		$("#news_dateline").show(0);
		$(".news_subtitle2").hide(0);
	}
}
$(function(){
	$("#sina_wb").click(function(){
		$.ajax({
			url : "/weibo_sina/geturl.php",
			dataType : "json",
			cache:false,
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				//alert("获取失败");
				},
			success : function(json, textStatus, XMLHttpRequest) {
				if(json.url)
					window.location.href=json.url;
			}
		});
	});
	$("#qq_wb").click(function(){
		$.ajax({
			url : "/weibo_qq/geturl.php",
			dataType : "json",
			cache:false,
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				//alert("获取失败");
				},
			success : function(json, textStatus, XMLHttpRequest) {
				if(json.url)
					window.location.href=json.url;
			}
		});
	});
});
