function init(){


	DTry( initTpxw ,  ["tpxw" ] );

	DTry( initArticleMarquee ,["gsgg"]);
	window.onload=function(){
		//flashAds();//浮动视频
	}
}

function closeflashAds(){
	var obj = $("flashAds");
	obj.parentNode.removeChild( obj );
}
//浮动视频
function flashAds(){
	var div=document.createElement("div");
	div.id="flashAds";
	div.innerHTML="<div class='border'></div>\
			<div class='close' onclick='closeflashAds()'>\u00d7</div>\
			<div id='flashAds-content'></div>\
		";
	document.body.appendChild( div );
	createFlv('flashAds-content','/xtjw_doc/web/sp/xtjs.flv');
	function resize(){
	
		div.style.top = Math.max(document.documentElement.scrollTop
					,document.body.scrollTop)
			+ document.documentElement.clientHeight - div.offsetHeight +"px";
		div.style.left = Math.max(document.documentElement.scrollLeft
					,document.body.scrollLeft)-5
			+ document.documentElement.clientWidth - div.offsetWidth +"px";
	}
	var timer = -1;
	function delay(){
		clearTimeout( timer);
		timer = setTimeout(resize,100);
	}
	addEvt( window, "scroll",delay);
	addEvt( window, "resize",resize);
	addEvt( window, "focus",resize);
	setTimeout(resize,100);
}
function createFlv(id,file){
	filePath = encodeURIComponent( file );
	if( filePath=="" || filePath==null)
		return;
	var html = 
	document.getElementById( id ) .innerHTML 
		=
	"<object  \
	  data='script/vcastr3.swf' \ type='application/x-shockwave-flash' > \
	  <param name='movie' value='script/vcastr3.swf' /> \
	 <param name='quality' value='high' />\
	 <param name='IsShowBar' value='1'/> \
	 <param name='allowFullScreen' value='true' /> \
	 <param name='BufferTime' value='10' /> \
	 <param name='FlashVars' value='xml=\
		 <vcastr>\
                        <channel>\
                                <item>\
                                        <source>"+ filePath +"</source>\
                                        <duration></duration>\
                                        <title>dfs</title>\
                                </item>\
                        </channel>\
                        <config>\
				<bufferTime>4</bufferTime>\
				<contralPanelAlpha>0.75</contralPanelAlpha>\
				<controlPanelBgColor>#4C4C61</controlPanelBgColor>\
				<controlPanelBtnColor>0xffffff</controlPanelBtnColor>\
				<contralPanelBtnGlowColro>#4C4C61</contralPanelBtnGlowColro>\
				<defautVolume>1.0</defautVolume>\
				<isAutoPlay>true</isAutoPlay>\
				<isLoadBegin>true</isLoadBegin>\
				<isShowAbout>true</isShowAbout>\
				<scaleMode>exactFit</scaleMode>\
				<controlPanelMode>float</controlPanelMode>\
				<isRepeat>false</isRepeat>\
                        </config>\
                        <plugins>\
                        </plugins>\
		</vcastr>\
              '/>\
	</param>\
	</object>";

}
function addEvt(obj,evt,fun){
	
	if(document.addEventListener){
		obj.addEventListener( evt , fun , false);
	}else{
		obj.attachEvent( "on"+evt , fun );
		
	}
}



function initArticleMarquee(id){
	var divs = document.getElementById(id).getElementsByTagName("div");
	//alert( divs[0].className=='listBody');
	for(var i=0;i<divs.length;i++)
	{
		if(divs[i].className == "listBody")
		{
			var listBody2 = divs[i];//.getElementsByTagName("div");
			//alert(listBody2.innerHTML)
			var m2=new Marquee(listBody2)
			m2.direction="top";
			m2.step=1;
			m2.timer=60;
			m2.scrollStep=100;
			m2.start();
			break;
		}
	}
}



/**********************************************************
 * 初始化图片新闻
 * @param {String} sid
 */
function initTpxw(sid ){
	var oTpxw = document.getElementById(sid);

	var links = oTpxw.getElementsByTagName("div")[0].getElementsByTagName("a");
	var numberdiv = document.createElement("div");
	numberdiv.id=sid+"-number";
	if(links.length==0)
		return;
	
	var info=new Array();
	var numberlinks=new Array();
	for( var i=0;i<links.length;i++)
	{
		info.push({
			C_XNPATH:links[ i ].getAttribute("xn"),
			href:links[ i ].getAttribute("href")
			
		})
		var a = document.createElement("a");
		a.setAttribute("href", links[ i ].getAttribute("href") );
		a.setAttribute("target","_blank");
		numberdiv.appendChild( a );
		a.innerHTML = i+1 ;
		a.id= sid + "-num-"+i;
		numberlinks.push( a );
		info[i].numid = a.id;
		
	}
	
	
	//oTpxw.innerHTML = "";
	var div = document.createElement("div");
	div.id = "tpxwBorder";
	oTpxw.appendChild(div);
	oTpxw.appendChild( numberdiv );
	
	div = null;
	var f_setIndex = _tpxw_rotate( info  );
	for( i=0;i<numberlinks.length;i++)
	{
		numberlinks[i].onmouseover = delegate(null,i,f_setIndex);
	}
	
	links=null;
}
function delegate(o , v , f){
	return function(){ f.call( o || window,v )};
}
function _tpxw_rotate(linksInfo){
	var index = 0;
	var preIndex =- 1 ;
	var timer = -1;
	var preselectednum= null;
	function f(){

		
		
		index = index % linksInfo.length;
		
		var border = document.getElementById("tpxwBorder");
		
		try{	border.style.filter="revealTrans(duration=1,transition=" + Math.floor(Math.random()*23) +")"
				border.filters.revealTrans.apply();
		}catch(ignore){}
		if( document.getElementById( linksInfo[index ].numid ))
		{
			document.getElementById( linksInfo[index ].numid ).className = "selected";
			if( preselectednum )
			{
				document.getElementById( preselectednum ).className = "";
			}
			preselectednum = linksInfo[index ].numid;
		}
		border.className="";
		if(linksInfo[ index ].C_XNPATH)
			border.innerHTML
				= "<img onload='fiximagesize(this)' onerror='picError(this)' src='" + linksInfo[ index ].C_XNPATH + "'"+
					" onclick='window.open(\"" +linksInfo[ index ].href  + "\")' />";
		else	
			border.innerHTML="";
		


		preIndex = index ;
		
		index ++;
		
		try	{
			
				border.filters.revealTrans.play();
		
		}catch(ignore){}
		
		timer = setTimeout(f,1000*10);
	}
	f();
	return function( index2 ){
		clearInterval(timer);
		index = index2;
		f();
		
	};
}

/***************************************************
 * 		图片新闻部分结束
 *************************************************/



function picError( obj ){
	///document.title = obj;
	setTimeout(function(){
		o = obj.parentNode;
		o.className="noimage";
		o.innerHTML ="";
	
	},0);
}


function deferExec( f  ){
	var arg = Array.prototype.slice.call(  arguments , 1 , arguments.length  ) ;
	function lsnr(){
		f.apply( window ,  arg );
		f = null;
		lsnr = null;
	}
	
	if( window.addEventListener )
	{
		window.addEventListener("load", lsnr, false);
	}
	else{
		window.attachEvent("onload",lsnr );
	}
}


function waitExec( fcondition , fdo , delay){
	if(fcondition)
	{
		fdo();
	}
	else{
		setTimeout(function(){
			conditionExec( fcondition , fdo , delay);
		}, delay || 100  )
	}
}



