/* The Range Comparator V2 */

//Globale
var RangeComparator = new Class({
	initialize : function(){
		this.frieze = new Frieze();
		this.cars = new CarsManager(this);
		this.loader = new Loader();
		this.criterias = new CriteriasPref(this);
		
		/*temporaire*/
		//evenements
		this.rcEvents = new SetEvents(this);
		
		//toggles
		this.initToggleCriterias();
		
		//Alignement Colonnes
		this.initColumnsAlign();
	},
	initColumnsAlign : function(){
		this.oLeftSide = document.getElement('.colLeft ul.toggleList');
		this.oRightSide = $('rangeComparator');
		this.oRightSide.frieze = this.oRightSide.getElement('div.tablePrix');
		this.oRightSide.ul = this.oRightSide.getElement('ul.listeRangeCar');

		
		this.columnsEffect = new Fx.Style(this.oRightSide, 'height',{duration:200});
		this.columnsAlign();
	},
	columnsAlign : function(){
		//alignement colonnes
		var newHeight = this.oLeftSide.offsetHeight;
		this.min = this.oRightSide.ul.offsetHeight;
		this.columnsEffect.start((newHeight<this.min.toInt()) ? this.min.toInt() : newHeight);
		
	},
	initToggleCriterias : function(){
		var _self = this;
		//gestion des toggles anim�s des crit�res
		var togglers = document.getElements('ul.toggleList .title');
 		togglers.each(function(toggler){
			var togglerCtt = getNextSibling(toggler, {nodeName:"div", className:"body"});
			if (!togglerCtt)
				return;
			var togglerCtn = toggler.getParent('li');
			var mySlide = new Fx.Slide(togglerCtt, {
				duration:300,
				onComplete :function(){
					_self.columnsAlign();
				}
			});
			mySlide.wrapper.addClass('toggleWrapper');
			if(togglerCtn.hasClass('closed')) mySlide.hide();
			toggler.addEvent('click', function(e){
				togglerCtn.hasClass('closed') ? togglerCtn.removeClass('closed') : togglerCtn.addClass('closed');
				e = new Event(e);
				mySlide.toggle();
				e.stop();
			});
		});
		
	}
})

var SetEvents = new Class({
	initialize : function(range){
		this.range = range;
		var _self = this;
		//evenements application
		this.onglets = $('frise').getElements('.liensOnglets');
		this.onglets.each(function(elm, i){
			elm.addEvent('click',function(e){
				_self.onglets.removeClass('actived');
				elm.addClass('actived');
				
				if(e)
					new Event(e).stop();
				_self.axisName = this.rel;
				_self.url = config.url +'&axisCode=' + this.rel;
				_self.remote(_self.url);
				
			})
			if(i == 0) elm.fireEvent('click');
		})
		
		this.fundingActions();
	},
	fundingActions:function(){
		var _self = this;
		//evenements refresh maxprice
		$('razFin').addEvent('click',function(e){
			if(e) new Event(e).stop();
			_self.remoteLimited();
			
			//remise a zero des preferences
			_self.range.criterias.preferences.option = {};
			_self.range.criterias.preferences.maxUserPrice = 0;
			$('budget').removeClass('sliderBoxUniver');
			$('financement').removeClass('sliderBoxUniver');

		})

		$('budget').getElement('a.bouton').addEvent('click',function(e){
			if(e) new Event(e).stop();
			var maxPrice = $('middlePrice').getText().toInt();
			_self.remoteLimited(maxPrice);
		})
		$('financement').getElement('a.bouton').addEvent('click',function(e){
			if(e) new Event(e).stop();
			var deposit = $('deposit').getText().toInt();
			var monthly = $('monthly').getText().toInt();

			computePriceRange(monthly, 60, deposit, 'VN');

			//
			// titre bien connu de MC solaar
			//

			// TODO : use the default computePriceRange(..) function from component-finance
			function computePriceRange (monthlyPayment, duration, deposit, type) {
					var url = [componentFinanceLib.parameters.computePriceRangeUrl, "&type=", type, "&monthlyPayment=", monthlyPayment, "&duration=", duration, "&deposit=",deposit].join('');
			        new Ajax(url, {
						method: 'get',
						onComplete : function(xhr){
							var response = Json.evaluate(xhr);
							_self.remoteLimited(response.upperPrice.toInt());
						}
					}).request();
			    }
		})
	},
	remote :function(url){
		var _self = this;
		var maxUserPrice = this.range.criterias.preferences.maxUserPrice;
		var myAjax = new Ajax(url, {
			method: 'get',
			data : 'maxUserPrice=' + (maxUserPrice ? maxUserPrice : 0),
			onRequest : function() {
				_self.range.loader.show();
			},
			onSuccess:function(obj){
				var response = Json.evaluate(obj);
				_self.range.frieze.setFrieze(response);
				_self.range.cars.setCars(response);
			},
			onComplete:function(){
				_self.range.loader.hide();
			},
			onFailure:function(){
			}
		}).request();

	},
	remoteLimited : function(maxUserPrice){
		var _self = this;
		if (!maxUserPrice){
			maxUserPrice = 0;
		}else{
			this.range.criterias.preferences.maxUserPrice = maxUserPrice;
		}
		var myAjax = new Ajax(_self.url, {
			method: 'get',
			data : 'maxUserPrice=' + maxUserPrice,
			onRequest : function() {
				_self.range.loader.show();
			},
			onSuccess:function(obj){
				var response = Json.evaluate(obj);
				initSIC(response.values);
				//on check les preferences
				_self.range.criterias.doRemoteAction();
			},
			onComplete:function(){
				_self.range.loader.hide();
			},
			onFailure:function(){
			}
		}).request();
	}
})

//gestion preferences entre axes
var CriteriasPref = new Class({
	initialize : function(range){
		this.range = range;
		this.togList = $('main').getElement('.toggleList');
		this.inputs = this.togList.getElements('input');
		this.preferences = {};
		this.preferences.option = {};
		
		this.inputs.each(function(input){
			input.addEvent('click',function(e){
				if (e)
					new Event(e).stop();
				this.clickAction(input);
				selectCritere(input.getAttribute('rel'));
			}.bind(this))
		}.bind(this))
	},
	clickAction : function(input){
		if (this.preferences.option[input.getAttribute('groupName')] == input){
			delete this.preferences.option[input.getAttribute('groupName')];
		}else{
			this.preferences.option[input.getAttribute('groupName')] = input;
		}
	},
	doRemoteAction : function(){
		var _self = this;
		for (i in this.preferences.option){
			selectCritere(this.preferences.option[i].getAttribute('rel'));
		}
		//_self.range.cars.updateCars.delay(2000, _self.range.cars(), currTarifs)
		var delayFunc = (function(){_self.range.cars.updateCars(currTarifs)}).delay(100);
		
	}
	
})

//Voitures
var CarsManager = new Class({
	
	initialize : function(range){
		this.range = range;
		this.oList = $('rangeComparator').getElement('ul.listeRangeCar');
		this.oEls = this.oList.getElements('li.oneCar');
		this.aCarsLayers = [];
		this.bFirstLaunch = true;
	},
	
	setCars : function(oFlow){
		if(!oFlow) return;
		this.low = oFlow.axis.low;
		this.high = oFlow.axis.high;
		this.fRuleOfThreeValues = this.oList.offsetWidth / (this.high - this.low);
		this.values = oFlow.values;
		this.aCars = [];
		oFlow.axis.code != 'PRICE_AXIS' ? this.friezeLabel = oFlow.axis.label : this.friezeLabel = null;
		this.friezeUnit = oFlow.axis.unit;
		var bSingleValued = oFlow.axis.singleValued;
		initSIC(oFlow.values);
		var _self = this;
		
		//on check les preferences
		this.range.criterias.doRemoteAction();
		if(typeof currTarifs != 'undefined') {
			var iIndex=config.iStartMatrixIndex;
			var time = (function(){
				var oCurrTarif = currTarifs[iIndex];
				var oCurrTarifFiltered = {
					minFmt:this.valuesInPixels(oCurrTarif.min),
					maxFmt:this.valuesInPixels(oCurrTarif.max),
					min: oCurrTarif.min,
					max:oCurrTarif.max,
					price:oCurrTarif.price,
					aboveLimit:oCurrTarif.abovelimit
				};
				var oCar = new Car(this,bSingleValued, this.oEls[iIndex - config.iStartMatrixIndex]);

				if (this.bFirstLaunch)
					var layer = new Layer(this.oEls[iIndex - config.iStartMatrixIndex], oCurrTarif.price);

				if (this.aCarsLayers[iIndex - config.iStartMatrixIndex]){
					this.aCarsLayers[iIndex - config.iStartMatrixIndex].hide();
				}else{
					oCar.layer = layer;
					this.aCarsLayers.push(layer);
				}

				this.aCars.push(oCar);
				oCar.update(oCurrTarifFiltered);
				oCar.limitCar(oCurrTarifFiltered);
				//ajout informations relatives au prix dans le layer
				this.aCarsLayers[iIndex - config.iStartMatrixIndex].populate.delay(500, this.aCarsLayers[iIndex - config.iStartMatrixIndex] , [oCurrTarif, this.friezeLabel, this.friezeUnit]);

				iIndex++;
				if (iIndex == currTarifs.length){
					$clear(time);
					this.bFirstLaunch = false;
				}
			}).periodical(30,this,iIndex)
		}
		
		
	},
	
	updateCars: function(currTarifs) {
		var _self = this;
		
		function doActions(){
			if(typeof currTarifs != 'undefined') {
				for (var iIndex=0; iIndex<_self.aCars.length; iIndex++){
					var oCurrTarif = currTarifs[iIndex + config.iStartMatrixIndex];

					var oCurrTarifFiltered = {
						minFmt:_self.valuesInPixels(oCurrTarif.min),
						maxFmt:_self.valuesInPixels(oCurrTarif.max),
						min: oCurrTarif.min,
						max:oCurrTarif.max,
						price:oCurrTarif.price,
						aboveLimit:oCurrTarif.abovelimit
					};
					//ajout informations relatives au prix dns le layer
					_self.aCarsLayers[iIndex].populate(oCurrTarif, _self.friezeLabel, _self.friezeUnit);
					_self.aCars[iIndex].update(oCurrTarifFiltered);
					_self.aCarsLayers[iIndex].hide(oCurrTarif.price);

					//mise a jour Makolab
					_self.aCarsLayers[iIndex].updateMakolabOffer(oCurrTarif.price);

					_self.aCars[iIndex].limitCar(oCurrTarifFiltered);
				}
			}
		}
		if (exchangeRateDef.enabled){
			secondaryPrices.setSecondaryPrices(doActions);
		}else{
			doActions();
		}
		
	},
	valuesInPixels:function(value){
		return (this.fRuleOfThreeValues * value) - (this.low * this.fRuleOfThreeValues);
	}
});


// Voiture
var Car = new Class({

	initialize: function(parent, bSingleValued, oCurrentCar) {
		this.HTMLElement = oCurrentCar;
		this.HTMLElement.statusBar = this.HTMLElement.getElement('div.status');
		this.HTMLElement.opacDiv = this.HTMLElement.getElement('div.opacityDivs');
		this.carEffect = new Fx.Elements([this.HTMLElement.statusBar, this.HTMLElement.opacDiv], {
			duration: 500,
			transition: Fx.Transitions.Quad.easeOut
		});
		this.bSingleValued = bSingleValued;
		this.carsManager = parent;
		if (parent.bFirstLaunch)
			this.valignlabel();
	},
	
	valignlabel: function() {
		var oCarLabel = this.HTMLElement.getElement('h5');
		var oCarLabelSpan = oCarLabel.firstChild;
		//on calcul la position en fonction du passage sur deux lignes ou non pour
		var topToUse = (oCarLabel.offsetHeight - oCarLabelSpan.offsetHeight) /2;
		if (topToUse > 0) $(oCarLabelSpan).setStyle('padding-top', topToUse);
	},
	
	update: function(oCurrTarif) {
		if (oCurrTarif.min == -2 || oCurrTarif.min == -1) return;
		if (isNaN(oCurrTarif.minFmt)) oCurrTarif.minFmt = 0;
		if (isNaN(oCurrTarif.maxFmt)) oCurrTarif.maxFmt = 0;
		
		var fLeft = oCurrTarif.minFmt;
		var fWidth = 0;
		if(this.bSingleValued){
			this.HTMLElement.addClass('priceMode');
			fWidth = 0;
		}else if(!this.bSingleValued){
			this.HTMLElement.removeClass('priceMode');
			fLeft = oCurrTarif.minFmt;
			fWidth = oCurrTarif.maxFmt - oCurrTarif.minFmt;
			fWidth = (fWidth == 0 || isNaN(fWidth))  && oCurrTarif.minFmt > 0 ? 3 : fWidth;
		}
		//le (-1) correspond � la bordure de la barre � annuler pr le rendu graphique
		this.carEffect.start({
			'0': {
			    'margin-left' : fLeft -1,
				'width' : fWidth
			},
			'1': {
		        'margin-left' : fLeft -1,
				'width' : fWidth
		    }
		});
	},
	limitCar: function(oCurrTarif){
		if (oCurrTarif.min == -1){
			this.HTMLElement.addClass('noData');
		}else if (oCurrTarif.aboveLimit || oCurrTarif.minFmt == 0){
			this.HTMLElement.addClass('unactive');
		}else{
			this.HTMLElement.removeClass('unactive');
			this.HTMLElement.removeClass('noData');
		}
	}
});

var Layer = new Class({
	initialize: function(oCar, fPrice){
		this.oCar = oCar;
		this.fPrice = fPrice;
		this.oCarLabel = oCar.getElement('h5');
		this.oCarValuesBar = oCar.getElement('div.blockFilledUniverse');
		this.oLayer = this.oCar.getElement('div.layer');
		this.oLayer.contentLayerPart = this.oLayer.getElement('div.contentLayerPart');
		this.oLayer.upZonePrix = this.oLayer.getElement('div.upZone span.prix');
		this.oLayer.moreInfos = this.oLayer.getElement('div.upZone p.moreInfos');
		this.oLayer.mak = this.oLayer.getElement('p.miniLoader span');
		this.hasMakolabOffer = false
		this.layerOpen = false;
		if (!window.$tmp) window.$tmp={};
		this.carEvent();
	
	},
	carEvent : function(){
		var _self = this;
		this.oCarValuesBar.removeEvents('click');
		this.oCarValuesBar.addEvent('click', (function(e){
			new Event(e).stop();
			if (!this.layerOpen){
				this.show();
				this.populateMakolabOffer();
			}else{
				this.hide();
			}
		}).bind(this));
	},
	show : function(){
		if(this.oCar.hasClass('noData')) return;
		if(window.$tmp.openedLayer) {
			window.$tmp.openedLayer.hide();
		}
		this.layerOpen = true;
		this.oLayer.effect('height',{
			duration:230,
			onComplete : function(){
				rangeComp.columnsAlign();
			}
		}).start(config.layerHeight);
		window.$tmp.openedLayer = this;
		this.oCarLabel.addClass('opened');
	},
	hide : function(){
		var _self = this;
		this.layerOpen = false;
		this.oLayer.effect('height',{
			duration:230,
			onComplete : function(){
				rangeComp.columnsAlign();
			}
		}).start(0);
		if(window.$tmp.openedLayer) {
			delete window.$tmp.openedLayer;
		}
		this.oCarLabel.removeClass('opened');
		
	},
	populate :function(oCurrTarif, friezeLabel, friezeUnit){
		this.oLayer.contentLayerPart.className = 'contentLayerPart';
		if (oCurrTarif && friezeLabel != null){
			if (oCurrTarif.max > oCurrTarif.min){
				this.oLayer.moreInfos.setText(friezeLabel + ' : ' + oCurrTarif.fmtmin + ' > ' + oCurrTarif.fmtmax + ' ' + friezeUnit);
			}else{
				this.oLayer.moreInfos.setText(friezeLabel + ' : ' + oCurrTarif.fmtmin + ' ' + friezeUnit);
			}
		}
		if(friezeLabel == null){
			this.oLayer.contentLayerPart.addClass('noInfos');
		}
		if (oCurrTarif.abovelimit){
			this.oLayer.contentLayerPart.addClass('infoUn');
		}
		if(!oCurrTarif.fmtmin){
			this.oLayer.contentLayerPart.addClass('infoDeux');
		}
		if (oCurrTarif){
			this.oLayer.upZonePrix.setText(oCurrTarif.fmtprice);
			if (exchangeRateDef.enabled){
				this.oLayer.upZonePrix.innerHTML += '<span>'+ oCurrTarif.fmtpriceSec +'</span>'
			}
		}
		
	},
	populateMakolabOffer:function(){
		//ajout Makolab offer
		if (this.hasMakolabOffer == false){
			updateFinanceMakolab(this.oCar, this.fPrice);
		}
	},
	updateMakolabOffer:function(fPriceUpdated){
		//suppression Makolab offer
		if (fPriceUpdated && fPriceUpdated != this.fPrice){
			this.fPrice = fPriceUpdated;
			this.hasMakolabOffer = false;
		}
	}
})


var Frieze = new Class({
	initialize : function(){		
		this.frieze = $('rangeComparator');
		this.steps = this.frieze.getElements('div.col');
		this.diffSteps = true;
	},
	setFrieze : function(obj){
		var _self = this;
		if(this.stepCount == obj.axis.stepCount){
			this.diffSteps = false;
		}else{
			this.diffSteps = true;
			this.stepCount = obj.axis.stepCount;
		}
		this.axis = config.axisArray[obj.axis.code];
		
		//calcul de la largeur de chaque step
		this.stepsWidth = config.friezeWidth / this.stepCount;
		if (exchangeRateDef.enabled && !!this.axis.axis.match(/PRICE/)){
			this.axisSec  = [];
			for (var i=0; i < this.axis.steps.length; i++) {
				var it = this.axis.steps[i];
				this.axisSec.push(it.fmtStep);
			};
			new remoteSecondaryPrice(this.axisSec, function(newPrices){
				for (var i=0; i < _self.axis.steps.length; i++) {
					_self.axis.steps[i]['fmtStepSec'] = newPrices[i];
				};
			})
		}
		
		
		
		
		
		var widthToGo = this.stepsWidth.toInt() - 1;
		//gestion de la largeur des steps
		this.steps.each(function(elm, index){
			
			if(index < _self.stepCount - 1){
				elm.className = 'col';
			}else if(index > _self.stepCount - 1){
				elm.className = 'col hidden';
				return;
			}
			if(_self.diffSteps == true){
				elm.effect('width',{
					onComplete:function(){
						if(index == _self.stepCount - 1){
							elm.className = 'col colLast';
						}
						_self.setLegend(elm, index, widthToGo);
					}
				}).start(widthToGo);
			}
			//ajout de la l�gende
			
			
			_self.setLegend(elm, index, widthToGo);
		})
	},
	setLegend : function(elm, index, widthToGo){
		if (index<this.axis.steps.length && !index==0)  {
			elm.getElement('h5').setText(this.axis.steps[index].fmtStep);
			if (exchangeRateDef.enabled && this.axis.steps[index].fmtStepSec) elm.getElement('h5').adopt(new Element('span').setText(this.axis.steps[index].fmtStepSec))
			var stepTitle = elm.getElement('h5');
			stepTitle.style.width = widthToGo + 'px';
			stepTitle.style.right = stepTitle.clientWidth/2 + 'px';
		}
	}
})

var ScrollTabs = new Class({
	initialize:function(){
		this.oScroller = $('titleTabs');
		this.oScroller.container = this.oScroller.getElement('div.scrollCtn');
		this.oScroller.links = this.oScroller.getElements('a.arrows');
		this.oScroller.liste = this.oScroller.getElement('ul');
		this.oScroller.titles = this.oScroller.getElements('ul li');
		this.fNewWidth = 0;
		
		this.setActions();
	},
	setActions:function(){
		var _self = this;
		this.oScroller.container.setStyle('width', this.oScroller.offsetWidth - (this.oScroller.links[0].offsetWidth*2) -10);//10 to resolve a bug
		
		this.oScroller.titles.each(function(oTitle,index){
			this.fNewWidth += oTitle.offsetWidth;
		}.bind(this))
		this.oScroller.liste.setStyle('width', this.fNewWidth);		
		
		this.scroll = new Fx.Scroll(this.oScroller.container, {
			duration:500,
			onStart:function(){
				_self.oScroller.links.removeClass('noArrow');
			},
			onComplete : function(){
				if (_self.oScroller.container.scrollLeft == 0){
					_self.oScroller.links[0].addClass('noArrow');
				}else if(_self.oScroller.container.scrollWidth == _self.oScroller.container.scrollLeft + _self.oScroller.container.offsetWidth){
					_self.oScroller.links[1].addClass('noArrow');
				}
			}
		});
		this.oScroller.titles.each(function(onglet){
			onglet.addEvent('mousedown',function(e){
				onglet.blur();
				new Event(e).stop();
				if (onglet.offsetLeft + onglet.offsetWidth > this.oScroller.container.offsetWidth){
					this.goRight();
				}
				
				
			}.bind(this))
			this.setTwoLinesIfNeeded(onglet);
		}.bind(this))
		
		this.oScroller.links[0].addEvent('click',function(e){
			this.oScroller.links[0].blur();
			new Event(e).stop();
			this.goLeft();
		}.bind(this));
		
		this.oScroller.links[1].addEvent('click',function(e){
			this.oScroller.links[1].blur();
			new Event(e).stop();
			this.goRight();
		}.bind(this));
	},
	goRight:function(){
		for (var i=0; i < this.oScroller.titles.length; i++) {
			var elm = this.oScroller.titles[i];
			if (this.oScroller.container.scrollLeft + this.oScroller.container.offsetWidth < elm.offsetWidth + elm.offsetLeft){
				this.elmToGo = elm;
				break;
			}else{
				this.elmToGo = elm.getNext()
			}
		};
		if (this.elmToGo) this.scroll.toElement(this.elmToGo);
	},
	goLeft:function(){
		this.elmToGoLeft = null;
		for (var i=0; i < this.oScroller.titles.length; i++) {
			var elm = this.oScroller.titles[i];
			if (elm.offsetLeft > this.oScroller.container.scrollLeft - this.oScroller.container.offsetWidth){
				this.elmToGoLeft = elm;
				break;
			}
		};
		if (this.elmToGoLeft){
			this.scroll.toElement(this.elmToGoLeft)
		} else {
			this.scroll.toLeft();
		}
	},
	setTwoLinesIfNeeded : function(o){
		
		if (o.offsetWidth > 100){
			var _oSpan = o.getElement('span');
			var _text = _oSpan.innerHTML;
			_oSpan.innerHTML = _text.replace(/ /, '<br />');
			//ajout classe
			o.addClass('twolines');
			
		}
	}
})


var Loader = new Class({
	initialize : function(){
		this.eLoader = $('rangeDataLoader');
	},
	show : function(){
		//affichage
		this.eLoader.style.display = 'block';
	},
	hide : function(){
		//cachage
		this.eLoader.style.display = 'none';
	}
})
var secondaryPrices = {
	setSecondaryPrices : function(callFunc){
		var _self = this;
		this.aPricesToPost = [];
		this.explorePrice(currTarifs);
		new remoteSecondaryPrice(this.aPricesToPost, function(newPrices){
			_self.mergePrices(newPrices, currTarifs);
			if (callFunc) callFunc();
		})
		
	},
	explorePrice : function(data){
		for (key in data){
			if (key == 'fmtprice'){
				this.aPricesToPost.push(data[key]);
			}else{
				if (typeof data[key] != 'function' && typeof data[key] != 'string' && typeof data[key] != 'number'){
					this.explorePrice(data[key]);
				}
			}
		}

	},
	mergePrices : function(aPrices, data){
		for (key in data){
			if (key == 'fmtprice'){
				data[key + 'Sec'] = aPrices[0];
				aPrices.shift();
			}else{
				if (typeof data[key] != 'function' && typeof data[key] != 'string' && typeof data[key] != 'number'){
					this.mergePrices(aPrices, data[key]);
				}
			}
		}
	}
}

var remoteSecondaryPrice = new Class({
	initialize : function(parameters, callBack, url){
		this.parameters = parameters;
		this.callBack = callBack ? callBack : null;
		this.urlParams = '?json=true&';
		this.url = url ? url : '/includes/conversion_price.jsp';
		this.not = [];
		if (typeof parameters == 'string' || typeof parameters == 'number'){
			this.urlParams += 'prices=' + parameters
		}else{
			for (var i=0; i < parameters.length; i++) {
				if (!!!parameters[i] || parameters[i] == -1){
					this.not.push(i);
					parameters[i] = 0;
				}
				this.urlParams += 'prices=' + parameters[i] + '&';
			};
		}
		this.send();
	},
	send : function(){
		var _this = this;
		new Ajax(this.url + this.urlParams, {
			method : 'get',
			onComplete : function(response){
				
				var response = eval(response);
				for (var i=0; i < _this.not.length; i++) {
					response[_this.not[i]] = null;
				};
				if (_this.callBack) _this.callBack(response);
			}
		}).request()
	}
})

window.addEvent('domready', function(){
	rangeComp = new RangeComparator();	
	
	new ScrollTabs();
})
window.addEvent('load', function(){
	$('rangeComparator').effect('opacity').start(1)
})
