﻿  window.addEvent('domready', function(){
  
  // Меню
  
	var accordion = new Accordion('div.menusection', 'ul.menusection', {
	opacity: false,
	onActive: function(toggler, element){toggler.setStyle('color', '#C18805');},
	onBackground: function(toggler, element){toggler.setStyle('color', '#0D3F8D');}});
	accordion.display(0);
	 
  //Скрывающиеся блоки
  
    var tgblock = $$('#block_with_hide div.block');
    var hidings = $$('#block_with_hide div.hide');
    var elements = new Array();
    hidings.each( function(hiding, i) {
     var element = new Fx.Slide(tgblock[i], { 
      duration: 500, transition: Fx.Transitions.linear,
      onComplete: function(request){var open = request.getStyle('margin-top').toInt();       
      }
     });
     elements[i] = element;
     hiding.onclick = function(){
     element.toggle();
     return false;
     }
     element.show();
    });
    
    //Скрывающиеся блоки в тексте
  
    var tgblock = $$('#block_with_hide div.hided');
    var hidings = $$('#block_with_hide span.hider');
    var closer = $$('#block_with_hide div.closer');
    var elements = new Array();
    hidings.each( function(hiding, i) {
     var element = new Fx.Slide(tgblock[i], { 
      duration: 500, transition: Fx.Transitions.linear,
      onComplete: function(request){var open = request.getStyle('margin-top').toInt();}
     });
     elements[i] = element;
     hiding.onclick = function(){
     element.toggle();
     return false;
     };
     closer[i].onclick=function(){
	 element.toggle();
	 };
     element.hide();
    });

    
    
   //Прокручивающиеся блоки (БАННЕР)
	  var butt				= 'button';
	  var totIncrement		= 0;
	  var increment			= 591;
	  var totelement		= 4;
	  var flg				= 1;
	  function selector () { 
			 if(totIncrement>(maxRightIncrement+increment*(totelement-flg))){
				totIncrement = maxRightIncrement+increment*(totelement-flg);
		    	fx.stop()
				fx.start(totIncrement);
				
			}
			if (totIncrement<(1-increment*flg)) {
					totIncrement = increment*(1-flg);
					fx.stop()
					fx.start(totIncrement);
				}
          };

	  var maxRightIncrement	= increment*(-(totelement-1));
	  var fx = new Fx.Style('myList', 'margin-left', {
				duration: 1000,
				transition: Fx.Transitions.Back.easeInOut,
				wait: true
	   });
$(butt + flg.toString()).setStyles('background:url("images/banner/banner_hover.png") repeat-x;');
function buttstyle(num){
var j = 0;
buttons = new Array();
while (j < (totelement)) {
buttons[j] = butt + num.toString();
j++;
if ( j !== num) {$(butt + j.toString()).setStyles('background:none;');};
};
$(butt + num.toString()).setStyles('background:url("images/banner/banner_hover.png") repeat-x;');
$(butt + '_inner' + num.toString()).setStyles('color:white');
};
	   
$('button1').onclick = function(){ 
          flg = 1; selector(); buttstyle(flg);};
$('button2').onclick = function(){ 
          flg = 2; selector(); buttstyle(flg);};
          
$('button3').onclick = function(){ 
          flg = 3; selector(); buttstyle(flg);};
          
$('button4').onclick = function(){ 
          flg = 4; selector(); buttstyle(flg);};
		  
		  
// Личный кабинет
		
	var PRcabinet = new Fx.Slide('private_form');
	PRcabinet.hide();
	$('private_cabinet_text').addEvent('click', function(e){
	e = new Event(e);
	PRcabinet.toggle();
	e.stop();
});



}); 


