var Scroller = new Class({	Implements: [Events, Options],	options: {		area: 250,		velocity: 1,		onChange: function(x, y){		    			this.element.scrollTo(x, y);		},		fps: 50,		horizontal: false, //v3 modified		vertical: true	},	initialize: function(element, options){		this.setOptions(options);		this.element = document.id(element);				this.listener = ($type(this.element) != 'element') ? document.id(this.element.getDocument().body) : this.element;		this.timer = null;		this.bound = {			attach: this.attach.bind(this),			detach: this.detach.bind(this),			getCoords: this.getCoords.bind(this)		};	},	start: function(){		this.listener.addEvents({			mouseenter: this.bound.attach, //v3 modified			mouseleave: this.bound.detach		});	},	stop: function(){		this.listener.removeEvents({			mouseenter: this.bound.attach,			mouseleave: this.bound.detach		});		this.detach();		this.timer = $clear(this.timer);	},	attach: function(){		this.listener.addEvent('mousemove', this.bound.getCoords);	},	detach: function(e){		var node = this;		this.detachTimer = (function() {			node.listener.removeEvent('mousemove', node.bound.getCoords);			node.timer = $clear(node.timer);		}).delay(50);	},	getCoords: function(event){			this.page = (this.listener.get('tag') == 'body') ? event.client : event.page;		if (!this.timer) this.timer = this.scroll.periodical(Math.round(1000 / this.options.fps), this);	},	scroll: function(){				var size = this.element.getSize(),			scroll = this.element.getScroll(),			pos = this.element.getOffsets(),			scrollSize = this.element.getScrollSize(),			change = {x: 0, y: 0};		// v3 modified		if (!this.options.horizontal) delete this.page.x;		if (!this.options.vertical) delete this.page.y;		for (var z in this.page){						if (this.page[z] < (this.options.area + pos[z]) ) {							change[z] = (this.page[z] - this.options.area - pos[z]) * this.options.velocity;							}			else if (this.page[z] + this.options.area > (size[z] + pos[z]) )			{							change[z] = (this.page[z] - size[z] + this.options.area - pos[z]) * this.options.velocity;			}		}						if (change.y || change.x) {		    			this.fireEvent('change', [scroll.x + change.x, scroll.y + change.y]);					}	}});Shadowbox.init({	language: 'ru',	adapter: 'mootools',	skipSetup: true,	players:  ['img']});window.addEvent('domready', function() {	// включаем shadowbox  var Shadowbox_options = {    resizeDuration: 0.2,    fadeDuration: 0.2,    viewportPadding: 10,    handleOversize: 'drag',    overlayOpacity: 0.5,    viewportPadding: 5,    autoDimensions: true,		animate: false  };       init_image();   function init_image() {	list = $$(document.links);  list = list.filter(function(item){  	//if (item.hasClass('no')) return false;    return item.href.test(/\.(jpe?g|png|gif|swf)$/);  })  if (list && list.length) {		Shadowbox.setup(list, Shadowbox_options);  }  }    //скрол в товаре  $$('.mi').each(function(item) {		var area = 100;				item.myScroller = new Scroller(item, {				area: area,				velocity: 0.05						});		item.myScroller.start();	});  //Кнопки в скроле   	$$('.arrow').addEvent('mousedown', function(e) {  			var  deltay=0;		var node =this.getParent().getParent().getElement('.mi');	         if (this.hasClass('up')) deltay = -6;		     if (this.hasClass('down')) deltay = 6;		     			this.timer = (function() {			var curCroll = node.getScroll();					node.scrollTo(0,curCroll.y+deltay);				}).periodical(20);		       	e.preventDefault(); 	}).addEvent('mouseup', function(e) {					this.timer = $clear(this.timer);				e.preventDefault();	}).addEvent('click', function(e) {      	e.preventDefault();    });   //менюшка if ($chk('#topmenu')) {		$$('#topmenu li').addEvent('mouseenter', function(event) {						event.preventDefault();		   		 if (!this.hasClass('current'))	 this.addClass ('Ho'); 									     }).addEvent('mouseleave', function(event) {		        				event.preventDefault();		          this.removeClass ('Ho');					      				     });}if ($chk('.topm')) {		$$('.topm li').addEvent('mouseenter', function(event) {				 event.preventDefault();		   	    this.addClass ('active'); 									     }).addEvent('mouseleave', function(event) {					event.preventDefault();		      this.removeClass ('active');					      				     });}/*if ($chk('.js-catName .active')) {      $$('.js-catName.active').each(function(item) {     		 item.getElement('.childmenu').setStyle('display', 'block');        		  	});      	  };      */if ($chk('.childmenu ul li.active')) {    $$('.childmenu ul li.active').each(function(item) {      // item.getParent('.childmenu').setStyle('visibility', 'visible');       item.getParent('.js-catName').addClass('active');       item.getParent('.js-catName').addClass('not');       item.getParent('.js-catName').addClass('open');       /* $$('.js-catName').each(function(item) {		         		      if (!item.hasClass('open'))       				           item.morph({      									'opacity': 0.3						      								});         }); */    })    }/*if ($chk('.childmenu1 ul li.active')) {    $$('.childmenu1 ul li.active').each(function(item) {       item.getParent('.childmenu1').setStyle('visibility', 'visible');       item.getParent('.js-catName').addClass('active');       item.getParent('.js-catName').addClass('not');       item.getParent('.js-catName').addClass('open');            })    }if ($chk('.childmenu2 ul li.active')) {    $$('.childmenu2 ul li.active').each(function(item) {       item.getParent('.childmenu2').setStyle('visibility', 'visible');       item.getParent('.js-catName').addClass('active');       item.getParent('.js-catName').addClass('not');       item.getParent('.js-catName').addClass('open');             })    } //Позиционируем  дочерние менюif ($chk('.childmenu1')) {             $$('.childmenu1').each(function(item) {             var margintop = item.getParent().getOffsets();             var marginleft = item.getParent().getParent().getParent().getStyle('width').toInt();                                       var newpos = 130-margintop.y+38;             item.setStyle('top',newpos);             item.setStyle('left', marginleft);       });		 }	 */if ($chk('.js-catName')) {		$$('.js-catName').addEvent('mouseenter', function(event) {		       this.addClass ('active');		      	var node = this;		        var man_str=node.get('rel');				    mans=man_str.split(',');				    				    $$('.js-topMan').each(function(item) {		         		 				           item.getParent().morph({									'opacity': 0.3														}); ;		                                			        }); 				 	for (i=0; i<mans.length;i++) {				         if ($chk('.man'+mans[i])) { 					 			$$('.man'+mans[i]).getParent().addClass('active');								$$('.man'+mans[i]).getParent().morph({									'opacity': 1														}); ; 					     }					 }		    						     				   															     }).addEvent('mouseleave', function(event) {									 if (!this.hasClass('not'))		      this.removeClass ('active');			     		     $$('.js-topMan').each(function(item) {		         		    if (!item.hasClass('not'))				           item.getParent().removeClass('active');				           item.getParent().morph({									'opacity': 1														}); ;		                                			        }); 				     });        /*  $$('.js-catName ').addEvent('mouseenter', function(event) {   	      		            		     	if (!this.hasClass('open')) {      		     	   $$('.js-catName').each(function(item) {                           node =item.getElement('.childmenu');    			               if (node!=null)  node.morph({                            									   'opacity': 0						                            								    });                              item.removeClass ('open');                           ;                            	                     });                                          node = this.getElement('.childmenu');    			            				    			          node.morph({									   'opacity': 1														    });    			          this.addClass ('open');    			         			          }          		 });		 $$('.childmenu li').addEvent('mouseenter', function(event) {        		     	                    $$('.childmenu1').morph({									   'opacity': 0														    });                            node = this.getElement('.childmenu1');    			          node.morph({									   'opacity': 1														    });                   				    			          var margintop = node.getParent().getOffsets();                    var marginleft = node.getParent().getParent().getParent().getStyle('width').toInt();                                                              var newpos = 130-margintop.y+38;                     node.setStyle('top',newpos);                     node.setStyle('left', marginleft);   			            			         			                    		 });		  $$('.childmenu1 li').addEvent('mouseenter', function(event) {        		     	                    $$('.childmenu2').morph({									   'opacity': 0														    });                                             node = this.getElement('.childmenu2');    			          node.morph({									   'opacity': 1														    });                    			    			          var margintop = node.getParent().getOffsets();                    var marginleft = node.getParent().getParent().getParent().getStyle('width').toInt();                                                              var newpos = 130-margintop.y+38;                     node.setStyle('top',newpos);                     node.setStyle('left', marginleft);    			            			         			                    		 });		 */		 $$('.js-close ').addEvent('click', function(event) {      		              		     	   this.getParent().setStyle('display', 'none');                      $$('.js-catName').each(function(item) {		         		         				           item.morph({      									'opacity': 1						      								}); ;      		              			        });     	    			        // this.getParent('.js-catName').removeClass ('open');    			        			             event.preventDefault();          		 });}  $$('.js-topMan').each(function(item) {				item.addEvent('mouseenter', function(e) {		      				var node = this;		        var cats_str=node.get('rel');				    cats=cats_str.split(',');				    				    $$('.js-catName').each(function(item) {		         		   				           item.morph({									'opacity': 0.3														}); ;		        			        }); 				 	for (i=0; i<cats.length;i++) {				         if ($chk('.cat'+cats[i])) { 					 			$$('.cat'+cats[i]).addClass('active');								$$('.cat'+cats[i]).morph({									'opacity': 1														}); ; 					     }					 }		    		          		          								 							     	}).addEvent('mouseleave', function(event) {    					         	$$('.js-catName').each(function(item) {		         		   if (!item.hasClass('not'))				           item.removeClass('active');				           item.morph({									'opacity': 1														}); ;		        			        });      });;    	     });	//Если находимся на верхнем уровне подморгнем пользователю строкойif ($chk('.js-firstlevel')) {       				     									$$('.js-filter-cats').morph({					    'opacity': [0.3,1],						'backgroundColor': ['#1f495e','#d9d9d9']												}); };  //AJAX запрос для списка городов $$('.idregion').addEvent('change', function(event) {		            	var  node= this;			         	var AJAXpost = new Request({			         		method: 'post',							url: node.get('url'),							data: {								ajax: 1,								id: node.get('value')							},							'link': 'ignore',											onSuccess: function(responseText) {								    $('idcity').set('html',responseText);								   							},											onFailure: function(xhr) {							      alert('Ошибка')							}							});													AJAXpost.send();   				  });	      }); 