
var picarry = {};
var lnkarry = {};
var ttlarry = {};

jQuery(function($){
	getTopPicBg();
	getTopPic();
	getNewsList();
	getPicNews();
});

function getNewsList(){
	var ob=$("#top8news");
	$.ajax({
		//url:"/tv33.net.cn/NewsAbout",
		url:"./temp/normalNews.txt",
		type:"post",
		data:"method=top8&timeStamp="+new Date().getTime(),
		beforeSend:function(){
			//ob.html("<div style='margin:10px 20px;' id='ajaxImage2'><img src='./images/ajax-loader2.gif'>数据加载中，请稍等...</div>");
		},
		success:function(data){
			//$("#ajaxImage2").remove();
			if(data=="")
			{
				ob.append("暂无新闻信息！");
				return;
			}
			if(data=="false2")
			{
				ob.append("暂无新闻信息！");
				return;
			}
			if(data!="false")
			{
				ob.append(data);
			}
			else
			{
				alert("加载推荐新闻失败！");
				return;
			}
		},
		error:function(){
			//$("#ajaxImage2").remove();
			alert("加载失败----原因未知！");
		}
	});
}

function getTopPic(){
	var ob=$("#logo");
	$.ajax({
		//url:"/tv33.net.cn/FileAbout",
		url:"./temp/topLogo.txt",
		type:"post",
		data:"method=toppic&timeStamp="+new Date().getTime(),
		beforeSend:function(){
			//ob.html("<div style='margin:10px 20px;' id='ajaxImage2'><img src='./images/ajax-loader2.gif' style='width:48px;height:48px;'>加载中，请稍等...</div>");
		},
		success:function(data){
			$("#ajaxImage2").remove();
			if(data=="")
			{
				ob.append("获取logo失败！");
				return;
			}
			if(data=="false2")
			{
				ob.append("获取logo失败！");
				return;
			}
			if(data!="false")
			{
				ob.append("<a href='./index.html'><img src='."+data+"'/></a>");
				correctPNG();
			}
			else
			{
				alert("获取logo失败！");
				return;
			}
		},
		error:function(){
			$("#ajaxImage2").remove();
			alert("加载失败----原因未知！");
		}
	});
}

function getTopPicBg(){
	//var ob=$("#logo");
	var ob=$("#top");
	$.ajax({
		//url:"/tv33.net.cn/FileAbout",
		url:"./temp/topLogoBg.txt",
		type:"post",
		data:"method=toppicbg&timeStamp="+new Date().getTime(),
		beforeSend:function(){
			
		},
		success:function(data){
			if(data=="")
			{
				alert("加载logo背景失败！");
				return;
			}
			if(data=="false2")
			{
				alert("加载logo背景失败！");
				return;
			}
			if(data!="false")
			{
				ob.css({"background":"url('."+data+"')"});
			}
			else
			{
				alert("加载logo背景失败！");
				return;
			}
		},
		error:function(){
			alert("加载logo背景失败----原因未知！");
		}
	});
}

function getPicNews(){
	var ob=$("#picture");
	$.ajax({
		//url:"/tv33.net.cn/NewsAbout",
		url:"./temp/picNews.txt",
		type:"post",
		data:"method=picnews&timeStamp="+new Date().getTime(),
		beforeSend:function(){
			//ob.html("<div style='margin:10px 20px;' id='ajaxImage2'><img src='./images/ajax-loader2.gif' style='width:48px;height:48px;'>加载中，请稍等...</div>");
		},
		success:function(data){
			$("#ajaxImage2").remove();
			if(data=="")
			{
				alert("加载图片新闻失败！");
				return;
			}
			if(data=="false2")
			{
				alert("加载图片新闻失败！");
				return;
			}
			if(data!="false")
			{
				ob.append("<div class='fpic'>"+data);
				//$.post("/tv33.net.cn/NewsAbout",{method:"picarray"},function(data2){
				$.post("./temp/picNewsArray.txt",{method:"picarray"},function(data2){
					var a=eval(data2);
					for(var i=0;i<a.length;i++)
					{
						ttlarry[i]=a[i][0];
						picarry[i]=a[i][1];
						lnkarry[i]=a[i][2];
					}
				});
				ob.append("</div></div>");
			}
			else
			{
				alert("加载图片新闻失败！");
				return;
			}
		},
		error:function(){
			$("#ajaxImage2").remove();
			alert("加载图片新闻失败----原因未知！");
		}
	});
}

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
	var arVersion = navigator.appVersion.split("MSIE");
    var version = parseFloat(arVersion[1]);
    if ((version >= 5.5) && (document.body.filters)) 
    { 
       for(var j=0; j<1; j++)
       { 
          var img = document.images[j];
          var imgName = img.src.toUpperCase();
			if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
				var imgID = (img.id) ? "id='" + img.id + "' " : "";
				var imgClass = (img.className) ? "class='" + img.className
						+ "' " : "";
				var imgTitle = (img.title)
						? "title='" + img.title + "' "
						: "title='" + img.alt + "' ";
				var imgStyle = "display:inline-block;" + img.style.cssText;
				if (img.align == "left")
					imgStyle = "float:left;" + imgStyle;
				if (img.align == "right")
					imgStyle = "float:right;" + imgStyle;
				if (img.parentElement.href)
					imgStyle = "cursor:hand;" + imgStyle;
				var strNewHTML = "<span "
						+ imgID
						+ imgClass
						+ imgTitle
						+ " style=\""
						+ "width:"
						+ img.width
						+ "px; height:"
						+ img.height
						+ "px;"
						+ imgStyle
						+ ";"
						+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
						+ "(src=\'" + img.src
						+ "\', sizingMethod='scale');\"></span>";
				img.outerHTML = strNewHTML;
				j = j - 1;
			}
		}
	}
}








