//<!--
var timer_slide = new Array();
var time_out = new Number(10000);

function getAbsolutePos(el)
{
   var r = { x: el.offsetLeft, y: el.offsetTop };
   if (el.offsetParent)
   {
       var tmp = getAbsolutePos(el.offsetParent);
       r.x += tmp.x;
       r.y += tmp.y;
   }
   return r;
}

function show_obj(id_obj, id_obj_holder)
{
 var Obj_set = document.getElementById(id_obj);
 var Holder_Obj = document.getElementById(id_obj_holder);
 Obj_set.style.left = getAbsolutePos(Holder_Obj).x -1;
 Obj_set.style.top = getAbsolutePos(Holder_Obj).y;
 Obj_set.style.visibility='visible';
 Obj_set.style.zIndex = 10;
 Obj_set.style.filter="alpha(opacity=0)";
 Obj_set.style.opacity = 0;
}

function hid_obj(id_obj)
{
  Obj_set = document.getElementById(id_obj);
  Obj_set.style.visibility = 'hidden';
  Obj_set.style.filter="alpha(opacity=0)";
  Obj_set.style.opacity = 0;
  Obj_set.style.zIndex = 0;
}

function apacity_change (id, apacity_start, mode)
{
 if(mode == 'hid')
 {apacity = apacity_start - 3;}
 
 if(mode == 'show')
 {apacity = apacity_start + 3;}
 
 Obj_set = document.getElementById(id);
 Obj_set.style.filter="alpha(opacity="+ apacity +")";
 Obj_set.style.opacity = apacity/100;
 
 timer_slide[id] = setTimeout("apacity_change('" + id + "', " + apacity + ", '" + mode + "')",1);
 if (apacity > 98 && mode == 'show') {clearTimeout(timer_slide[id]);}
 if (apacity <= 0 && mode == 'hid') {Obj_set.style.zIndex = 0; hid_obj(id); clearTimeout(timer_slide[id]);}

}

// Перелистывает баннеры на определенной позиции если их несколько
// pos -- номер позиции холдера
// show_Obj_num -- номер картинки, которую следует показать
// all_Obj - количество всех объектов

function slider(pos, show_Obj_num, all_Obj)
{

if (all_Obj == -1) return;

pred_num = show_Obj_num -1;
next_num = show_Obj_num +1;

pred_obj = document.getElementById('banner_' + pos + '_' + pred_num);
this_obj = document.getElementById('banner_' + pos + '_' + show_Obj_num);
next_obj = document.getElementById('banner_' + pos + '_' + next_num);
last_obj = document.getElementById('banner_' + pos + '_' + all_Obj);

if (pred_obj&&this_obj) 
{ 
 apacity_change ('banner_' + pos + '_' + pred_num, 100, 'hid');
 show_obj('banner_' + pos + '_' + show_Obj_num, 'holder_' + pos);
 apacity_change ('banner_' + pos + '_' + show_Obj_num, 0, 'show');
}
else
 {
	  apacity_change ('banner_' + pos + '_' + all_Obj, 100, 'hid');
	  show_obj('banner_' + pos + '_' + show_Obj_num, 'holder_' + pos);
	  apacity_change ('banner_' + pos + '_' + show_Obj_num, 0, 'show');
  }

if (next_obj) 
{
 timer_slide[pos] = setTimeout("slider(" + pos + ", " + next_num + ", " + all_Obj + ")", time_out);
}
else 
{ 
 timer_slide[pos] = setTimeout("slider (" + pos + ", 0, " + all_Obj + ")", time_out);
}

}
//-->
