﻿
if (top.location != self.location)top.location=self.location; 

function innerhtml_change(divid,htmstr) {
document.all(divid).innerHTML=htmstr;
}
	
function js_callpage(htmlurl) {
var newwin=window.open(htmlurl,"newWin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=2,left=2,width=660,height=400");
}

function subpage(pageid){
document.writeln("<iframe maginheight='0' marginwidth='0' frameborder='0' width='100%' height='100%' SCROLLING='NO' id='sub"+pageid+"'></iframe>");
document.getElementById("sub"+pageid).src="http://page.cfi.cn/page/pg"+pageid+".htm";
}

function DateDiff(strInterval, dtStart, dtEnd) {
 var dtStart = new Date(dtStart);
 if (isNaN(dtStart)) dtStart = new Date();
 var dtEnd = new Date(dtEnd);
 if (isNaN(dtEnd)) dtEnd = new Date();
 switch (strInterval) {
  case "s":return parseInt((dtEnd - dtStart) / 1000);
  case "n":return parseInt((dtEnd - dtStart) / 60000);
  case "h":return parseInt((dtEnd - dtStart) / 3600000);
  case "d":return parseInt((dtEnd - dtStart) / 86400000);
  case "w":return parseInt((dtEnd - dtStart) / (86400000 * 7));
  case "m":return (dtEnd.getMonth()+1)+((dtEnd.getFullYear()-dtStart.getFullYear())*12) - (dtStart.getMonth()+1);
  case "y":return dtEnd.getFullYear() - dtStart.getFullYear();
 }
}


function DateAdd(strInterval, NumDay, dtDate) {
 var dtTmp = new Date(dtDate);
 if (isNaN(dtTmp)) dtTmp = new Date();
 switch (strInterval) {
  case "s":return new Date(Date.parse(dtTmp) + (1000 * NumDay));
  case "n":return new Date(Date.parse(dtTmp) + (60000 * NumDay));
  case "h":return new Date(Date.parse(dtTmp) + (3600000 * NumDay));
  case "d":return new Date(Date.parse(dtTmp) + (86400000 * NumDay));
  case "w":return new Date(Date.parse(dtTmp) + ((86400000 * 7) * NumDay));
  case "m":return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + NumDay, dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
  case "y":return new Date((dtTmp.getFullYear() + NumDay), dtTmp.getMonth(), dtTmp.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
 }
}

//树
function k(vd)
{
  var ob=document.getElementById(vd);
  if(ob.style.display=="block")
  {
     ob.style.display="none";
     var ob2=document.getElementById(vd.substring(0,vd.length-4));
     ob2.style.backgroundImage="url(pic/cfidata_jia.gif)";
  }
  else
  {
    ob.style.display="block";
    var ob2=document.getElementById(vd.substring(0,vd.length-4));
    ob2.style.backgroundImage="url(pic/cfidata_jian.gif)";
   
  }
   
}
function ksel(vd)
{
  for   (i=0; i<document.body.all.length; i++)   
  {   
     if (document.body.all[i].style.border=="solid 1px rgb(200,200,200)")
          {   
           document.body.all[i].style.border=""
           }   
 }   

 var ob1=document.getElementById(vd);
 ob1.style.border="solid 1px rgb(200,200,200)";
}


function gotourl()
{       
       window.parent.location="/pic/";           
}


//图片滚动
var isIE=!(navigator.userAgent.indexOf('MSIE')==-1);
var news;
var curNew=0;
var timer;
function init(pic,txt)
{
    if(!pic)pic="NewsPic";
    if(!txt)txt="NewsPicTxt";
	var div=document.getElementById(pic);
	if(!div)return;
	var nav=document.createElement("DIV");
	nav.className="Nav";
	var nodes;
	if(isIE)
	{
	    nodes=div.childNodes;
	}
	else
	{
	    nodes=childrenNodes(div.childNodes);
	}
	news=new Array(nodes.length);
	for(var i=nodes.length-1;i>=0;i--)
	{
	    var element=nodes[i];
	    
	    
		news[i]={};
		news[i].Element=element;
		news[i].Text=element.getAttribute("title");
		news[i].Url=element.getAttribute("href");
		
		var n=document.createElement("span");
		n.innerHTML="<a herf=\"javascript:;\" onclick=\"javascript:curNew="+(i-1)+";change('"+pic+"','"+txt+"');\">"+(i+1)+"</a>";
		if(i==curNew)n.className="Cur";
		nav.appendChild(n);
		
		news[i].LinkElement=n;
	}
	div.appendChild(nav);
	curNew--;
	window.setTimeout("change('"+pic+"','"+txt+"')",3000);

}

function childrenNodes(node)
{
    var c=new Array();
    for(var i=0;i<node.length;i++)
    {
        if(node[i].nodeName.toLowerCase()=="a")
            c.push(node[i]);
    }
    return c;
}
function change(pic,txt)
{
    var div=document.getElementById(pic);
    var text=document.getElementById(txt);
    if(!div)return;
    curNew=curNew+1;
    if(curNew>=news.length)curNew=0;
    for(var i=0;i<news.length;i++)
    {
        if(i==curNew)
        {
            news[i].Element.style.display="block";
            news[i].Element.style.visibility="visible";
            news[i].LinkElement.className="Cur";
            text.innerHTML="<a href=\""+news[i].Url+"\" title=\""+news[i].Text+"\" target=\"_blank\">"+news[i].Text+"</a>";
        }
        else
        {
            news[i].Element.style.visibility="hidden";
            news[i].Element.style.display="none";
            news[i].LinkElement.className="Normal";
        }
    }
    if(timer)window.clearTimeout(timer);
    timer=window.setTimeout("change('"+pic+"','"+txt+"')",5000);
    
}
