// Основа скрипта взята с www.ricom.co.uk

orientation = "horizontal"
scrollerWidth = "3000" // Дурим ИЕ
scrollerHeight = "95"
borderWidth = 0
borderColour = "#4eabe9"
backColour = "#FFFFFF"
staticColour = "#000000"
stopScroll = 1
textAlignment = "center"
posterTitle = "Фотографии туалетных модулей-павильонов в местах установки"
scrollerDivider = "<span style=\"display: block; width: 30px;\">&nbsp;</span>"

// Проверяем браузер
var isIE = (document.getElementById && document.all)?true:false;
var isNS4 = (document.layers)?true:false;
var isNS6 = (document.getElementById && !document.all)?true:false;
var isLoaded=false;

// Показываем факер нетскейпу (был, сынок, такой браузер...)
ns4Text = "Фотографии туалетных модулей-павильонов в местах установки";
ns4URL = "http://www.bioec.ru/21/168/173/";
ns4Target = "_top";

// Генерируем скроллер на странице
function buildScroller()
{
boundry='<div name="boundry" id="boundry" style="position:relative"></div>';
document.writeln(boundry);
}

// А ручки-то - вот они:
function loadScroller(){
if(isNS4){
scroller='<TABLE border="0" cellpadding="0" cellspacing="0" width="'+scrollerWidth+'" bgcolor="'+borderColour+'"><TR><TD>'
scroller+='<TABLE border="0" cellpadding="3" cellspacing="1" width="100%" height="'+scrollerHeight+'" style="text-align:center;overflow: hidden;"><TR><TD align="center" nowrap><P>';
if(ns4URL.toLowerCase()!="none"){scroller+='<A href="'+ns4URL+'" target="'+ns4Target+'">'+ns4Text+'</A>';}
else{scroller+=ns4Text;} 
scroller+='</P></TD></TR></TABLE></TD></TR></TABLE>'   
}else{
scroller='<TABLE border="0" cellpadding="0" cellspacing="0" style="width:'+scrollerWidth+';height:'+scrollerHeight+';border:'+borderWidth+'px solid '+borderColour+';text-align:center;">';
scroller+='<TR valign="top"><TD><DIV id="div" style="text-align: center; margin-top: 3px;';
if(orientation.toLowerCase()=="vertical"){scroller+='height:'+scrollerHeight+';';}
scroller+='width:'+scrollerWidth+'; position:relative; overflow:hidden">';
scroller+='<DIV id="div1" style="position:relative; left:0; z-index:1;">';
scroller+='<TABLE border="0" name="table" id="table"';
if(orientation.toLowerCase()=="vertical"){scroller+='style="text-align:center;width:'+scrollerWidth+'"';}
scroller+='><TR>';
y=0;
while (y<4)
{
for (x=0; x<(Article.length); x++)
{
if(orientation.toLowerCase()=="vertical"){scroller+='<tr>';}
scroller+='<TD ';
if(orientation.toLowerCase()=="horizontal"){scroller+='nowrap';} if(stopScroll==1){scroller+=' onMouseOver="stopScroller();" onMouseOut="setWidth()"';}
scroller+=' valign="top"><DIV><P align="center">';
if(Article[x][1].toLowerCase()!="none"){scroller+='<A href="'+Article[x][1]+'"><IMG src="'+Article[x][0]+'" border="0" alt="'+posterTitle+' - '+Article[x][2]+'" title="'+posterTitle+' - '+Article[x][2]+'"><\/A><TABLE align="center" cellspacing="0" cellpadding="0" border="0"><TR><TD><DIV><A href="'+Article[x][1]+'" title="'+Article[x][2]+' - туалетный модуль-павильон (общественный туалет)">'+Article[x][2]+'<\/A></DIV></TD></TR></TABLE>';
}else{scroller+=Article[x][0];}          
scroller+='</P></DIV><\/TD>';
if(orientation.toLowerCase()=="vertical"){scroller+='<\/TR>';}
if(scrollerDivider.toLowerCase() != "none"){scroller+='<TD nowrap><P>'+scrollerDivider+'<\/P><\/TD>';}
}
y++
}
scroller+='<\/TR><\/TABLE><\/DIV><\/DIV><\/TD><\/TR><\/TABLE>';  
}
document.getElementById("boundry").innerHTML=scroller;
setWidth();
}

// Определяем, делится ли ширина скроллера на 2 (для более плавной прокрутки)
function setWidth()
{ 
  tableObj=(isIE)?document.all("table"):document.getElementById("table"); 
  obj=(isIE)?document.all.div1:document.getElementById("div1");   
  objWidth=(orientation.toLowerCase()=="horizontal")?getOffset(tableObj,"width"):getOffset(tableObj,"height");
  HalfWidth=Math.floor(objWidth/2);
  newWidth = (HalfWidth*2)+2;
  obj.style.width=newWidth
  moveLayer(obj, newWidth);
  
}

// Сдвигаем слой по пикселю влево
function moveLayer(obj, width)
{
maxLeft = (0-(width/2)+2)/2
if(orientation.toLowerCase()=="horizontal"){
obj.style.left=(parseInt(obj.style.left) <= maxLeft)?0:parseInt(obj.style.left)-1
}else{
if(obj.style.top==""){obj.style.top=0;}
// alert(obj.style.top)
if (parseInt(obj.style.top)<(0-(width/2)+6)){
obj.style.top = 0
}else{
obj.style.top = parseInt(obj.style.top)-1
}
}
timer = setTimeout ("moveLayer(obj, "+width+");", 13); 
}

// Определяем размеры слоя
function getOffset(obj, dim) 
{
if(dim=="width")
{
oWidth = obj.offsetWidth
return oWidth
}  
else if(dim=="height")
{
oHeight = obj.offsetHeight
return oHeight
}    
}

// Паузим при наведении
function stopScroller()
{
clearTimeout(timer)  
}
