//////////////////////////////////////////////////////////////////
// 无逢滚动    //
//第 8，9，10，11 行更改总体设置  //
//第 87 行开始加入自定义内容   //
//将JS嵌入到显示的固定位置   //
// 2006.02.10 V1.00 By Clear for PPLive.com //
//////////////////////////////////////////////////////////////////
var speed = 30; //定义滚动速度，数字越大速度越慢
var intAWidth = 2000;//定义滚动区域宽度，单位：像素
var intAHeight = 30;//定义滚动区域高度，单位：像素
var direction = "left";//定义滚动方向，上："top"|下："down"|左："left"|右："right"
//var collectScroll;
var tab;
var tab1;
var tab2;
var MyMar;
var scroll = 1;
function autoScroll(){
 scroll += 2;
 this.items = [];
 //增加图片滚动元素的方法
 this.addItem = function(adURL,strURL,strBak,intTarget,imgWidth,imgHeight){
  var newItem  = {};
  newItem.adURL = adURL;
  newItem.strURL = strURL;
  newItem.strBak = strBak;
  newItem.intTarget = intTarget;
  newItem.width = imgWidth;
  newItem.height = imgHeight;
  this.items[this.items.length] = newItem;
 }
 //增加文字滚动元素的方法
 this.addStrItem = function(strURL, strTitle, strTarget){
   var newItem  = {};
   newItem.strURL = strURL;
   newItem.strTitle = strTitle;
   newItem.strTarget = strTarget;
   this.items[this.items.length] = newItem;
 }
 //开始滚动方法，参数是要滚动的数组，滚动类型s_type，速度s_speed，滚动区域宽度s_width，滚动区域高度s_height，滚动方向s_direction，元素之间距离s_margin
 this.play = function(s_type,s_speed,s_width,s_height,s_direction,s_margin){
  var collectScroll = this.items;
  if(s_speed != null){
	speed = s_speed;
  }
  if(s_width != null){
	intAWidth = s_width;
  }
  if(s_height != null){
	intAHeight = s_height;
  }
  if(s_direction != null){
    direction = s_direction;
  }
  scrollHtml(collectScroll,s_type,s_margin);
  tab=document.getElementById("demo" + scroll);
  tab1=document.getElementById("demo" + scroll + "1");
  tab2=document.getElementById("demo" + scroll + "2");
  tab2.innerHTML = tab1.innerHTML;
  MyMar=setInterval(Marquee,speed);
 }
}
function scrollHtml(collectScroll,type,margin){
 var imgHtml = "";
 for(var i=0;i<collectScroll.length;i++){
  var a = collectScroll[i];
  if(type == "img"){
    imgHtml += "<a href='"+a.strURL+"' target='"+a.intTarget+"'><span style='"+margin+"'><img src='"+a.adURL+"' alt='"+a.strBak+"' border='0' width='"+ a.width +"' height='"+ a.height+"'/></span></a>";
  }else if(type =="str"){
	if(direction == "top" || direction == "down"){
	   imgHtml += "<span style='"+margin+"'>"+ a.strTitle +"</span><br>";
	}else{
	   imgHtml += "<a href='"+a.strURL+"' target='"+a.strTarget+"'><span style='"+margin+"'>"+ a.strTitle +"</span></a>";
	}
  }else if(type == "strImg"){
    var title=a.strBak;
    if(a.strBak.length>10){
		title = title.substring(0,10)+"..."; 
	}
    imgHtml += "<div style=float:left><a href='"+a.strURL+"' target='"+a.intTarget+"'><span style='"+margin+"'><img src='"+a.adURL+"' alt='"+a.strBak+"' border='0' width='"+ a.width +"' height='"+ a.height+"'/></span><br><span style='"+margin+"'>"+title+"</span></a></div>";
  }
 }
 var b,c,d
 if(direction == "left" || direction == "right"){
  b = "<div id='indemo"+ scroll +"' style='float: left;width: 800%'>"
  c = " style='float: left'"
  d = "</div>"
 }else{
  b = ""
  c = ""
  d = ""
 }
 document.writeln("<div id='demo" + scroll +"' onmouseover='clearInterval(MyMar)' onmouseout='MyMar=setInterval(Marquee,speed)' style='overflow:hidden; width:"+intAWidth+"px;height:"+intAHeight+"px'>")
 document.writeln(b+"<div id='demo"+ scroll +"1'"+c+">")
 document.writeln(imgHtml)
 document.writeln("</div><div id='demo"+ scroll +"2'"+c+">"+d+"</div></div>")
}
function Marquee(){
 if(direction == "top"){
  if(tab2.offsetTop-tab.scrollTop<=0){
   tab.scrollTop-=tab1.offsetHeight
  }else{
   tab.scrollTop++
  }
 }else if(direction == "down"){
  if(tab1.offsetTop-tab.scrollTop>=0)
   tab.scrollTop+=tab2.offsetHeight
  else{
   tab.scrollTop--
  }
 }else if(direction == "left"){
  if(tab2.offsetWidth-tab.scrollLeft<=0)
   tab.scrollLeft-=tab1.offsetWidth
  else{
   tab.scrollLeft++;
  }
 }else if(direction == "right"){
  if(tab.scrollLeft<=0)
   tab.scrollLeft+=tab2.offsetWidth
  else{
   tab.scrollLeft--
  }
 }
}
//var theAutoScroll= new autoScroll();
//theAutoScroll.addStrItem("http://www.alixixi.com/alixixi.gif","asdadaadads","_blank");
//theAutoScroll.addStrItem("http://www.alixixi.com/alixixi.gif","xxxxxxxxxx","_blank");
//theAutoScroll.addStrItem("http://www.alixixi.com/alixixi.gif","sfdsdfwerwre","_blank");
//theAutoScroll.addItem("http://www.alixixi.com/alixixi.gif","http://www.alixixi.com","图片4","_blank")
//theAutoScroll.addItem("http://www.alixixi.com/alixixi.gif","http://www.alixixi.com","图片5","_blank")
//theAutoScroll.play("str", 10, 2000, 50, "top","margin-left:100px;");
//使用方法：
//首先修改8，9，10，11行总体设置
//然后重复调用控件：
//theAutoScroll.addItem(adURL,strURL,strBak,intTarget)
//adURL 定义图片路径
//strURL 定义图片链接
//strBak 定义图片出错时的备用提示
//intTarget 定义广告弹出方式，可选参数"_blank","_self","_top","_parent"