var B=document.body;
function isIE(){
return (document.all && window.ActiveXObject && !window.opera) ? true : false;
}
function $(id){
return document.getElementById(id);
}
function $N(Names){
return document.getElementsByName(Names);
}
function C$(element){
return document.createElement(element);
}
//--------------------------------网页下拉 伸缩广告-------------------------------------------------------------
function down_ad(id,cgTime,stTime,H,h,cH){ //参数依次为伸缩速度,停留时间,伸缩高度,初始高度,单位伸缩高度
var obj=$(id).style;
this.addCount=function()
{
h +=cH;
obj.display = "";
obj.height = h+"px";
if(h>=H) //高度
{
setTimeout('this.noneAds()',stTime)
return;
}
setTimeout("addCount()",cgTime);
}
this.noneAds=function()
{
h -=cH;
if(h<=0)
{
obj.display = "none";
return;
}
obj.height =h+"px";
setTimeout("noneAds()",cgTime);
}
addCount();
}
//------------------------------------随机浮动广告----------------------------------------------------------------
function randomFloat(x,y,dx,dy,width,height,src,closeSize,closeColor){
document.write('
');
var obj=$("img");
var Close=$("close");
with(Close.style){
height=closeSize+2+'px';
width=closeSize+2+'px';
lineHeight=height;
textAlign='center';
paddingLeft='2px';
}
var timeout;
this.float=function(){
x+=dx;
y+=dy;
obj.style.left=document.body.scrollLeft+x+"px";
obj.style.top=document.body.scrollTop+y+"px";
dx=(document.body.clientWidth-x-width<0?-dx:dx);
dy=(document.body.clientHeight-y-height<0?-dy:dy);
dx=(x<0?-dx:dx);
dy=(y<0?-dy:dy);
timeout=setTimeout('float()',30);
}
float();
obj.onmouseover=function(){clearTimeout(timeout);}
obj.onmouseout=function(){if(obj.style.display!="none"){timeout=setTimeout('float()',100);}else{return;}}
Close.onclick=function(){obj.style.display="none";}
}
//-----------------------------------js 图片轮换---标题在图片上的面透明样式----------------------------------------------------
function img_switch(receptacle,imgSrc,imgUrl,newsTitle,imgWidth,imgHeight,titleHeight,showTitle,showRim,rimColor,rimFill,rimWidth,imgButtonWidth,imgButtonHeight,imgButtonBg,imgButtonOverBg,speed){
var num=0;
var imgPlay;
count=imgSrc.length;
if(!showRim){rimWidth=0;rimFill=0;}//边框是否显示
var rim=C$('div');//外侧边框
$(receptacle).appendChild(rim);
with(rim.style){
border=rimWidth+'px solid '+rimColor;
width=imgWidth+rimFill*2+'px';
height=imgHeight+rimFill*2+'px';
margin='0px';
}
var img_div=C$('div');//装载图片的DIV
rim.appendChild(img_div);
with(img_div.style){
width=imgWidth+'px';
height=imgHeight+'px';
margin=rimFill+'px';
overflow='hidden';
zIndex=900;
}
var img_a=C$('a');//图片链接A标签
img_div.appendChild(img_a);
img_a.target='_blank';
img_a.id='img_a';
with(img_a.style){
display='block';
width=imgWidth+'px';
height=imgHeight+'px';
overflow='hidden';
}
var Img=C$('img');//图片
img_a.appendChild(Img);
Img.border='0';
Img.height=imgHeight;
Img.width=imgWidth;
Img.src='1.jpg';
Img.id='img_Id';
var o_img_div=C$('div');//标题框
img_div.appendChild(o_img_div);
o_img_div.id='o_img_div';
with(o_img_div.style){
height=titleHeight+'px';
lineHeight=titleHeight+'px';
width=imgWidth+'px';
background='#000000';
position='relative';
if (isIE()) {
filter = "Alpha(Opacity=80)";
} else {
opacity = 0.8;
}
bottom=titleHeight+'px';
overflow='hidden';
}
for(i=count;i>0;i--){
var img_button=C$('a');//数字按钮
o_img_div.appendChild(img_button);
img_button.id='img_button_'+i;
with(img_button.style){
position='relative';
display='block';
height=imgButtonHeight+'px';
lineHeight=imgButtonHeight+'px';
width=imgButtonWidth+'px';
textAlign='center';
background=imgButtonBg;
if (isIE()) {
styleFloat='right';
}else{
cssFloat='right';
}
marginRight='1px';
marginTop=Math.round((titleHeight-imgButtonHeight)/2)+'px';
fontSize='12px';
color='#ffffff';
fontWeight='bold';
cursor='pointer';
}
img_button.innerHTML=i;
}
var title_button=C$('a');//文字标题
o_img_div.appendChild(title_button);
title_button.id='title_button';
title_button.target='_blank';
with(title_button.style){
position='relative';
display='block';
height=imgButtonHeight+'px';
lineHeight=imgButtonHeight+'px';
width=imgWidth-15-(imgButtonWidth+1)*count+'px';
textAlign='left';
textDecoration='none';
if (isIE()) {
styleFloat='right';
}else{
cssFloat='right';
}
marginRight='8px';
marginTop=Math.round((titleHeight-imgButtonHeight)/2)+'px';
fontSize='12px';
color='#ffffff';
cursor='pointer';
overflow='hidden';
}
if(!showTitle){title_button.style.display='none'}
for(i=1;i<=count;i++){//按钮点击触发
$('img_button_'+i).onclick=function(){clearTimeout(imgPlay); play(this);}
}
this.play=function(position){//开始播放
if(typeof(position)!='undefined')num=parseInt(position.innerHTML)-1;
if(isIE()){//---IE----
$('img_Id').style.filter='revealTrans(Duration=1,Transition='+Math.round(Math.random()*23)+')';
$('img_Id').filters[0].apply();
$('img_Id').filters[0].play();
$('img_Id').src=imgSrc[num];
$('title_button').innerHTML=newsTitle[num];
$('title_button').href=imgUrl[num];
for(j=1;j<=count;j++){
$('img_button_'+j).style.backgroundColor=imgButtonBg;
}
$('img_button_'+(num+1)).style.backgroundColor=imgButtonOverBg;
}
else{//---其他浏览器---
$('img_Id').src=imgSrc[num];
$('title_button').innerHTML=newsTitle[num];
$('title_button').href=imgUrl[num];
for(j=1;j<=count;j++){
$('img_button_'+j).style.backgroundColor=imgButtonBg;
}
$('img_button_'+(num+1)).style.backgroundColor=imgButtonOverBg;
}
$('title_button').title=$('title_button').innerHTML;
$('img_a').href=$('title_button').href;
num++;
num=num>=count?0:num;
imgPlay=setTimeout('play()',speed);
}
$('title_button').onfocus=function(){this.blur();}
$('title_button').onmouseover=function(){this.style.color='#7DBCFB';}
$('title_button').onmouseout=function(){this.style.color='#fff';}
play();
}