/* methods list packs */
var listPacks = {
	 
	// Method to sort by theme asc
	sortThemeAscHandler : function(thisObject,thatObject){
		if (thisObject.theme > thatObject.theme){
			return 1;
		}else if (thisObject.theme < thatObject.theme){
			return -1;
		}
		return 0;
	},
	
	// Method to sort by country asc
	sortCountryAscHandler : function(thisObject,thatObject){
		if (thisObject.geo_name > thatObject.geo_name){
			return 1;
		}else if (thisObject.geo_name < thatObject.geo_name){
			return -1;
		}
		return 0;
	},
	
	// Method to sort by country desc
	sortCountryDescHandler : function(thisObject,thatObject){
		if (thisObject.geo_name > thatObject.geo_name){
			return -1;
		}else if (thisObject.geo_name < thatObject.geo_name){
			return 1;
		}
		return 0;
	},
	
	// Method to sort by city
	sortCityAscHandler : function(thisObject,thatObject){
		if (thisObject.city_name > thatObject.city_name){
			return 1;
		}else if (thisObject.city_name < thatObject.city_name){
			return -1;
		}
		return 0;
	},
	
	//Method to sort by theme asc
	sortThemeAscHandler : function(thisObject,thatObject){
		if (thisObject.theme_name > thatObject.theme_name){
			return 1;
		}else if (thisObject.theme_name < thatObject.theme_name){
			return -1;
		}
		return 0;
	},
	
	//Method to sort by theme desc
	sortThemeDescHandler : function(thisObject,thatObject){
		if (thisObject.theme_name > thatObject.theme_name){
			return -1;
		}else if (thisObject.theme_name < thatObject.theme_name){
			return 1;
		}
		return 0;
	},
	
	//Method to sort by price asc
	sortAmountAscHandler : function(thisObject,thatObject){
		if (thisObject.amount > thatObject.amount){
			return 1;
		}else if (thisObject.amount < thatObject.amount){
			return -1;
		}
		return 0;

	},
	
	//Method to sort by price desc			
	sortAmountDescHandler : function(thisObject,thatObject){
		if (thisObject.amount > thatObject.amount){
			return -1;
		}else if (thisObject.amount < thatObject.amount){
			return 1;
		}
		return 0;
	},
	
	displayNbCities : function(nbCities, str){
		var s = {};
		s["%x"] = nbCities;		
		
		var re = /%./g;

		var a = str.match(re);
		for (var i = 0; i < a.length; i++) {
			var tmp = s[a[i]];
			if (tmp) {
				re = new RegExp(a[i], 'g');
				str = str.replace(re, tmp);
			}
		}
		return str;
	}
};

/* methods fill date */
var fillDate = {
	
	dateDeparture : "",
	dateArrival : "",
	validityStart : "",
	validityEnd : "",
	minDate : "",
	maxDate : "",
	handChange : false,
	days : new Array,
	type : '',
	currentSelect : '',
	
	//Method to return criteria stored in cookies
	getSearchArgs : function(criterias){
		tab_c = criterias.split('&');
		var tab = new Array();
		
		for(i=0; i<tab_c.length; i++){
			if(tab_c[i]){
				tempTab = tab_c[i].split('=');
				tab[tempTab[0]] = tempTab[1] ;
			}
		}
		return tab;
	},
	/**
	*	Method to return query string
	*/
	extractUrlParams : function(){
		var ancre = window.location.hash;
		if(ancre){
			var gets = ancre.substring(1, ancre.length);
			var t = gets.split('&');
			var f = [];
			
			for (var i=0; i<t.length; i++) {
			
				var x = t[ i ].split('=');
				
				f[x[0]]=x[1];
				
			}
			return f;
		}else {
			return null;	
		}
	},
	
	//Method to encode criteria and store it in cookies
	setSearchArgs : function(criterias){
		var str = new Array();
		
		for(var prop in criterias) {
			str.push(prop+'='+criterias[prop]);
		}
		return str.join("&");
	},
	
	
	//Method to return a number of element present in object	
	countObjs : function(obj){

		var count = 0;
		var tab = [];
		for(var prop in obj) {
			if(obj.hasOwnProperty(prop)){
				++count;
			}
		}
		return count;

	},
	
	// convert date in time
	convertDate : function(date){
		dateTab = date.split('/');
		dateTime  = new Date(dateTab[2],dateTab[1]-1,dateTab[0]);
		return dateTime.getTime();
	},
	// convert date +/- days in time
	convertDateTime : function(date,day){
		dateTab = date.split('/');
		if( parseInt(dateTab[0]) < 10){
			dateTab[0] = dateTab[0].substring(1, 2);
		}
		var difference = parseInt(dateTab[0]) + parseInt(day);	
		dateTime  = new Date(dateTab[2],dateTab[1]-1,difference);		
		return dateTime.getTime();
	},
	
	// convert date +/- days in date format d/m/y
	convertDateDate : function(date,day){
		dateTab = date.split('/');
		if( parseInt(dateTab[0]) < 10){
			dateTab[0] = dateTab[0].substring(1, 2);
		}
		
		var difference = parseInt(dateTab[0]) + parseInt(day);	
		dateTime  = new Date(dateTab[2],dateTab[1]-1,difference);		
		return fillDate.correctDate(dateTime.getDate())+"/"+ fillDate.correctDate(dateTime.getMonth()+1)+"/"+dateTime.getFullYear();
	},
	
	// test format of date
	testFormatDate : function(date){
		
		var tabD = date.split('/');
		var reg = new  RegExp(i18n.calendar.dateFormat);
		
		// test if year is bissextile
		if (tabD[2]%4==0 && tabD[2] %100!=0 || tabD[2]%400==0) {
			var d_Biss = 29;
		}else{
			var d_Biss= 28;
		}
		
		var tabMounths = new Array(31,d_Biss,31,30,31,30,31,31,30,31,30,31);
		
		if( parseInt(tabD[0]) < 10){
			tabD[0] = tabD[0].substring(1, 2);
		}
		if( parseInt(tabD[1]) < 10){
			tabD[1] = tabD[1].substring(1, 2);
		}
		
		if (!reg.test(date)) {
			return i18n.calendar.error;
		}else if(parseInt(tabD[0]) > tabMounths[parseInt(tabD[1]-1)] || parseInt(tabD[0]) <= 0  || tabD[1]<= 0 || tabD[2] <= 0 || parseInt(tabD[1]) >12){
			return i18n.calendar.error;
		}
	},
	
	// output html errors
	displayMessage : function(date, selector){
		if(date){
			testFormat = fillDate.testFormatDate(date);

			if(testFormat){
				selector.css('border','1px solid red');
				var html = '<div class="errorMessage validatorInvalidState tErrorMessage">'+testFormat+'</div>';

				if(jQuery('#bookingEngine .errorMessage').html() != null){
					jQuery('#bookingEngine .errorMessage').html(testFormat);
				}else{
					jQuery('#bookingEngine').prepend(html);
				}
				
			}else{
				//var tabdays = jQuery.datepicker.regional['fr']['dayNames'];
				jQuery('#bookingEngine .validatorInvalidState').remove();
				var date = selector.val();
				day = fillDate.getDateDay(date);	
				selector.prev().html(fillDate.days[day]);	
				selector.removeAttr('style');
			}
			
		}		
	},
	
	// return the day of date
	getDateDay : function(date){
		dateTab = date.split('/');
		dateTime  = new Date(dateTab[2],dateTab[1]-1,dateTab[0]);		
		return dateTime.getDay();
	},
	
	// correct date 
	correctDate : function(d){
		if(d<10){
			return d = '0' + d;	
		}else{
			return d;
		}
	},	
	
	// return inputs value of datepick
	checkInputs : function(){
		var dateNow = new Date();
		var dateDate = fillDate.correctDate(dateNow.getDate())+"/"+fillDate.correctDate(dateNow.getMonth()+1)+"/"+dateNow.getFullYear();
		var date = fillDate.convertDate(dateDate);
		
		var dateArrivalConv = fillDate.convertDate(fillDate.dateArrival);
		var dateDepartureConv = fillDate.convertDate(fillDate.dateDeparture );
		
		response = {
			arrival: { auto:[],min:[],max:[]},
			departure: { auto:[], min:[],max:[]}
				};
		
			// only arrival date entered manually < date of day	
			if(fillDate.convertDate(fillDate.dateArrival) < date || fillDate.convertDate(fillDate.dateDeparture) < date || (fillDate.convertDateTime(fillDate.dateDeparture, -fillDate.minDate) < date  && fillDate.convertDate(fillDate.validityStart) < date) || (fillDate.convertDate(fillDate.dateDeparture) < fillDate.convertDateTime(fillDate.validityStart, +fillDate.minDate)  && fillDate.convertDate(fillDate.validityStart) >= date) || (fillDate.convertDate(fillDate.dateArrival) < fillDate.convertDate(fillDate.validityStart)  && fillDate.convertDate(fillDate.validityStart) >= date)){
						
				if(fillDate.convertDate(fillDate.validityStart) >= date){
					response.arrival.auto = fillDate.validityStart;
					response.departure.auto = fillDate.convertDateDate(fillDate.validityStart, +fillDate.minDate);
					return response;
				}else{
					response.arrival.auto = dateDate;
					response.departure.auto = fillDate.convertDateDate(dateDate, +fillDate.minDate);
					return response;
				}
				
			
			}else if(fillDate.convertDate(fillDate.dateDeparture) >= date && fillDate.convertDate(fillDate.dateArrival) < fillDate.convertDate(fillDate.validityStart) ){
			
				response.arrival.auto = fillDate.validityStart;
				response.departure.auto = fillDate.convertDateDate(fillDate.validityStart, +fillDate.minDate);
				return response;
				
			}else{
				// only arrival date entered				
				if(fillDate.type == 'arrival'){
					// case 4 spec
					if( fillDate.convertDateTime(fillDate.dateArrival, +fillDate.minDate) > fillDate.convertDate(fillDate.validityEnd) || fillDate.convertDate(fillDate.dateDeparture) > fillDate.convertDate(fillDate.validityEnd)){

						response.arrival.auto = fillDate.convertDateDate(fillDate.validityEnd, -fillDate.minDate);
						response.departure.auto = fillDate.validityEnd;
						return response;
					}	

					if(dateArrivalConv >= fillDate.convertDate(fillDate.validityStart) && dateArrivalConv >= date){

						//case min = max
						if(fillDate.minDate == fillDate.maxDate ){	
							
							if(dateDepartureConv && dateDepartureConv < fillDate.convertDateTime(dateDate, +fillDate.minDate) ){
						
								response.arrival.auto   = dateDate;
								response.departure.auto = fillDate.convertDateDate(dateDate, +fillDate.minDate);
								return response;
							}
							if(fillDate.currentSelect == 'date_in'){
								response.arrival.auto   = fillDate.dateArrival;
								response.departure.auto = fillDate.convertDateDate(fillDate.dateArrival, +fillDate.minDate);
								return response;
							
							}else{
								response.arrival.auto = fillDate.convertDateDate(fillDate.dateDeparture, -fillDate.minDate);
								response.departure.auto = fillDate.dateDeparture;
								return response;
							}
						//case min != max
						}else{	
	
							// if user change departure date manually
							if((fillDate.dateDeparture &&  (((parseInt(fillDate.convertDate(fillDate.dateDeparture)) - parseInt(fillDate.convertDate(fillDate.dateArrival)))/(24*360*10000)) > fillDate.maxDate)) && dateDepartureConv <= fillDate.convertDate(fillDate.validityEnd)  ){
									
									if(fillDate.currentSelect == 'date_in'){
										response.arrival.auto = fillDate.dateArrival			
										response.departure.auto =fillDate.convertDateDate(fillDate.dateArrival, +fillDate.minDate);						
									}else{
										response.arrival.auto = fillDate.convertDateDate(fillDate.dateDeparture, -fillDate.minDate);						
										response.departure.auto = fillDate.dateDeparture
	
									}
						
								
							}else if( fillDate.convertDateTime(fillDate.dateArrival,+fillDate.minDate) > fillDate.convertDateTime(fillDate.validityStart, +fillDate.minDate) && fillDate.convertDateTime(fillDate.dateArrival, +fillDate.maxDate) < fillDate.convertDateTime(fillDate.validityStart, +fillDate.maxDate)){
								
								response.arrival.auto = fillDate.validityStart;
								response.departure.auto = fillDate.convertDateDate(fillDate.validityStart, +fillDate.minDate);
							}
							else if(fillDate.dateDeparture && dateDepartureConv <= fillDate.convertDate(fillDate.validityEnd)  &&  (((parseInt(fillDate.convertDate(fillDate.dateDeparture)) - parseInt(fillDate.convertDate(fillDate.dateArrival)))/(24*360*10000)) <= fillDate.maxDate) && (((parseInt(fillDate.convertDate(fillDate.dateDeparture)) - parseInt(fillDate.convertDate(fillDate.dateArrival)))/(24*360*10000)) >= fillDate.minDate)){

								response.arrival.auto = 0;						
								response.departure.auto = 0;
								
							}
							else{
							
								if(fillDate.currentSelect == 'date_in'){
									response.arrival.auto   = fillDate.dateArrival;
									response.departure.auto = fillDate.convertDateDate(fillDate.dateArrival, +fillDate.minDate);
									return response;
								}else{
									response.arrival.auto = fillDate.convertDateDate(fillDate.dateDeparture, -fillDate.minDate);
									response.departure.auto = fillDate.dateDeparture;
									return response;
								}
								
							}		
						}
						return response;
					}
				}
				
				// only dateDeparture date entered
				if(fillDate.type == 'departure'){

					// case 4 spec
						if( fillDate.convertDateTime(fillDate.dateArrival, +fillDate.minDate) > fillDate.convertDate(fillDate.validityEnd) || fillDate.convertDate(fillDate.dateDeparture) > fillDate.convertDate(fillDate.validityEnd)){

							response.arrival.auto   = fillDate.convertDateDate(fillDate.validityEnd, -fillDate.minDate);	
							response.departure.auto = fillDate.validityEnd;
							return response;

					}
					
					// case 3 spec
					if( dateDepartureConv <= fillDate.convertDate(fillDate.validityEnd) && 
						dateDepartureConv >= fillDate.convertDate(fillDate.validityStart) ){
							
							if(fillDate.minDate == fillDate.maxDate){
								if( dateDepartureConv < fillDate.convertDateTime(dateDate, +fillDate.minDate)){
									response.arrival.auto   = dateDate;
									response.departure.auto = fillDate.convertDateDate(dateDate, +fillDate.minDate);
									return response;
								}
								if(fillDate.currentSelect == 'date_out'){
									response.arrival.auto = fillDate.convertDateDate(fillDate.dateDeparture, -fillDate.minDate);
									response.departure.auto = fillDate.dateDeparture;
									return response;
								}else{
									response.arrival.auto = fillDate.dateArrival
									response.departure.auto = fillDate.convertDateDate(fillDate.dateArrival, +fillDate.minDate);
									return response;
								}
							}else{
								// if user change departure date manually
							
							if(dateDepartureConv <= fillDate.convertDate(fillDate.validityEnd)  && dateArrivalConv >= fillDate.convertDate(fillDate.validityStart) &&  (((parseInt(fillDate.convertDate(fillDate.dateDeparture)) - parseInt(fillDate.convertDate(fillDate.dateArrival)))/(24*360*10000)) <= fillDate.maxDate) && (((parseInt(fillDate.convertDate(fillDate.dateDeparture)) - parseInt(fillDate.convertDate(fillDate.dateArrival)))/(24*360*10000)) >= fillDate.minDate)){
								response.arrival.auto = 0;						
								response.departure.auto = 0;
							}
							else{

								if(fillDate.currentSelect == 'date_in'){
									response.arrival.auto   = fillDate.dateArrival;
									response.departure.auto = fillDate.convertDateDate(fillDate.dateArrival, +fillDate.minDate);
								}else{
									response.arrival.auto   = fillDate.convertDateDate(fillDate.dateDeparture, -fillDate.minDate);
									response.departure.auto = fillDate.dateDeparture;
									
								}
							}	
							return response;
						}
					}
					
					
				}	
			}
		
  		}
  
};

// scroll method
var scrolling = {
    speed:10,
	
	goTo : function(ancre){
    		jQuery('html,body').animate({scrollTop:jQuery(ancre).offset().top},scrolling.speed,'swing',function(){
         
            jQuery(ancre).attr('tabindex','-1');
            jQuery(ancre).focus();
            jQuery(ancre).removeAttr('tabindex');
        });
    }
};


/* Carrousel Plugin */

(function($) {

var types = ['DOMMouseScroll', 'mousewheel'];

jQuery.event.special.mousewheel = {
	setup: function() {
		if ( this.addEventListener )
			for ( var i=types.length; i; )
				this.addEventListener( types[--i], handler, false );
		else
			this.onmousewheel = handler;
	},
	
	teardown: function() {
		if ( this.removeEventListener )
			for ( var i=types.length; i; )
				this.removeEventListener( types[--i], handler, false );
		else
			this.onmousewheel = null;
	}
};

jQuery.fn.extend({
	mousewheel: function(fn) {
		return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
	},
	
	unmousewheel: function(fn) {
		return this.unbind("mousewheel", fn);
	}
});


function handler(event) {
	var args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true;
	
	event = jQuery.event.fix(event || window.event);
	event.type = "mousewheel";
	
	if ( event.wheelDelta ) delta = event.wheelDelta/120;
	if ( event.detail     ) delta = -event.detail/3;
	
	args.unshift(event, delta);

	return jQuery.event.handle.apply(this, args);
}

})(jQuery);

(function($) {
	 jQuery.fn.lofJSidernews = function( settings ) {
	 	return this.each(function() {
			// get instance of the SiderNews.
			new  jQuery.lofSidernews( this, settings ); 
		});
 	 }
	 jQuery.lofSidernews = function( obj, settings ){
		this.settings = {
			direction	    	: '',
			mainItemSelector    : 'li',
			navInnerSelector	: 'ul',
			navSelector  		: 'li' ,
			navigatorEvent		: 'click',
			wapperSelector: 	'.carrouselContent',
			interval	  	 	: 4000,
			auto			    : true, 
			maxItemDisplay	 	: 4,
			startItem			: 0,
			navPosition			: 'vertical', 
			navigatorHeight		: 47,
			navigatorWidth		: 231,
			duration			: 600,
			navItemsSelector    : '.carrouselNavigator li',
			navOuterSelector    : '.navigatorContainer' ,
			isPreloaded			: true
		}	
		
		jQuery.extend( this.settings, settings ||{} );	
		this.nextNo         = null;
		this.previousNo     = null;
		this.maxWidth  = this.settings.mainWidth || 422;
		this.wrapper = jQuery( obj ).find( this.settings.wapperSelector );	
		this.slides = this.wrapper.find( this.settings.mainItemSelector );
		if( !this.wrapper.length || !this.slides.length ) return ;
		// set width of wapper
		if( this.settings.maxItemDisplay > this.slides.length ){
			this.settings.maxItemDisplay = this.slides.length;	
		}
		this.currentNo      = isNaN(this.settings.startItem)||this.settings.startItem > this.slides.length?0:this.settings.startItem;
		this.navigatorOuter = jQuery( obj ).find( this.settings.navOuterSelector );	
		this.navigatorItems = jQuery( obj ).find( this.settings.navItemsSelector ) ;
		this.navigatorInner = this.navigatorOuter.find( this.settings.navInnerSelector );
		
		if( this.settings.navPosition == 'horizontal' ){ 
			this.navigatorInner.width( this.slides.length * this.settings.navigatorWidth );
			this.navigatorOuter.width( this.settings.maxItemDisplay * this.settings.navigatorWidth );
			this.navigatorOuter.height(	this.settings.navigatorHeight );
			
		} else {
			this.navigatorInner.height( this.slides.length * this.settings.navigatorHeight );	
			
			this.navigatorOuter.height( this.settings.maxItemDisplay * this.settings.navigatorHeight );
			this.navigatorOuter.width(	this.settings.navigatorWidth );
		}		
		this.navigratorStep = this.__getPositionMode( this.settings.navPosition );		
		this.directionMode = this.__getDirectionMode();  
		
		
		if( this.settings.direction == 'opacity') {
			this.wrapper.addClass( 'lof-opacity' );
			jQuery(this.slides).css('opacity',1).eq(this.currentNo).css('opacity',1);
			this.caption = jQuery( obj ).find( '.lof-main-item-desc' );
			jQuery( obj ).find( '.lof-main-item-desc' ).hide().eq(0).show();
		} else { 
			this.wrapper.css({'left':'-'+this.currentNo*this.maxSize+'px', 'width':( this.maxWidth ) * this.slides.length } );
		}

		
		if( this.settings.isPreloaded ) {
			this.preLoadImage( this.onComplete );
		} else {
			this.onComplete();
		}
		
	 }
     jQuery.lofSidernews.fn =  jQuery.lofSidernews.prototype;
     jQuery.lofSidernews.fn.extend =  jQuery.lofSidernews.extend = jQuery.extend;
	 
	 jQuery.lofSidernews.fn.extend({
							  
		startUp:function( obj, wrapper ) {
			seft = this;
			this.navigatorItems.each( function(index, item ){
				jQuery(item).click( function(){
					if(jQuery(this).attr("class") == "desabled" || jQuery(this).attr("class") == "active") return;
					jQuery(this).removeClass("desabled").siblings("li").addClass("desabled");				
					seft.jumping( index, true );
					seft.setNavActive( index, item );					
					seft.stop()
				} );
				
				jQuery(item).css( {'height': seft.settings.navigatorHeight, 'width':  seft.settings.navigatorWidth} );
				jQuery(item).hover( function(){
					jQuery(this).children("span.title ").css("text-decoration","underline")
				},function(){
					jQuery(this).children("span.title ").css("text-decoration","none")
					} );

			})
		//	this.registerWheelHandler( this.navigatorOuter, this );
			this.setNavActive(this.currentNo );
			
			if( this.settings.buttons && typeof (this.settings.buttons) == "object" ){
				this.registerButtonsControl( 'click', this.settings.buttons, this );

			}
			if( this.settings.auto ) 
			this.play( this.settings.interval,'next', true );
			
			return this;
		},
		onComplete:function(){
			setTimeout( function(){ jQuery('.preload').fadeOut( 900 ); }, 400 );	this.startUp( );
		},
		preLoadImage:function(  callback ){
			var self = this;
			var images = this.wrapper.find( 'img' );
	
			var count = 0;
			images.each( function(index,image){ 
				if( !image.complete ){				  
					image.onload =function(){
						count++;
						if( count >= images.length ){
							self.onComplete();
						}
					}
					image.onerror =function(){ 
						count++;
						if( count >= images.length ){
							self.onComplete();
						}	
					}
				}else {
					count++;
					if( count >= images.length ){
						self.onComplete();
					}	
				}
			} );
		},
		navivationAnimate:function( currentIndex ) { 
			if (currentIndex <= this.settings.startItem 
				|| currentIndex - this.settings.startItem >= this.settings.maxItemDisplay-1) {
					this.settings.startItem = currentIndex - this.settings.maxItemDisplay+2;
					if (this.settings.startItem < 0) this.settings.startItem = 0;
					if (this.settings.startItem >this.slides.length-this.settings.maxItemDisplay) {
						this.settings.startItem = this.slides.length-this.settings.maxItemDisplay;
					}
			}		
			this.navigatorInner.stop().animate( eval('({'+this.navigratorStep[0]+':-'+this.settings.startItem*this.navigratorStep[1]+'})'), 
												{duration:500} );	
		},
		setNavActive:function( index, item ){
			if( (this.navigatorItems) ){ 
				this.navigatorItems.removeClass( 'active' );
				jQuery(this.navigatorItems.get(index)).addClass( 'active' );	
				this.navivationAnimate( this.currentNo );	
			}
		},
		__getPositionMode:function( position ){
			if(	position  == 'horizontal' ){
				return ['left', this.settings.navigatorWidth];
			}
			return ['top', this.settings.navigatorHeight];
		},
		__getDirectionMode:function(){
			switch( this.settings.direction ){
				case 'opacity': this.maxSize=0; return ['opacity','opacity'];
				default: this.maxSize=this.maxWidth; return ['left','width'];
			}
		},
		registerWheelHandler:function( element, obj ){ 
			 element.bind('mousewheel', function(event, delta ) {
				var dir = delta > 0 ? 'Up' : 'Down',
					vel = Math.abs(delta);
				if( delta > 0 ){
					obj.previous( true );
				} else {
					obj.next( true );
				}
				return false;
			});
		},
		registerButtonsControl:function( eventHandler, objects, self ){ 
			for( var action in objects ){ 
				switch (action.toString() ){
					case 'next':
						objects[action].click( function() { self.next( true) } );
						break;
					case 'previous':
						objects[action].click( function() { self.previous( true) } );
						break;
				}
			}
			return this;	
		},
		onProcessing:function( manual, start, end ){	 		
			this.previousNo = this.currentNo + (this.currentNo>0 ? -1 : this.slides.length-1);
			this.nextNo 	= this.currentNo + (this.currentNo < this.slides.length-1 ? 1 : 1- this.slides.length);				
			return this;
		},
		finishFx:function( manual ){
			if( manual ) this.stop();
			if( manual && this.settings.auto ){ 
				this.play( this.settings.interval,'next', true );
			}		
			this.setNavActive( this.currentNo );	
		},
		getObjectDirection:function( start, end ){
			return eval("({'"+this.directionMode[0]+"':-"+(this.currentNo*start)+"})");	
		},
		fxStart:function( index, obj, currentObj ){
				if( this.settings.direction == 'opacity' ) { 
					jQuery(this.slides).stop().animate({opacity:'toogle', height:200}, {duration: this.settings.duration} );
					jQuery(this.slides).eq(index).stop().animate( {opacity:'show', height:200}, {duration: this.settings.duration} );
					
				}else {
				/*	jQuery(this.slides).find('.content').css({
											  'filter' : 'alpha(opacity=60)',
											  '-moz-opacity' : 0.6,
											  'opacity' : 0.6									  
											  });
    
     
*/
					jQuery(this.slides).stop().animate({
height:190, opacity: "hide"
}, 800);
					jQuery(this.slides).eq(index).stop().animate({
height:190, opacity: "show"
}, 800, function(){jQuery(".carrouselNavigator li").removeClass("desabled")});
				}
				
			return this;
		},
		jumping:function( no, manual ){
			this.stop(); 
			if( this.currentNo == no ) return;		
			 var obj = eval("({'"+this.directionMode[0]+"':-"+(this.maxSize*no)+"})");
			this.onProcessing( null, manual, 0, this.maxSize )
				.fxStart( no, obj, this )
				.finishFx( manual );	
				this.currentNo  = no;
		},
		next:function( manual , item){

			this.currentNo += (this.currentNo < this.slides.length-1) ? 1 : (1 - this.slides.length);	
			this.onProcessing( item, manual, 0, this.maxSize )
				.fxStart( this.currentNo, this.getObjectDirection(this.maxSize ), this )
				.finishFx( manual );
		},
		previous:function( manual, item ){
			this.currentNo += this.currentNo > 0 ? -1 : this.slides.length - 1;
			this.onProcessing( item, manual )
				.fxStart( this.currentNo, this.getObjectDirection(this.maxSize ), this )
				.finishFx( manual	);			
		},
		play:function( delay, direction, wait ){	
			this.stop(); 
			if(!wait){ this[direction](false); }
			var self  = this;
			this.isRun = setTimeout(function() { self[direction](true); }, delay);
		},
		stop:function(){ 
			if (this.isRun == null) return;
			clearTimeout(this.isRun);
            this.isRun = null; 
		}
	})
})(jQuery)
