//主函数
var s=function(){
	
	if(typeof(showAds)== "function"){showAds();}//加载首页下推广告
	if(typeof(scall)== "function"){scall();}//对联广告

	var interv=4000; //切换间隔时间
	var interv2=0; //切换速速
	var opac1=0; //文字背景的透明度
	var source="fade_focus"; //焦点轮换图片容器的id名称
	var opac=0,j=0,t=63,num,scton=0,timer,timer2,timer3;
	var id=getid(source);
	id.removeChild(getTag("div",id)[0]);
	var li=getTag("li",id);
	var div=document.createElement("div");
	var title=document.createElement("div");
	var span=document.createElement("span");
	var button=document.createElement("div");
	button.className="button";
	for(var i=0;i<li.length;i++)
	{
	var a=document.createElement("a");
	a.innerHTML=i+1;
	var n = i+1;
	a.onclick=function()
	{
	clearTimeout(timer);
	clearTimeout(timer2);
	clearTimeout(timer3);
	j=parseInt(this.innerHTML)-1;
	scton=0;
	t=63;
	opac=0;
	fadein();
	};
	a.className="b1";
	//	a.onmouseover=function(){this.className="b2";};
	a.onmouseover=function()
	{
	interv=100000;
	clearTimeout(timer);
	clearTimeout(timer2);
	clearTimeout(timer3);
	j=parseInt(this.innerHTML)-1;
	scton=0;
	t=63;
	opac=0;
	fadein();
	};
	a.onmouseout=function()
	{
	interv=2000;						
	clearTimeout(timer);
	clearTimeout(timer2);
	clearTimeout(timer3);
	j=parseInt(this.innerHTML)-1;
	scton=0;
	t=63;
	opac=0;
	timer=setTimeout(fadein,interv);
	};
	button.appendChild(a);
	}
	//获取对象
	function getTag(tag,obj)
	{
	if(obj==null)
	{
	return document.getElementsByTagName(tag);
	}
	else
	{
	return obj.getElementsByTagName(tag);
	}
	}
	function getid(id)
	{
	return document.getElementById(id);
	}
	//控制图层透明度
	function alpha(obj,n)
	{
	if(document.all)
	{
	obj.style.filter="alpha(opacity="+n+")";
	}
	else
	{
	obj.style.opacity=(n/100);
	}
	}
	//控制焦点按钮
	function sc(n)
	{
	for(var i=0;i<li.length;i++)
	{
	button.childNodes[i].className="b1";
	}
	button.childNodes[n].className="b2";
	}
	title.className="num_list";
	title.appendChild(span);
	alpha(title,opac1);
	id.className="d1";
	div.className="d2";
	id.appendChild(div);
//	id.appendChild(title);
	id.appendChild(button);
	//渐显
	var fadein=function()
	{
	//				opac+=50;
	div.innerHTML=li[j].innerHTML;
	span.innerHTML=getTag("img",li[j])[0].alt;
	div.onmouseover=function()
	{
	interv=100000;
	clearTimeout(timer);
	clearTimeout(timer2);
	clearTimeout(timer3);
	//j++;
	scton=0;
	t=63;
	opac=0;
	};
	div.onmouseout=function()
	{
	interv=2000;						
	clearTimeout(timer);
	clearTimeout(timer2);
	clearTimeout(timer3);
	scton=0;
	t=63;
	opac=0;
	timer=setTimeout(fadeout,interv);					
	};
	if(scton==0)
	{
	sc(j);
	scton=1;
	}
	timer2=setTimeout(fadeout,interv);
	}
	//渐隐
	var fadeout=function()
	{
	if(scton==1)
	{
	scton=0;
	}
	if(j<li.length-1)
	{
	j++;
	}
	else
	{
	j=0;
	}
	fadein();
	}
	//滚动文字
	var scrolltxt=function()
	{
	t+=num;
	span.style.marginTop=t+"px";
	if(num<0&&t>3)
	{
	timer3=setTimeout(scrolltxt,interv2);
	}
	else
	{
	if(num>0&&t<62)
	{
	timer3=setTimeout(scrolltxt,interv2);
	}
	else
	{
	scton=0;
	}
	}
	};
	fadein();
};
//初始化
window.onload=s;
