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]);					}	}});/////////////////////////////////////////////Плагин ротации объявлений и новостейvar Rotator = new Class({    	Implements: [Events, Options],    	options: {      		        cur: 0,                  timeout: 3000,        method: 'visibility'    	},         initialize: function(list, options,events){        		 this.setOptions(options);        	 	 this.list=list;        		 this.length=list.length;             if (this.options.method=='visibility') {	        		     this.list[0].setStyle('opacity', 1);        		} else {              //  this.list[0].setStyle('display', 'block');            }    			 	 this.f.delay(this.options.timeout, this);                	  	},  	start: function() {              this.active=true;    },    stop: function() {              this.active=false;    },    setpos: function(pos) {            this.options.cur = pos;            this.slide();                },   getpos: function(pos) {                        return   this.options.cur;                },    f: function() {        if (this.active) {            this.options.cur++;    	      this.slide();	        }                	      this.f.delay(this.options.timeout, this);                   },     //События      slide: function() {                 	for(i=0;i<this.length;i++) {			    //this.list[i].tween('opacity', 0);			   			     if (this.options.method=='visibility') {	        		     this.list[i].setStyle('opacity', 0);        		} else {                //this.list[i].setStyle('display', 'none');            }			  		    	}  			         	        if (this.options.cur >=this.length  ) this.options.cur = 0;	        if (this.options.cur < 0) this.options.cur = this.length-1;	        	        //this.list[this.options.cur].tween('opacity', 1);	         if (this.options.method=='visibility') {	        		     //this.list[this.options.cur].setStyle('opacity', 1);        		     this.list[this.options.cur].tween('opacity', 1);        		} else {                //this.list[this.options.cur].setStyle('display', 'block');            }	        //this.list[this.options.cur].setStyle('opacity', 1).set('tween', {duration: 200});          this.public.slideAfter();             },     public: { slideAfter: function() {         }    } })var Scroller2 = new Class({	Implements: [Events, Options],	options: {		area: 112,		velocity: 1,		onChange: function(x, y){		 		  			this.element.scrollTo(x, y);			   		},		fps: 50,		horizontal: true, //v3 modified		vertical: false	},	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', 'html', 'iframe']});window.addEvent('domready', function() {  //  $('m32').getFirst().addEvent('click', function(e) {  //	e.stop();       // });	// включаем shadowbox var Shadowbox_options = {    resizeDuration: 0.5,    fadeDuration: 0.5,    viewportPadding: 10,    handleOversize: 'drag',    overlayOpacity: 0.5,    viewportPadding: 5,    autoDimensions: true,		animate: true  };      $$('.week .shifting_block').each(function(item) {    var area = 600;    item.myScroller = new Scroller2(item, {            area: area,            velocity: 0.05                });        item.myScroller.start();		});      $$('.js-order').addEvent('click', function(event) {       event.stop();           			Shadowbox.open({             content:    this.get('href'),              player:     'iframe',             title:      '',             width: '640px',             height: '600px'                    });			    }); $$('.js-order-free').addEvent('click', function(event) {       event.stop();           			Shadowbox.open({             content:    this.get('href'),              player:     'iframe',             title:      '',             width: '640px',             height: '330px'                    });			    });        $$('.rec').addEvent('click', function(event) { event.stop();           			Shadowbox.open({             content:    this.get('href'),              player:     'iframe',             title:      '',             width: '640px',             height: '420px'                    });			    });   //новинки на главной  if ($chk($('newsrotator'))) {  	var  newslist = $$('#newsrotator > div ').setStyle('opacity', 0).set('tween', {duration: 200});  	var maxheight = $('newsrotator').getStyle('height').toInt();  	if (newslist.length>0) {  		newslist.Rotator = new Rotator(newslist, {timeout: 5000});          newslist.Rotator.public.slideAfter = function () {	         var pos = newslist.Rotator.getpos();       			         			   $$('.js-latest-list a').removeClass('active');		       $$('.js-latest-list .item'+pos).addClass('active');                    	    };	   		newslist.Rotator.start();		  	}   	  $$('.js-latest-block').addEvent('mouseenter', function(e) {       	    					 newslist.Rotator.stop();    		}).addEvent('mouseleave', function(e) {		       newslist.Rotator.start();	    }); 		    }  //клики по новинкам на главной  if ($chk($$('.js-latest-list'))) {  	//js-latest-list  	           		$$('.js-latest-list a').addEvent('click', function(event) {  			 var pos = this.get('rel');  			 $$('.js-latest-list a').removeClass('active');		     newslist.Rotator.setpos(pos);		     this.addClass('active');		     event.preventDefault();				     });}    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();	});	  //скрол в товаре  $$('.miniimg').each(function(item) {		var area = 100;				item.myScroller = new Scroller(item, {				area: area,				velocity: 0.05,				horizontal: true, //v3 modified		    vertical: false		});		item.myScroller.start();	});        $$('.day').each(function(item) {		var area = 10;				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.hasClass('child')) && (!this.hasClass('not')) )	 this.addClass ('Ho'); 									     }).addEvent('mouseleave', function(event) {		        				event.preventDefault();		          this.removeClass ('Ho');					      				     });}if ($chk('.js-topm')) {		$$('.js-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();   				  });	       //AJAX запрос для списка подкатегорий $$('.vendor_id').addEvent('change', function(event) {		            	var  node= this;		            	$$('.category_id').set('html',"<option>Идет загрузка...</option>");				         	var AJAXpost = new Request({			         		method: 'post',							url: node.get('url'),							data: {								ajax: 'vendor',								id: node.get('value')							},							'link': 'ignore',											onSuccess: function(responseText) {								   $$('.category_id').set('html',responseText);								   $$('.catalog_id').set('html',"<option>Не выбран</option>");                   								   							},											onFailure: function(xhr) {							      alert('Ошибка')							}							});													AJAXpost.send();   });	 $$('.category_id').addEvent('change', function(event) {		            	var  node= this;		            	$$('.catalog_id').set('html',"<option>Идет загрузка...</option>");				         	var AJAXpost = new Request({			         		method: 'post',							url: node.get('url'),							data: {								ajax: 'category',								id: node.get('value'),								vendor_id:  $('vendor_id').get('value')							},							'link': 'ignore',											onSuccess: function(responseText) {								   $$('.catalog_id').set('html',responseText);                   				   							},											onFailure: function(xhr) {							      alert('Ошибка')							}							});													AJAXpost.send();   });	  //Если находимся на верхнем уровне подморгнем пользователю строкойif ($chk('serviceline')) {		            $$('.js-serviceline .js-item').addEvent('mouseenter', function(event) {      		              		     	     						   if (!this.hasClass('expand')) {						   this.set('morph', {duration: 200});								    this.morph({							   			'height': '400px'																		}); 																	this.addClass('expand');														  }     			            			        			             event.preventDefault();          		 }).addEvent('mouseleave', function(event) { 		          				this.morph({							   			'height': '10px'																	});																	this.removeClass('expand');		 		 });				     									 }; /*	window.onresize = santaclause;	function santaclause() { 	 if ($chk('santaclaus')) {			var wwidth=(window.innerWidth)?window.innerWidth: ((document.all)?document.body.offsetWidth:null); 	 	 	var  santaposition = (wwidth - 960)/2;	 	 	$('santaclaus').setStyle('right',santaposition);	 };    };   */}); 
