//
// Copyright (c) Pitri - web-studio | http://pitri.com/ 
// Author - Eugene Ryabtsev | rea@otvertka.biz
// 25.12.06
//

var kolvo; //количество станиц
var page;  //текущая (1,4,8,12 ...)
var pagesp;  //текущая (1,4,8,12 ...)
var j; // фиксируетя при загрузке страницы
var din; // отвечает за действия
var pusk; // пусковой индексатор


function content(n) { // при загрузке страницы
	elemContainer=document.getElementById('scroll');
}
page = 1;
pagesp = 1;

xspeed = 140;
x2speed = 72; // ускорение
din = 0;
pusk = 0;
	


// программный буфер последовательности выполнения функйий
function action() {
if (din == 0) {pusk=0;} else {
	pusk=1;
	if (din < 0) {
		if (din < -2) {feedback(x2speed); setTimeout('action()',x2speed*4); } else {
			feedback(xspeed); setTimeout('action()',xspeed*4.51); setTimeout('s8s9()',xspeed*4.5);}
	din = din + 1;
	} else { 
		if (din >  2) {foreword(x2speed); setTimeout('action()',x2speed*5); } else {
			foreword(xspeed); setTimeout('action()',xspeed*4.51); setTimeout('s8s9()',xspeed*4.5);}
	din = din - 1;	
	}
// поменять номер страницы
number_page = document.getElementById('number');
number_page.innerHTML=((pagesp+3)*0.25);
}
}

function s8s9() {
	 document.getElementById('s3').style.display = 'none'; 
	 document.getElementById('s4').style.display = 'none';
		if (currentBrowser.isIE4up) {
		 document.getElementById('s8').style.display = 'block'; 
		 document.getElementById('s9').style.display = 'block';
		 } else  {document.getElementById('s8').style.display = 'table-cell';
				  document.getElementById('s9').style.display = 'table-cell';}
}

function botton() {
	if (document.getElementById('forward_botton'))
	{
		if (page == kolvo-3)
			document.getElementById('forward_botton').style.display = 'none';
		else
			document.getElementById('forward_botton').style.display = 'inline';
	};
	if (document.getElementById('back_botton'))
	{
		if (page == 1)
			document.getElementById('back_botton').style.display = 'none';
		else
			document.getElementById('back_botton').style.display = 'inline';
	};
}

function dedect_foreword() {  
	if (pagesp < kolvo-3) {
		din = din+1; pagesp= pagesp + 4;
		if ( pusk == 0) {action();}
	}
botton();
}

function dedect_feedback() {
	if (pagesp > 3) {	
		din = din-1;  pagesp= pagesp - 4;
		if ( pusk == 0) {action();} 
	}
botton();
}

// на какой странице находимся
function hide_two_td(k) {
g=3; if (k==3) g=4;
		document.getElementById('s'+g).style.display = 'none'; 
		 		if (currentBrowser.isIE4up) {
		 document.getElementById('s'+k).style.display = 'block'; 
		 } else { document.getElementById('s'+k).style.display = 'table-cell';

		 }

}

function show_two_td(k) {
	g=3; if (k==3) g=4;
		document.getElementById('s'+k).style.display = 'none';
		if (currentBrowser.isIE4up) {
		 document.getElementById('s'+g).style.display = 'block'; 
		 } else { document.getElementById('s'+g).style.display = 'table-cell';}
}

function step_f(j) {
	hide_two_td('4');
	document.getElementById('s7').style.display = 'none';
		 if (currentBrowser.isIE4up) {
		 document.getElementById('effect'+j).style.display = 'block'; 
		 } else  {
		 document.getElementById('effect'+j).style.display = 'table-cell';
		 }
}
function step_b(j) {
	hide_two_td('3');
	document.getElementById('s6').style.display = 'none';
		 if (currentBrowser.isIE4up) {
		 document.getElementById('effect'+j).style.display = 'block'; 
		 } else  {document.getElementById('effect'+j).style.display = 'table-cell';}
}


function foreword_one(i) {
		 document.getElementById('effect'+i).style.display = 'none'; 
		 if (currentBrowser.isIE4up) {
		 document.getElementById('s7').style.display = 'block'; 
		 } else  {document.getElementById('s7').style.display = 'table-cell';}
		 j=i+4;
		 show_two_td('4');
		 /*step(j);*/
}

function feedback_one(i) {
		j=i+3;
		document.getElementById('effect'+j).style.display = 'none'; 
		 if (currentBrowser.isIE4up) {
		 document.getElementById('s6').style.display = 'block'; 
		 } else  {document.getElementById('s6').style.display = 'table-cell';}

		j=i-1;
		show_two_td('3');
		/*step(j);*/
}

function setpacity_back(value){
	document.getElementById('back').style.opacity = value/10;
	document.getElementById('back').style.filter = 'alpha(opacity=' + value*10 + ')';
}

function setpacity_forward(value){
	document.getElementById('forward').style.opacity = value/10;
	document.getElementById('forward').style.filter = 'alpha(opacity=' + value*10 + ')';
}

function foreword(speed) {
	
     	document.getElementById('s8').style.display = 'none';
		   	document.getElementById('s9').style.display = 'none';


	document.getElementById('s3').style.display = 'none'; 
		 if (currentBrowser.isIE4up) {
		 document.getElementById('s4').style.display = 'block'; 
		 } else  {document.getElementById('s4').style.display = 'table-cell';}
	
	for (var i=3;i<11;i++) {setTimeout('setpacity_forward('+(10-i)+')',speed*0.25*i);}
	for (var i=3;i<11;i++) {setTimeout('setpacity_forward('+i+')',speed*0.25*i+speed*2);}
	for (var i=page;i<page+4;i++) {
		k=i-page+1;
		setTimeout('foreword_one('+i+')',speed*k);
		setTimeout('step_f('+(i+4)+')',speed*(k+0.5));
	}
   page=page+4;
   botton();
}

function feedback(speed) {

   	document.getElementById('s8').style.display = 'none';
	   	document.getElementById('s9').style.display = 'none';


document.getElementById('s4').style.display = 'none';
		 if (currentBrowser.isIE4up) {
		 document.getElementById('s3').style.display = 'block'; 
		 } else  {document.getElementById('s3').style.display = 'table-cell';}
	
	for (var i=3;i<11;i++) {setTimeout('setpacity_back('+(10-i)+')',speed*0.25*i);}
	for (var i=3;i<11;i++) {setTimeout('setpacity_back('+i+')',speed*0.25*i+speed*2);}
	for (var i=page;i<page+4;i++) {
		k=i-page+1;
    	g=i-2*k+2;
 		setTimeout('feedback_one('+g+')',speed*k);
		setTimeout('step_b('+(g-1)+')',speed*(k+0.5));
	}
   page=page-4;
   botton();
}


function displey_td(id_id) {
    document.getElementById(id_id).style.display = 'block'; 
} 

function pacity(value)  {
	document.getElementById(k).style.opacity = value/10;
	document.getElementById(k).style.filter = 'alpha(opacity=' + value*10 + ')';
}


function BrowserInfo() {
  var agt = navigator.userAgent.toLowerCase();
  this.version = parseFloat(navigator.appVersion);
  this.isIE = (agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1);
  this.isIE4up = this.isIE && (this.version >= 4);
  if (this.isIE) {
    if (this.isIE4up) {
      if (agt.indexOf("msie 6") != -1) this.version = 6;
      else if (agt.indexOf("msie 5.5") != -1) this.version = 5.5;
      else if (agt.indexOf("msie 5") != -1) this.version = 5;
    } else
      this.version = 3;
  }
  this.isIE5up = this.isIE && (this.version >= 5);
  this.isIE5_5up = this.isIE && (this.version >= 5.5);
  this.isIE6up = this.isIE && (this.version >= 6);
  this.isNN = (agt.indexOf('mozilla') != -1) && (agt.indexOf('spoofer') == -1) &&
              (agt.indexOf('compatible') == -1) && (agt.indexOf('opera') == -1) &&
              (agt.indexOf('webtv') == -1) && (agt.indexOf('hotjava') == -1);
  this.isNN4up = this.isNN && (this.version >= 4);
  this.isNN6up = this.isNN && (this.version >= 5);
  this.isOnline = true;
  if (this.isIE4up)
    this.isOnline = navigator.onLine;
  this.name = "Unknown";
  if (this.isIE)
    this.name = "Internet Explorer";
  else if (agt.indexOf("netscape6/") != -1) {
    this.name = "Netscape";
    this.version = parseFloat(agt.substr(agt.indexOf("netscape6/") + 10));
    if (!this.version) this.version = 6;
  } else if (agt.indexOf('gecko') != -1)
    this.name = "Mozilla";
  else if (this.isNN)
    this.name = "Netscape Navigator";
  else if (agt.indexOf("aol") != -1) {
    this.name = "AOL Browser";
    if (this.version < 4) this.version = 3;
  }
  else if (agt.indexOf("opera") != -1) {
    this.name = "Opera";
    this.version = parseFloat(agt.substr(agt.indexOf("opera") + 6));
  }
  else if (agt.indexOf("webtv") != -1)
    this.name = "WebTV";
  else if ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1))
    this.name = "AOL TV Navigator";
  else if (agt.indexOf("hotjava") != -1)
    this.name = "HotJava";
  this.fullName = this.name + ' ' + this.version;
  if (this.version == Math.floor(this.version))
    this.fullName += '.0';
}

/* меню уходит через заданный промежуток времени */

/* закрыть через паузу */
function closeMenu(id_id) {
	    if (hideMenu(id_id))
			tm = setTimeout(hideMenu(id_id),10000);
	}

/* закрыть */
function hideMenu(id_id) {
    if (document.getElementById(id_id))
		document.getElementById(id_id).style.display = 'none';
	
}

