﻿var APP_Key="2984059766";
var APP_SECRET="d610ecb28a6770ac1de1d662b1065a00";



function tabs(id, index, tag) {
    var count = $("#" + id + " > " + tag).length;
    for (i = 1; i <= count; i++) {
        if (i == index) {
            $("#" + id + "-" + i).css("display", "");
            $("#" + id + "-nav-" + i).css({ 'color': 'red', 'background-color': '#fff', 'border-left': 'solid 1px #666', 'border-right': 'solid 1px #666', 'border-top': 'solid 1px #666' });
        }
        else {
            $("#" + id + "-" + i).css("display", "none");
            $("#" + id + "-nav-" + i).css({ 'color': '', 'background-color': '', 'border-left': 'none', 'border-right': 'none', 'border-top': 'none' });
        }
    }
}


function GetRss(url,maxlist,showtext,islocal,boxID)
{
 var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
 xmlDoc.async="false";
 var realUrl=url;
 if(!islocal)
 {
 realUrl="/GetRss.ashx?url="+url
 }
 xmlDoc.load(realUrl);
 /*读取远程xml数据源,可以使用本地数据源,但要以index.html为基点,
 这里应该写为index.html在http://7thpark.com/06/下面，所以为../parklog/rss.xml*/
 var nodes=null;
 nodes = xmlDoc.selectNodes("/rss/channel/item");//读取节点,筛选节点最低端用item[title='xxx']或者//last
 if(nodes==null)
  var returnHtml = "没有可载入的数据......";
 
 else
 {
  returnHtml = "<ul>";
  maxlength=nodes.length;
  if(maxlength>maxlist)//控制列表长度
   maxlength=maxlist;//控制列表长度
  for(i=0;i<maxlength;i++){
   returnHtml +="<li>";
   returnHtml +="<a href='" + nodes[i].selectSingleNode("link").text + "' target='_blank'>" + nodes[i].selectSingleNode("title").text + "</a>";
   if(showtext)
   {
   returnHtml +="<div>"+nodes[i].selectSingleNode("description").text+"</div>";
   }
   returnHtml +="</li>";
  }
  returnHtml += "</ul>";
 }
 document.getElementById(boxID).innerHTML=returnHtml;
}


function GetRssForli(url,maxlist,showtext,islocal,boxID,gopage)
{
 var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
 xmlDoc.async="false";
 var realUrl=url;
 if(!islocal)
 {
 realUrl="/GetRss.ashx?url="+url
 }
 xmlDoc.load(realUrl);
 /*读取远程xml数据源,可以使用本地数据源,但要以index.html为基点,
 这里应该写为index.html在http://7thpark.com/06/下面，所以为../parklog/rss.xml*/
 var nodes=null;
 nodes = xmlDoc.selectNodes("/rss/channel/item");//读取节点,筛选节点最低端用item[title='xxx']或者//last
 if(nodes==null)
  var returnHtml = "没有可载入的数据......";
 
 else
 {
  returnHtml = "";
  maxlength=nodes.length;
  if(maxlength>maxlist)//控制列表长度
   maxlength=maxlist;//控制列表长度
  for(i=0;i<maxlength;i++){
   returnHtml +="<li>";
   if(gopage=="")
      returnHtml +="<a href='"+ nodes[i].selectSingleNode("link").text + "' target='_blank'>" + nodes[i].selectSingleNode("title").text + "</a>";
   else
      returnHtml +="<a href='"+gopage + escape(nodes[i].selectSingleNode("link").text) + "' target='_blank'>" + nodes[i].selectSingleNode("title").text + "</a>";

   if(showtext)
   {
   returnHtml +="<div>"+nodes[i].selectSingleNode("description").text+"</div>";
   }
   returnHtml +="</li>";
  }
 }
 document.getElementById(boxID).innerHTML=returnHtml;
}


function GetContentMsg(contentGuid)
{
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
 xmlDoc.async="false";
 var realUrl="/service/ContentMsg.ashx?content="+contentGuid;
 xmlDoc.load(realUrl);
 return xmlDoc;
}


//设置图片尺寸，给图片加点击动作
function SetImageSite(contentBox,maxWidth,nextPageBox,nextNews)
{
    var contentBoxObj=document.getElementById(contentBox);
	var pageBoxObj=document.getElementById(nextPageBox);
	var nextNewBoxObj=document.getElementById(nextNews);
	var imgList=contentBoxObj.getElementsByTagName("img");
	var url = window.location.href;
	var pageNum=url.substring(url.indexOf("_")+1,url.indexOf(".shtml"));
	

	var pageLings=pageBoxObj.getElementsByTagName("a");
	var nextNum=parseInt(pageNum);

    
    //alert(pageLings.length);
	for(i=0;i<imgList.length;i++)
	{
		
		imgList[i].title="单击查看下一页";
		imgList[i].style.cursor="hand";
		
        if(imgList[i].width>maxWidth)
		{
				imgList[i].width=maxWidth;
		}

		imgList[i].onload=function()
		{
			if(this.width>maxWidth)
			{
				this.width=maxWidth;
			}
		}


		    if(pageLings.length>1)
	        {
                 imgList[i].onclick=function()
				{
					 if(nextNum+1<=pageLings.length)
					     window.location.href=pageLings[nextNum].href;
					 else
						 window.location.href=nextNewBoxObj.getElementsByTagName("a")[1].href;
				}
	        }else{
				imgList[i].onclick=function(){
					 window.location.href=nextNewBoxObj.getElementsByTagName("a")[1].href;
				}
			}


	}
}

function SetTextLink(contentBox)
{
	 var contentBoxObj=document.getElementById(contentBox);
	 var aList=contentBoxObj.getElementsByTagName("a");
	 for(i=0;i<aList.length;i++)
	{
		 aList[i].onmouseover=function()
		{
			if(this.href.indexOf("xct.cn")>0 || this.href.indexOf("http://")==-1 || this.href.indexOf("/go.aspx")>-1)
			{
				this.href=this.href;
			}else{
				this.href="/go.aspx?url="+escape(this.href);
			}
		}
	}
}
