/**
 * mouratimmobilier.fr
 * 
 * Main script
 *
 * @author		SOMARE Ludovic <webmaster@mouratimmobilier.fr>
 * @version		1
 *
 * @copyright	2010 - 211 © mouratimmobilier.fr
 *
 */
 
// --------------------------------------------------------------------

/**
 * Main Class
 *
 * @access 	public
 * @lang 		object (lang lines)
 * @forms		object (save forms created)
 * @alerts	object (save alerts created)
 * @Tips		object (save tips created)
 */
var mi = {
	config:			false,
	lang: 			false,
	forms: 			{}, //Forms data
	alerts: 		{}, //Alerts data
	tips: 			{}, //Tips data
	inputInfo:	[], //Input empty info data
	
	/*--------------------------------
	| Init "mi class"
	--------------------------------*/
	init: function() {
		
		//Init language
		this.lang = mi.language.init( mi.config.language );
		
		//Ajax
		$.ajaxSetup({
			beforeSend: function (jqXHR) {
				if (this.url.indexOf("http://") == -1)
					this.url = mi.config.baseUrl + this.url;
			},
			
			error: function (XMLHttpRequest, textStatus, errorThrown) {
				if ( ! mi.config.debug)
					return false;
					
				var form = "";
				
				if (typeof(selfForm) != 'undefined')
					form = ' (' +selfForm.opts.formId + ')';
				
				alert('Ajax' + form + ' error ! (' + textStatus + ') : ' + XMLHttpRequest.responseText);	
			}
		});
		
		//Init anchor anim
	  var anchor = window.location.hash; 		//anchor with the # character - .substring(1) del #
   	if (anchor != '')
   		mi.utils.goToAnchor(anchor, 800);
   	
   	//** Radio / Checkbox special button
   	//Event
		$('.radio-checkbox-button li, .radio-checkbox-button li label, .radio-checkbox-button li input').click(function() { return false; });
		$('.radio-checkbox-button li, .radio-checkbox-button li label, .radio-checkbox-button li input').mouseup(function() { mi.utils.radioCheckbox($(this)); });
		
		//Give class at checked
   	$('.radio-checkbox-button li input:checked').each(function(index) {
   		$(this).parent().addClass('selected');
		});
		
		//Newsletter
		if ($('#newsletter-right-form').length) {
			//Contact
			mi.inputInfo.formNewsletterInfo = mi.utils.emptyInputInfo([
																		{inputId: '#newsletter_email', text: mi.lang.email}
																]);
			
			mi.forms.newsletterRightCol = new form;
			mi.forms.newsletterRightCol.init('newsletter-right-form', 'index.php?c=newsletterajax&m=setinfo', {
				submitButtonId: '#newsletter-right-form-submit',
				resetData:	[
											{name: 'newsletter_email', value:''}
										],
				//debug: true,
				
				beforeGetValue: function(selfForm, dataForm) {
					mi.utils.emptyInputInfoDesactive(mi.inputInfo.formNewsletterInfo);
				},
				onError: function(selfForm) {
					mi.utils.emptyInputInfoActive(mi.inputInfo.formNewsletterInfo);
				},
				onSend: function(selfForm, dataForm) {
					mi.alerts.newsletterRightCol = new alerts;
					mi.alerts.newsletterRightCol.init({
						title: mi.lang.newsletterRightColTitle,
						content: '<div class="alerts-selection-add-property"><img src="' + mi.config.baseUrl + mi.config.baseImages + 'valid.png" border="0" alt="' + mi.lang.newsletterRightSuccess + '" /><br />' + mi.lang.newsletterRightSuccess + '</div>'
					});
					
					selfForm.reset();
					mi.utils.emptyInputInfoActive(mi.inputInfo.formNewsletterInfo);
				}
			});
		}
	},

	// --------------------------------------------------------------------
	
	/**
	 * Home class
	 *
	 * @access public
	 */
	home: {
		/*--------------------------------
		| Init "home" class
		| @var		mi.home.init
		--------------------------------*/
		init: function (priceMaxi, surfaceMini) {			
			$('select#search_price_maxi_select')
			.css('display', 'none')
			.selectToUISlider({
				labels: false,
				sliderOptions: {
					change: function(e, ui) {
						var currentSelect 	= $('#' + $(ui.handle).attr('id').split('handle_')[1]);
						var inputTxt 				= $('#' + $(ui.handle).attr('id').split('handle_')[1].split('_select')[0]);
						var value						= currentSelect.find('option').eq(ui.value).attr('value');
						
						inputTxt.val((value == 'mini' || value == 'maxi') ? '' : value);
					}
				}
			});
			
			$('select#search_price_maxi_select').next('.ui-slider').css({
				float: 'right',
				width: 189,
				marginTop:6,
				marginRight:10
			});
			
			//Chambers
			mi.search.initChambers();
			
			//Form search fast
			mi.forms.searchHomeFast = new form;
			mi.forms.searchHomeFast.init('home-search-fast-form', 'index.php?c=searchajax&m=searchfast', {
				submitButtonId: '#search_fast_submit'
			});
			
			$('.search-fast-advanced').click(function() {
				mi.forms.searchHomeFast.opts.onSend = function(self) {
					$(self.opts.formId).attr('action', 'recherche_avancee_d-annonce_immobiliere.html?renew=0');
					self.submit();
				};
				mi.forms.searchHomeFast.check();
				
				return false;
			});
			
			//Form search reference
			mi.forms.searchHomeRef = new form;
			mi.forms.searchHomeRef.init('home-search-reference-form', 'index.php?c=searchajax&m=searchreference', {
				submitButtonId: '#search_reference_submit'
			});
			
			//Auto complete
			mi.forms.searchHomeFast.location = mi.search.initLocation({
																				position:				{top: 22, left: 2},
																				noResult: 			'<p style="text-align:center; padding:2px;">' + mi.lang.townNoResult + '</p>'
																			});
			
			//Init tab
			$('#home-search-tab-fast, #home-search-tab-ref').click(function() {
				var id = $(this).attr('id').replace('tab', 'content');
				
				//Select new button
				$('#home-search-tab-fast, #home-search-tab-ref').removeClass('tab-selected');
				$(this).addClass('tab-selected');
				
				//Display content
				$('#home-search-content-fast, #home-search-content-ref').css('display', 'none');
				$('#' + id).css('display', 'block');
				
				//Delette tips
				mi.forms.searchHomeFast.removeErrors();
				mi.forms.searchHomeRef.removeErrors();
			});
			
			//Pub
			mi.pub.init(4);
			
			//Property slider
			mi.property.slider.init();
		}
	},
	
	// --------------------------------------------------------------------
	
	/**
	 * Selection class
	 *
	 * @access public
	 */
	userSelection: {
		
		/*--------------------------------
		| Init "userSelection" class
		| @var		mi.userSelection.init
		--------------------------------*/
		init: function() {
	   	//Del property into selection
	   	$('a[class~=selection-property-delete]').click(function() {
	   		var _self, id;
	   		
	   		//Init
	   		_self = $(this);
	   		id		= $(this).attr('href').split('_');
	   		id		= id[1];
	   		
	   		//Alert
				$.ajax({
					type: 'POST',
					url: 'index.php?c=selectionajax&m=delproperty',
					data: {idProperty: id},
					dataType: 'json',
					
					success: function(res) {
						if (res.success) {
							var count = parseInt($('#breadcrum-selection-count').html()) - 1;
							
							mi.userSelection.updateCount(count);
							_self.parents('.property-search-bloc').next().remove();
							_self.parents('.property-search-bloc').remove();
							
							if ( ! $('#selection-index-container').find('.property-search-bloc').length)
								$('.selected-property-empty').css('display', 'block');
						}
					}
				});
	   		
	   		return false;
	   	});
	   	
	   	//Del search into selection
	   	$('a[class~=selection-search-delete]').click(function() {
	   		var _self, id;
	   		
	   		//Init
	   		_self = $(this);
	   		id		= $(this).attr('href').split('_');
	   		id		= id[1];
	   		
	   		//Alert
				$.ajax({
					type: 'POST',
					url: 'index.php?c=selectionajax&m=delsearch',
					data: {idSearch	: id},
					dataType: 'json',
					
					success: function(res) {	
						if (res.success) {
							var count = parseInt($('#breadcrum-selection-count').html()) - 1;
							
							mi.userSelection.updateCount(count);
							_self.parents('.selection-search-bloc').next().remove();
							_self.parents('.selection-search-bloc').remove();
							
							if ( ! $('#selection-index-container').find('.selection-search-bloc').length)
								$('.selected-search-empty').css('display', 'block');
						}
					}
				});
	   		
	   		return false;
	   	});
		},
		
		/*--------------------------------
		| Update count
		| @var		mi.userSelection.updateCount
		|
		| @count	int
		--------------------------------*/
		updateCount: function(count) {
			$('#breadcrum-selection-count').html(count);
			
			if (count >= 1)	 {		
				$('#breadcrum-selection-icon')
				.removeClass('mi-icon-star-grey')
				.addClass('mi-icon-star');
			} else {
					$('#breadcrum-selection-icon')
					.removeClass('mi-icon-star')
					.addClass('mi-icon-star-grey');
			}
		},
		
		/*--------------------------------
		| "userSelection.initButton" class
		| @var		mi.userSelection.initButton
		--------------------------------*/
		initButton: function () {	
	   	//** Add property into selection
	   	$('a[class~=add-selection-property]:not([selectioninit])').click(function() {
	   		var _self, id;
	   		
	   		//Init
	   		_self = $(this);
	   		id		= $(this).attr('href').split('_');
	   		id		= id[1];
	   		
	   		//Alert
				$.ajax({
					type: 'POST',
					url: 'index.php?c=selectionajax&m=addproperty',
					data: {idProperty: id},
					dataType: 'json',
					
					success: function(res) {
						mi.alerts.addSelProperty = new alerts;
						mi.alerts.addSelProperty.init({
							title: mi.lang.selectionTitle,
							content: '<div class="alerts-selection-add-property"><img src="' + mi.config.baseUrl + mi.config.baseImages + 'add_selection_property.png" border="0" alt="' + mi.lang.addSelPropertySuccess + '" /><br />' + mi.lang.addSelPropertySuccess + '</div>'
						});
						
						if (res.success) {
							mi.userSelection.updateCount(parseInt($('#breadcrum-selection-count').html()) + 1);
							_self.parent().attr('class', 'property-search-actions-selected');
						}
					}
				});
	   		
	   		return false;
	   	})
	   	.attr('selectioninit', 1);
	   	
	   	//** Add search into selection 
	   	$('a[class~=add-selection-search]:not([selectioninit])').click(function() {
	   		var _self;
	   		
	   		//Init
	   		_self = $(this);
	   		
	   		//Alert
				$.ajax({
					type: 'POST',
					url: 'index.php?c=selectionajax&m=addsearch',
					dataType: 'json',
					
					success: function(res) {
						mi.alerts.addSelProperty = new alerts;
						mi.alerts.addSelProperty.init({
							title: mi.lang.selectionTitle,
							content: '<div class="alerts-selection-add-search"><img src="' + mi.config.baseUrl + mi.config.baseImages + 'add_selection_search.png" border="0" alt="' + mi.lang.addSelSearchSuccess + '" /><br />' + mi.lang.addSelSearchSuccess + '</div>'
						});
						
						if (res.success)
							mi.userSelection.updateCount(parseInt($('#breadcrum-selection-count').html()) + 1);
					}
				});
	   		
	   		return false;
	   	})
	   	.attr('selectioninit', 1);
		}
	},
	
	// --------------------------------------------------------------------
	
	/**
	 * Newsletter class
	 *
	 * @access public
	 */
	newsletter: {
		
		/*--------------------------------
		| Init "newsletter" class
		| @var		mi.newsletter.initButton
		--------------------------------*/
		initButton: function() {			
			//Create newsletter
	   	$('a[class~=create-newsletter-search]:not([newsletterinit])').click(function() {	   		
				$.ajax({
				  url: 'index.php?c=newsletterajax&m=getsearch',
				  dataType: 'json',
				  success: function(res) {
				  	if ( ! res.success)
				  		return false;
				  	
						mi.alerts.createNewsletterSearch = new alerts;
						mi.alerts.createNewsletterSearch.init({
							alertId: 'mi-alert-newsletter-search',
							title: res.title,
							content: res.content,
							afterCreate: function() {								
								//Form
								mi.forms.newsletterSearch = new form;
								mi.forms.newsletterSearch.init('newsletter-search-form', 'index.php?c=newsletterajax&m=setsearch', {
									submitButtonId: '#newsletter-search-submit',
									debug: false,
									
									onSend: function(selfForm, dataForm) {
										$('#mi-alert-newsletter-search .mi-alert-content')
										.empty()
										.append('<div class="newsletter-saved">' + mi.lang.newsletterSaved + '</div>' +
														'<div class="spacer5"></div>' +
														'<p>' + mi.lang.newsletterUnregister + '</p>'
										);
										
										mi.alerts.createNewsletterSearch.setPosition();
									}
								});
							},
							onClose: function() {
								mi.forms.newsletterSearch.removeErrors();
							}
						});
				  }			  
				});
				
				
				return false;
			})
			.attr('newsletterinit', 1);
			
		}
	},
	
	// --------------------------------------------------------------------
	
	/**
	 * Pub class
	 *
	 * @access public
	 */
	pub: {
		pageActive: 0,
		pageMax: 3, //Start at 0
		pageWidth: 628,
		pageSlideTime: 400,
		changeAuto: true,
		changeAutoTime: 5000,
		
		/*--------------------------------
		| Init "pub" class
		| @var		mi.pub.init
		--------------------------------*/
		init: function(pageMax) {
			if (pageMax)
				this.pageMax = pageMax;
			
			$('.pub-list li').click(function() {
				mi.pub.changeAuto = false;
				mi.pub.change( $(this).html() - 1 );
			});
			
			$('.pub-slider').scrollLeft(0);
			
			//Set auto slide
			setTimeout("mi.pub.autoChange()", this.changeAutoTime);
		},
		
		/*--------------------------------
		| Page change
		| @var		mi.pub.change
		|
		| @page		int
		| @auto		bolean
		--------------------------------*/
		change: function(page, auto) {
			if (page == this.pageActive || (auto == true && ! mi.pub.changeAuto))
				return false;
				
			//Buttons
			$('.pub-list li').removeClass('selected');
			$('.pub-list-' + (page + 1)).addClass('selected');
			
			//Slide
			$('.pub-slider').animate({
				scrollLeft: (this.pageWidth * page)
			},
			this.pageSlideTime * ((this.pageActive > page) ? this.pageActive - page : page - this.pageActive),
			function() {			
				//Active page marker
				mi.pub.pageActive = page;
			});
		},
		
		/*--------------------------------
		| Auto page change
		| @var		mi.pub.autoChange
		--------------------------------*/
		autoChange: function() {
			this.change((this.pageActive == this.pageMax) ? 0 : this.pageActive + 1, true);
			
			if ( ! this.changeAuto)
				return false;
			
			setTimeout("mi.pub.autoChange()", mi.pub.changeAutoTime);
		}
	},
	
	// --------------------------------------------------------------------
	
	/**
	 * Search class
	 *
	 * @access public
	 */
	search: {
		/*--------------------------------
		| Init "search" class
		| @var		mi.search.init
		--------------------------------*/
		init: function() {
		},
		
		/*--------------------------------
		| Init location forms
		| @var		mi.search.initLocation
		--------------------------------*/
		initLocation: function(options) {
			//Default options
			var opts = {
				acId: 					'autocomplete_search_location',
				ajaxUrl: 				'index.php?c=searchajax&m=townList',
				parent: 				'search_location',
				parentPos: 			'#search_location',
				position:				{top: 21, left: 2},
				ieCorrection:	  {top: -1, left: 0},
				noResult: 			'<p style="text-align:center; padding:2px;">' + mi.lang.townNoResult + '</p>',
				mapValue:				'%ville% %code_postal%', // - 
				mapList:				'<li villeid="%_ID%" dataId="%dataId%" style="clear:both; height:18px;">' +
												'<div><p style="float:left;">{ville}</p><p style="float:right;">%code_postal%</p></div>' +
												'</li>'
			};
			
			//Check if opts passed
			if (typeof(options) == 'object')
				opts = $.extend(opts, options);
			
			//Create autocomplete
			var ac = new autocomplete();
			ac.init(opts);
			
			//Return object
			return ac;
		},
		
		/*--------------------------------
		| Init location extend forms
		| @var		mi.search.initLocationExtend
		--------------------------------*/
		initLocationExtend: function() {
		},
		
		/*--------------------------------
		| Init chambers forms
		| @var		mi.search.initChambers
		--------------------------------*/
		initChambers: function() {
			$('#search_chamber_0').click(function() {
				if ($('#search_chamber_0:checked').length)
					for(i=1; i<=5; i++) $('#search_chamber_' + i).removeAttr('checked');
				
				if ( ! $('#search_chamber_1:checked, #search_chamber_2:checked, #search_chamber_3:checked, #search_chamber_4:checked, #search_chamber_5:checked').length)
					$('#search_chamber_0').attr('checked', 'checked');
			});
			$('#search_chamber_1, #search_chamber_2, #search_chamber_3, #search_chamber_4, #search_chamber_5').click(function() {
				if ($('#search_chamber_0:checked').length)
					$('#search_chamber_0').removeAttr('checked');
				
				if ( ! $('#search_chamber_1:checked, #search_chamber_2:checked, #search_chamber_3:checked, #search_chamber_4:checked, #search_chamber_5:checked').length)
					$('#search_chamber_0').attr('checked', 'checked');
			});
		},
		
		/*--------------------------------
		| Init rooms forms
		| @var		mi.search.initRooms
		--------------------------------*/
		initRooms: function() {
			$('#search_room_0').click(function() {
				if ($('#search_room_0:checked').length)
					for(i=1; i<=5; i++) $('#search_room_' + i).removeAttr('checked');
					
				else if ( ! $('#search_room_1:checked, #search_room_2:checked, #search_room_3:checked, #search_room_4:checked, #search_room_5:checked').length)
						$('#search_room_0').attr('checked', 'checked');
			});
			$('#search_room_1, #search_room_2, #search_room_3, #search_room_4, #search_room_5').click(function() {
				if ($('#search_room_0:checked').length)
					$('#search_room_0').removeAttr('checked');
				
				if ( ! $('#search_room_1:checked, #search_room_2:checked, #search_room_3:checked, #search_room_4:checked, #search_room_5:checked').length)
					$('#search_room_0').attr('checked', 'checked');
			});
		},
		
		/*--------------------------------
		| Init types forms
		| @var		mi.search.initTypes
		--------------------------------*/
		initTypes: function() {
			$('#search_type_0').click(function() {
				if ($('#search_type_0:checked').length)
					for(i=1; i<=12; i++) $('#search_type_' + i).removeAttr('checked');
					
				else if ( ! $('#search_type_1:checked, #search_type_2:checked, #search_type_3:checked, #search_type_4:checked, #search_type_5:checked, #search_type_6:checked, #search_type_7:checked, #search_type_8:checked, #search_type_9:checked, #search_type_10:checked, #search_type_11:checked, #search_type_12:checked').length)
						$('#search_type_0').attr('checked', 'checked');
			});
			$('#search_type_1, #search_type_2, #search_type_3, #search_type_4, #search_type_5, #search_type_6, #search_type_7, #search_type_8, #search_type_9, #search_type_10, #search_type_11, #search_type_12').click(function() {
				if ($('#search_type_0:checked').length)
					$('#search_type_0').removeAttr('checked');
				
				if ( ! $('#search_type_1:checked, #search_type_2:checked, #search_type_3:checked, #search_type_4:checked, #search_type_5:checked, #search_type_6:checked, #search_type_7:checked, #search_type_8:checked, #search_type_9:checked, #search_type_10:checked, #search_type_11:checked, #search_type_12:checked').length)
					$('#search_type_0').attr('checked', 'checked');
			});
		},
		
		/*--------------------------------
		| Init price forms
		| @var		mi.search.initPrice
		--------------------------------*/
		initPrice: function(options) {
			sliderCssOptions = {
				width: 147,
				marginLeft: 5
			};
			
			if (options)
				sliderCssOptions = $.extend(sliderCssOptions, options);
			
			$('select#search_price_mini_select, select#search_price_maxi_select')
			.css('display', 'none')
			.selectToUISlider({
				labels: false,
				sliderOptions: {
					change: function(e, ui) {
						var currentSelect 	= $('#' + $(ui.handle).attr('id').split('handle_')[1]);
						var inputTxt 				= $('#' + $(ui.handle).attr('id').split('handle_')[1].split('_select')[0]);
						var value						= currentSelect.find('option').eq(ui.value).attr('value');
						
						inputTxt.val((value == 'mini' || value == 'maxi') ? '' : value);
					}
				}
			});
			
			$('select#search_price_maxi_select').next('.ui-slider').css(sliderCssOptions);
		},
		
		/*--------------------------------
		| Init surface forms
		| @var		mi.search.initSurface
		--------------------------------*/
		initSurface: function(options) {
			sliderCssOptions = {
				width: 147,
				marginLeft: 5
			};
			
			if (options)
				sliderCssOptions = $.extend(sliderCssOptions, options);
			
			$('select#search_surface_mini_select, select#search_surface_maxi_select')
			.css('display', 'none')
			.selectToUISlider({
				labels: false,
				sliderOptions: {
					change: function(e, ui) {
						var currentSelect 	= $('#' + $(ui.handle).attr('id').split('handle_')[1]);
						var inputTxt 				= $('#' + $(ui.handle).attr('id').split('handle_')[1].split('_select')[0]);
						var value						= currentSelect.find('option').eq(ui.value).attr('value');
						
						inputTxt.val((value == 'mini' || value == 'maxi') ? '' : value);
					}
				}
			});
			
			$('select#search_surface_maxi_select').next('.ui-slider').css(sliderCssOptions);
		},
		
		/*--------------------------------
		| Init since "date" form
		| @var		mi.search.initSince
		--------------------------------*/
		initOptions: function(datepickerCallback) {
			//Since					
			$('#search_option_since').click(function() {
				if ( ! $('#search_option_since:checked').length) {
					$('.search_option_since_date').val('');
					$('#search_option_7day, #search_option_15day').removeAttr('checked');
				} else
					$('.search_option_since_date').datepicker('show');
			});
			
			$('.search_option_since_date')
			.addClass('mi-date-picker')
			.attr('readonly', 'readonly')
			.datepicker({
				dateFormat: (mi.config.language == 'french') ? 'dd/mm/yy' : 'mm-dd-yy',
				dayNamesMin: (mi.config.language == 'french') ? ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'] : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
				monthNames: (mi.config.language == 'french') ? ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'Décembre'] : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
				onSelect: datepickerCallback,
				onClose: function(dateText, inst)  {
					if (dateText == "")
						$('#search_option_since')
						.removeAttr('checked')
						.val('');
    		}
			});
			
			//7 day
			$('#search_option_7day').click(function() {
				$('#search_option_15day, #search_option_since').removeAttr('checked');
				$('.search_option_since_date').val('');
			});
			
			//15 day
			$('#search_option_15day, #search_option_since').click(function() {
				$('#search_option_7day').removeAttr('checked');
				$('.search_option_since_date').val('');
			});
		}
	},
	
	// --------------------------------------------------------------------
	
	/**
	 * Advanced form search class
	 *
	 * @access public
	 */
	advancedSearch: {
		/*--------------------------------
		| Init "advanced form search" class
		| @var		mi.search.advanced.init
		--------------------------------*/
		init: function() {
			//Autocomplete
			var acLocation = mi.search.initLocation({
				position:	{top: 27, left: 2}
			});
			mi.search.initChambers();
			mi.search.initRooms();
			mi.search.initOptions(function () {
				$('#search_option_since').attr('checked', 'checked');
				$('#search_option_7day, #search_option_15day').removeAttr('checked');
			});
			mi.search.initTypes();
			mi.search.initPrice({
				width: 310,
				marginLeft: 100,
				marginTop: 10
			});
			mi.search.initSurface({
				width: 360,
				marginLeft: 130,
				marginTop: 10
			});
			
			//Form
			mi.forms.advancedSearch = new form;
			mi.forms.advancedSearch.init('search-advanced-form', 'index.php?c=searchajax&m=searchfull', {
				submitButtonId: '#search-advanced-form-submit'
			});
		}
	},
	
	// --------------------------------------------------------------------
	
	/**
	 * LeftSearch class
	 *
	 * @access public
	 */
	leftSearch: {
		/*--------------------------------
		| Init "leftSearch" class
		| @var		mi.leftSearch.init
		--------------------------------*/
		init: function() {
			//Autocomplete
			mi.forms.acLocation = mi.search.initLocation({
				width: 350,
				ieCorrection:	{top: 0, left: 0},
				noResult: '<p style="text-align:center; padding:2px;">' + mi.lang.townNoResult + '</p>',
				onOptionClick: function() {
					mi.forms.leftSearch.check();
				}
			});
			mi.search.initChambers();
			mi.search.initRooms();
			mi.search.initOptions(function () {
				$('#search_option_since').attr('checked', 'checked');
				$('#search_option_7day, #search_option_15day').removeAttr('checked');
				mi.forms.leftSearch.check();
			});
			mi.search.initTypes();
			mi.search.initPrice();
			mi.search.initSurface();
			
			//Form
			mi.forms.leftSearch = new form;
			mi.forms.leftSearch.init('left-search', 'index.php?c=searchajax&m=searchfull', {
				//debug: true,
				beforeCheck: function(selfForm) {
					
					mi.forms.submitModal = new modal();
					mi.forms.submitModal.init({
						closeOnClick: false,
						opacity: .3,
						afterCreate: function(self) {					
							//Set pos & init display
							$('#search-result-map-loading').css({
								top: ($(window).height() / 2) - ($('#search-result-map-loading').height() / 2),
								left: ($(window).width() / 2) - ($('#search-result-map-loading').width() / 2),
								display: 'block'
							});
						}
					});
					
					
					//--------------------------------------------------------------				
					mi.forms.submitModal = new modal;
					mi.forms.submitModal.init({
						closeOnClick: 	false,
						displayDelay:		75
					});
				},
				onError: function(selfForm) {				
					mi.forms.submitModal.remove(mi.forms.submitModal);
				}
			});
			
			//Checkbox / radio event
			$('#left-search-form-button-price, #left-search-form-button-surface, #left-search-form-button-location, #left-search input[type=checkbox][name!=search_option_since], input[type=radio][name=search_location_extand], input[type=radio][name=search_deal]').click(function() {
				mi.forms.leftSearch.check();
			});
			
			$('#left-search input[type=checkbox][name=search_option_since]').click(function() {
				if ( ! $('#search_option_since:checked').length)
					mi.forms.leftSearch.check();
			});
			
			//Init selection buttons
			mi.userSelection.initButton();
			mi.newsletter.initButton();
		}
		
		//UPDATING IF CODE POSTAL OR VILLE (IF MAP)
	},
	
	// --------------------------------------------------------------------
	
	/**
	 * mapSearch class
	 *
	 * @access public
	 */
	mapSearch: {
		map: false,
		loading: false,
		cantonDisplay: 1,
		markerMergeType: 'canton',
		currentMapCoord: { 					//NOT SET
			latitude: 	0,
			longitude: 	0
		},
		markerMaxMinCoord: {
			maxLatitude: 	false,
			minLatitude: 	false,
			maxLongitude: false,
			minLongitude: false
		},
		siblingMarkerNextLoading: false,
		listingSelector: '#search-result-map-listing',
		infoWinSelector: '#search-result-map-info-window',
		infoWinOpened: false,
		infoWinPage: false,
		
		/*--------------------------------
		| Init "mapSearch" class
		| @var		mapSearchmapSearch.init
		--------------------------------*/
		init: function(zoom, la, lo, page, sidx, sord) {			
			//Google map
			this.map = new cocciMap();
			this.map.init('search-result-map', {
				'zoom': zoom,
				maxZoom: 12,
				minZoom: 8,
				latitude: la,
				longitude: lo,
				address: ((la == false && lo == false) ? '85400, Luçon' : false)
			});
			
			//open loading
			this.displayLoading();
			
			//Map listeners
			mi.mapSearch.map.createListener('map', 'click', function() {
				mi.mapSearch.hideInfoWin(true);
				mi.mapSearch.map.hideRollover(false, '#search-result-map-rollover');
			});
			mi.mapSearch.map.createListener('map', 'dblclick', function() {
				mi.mapSearch.hideInfoWin(true);
				mi.mapSearch.map.hideRollover(false, '#search-result-map-rollover');
				
				mi.mapSearch.map.map.setZoom(mi.mapSearch.map.getMapZoom() + 1);
			});
			mi.mapSearch.map.createListener('map', 'drag', function() {
				mi.mapSearch.hideInfoWin(true);
				mi.mapSearch.map.hideRollover(false, '#search-result-map-rollover');
			});
			mi.mapSearch.map.createListener('map', 'dragend', function() {	
				mi.mapSearch.saveSearchMapOptions();
			});
			mi.mapSearch.map.createListener('map', 'zoom_changed', function() {
				mi.mapSearch.hideInfoWin(true);
				mi.mapSearch.map.hideRollover(false, '#search-result-map-rollover');				
				
				if ((mi.mapSearch.markerMergeType == 'canton' && mi.mapSearch.map.getMapZoom() > mi.mapSearch.cantonDisplay) || (mi.mapSearch.markerMergeType == 'town' && mi.mapSearch.map.getMapZoom() <= mi.mapSearch.cantonDisplay)) {
					mi.mapSearch.displayLoading();
					mi.mapSearch.update($.merge($(mi.forms.leftSearch.opts.formId).serializeArray(), [{name: 'zoom', value: mi.mapSearch.map.getMapZoom()}]));
				}
				
				mi.mapSearch.saveSearchMapOptions();
			});
			
			//left search engine init
			mi.leftSearch.init();
			
			//left search engine format for map
			mi.forms.leftSearch.opts.beforeCheck = function(self, data) {
				//Display loading
				mi.mapSearch.displayLoading();
				
				//Reset input location
				$('input[name=search_location]').val('');
				
				//set additional data in check
				var mapCenter = mi.mapSearch.map.getLatLngMapCenter();
				
				self.opts.additionalValues = [
					{name: 'zoom', value: mi.mapSearch.map.getMapZoom()},
					{name: 'latitude', value: mapCenter.lat},
					{name: 'longitude', value: mapCenter.lng}
				];
			};
			mi.forms.leftSearch.opts.onError = false;
			mi.forms.leftSearch.opts.onSend = function(self, data) {
				mi.utils.goToAnchor('#left-menu-top', 800);
				
				//Update marker
				mi.mapSearch.update(data);
				
				//Update list
				mi.mapSearch.getContentListing(data);
			};
			
			//Location
			mi.forms.acLocation.opts.onOptionClick = function(self, parent, data, mappedData) {
				$('input[name=search_location_hidden]').val(mappedData);
				
				$('.delete-grouped-location').click(function() {
					$('input[name=search_location_hidden]').val('');
					
					$(this).next().val();
					$(this).prev().remove();
					$(this).remove();
										
					mi.forms.leftSearch.check();
					
					return false;
				});
				
				mi.forms.leftSearch.check();
				
				return false;
			};
			
			$('.delete-grouped-location').click(function() {
				$('input[name=search_location], input[name=search_location_hidden]').val('');
				
				$(this).next().val();
				$(this).prev().remove();
				$(this).remove();
				
				$('#left-search-form-location, #left-search-form-location-extand').css('display', 'block');
				
				mi.forms.leftSearch.check();
				
				return false;
			});
			
			//Location extend
			$('input[name=search_location_extand]')
			.unbind('click')
			.click(function() {
				if ($('input[name=search_location_hidden]').val() != '')
					mi.forms.leftSearch.check();
			});
			
			//Group
			$('.delete-grouped-agent, .delete-grouped-agency, .delete-grouped-sector').click(function() {
				$('input[name=search_groupId], input[name=search_agentId], input[name=search_sectorId]').val('');
				
				$(this).prev().remove();
				$(this).next().remove();
				$(this).remove();
				
				mi.forms.leftSearch.check();
				
				return false;
			});
			
			//Init selection buttons
			mi.userSelection.initButton();
			mi.newsletter.initButton();
			
			//Init search
			mi.mapSearch.update($.merge($(mi.forms.leftSearch.opts.formId).serializeArray(), [
					{name: "zoom", value: zoom},
					{name: "latitude", value: la},
					{name: "longitude", value: lo}
			]));
			if (page && sidx && sord) {
				mi.mapSearch.getContentListing($(mi.forms.leftSearch.opts.formId).serializeArray(), 
				[
					{name: "page", value: page},
					{name: "sidx", value: sidx},
					{name: "sord", value: sord}
				], 
				function() {
					mi.mapSearch.removeLoading();
				});
			
			} else {
				mi.mapSearch.getContentListing($(mi.forms.leftSearch.opts.formId).serializeArray(), 
				function() {
					mi.mapSearch.removeLoading();
				});
			}
			
			//Add tips on search form bloc
			mi.tips.mapSearchHelper = new tips();
			mi.tips.mapSearchHelper.init('Affinez votre recherche grâce à ce formulaire !', {
				tipId: 'mi-tip-map-helper',
				parent: '#search-left-container',
				position: {top: 150, left: 120}
			});
			
			setTimeout('mi.tips.mapSearchHelper.remove(mi.tips.mapSearchHelper)', 6500);
		},
		
		/*--------------------------------
		| Init "mapSearch" class
		| @var		mi.mapSearch.update
		--------------------------------*/
		update: function(searchData) {	
			$.ajax({
				type: 'POST',
				url: 'index.php?c=searchmapajax&m=getmarkers',
				data: searchData,
				dataType: 'json',
				
				success: function(res) {
					//Result find
					if (res.success) {
						//Reset map
						mi.mapSearch.removeLoading();
						mi.mapSearch.resetMap();
						
						//Save group
						mi.mapSearch.markerMergeType = res.search.marker_merge;
						
						//Create markers
						for (x in res.markers) {											
							//Generate marker image
							res.markers[x].options.icon = new google.maps.MarkerImage(res.markers[x].options.icon,
																			      new google.maps.Size(23, 37),
																			      new google.maps.Point(0,0),
																			      new google.maps.Point(11.5, 37)
																			    );
							
							//Create marker
							mi.mapSearch.map.createMarker(res.markers[x], function(marker, geocodeRes) {
								//Check marker
								if ( ! marker)
									return;
								//Save geocode in db
								else if (geocodeRes) {
									var markerPos = mi.mapSearch.map.getLatLngFromMarker(marker);
									
									$.ajax({
										type: "POST",
										url: 'index.php?c=searchmapajax&m=settowncoordinates',
										data: {la: markerPos.lat, lo: markerPos.lng, idVille: marker.idVille, updKey: marker.updKey}
									});
									
									res.markers[x].latitude = markerPos.lat;
									res.markers[x].longitude = markerPos.lng;
								};
								
								//Set max&min cood								
								if ((mi.mapSearch.markerMaxMinCoord.maxLatitude && mi.mapSearch.markerMaxMinCoord.maxLatitude < res.markers[x].latitude) || ! mi.mapSearch.markerMaxMinCoord.maxLatitude)
									mi.mapSearch.markerMaxMinCoord.maxLatitude = res.markers[x].latitude;
								if (mi.mapSearch.markerMaxMinCoord.minLatitude && mi.mapSearch.markerMaxMinCoord.minLatitude > res.markers[x].latitude || ! mi.mapSearch.markerMaxMinCoord.minLatitude)
									mi.mapSearch.markerMaxMinCoord.minLatitude = res.markers[x].latitude;
								if (mi.mapSearch.markerMaxMinCoord.maxLongitude && mi.mapSearch.markerMaxMinCoord.maxLongitude < res.markers[x].longitude || ! mi.mapSearch.markerMaxMinCoord.maxLongitude)
									mi.mapSearch.markerMaxMinCoord.maxLongitude = res.markers[x].longitude;
								if (mi.mapSearch.markerMaxMinCoord.minLongitude && mi.mapSearch.markerMaxMinCoord.minLongitude > res.markers[x].longitude || ! mi.mapSearch.markerMaxMinCoord.minLongitude)
									mi.mapSearch.markerMaxMinCoord.minLongitude = res.markers[x].longitude;
								
								//RollOver
								mi.mapSearch.map.createListener({type: 'marker', marker: marker}, 'mouseover', function(event) {
									//Shadow "mouseover"
									/*
									marker.setShadow(new google.maps.MarkerImage('css/map/google_marker_property_over_shadow.png',
															      new google.maps.Size(29, 21),
															      new google.maps.Point(0,0),
															      new google.maps.Point(7, 17)
															    )
									);
									*/
									
									//Check if early opened
									if (mi.mapSearch.infoWinOpened && mi.mapSearch.infoWinOpened == marker.id)
										return;
									
									mi.mapSearch.map.showRollover(marker, '#search-result-map-rollover', {down: 'search-result-map-rollover-down'}, marker.rollOver);
								});
								
								//RollOut
								mi.mapSearch.map.createListener({type: 'marker', marker: marker}, 'mouseout', function() {
									//Shadow "default"
									//marker.setShadow(mi.mapSearch.map.opts.markerOptions.shadow);
									
									mi.mapSearch.map.hideRollover(marker, '#search-result-map-rollover');
								});
								
								//Click
								mi.mapSearch.map.createListener({type: 'marker', marker: marker}, 'click', function() {
									//Init
									var mapZoom = mi.mapSearch.map.getMapZoom();
									
									//Hide rollOver
									mi.mapSearch.map.hideRollover(marker, '#search-result-map-rollover');
									
									//Check type action
									if (mapZoom > mi.mapSearch.cantonDisplay) {
										//Check if not open or early open for this marker
										if ( ! mi.mapSearch.infoWinOpened || mi.mapSearch.infoWinOpened != marker.id) {
											mi.mapSearch.map.hideRollover(marker, '#search-result-map-rollover');
											
											mi.mapSearch.hideInfoWin(true);
											mi.mapSearch.createInfoWin(marker);
											
										} else {
											mi.mapSearch.hideInfoWin(true);
										}
									
									} else {
										mi.mapSearch.map.map.setCenter(marker.getPosition());
										mi.mapSearch.map.map.setZoom(10);
									}
								});
							});
						}	
						
						//Set new position of map
						if (res.search.location != "" && mi.mapSearch.markerMaxMinCoord.minLatitude != 0 && mi.mapSearch.markerMaxMinCoord.maxLatitude != 0 && mi.mapSearch.markerMaxMinCoord.maxLongitude != 0 && mi.mapSearch.markerMaxMinCoord.minLongitude != 0) {
							var centerLa = mi.mapSearch.markerMaxMinCoord.minLatitude + ((mi.mapSearch.markerMaxMinCoord.maxLatitude - mi.mapSearch.markerMaxMinCoord.minLatitude) / 2);
							var centerLo = mi.mapSearch.markerMaxMinCoord.maxLongitude + ((mi.mapSearch.markerMaxMinCoord.minLongitude - mi.mapSearch.markerMaxMinCoord.maxLongitude) / 2);
							//alert(mi.mapSearch.markerMaxMinCoord.toSource()); alert('la : ' + centerLa); alert('lo : ' + centerLo);				
							mi.mapSearch.map.map.setCenter(new google.maps.LatLng(centerLa, centerLo)); 
						} else {
							mi.mapSearch.map.map.setCenter(new google.maps.LatLng(46.67279821668, -1.4299995242434)); //Luçon
						}
						
						//Update search title
						mi.mapSearch.setSearchTitle(res.search.title);
						mi.mapSearch.setSearchCount(res.search.count);
						
						//Update facebook link
						$('#search-left-container .facebook').attr('src', res.search.fb_like_link);
						
						//Update link "back to listing search"
						$('#search-map-back-basic-link').attr('href', res.search.url_basic);
						
						//Update rss link
						$('#search-left-container .get-rss-search').attr('href', res.search.rss_link);
						
						//Update left location content
						//Location
						if (res.search.is_town || res.search.is_postal_code) {
							//Delete old
							if ($('.delete-grouped-location').length) {
								$('.delete-grouped-location').next().val();
								$('.delete-grouped-location').prev().remove();
								$('.delete-grouped-location').remove();
							}
							
							$('input[name=search_location_hidden]').val(res.search.location);
							$('input[name=search_location]').after('<div class="spacer5"></div>	<a href="#add_location" class="delete-grouped delete-grouped-location"><span id="search_location_button">' + res.search.location + '</span><span class="mi-icon mi-icon-close"></span></a>');
							
							$('.delete-grouped-location').click(function() {
								$('input[name=search_location_hidden], input[name=search_location]').val('');
								
								$(this).next().val();
								$(this).prev().remove();
								$(this).remove();
																	
								mi.forms.leftSearch.check();
												
								return false;
							});
						}
						
						//Display
						if (res.search.is_grouped) {
							$('#left-search-form-location, #left-search-form-location-extand').css('display', 'none');
						} else if (res.search.is_town) {
							$('#left-search-form-location, #left-search-form-location-extand').css('display', 'block');
						} else if (res.search.is_postal_code || res.search.is_empty) {
							$('#left-search-form-location').css('display', 'block');
							$('#left-search-form-location-extand').css('display', 'none');
						}
						
						//Sibling marker
						if (mi.mapSearch.siblingMarkerNextLoading) {
							mi.mapSearch.map.setMarkerCenter(mi.mapSearch.siblingMarkerNextLoading, function(Ca, Ea) {
								mi.mapSearch.saveSearchMapOptions();
							});
							
							var marker = mi.mapSearch.map.getMarkerById(mi.mapSearch.siblingMarkerNextLoading);
							
							if (marker.win.property_count > 1)
								mi.mapSearch.map.showRollover(marker, '#search-result-map-rollover', {down: 'search-result-map-rollover-down'}, marker.rollOver);
							else
								mi.mapSearch.createInfoWin(marker);
							
							mi.mapSearch.siblingMarkerNextLoading = false;
						}
						
						//Remove loading
						mi.mapSearch.removeLoading();
						
						//Auto open win
						if (res.search.auto_open_win) {
							//Set options
							var marker = mi.mapSearch.map.getMarkerById(res.search.auto_open_win.maker_id);
							
							//Check exists marker
							if (marker) {
								marker.win.ajax.data = $.extend(marker.win.ajax.data, res.search.auto_open_win.ajax_data);
								
								//Reset options of autoload
								mi.mapSearch.createInfoWin(marker, function() {
									//Reset order
									marker.win.ajax.data = $.extend(marker.win.ajax.data, {
										page: 1,
										sidx:	'date',
										sort: 'desc'
									});
									
									//Destroy auto open win
									mi.mapSearch.delAutoOpenWin();
								});
							}
						}
						
					//No result
					} else {
						//Update search title
						mi.mapSearch.setSearchTitle(res.search.title);
						mi.mapSearch.setSearchCount(res.search.count);
						
						//Reset map
						mi.mapSearch.removeLoading();
						mi.mapSearch.resetMap();
					}
				}
			});
		},
		
		/*--------------------------------
		| Init "mapSearch.getContentListing" class
		| @var		mi.mapSearch.getContentListing
		--------------------------------*/
		getContentListing: function(searchData, mergeData, callBack) {
			if (mergeData)
				searchData = $.merge(searchData, mergeData);
			
			$.ajax({
				type: 'GET',
				url: 'index.php',
				data: $.merge(searchData, [{name: 'c', value: 'searchmapajax'}, {name: 'm', value: 'getlisting'}]),
			
				success: function(content) {
					$(mi.mapSearch.listingSelector).html(content);
					mi.mapSearch.initListing();
					
					//CallBack
					if (callBack)
						eval('callBack()');
				}
			});
		},
		
		/*--------------------------------
		| Init "mapSearch.initListing" class
		| @var		mi.mapSearch.initListing
		--------------------------------*/
		initListing: function() {			
			//Ordering
			$('.search-result-toolbar .order li a').click(function() {				
				mi.mapSearch.getContentListing($(mi.forms.leftSearch.opts.formId).serializeArray(), 
					[
						{name: "page", value: mi.tools.getUrlParam($(this).attr('href'), 'page')},
						{name: "sidx", value: mi.tools.getUrlParam($(this).attr('href'), 'sidx')},
						{name: "sord", value: mi.tools.getUrlParam($(this).attr('href'), 'sord')}
					]
				);
				
				return false;
			});
			
			//Nav
			$(this.listingSelector + ' .mi-page-selector a').click(function() {		
				mi.mapSearch.getContentListing($(mi.forms.leftSearch.opts.formId).serializeArray(), 
					[
						{name: "page", value: mi.tools.getUrlParam($(this).attr('href'), 'page')},
						{name: "sidx", value: mi.tools.getUrlParam($(this).attr('href'), 'sidx')},
						{name: "sord", value: mi.tools.getUrlParam($(this).attr('href'), 'sord')}
					]
				);
				
				return false;
			});
			
			//Sibling map button
			$(this.listingSelector + ' .search-result-map-sibling a').click(function() {
				//Get marker id
				var id = $(this).attr('href').replace('\#', '');
				
				//Hide info win					
				mi.mapSearch.hideInfoWin();
				
				if (mi.mapSearch.map.getMapZoom() <= mi.mapSearch.cantonDisplay) {
					//Get marker
					mi.mapSearch.siblingMarkerNextLoading = id;
					
					//Set zoom
					mi.mapSearch.map.map.setZoom(12);
				
				} else {
					//Set zoom
					mi.mapSearch.map.map.setZoom(12);
					
					mi.mapSearch.map.setMarkerCenter(id, function() {
						mi.mapSearch.saveSearchMapOptions();
					});
					
					var marker = mi.mapSearch.map.getMarkerById(id);
					mi.utils.goToAnchor('#left-menu-top', 800, function() {
						if (marker.win.property_count > 1)
							mi.mapSearch.map.showRollover(marker, '#search-result-map-rollover', {down: 'search-result-map-rollover-down'}, marker.rollOver);
						else
							mi.mapSearch.createInfoWin(marker);
					});
				}
				
				return false;
			});
			
			//Selection
			mi.userSelection.initButton();
		},
		
		/*--------------------------------
		| Init "mapSearch.createInfoWin" class
		| @var		mi.mapSearch.createInfoWin
		--------------------------------*/
		createInfoWin: function(marker, callBack) {
			//Hide if early opened
			this.hideInfoWin(true);
			
			//Get content AJAX
			if (typeof(marker.win.ajax) == "object") {
				this.getContentInfoWin(marker.win.ajax, false, function() {
					mi.mapSearch.displayInfoWin(marker, callBack);
				});
				
			//Set content HTML
			} else {
				this.getContentInfoWin(false, marker.win.content, function() {
					mi.mapSearch.displayInfoWin(marker, callBack);
				});			
			}
		},
		
		/*--------------------------------
		| Init "mapSearch.setTextLoading" class
		| @var		mi.mapSearch.setTextLoading
		--------------------------------*/
		setMapCenter: function(la, lo) {
			//Scale position (zoom)
			var scale = new Array();
			scale[8] = 0.48;
			scale[9] = 0.24;
			scale[10] = 0.12;
			scale[11] = 0.07;
			scale[12] = 0.030;
			
			this.map.map.setCenter(new google.maps.LatLng(la + scale[this.map.getMapZoom()], lo)); 
		},
		
		/*--------------------------------
		| Init "mapSearch.displayInfoWin" class
		| @var		mi.mapSearch.displayInfoWin
		--------------------------------*/
		displayInfoWin: function(marker, callBack) {
			//Set map center	(marker is now the center		
			var mapCenter = mi.mapSearch.map.getLatLngFromMarker(marker);
			this.setMapCenter(mapCenter.lat, mapCenter.lng);
			
			//Get marker pos
			var markerPos = this.map.getPixelPosition(marker, {x:0, y:-35}, true);
			
			$(this.infoWinSelector).css({
				left: markerPos.x - ($(this.infoWinSelector).width() / 2),
				top: markerPos.y - $(this.infoWinSelector).height(),
				display: 'block'
			});
			
			this.infoWinOpened 	= marker.id;
			
			//Save new pos in search
			this.saveSearchMapOptions();
			
			//CallBack
			if (callBack)
				eval('callBack()');
		},
		
		/*--------------------------------
		| Init "mapSearch.getContentInfoWin" class
		| @var		mi.mapSearch.getContentInfoWin
		--------------------------------*/
		getContentInfoWin: function(ajax, html, callBack) {
			//Ajax
			if (ajax) {
				$.ajax({
					type: "POST",
					url: ajax.url,
					data: ajax.data,
					success: function(content) {
						$(mi.mapSearch.infoWinSelector).html(content);
						mi.mapSearch.initInfoWin();
						
						//CallBack
						if (callBack)
							eval('callBack()');
					}
				});
		
		//Html
		} else if (html) {
			$(this.infoWinSelector).html(marker.win.content);
			mi.mapSearch.initInfoWin();
			
			//CallBack
			if (callBack)
				eval('callBack()');
		
		//Unknow
		} else
			alert('unknow type in "mi.mapSearch.getContentInfoWin"');
		
		},
		
		/*--------------------------------
		| Init "mapSearch.initPageInfoWin" class
		| @var		mi.mapSearch.initInfoWin
		--------------------------------*/
		initInfoWin: function() {
			//Close button
			$(this.infoWinSelector + ' .container .header .button-close').click(function() {
				mi.mapSearch.hideInfoWin(true);
			});
			
			//Ordering
			$(this.infoWinSelector + ' .toolbar .order li').click(function() {
				mi.mapSearch.getContentInfoWin({url: $(this).attr('ajax')}, false);
			});
			
			//Nav
			$(this.infoWinSelector + ' .nav .active').click(function() {
				mi.mapSearch.getContentInfoWin({url: $(this).attr('ajax')}, false);
			});
			
			//Selection
			mi.userSelection.initButton();
		},
		
		/*--------------------------------
		| Init "mapSearch.hideInfoWin" class
		| @var		mi.mapSearch.hideInfoWin
		--------------------------------*/
		hideInfoWin: function(clear) {
			if ( ! this.infoWinOpened)
				return false;
			
			this.infoWinOpened = false;
			
			//Hide
			$(this.infoWinSelector).css('display', 'none');
			
			//Clear content
			if (clear)
				$(this.infoWinSelector).empty();
			
			//Destroy auto open win
			this.delAutoOpenWin();
		},
	
		/*--------------------------------
		| Init "mapSearch" class
		| @var		mi.mapSearch.rollOverHtml
		--------------------------------*/
		rollOverHtml: function(data, callBack) {
			$('#search-result-map-rollover').html(data.toSource());
			
			if (typeof(callBack) == 'function')
				eval('callBack()');
		},
		
		/*--------------------------------
		| Init "mapSearch" class
		| @var		mi.mapSearch.setSearchTitle
		--------------------------------*/
		setSearchTitle: function(txt) {
			$('.search-result-description').empty()
			.html(txt);
		},
		
		/*--------------------------------
		| Init "mapSearch.setSearchCount" class
		| @var		mi.mapSearch.setSearchCount
		--------------------------------*/
		setSearchCount: function(txt) {
			$('.search-result-map-count').empty()
			.html(txt);
		},
		
		/*--------------------------------
		| Init "mapSearch.saveSearchMapOptions" class
		| @var		mi.mapSearch.saveSearchMapOptions
		--------------------------------*/
		saveSearchMapOptions: function(data) {			
			//Generate data id doesnt exsits
			if ( ! data) {
				var mapCenter = mi.mapSearch.map.getLatLngMapCenter();
				
				var data = {
					zoom: 				mi.mapSearch.map.getMapZoom(),
					latitude: 		mapCenter.lat,
					longitude: 		mapCenter.lng
				};
			}
			
			$.ajax({
				type: "POST",
				url: 'index.php?c=searchmapajax&m=setsearchmapoptions',
				data: data
			});
		},
		
		/*--------------------------------
		| Init "mapSearch.delAutoOpenWin" class
		| @var		mi.mapSearch.delAutoOpenWin
		--------------------------------*/
		delAutoOpenWin: function() {
			$.ajax({url: 'index.php?c=searchmapajax&m=destroyAutoLoad'});
		},

		/*--------------------------------
		| Init "mapSearch.displayLoading" class
		| @var		mi.mapSearch.displayLoading
		--------------------------------*/
		displayLoading: function() {
			this.loading = new modal();
			this.loading.init({
				closeOnClick: false,
				opacity: 0,
				afterCreate: function(self) {
					//Add message
					mi.mapSearch.setTextLoading(mi.lang.loadingBase);
					
					//Set pos & init display
					$('#search-result-map-loading').css({
						opacity: 0,
						top: $('#' + mi.mapSearch.map.opts.mapId).offset().top + ($('#' + mi.mapSearch.map.opts.mapId).height() / 2) - ($('#search-result-map-loading').height() / 2),
						left: $('#' + mi.mapSearch.map.opts.mapId).offset().left + ($('#' + mi.mapSearch.map.opts.mapId).width() / 2) - ($('#search-result-map-loading').width() / 2),
						display: 'block'
					})
					
					//Display
					.animate({
						opacity: 1
					}, self.opts.displayDelay);
				}
			});
		},
		
		/*--------------------------------
		| Init "mapSearch.setTextLoading" class
		| @var		mi.mapSearch.setTextLoading
		--------------------------------*/
		setTextLoading: function(text) {
			$('#search-result-map-loading p').html(text);
		},
		
		/*--------------------------------
		| Init "mapSearch.displayLoading" class
		| @var		mi.mapSearch.displayLoading
		--------------------------------*/
		removeLoading: function() {
			if ( ! this.loading)
				return false;
			
			this.loading.remove();
			
			$('#search-result-map-loading').animate({
				opacity: 0
			}, this.loading.opts.displayDelay, function() {
				$('#search-result-map-loading').css('display', 'none');
			});
			
			this.loading = false;
		},
		
		/*--------------------------------
		| Init "mapSearch.resetMap" class
		| @var		mi.mapSearch.resetMap
		--------------------------------*/
		resetMap: function() {
			this.hideInfoWin(true);
			this.map.hideRollover();
			this.map.clearMarker();
			this.markerMaxMinCoord = {
				maxLatitude: 	false,
				minLatitude: 	false,
				maxLongitude: false,
				minLongitude: false
			};
		}
	},
	
	// --------------------------------------------------------------------
	
	/**
	 * Listing class
	 *
	 * @access public
	 */
	listing: {
		/*--------------------------------
		| Init "listing" class
		| @var		mi.listing.init
		--------------------------------*/
		init: function() {
			//Init selection buttons
			mi.userSelection.initButton();
			mi.newsletter.initButton();
		}
	}, //En of "mi.listing"
	
	// --------------------------------------------------------------------
	
	/**
	 * Detail class
	 *
	 * @access public
	 */
	detail: {
		map: false,
		
		/*--------------------------------
		| Init "detail" class
		| @var		mi.detail.init
		--------------------------------*/
		init: function(mapAdress, sold, deal, town, reference) {	
				
			//Calculator monthly
			if ( ! sold) {
				mi.calculator.monthlyCredit('#property-detail-calculator-submit', '#detail-calculator-monthly', [
					'length',
					'rate',
					'monthly'
				]);	
			}
			
			//Photos
			if ($('.property-photo-big').length) {
				this.photos.init();
			}
			
			//Formated input
			//mi.utils.formatedNumberObject(['#calculator_amount', '#calculator_contribution', '#calculator_rate', '#calculator_insurance_rate']);
			
			//Init selection buttons
			mi.userSelection.initButton();
			
			//Contact
			mi.inputInfo.formContact = mi.utils.emptyInputInfo([
																		{inputId: '#contact_name', text: mi.lang.fullname},
																		{inputId: '#contact_phone', text: mi.lang.phone},
																		{inputId: '#contact_email', text: mi.lang.email},
																		{inputId: '#contact_message', text: mi.lang.message}
																]);
			
			$('#property-detail-contact-submit').css('display', 'block');
			
			//Form contact
			mi.forms.detailContact = new form;
			mi.forms.detailContact.init('contact-detail', 'index.php?c=contactajax&m=detailContact', {
				submitButtonId: '#property-detail-contact-submit',
				resetData:	[
											{name: 'contact_name', value:''},
											{name: 'contact_phone', value:''},
											{name: 'contact_email', value:''},
											{name: 'contact_subject', value:''},
											{name: 'contact_message', value:''}
										],
				
				beforeGetValue: function(selfForm, dataForm) {
					mi.utils.emptyInputInfoDesactive(mi.inputInfo.formContact);
				},
				onError: function(selfForm) {
					mi.utils.emptyInputInfoActive(mi.inputInfo.formContact);
				},
				onSend: function(selfForm, dataForm) {
					//Request
					$.ajax({
						type: 'POST',
						url: 'index.php?c=contactajax&m=detailcontactsend',
						data: dataForm,
						dataType: 'json',
						
						success: function(res) {											
							if (res.success) {
								mi.alerts.detailContactSend = new alerts;
								mi.alerts.detailContactSend.init({
									title: 'Contact',
									content: '<div class="contact-alert-send"><img src="' + mi.config.baseUrl + mi.config.baseImages + 'valid.png" border="0" alt="' + mi.lang.contactSendSuccess + '" /><br />' + mi.lang.contactSendSuccess + '</div>'
								});
								
								_gaq.push(['_trackEvent', "Contact annonce", "'" + town + "'", "'" + reference + "'"]);
								
								selfForm.reset();
								mi.utils.emptyInputInfoActive(mi.inputInfo.formContact);
								
							} else {
								alert('Send message error !');	
							}
						}
					});
				}
			});
			
			//Google map
			this.map = new cocciMap();
			this.map.init('property-detail-map', {
				zoom: 9,
				address: mapAdress,
				markers: [
									{
										address: mapAdress
									}
								 ]
		  });
		},
		
		photos: {
			currentKey: 			1,
			maxKey:						1,
			changeDelay: 			300,
			autoChange: 			true,
			autoChangeDelay:	3700,
			inChange: 				false,
			
			init: function() {
				//Mask photos (except first)
				var i = 0;
				
				//Set zIndex
				$('.property-photo-big img').each(function() {
					if (i)
						$(this).css('z-index', 1);
					else {
						$(this).css('z-index', 2);
					}
					
					i++;
				});
				
				//Set max key
				this.maxKey = $('.property-photo-big img').length;
				
				if (this.maxKey > 1) {
					//Selector init
					$('.property-photo-selector li').click(function() {
						mi.detail.photos.autoChange = false;
						mi.detail.photos.change($(this).html(), false);
					});
					
					//Auto change
					if (this.autoChange) {
						setTimeout('mi.detail.photos.change(' + parseInt(this.currentKey + 1) + ', true)', this.autoChangeDelay);
					}
				}
			},
			
			change: function(key, auto) {						
				//Check if in change
				if (this.inChange || (auto && ! this.autoChange) || key == this.currentKey)
					return false;
				
				//Change button style
				$('.property-photo-selector-' + this.currentKey).removeClass('selected');
				$('.property-photo-selector-' + key).addClass('selected');
				
				//Marker change on
				this.inChange = true;
				
				//Set new z-index
				$('.property-photo-' + this.currentKey).css('z-index', 3);
				$('.property-photo-' + key).css('z-index', 2);
				
				//Animate
				$('.property-photo-' + this.currentKey).animate({
					opacity: 0
				}, this.displayDelay, function() {
					$('.property-photo-' + mi.detail.photos.currentKey).css({
						zIndex: 	1,
						opacity: 	1
					});
					
					//Set new current key
					mi.detail.photos.currentKey = parseInt(key);
					
					//Marker change off
					mi.detail.photos.inChange = false;
					
					//Auto change
					if (mi.detail.photos.autoChange)
						setTimeout('mi.detail.photos.change(' + ((mi.detail.photos.currentKey + 1 > mi.detail.photos.maxKey) ? 1 : mi.detail.photos.currentKey + 1) + ', true)', mi.detail.photos.autoChangeDelay);
				});
				
			}
		}
	
	},
	
	// --------------------------------------------------------------------
	
	/**
	 * Property class
	 *
	 * @access public
	 */
	property: {
		/*--------------------------------
		| Init "property" class
		| @var		mi.property.init
		--------------------------------*/
		init: function() {
		},
		
		/*--------------------------------
		| Slider class
		| @var		mi.slider
		--------------------------------*/
		slider: {
			currentTab: false,
			pageActive: 0,
			pageMax: 1, //start at 0
			pageMaxAbs: 2, //start at 0
			byPage:	3,
			pageWidth: 591,
			slideTime: 450,
			slideIn: false,
			slideAuto: true,
			slideAutoTime: 5000,
			tabs: ['new', 'exclu', 'prestige', 'rent'],
			
			/*--------------------------------
			| Init "slider" class
			| @var		mi.property.slider.init
			--------------------------------*/
			init: function () {
				//Reset slide
				this.resetSlide();
				
				//Set click action on tab
				$('.property-slider-tab-new, .property-slider-tab-exclu, .property-slider-tab-prestige, .property-slider-tab-rent').click(function() {
					//Get tab ID
					var tab = $(this).attr('id').split('-');
					tab = tab[4];
					
					//Change tab
					mi.property.slider.slideAuto = false;
					mi.property.slider.tab(tab);
				});
				
				//Set click action au side buttons
				$('.property-slider-button-side-left').click(function() {
					mi.property.slider.slideAuto = false;
					mi.property.slider.slide(0);
				});
				
				$('.property-slider-button-side-right').click(function() {
					mi.property.slider.slideAuto = false;
					mi.property.slider.slide(1);
				});
				
				//Get default tab
				this.tab('new');
				
				//Set auto slide
				setTimeout("mi.property.slider.autoSlide()", this.slideAutoTime);
			},
			
			/*--------------------------------
			| Tab change
			| @var		mi.property.slider.tab
			|
			| @tab		string
			--------------------------------*/
			tab: function (tab) {
				if (tab == mi.property.slider.currentTab || mi.property.slider.slideIn)
					return false;
				
				//Display / mask content
				for(x in mi.property.slider.tabs)
					$('.property-slider-content-' + mi.property.slider.tabs[x]).css('display', (tab == mi.property.slider.tabs[x]) ? 'block' : 'none');
				
				//Display / mask over tab
				for(x in mi.property.slider.tabs) {
					if (tab == mi.property.slider.tabs[x])
						$('.property-slider-tab-' + tab).addClass('tab-selected');
					else
						$('.property-slider-tab-' + mi.property.slider.tabs[x]).removeClass('tab-selected');
				}
				
				//Get page max
				this.pageMax = Math.ceil($('.property-slider-content-' + tab + ' .property-slider-bloc').length / this.byPage) - 1;
				
				//Reset slide
				this.resetSlide();
				
				//Set new tab avtive
				mi.property.slider.currentTab = tab;
			},
			
			/*--------------------------------
			| Slide
			| @var		mi.property.slider.slide
			|
			| @type		bolean (0: left, 1: right)
			| @auto		bolean
			--------------------------------*/
			slide: function(type, auto) {
				if (( ! type && this.pageActive == 0) || mi.property.slider.slideIn || (auto == true && ! mi.property.slider.slideAuto))
					return false;
				
				//Marker
				mi.property.slider.slideIn = true;
				
				//Set current X
				currentX = $('.property-slider-container-overflow').scrollLeft();
				
				//If max page
				if (this.pageActive + 1 > this.pageMax && type) {
					$('.property-slider-container-overflow').animate({
						scrollLeft: 0
					},
					this.slideTime * this.pageMax,
					function() {
						mi.property.slider.pageActive = 0;
						mi.property.slider.slideIn = false;
						
						mi.property.slider.buttonSlide();
					});
				
				//if normal page
				} else {
					var newPage = (type) ? this.pageActive + 1 : this.pageActive - 1;
					
					$('.property-slider-container-overflow').animate({
						scrollLeft: this.pageWidth * newPage
					},
					this.slideTime,
					function() {
						mi.property.slider.pageActive = newPage;
						mi.property.slider.slideIn = false;
						
						mi.property.slider.buttonSlide();
					});
				}
			},
			
			/*--------------------------------
			| Buttons
			| @var		mi.property.slider.buttonSlide
			--------------------------------*/
			buttonSlide: function () {
				$('.property-slider-button-side-left').animate({
					opacity: (this.pageActive == 0) ? 0 : 1
				},250);
				
				$('.property-slider-button-side-right').animate({
					opacity: (this.pageMax == 0) ? 0 : 1
				},250);
			},
			
			/*--------------------------------
			| Auto slide
			| @var		mi.property.slider.autoSlide
			--------------------------------*/
			autoSlide: function() {
				this.slide(1, true);
				
				if ( ! this.slideAuto)
					return false;
				
				setTimeout("mi.property.slider.autoSlide()", mi.property.slider.slideAutoTime);
			},
			
			/*--------------------------------
			| Reset slide
			| @var		mi.property.slider.autoSlide
			--------------------------------*/
			resetSlide: function () {
				$('.property-slider-container-overflow').scrollLeft(0);
				this.pageActive = 0;
				
				this.buttonSlide();
			}
		}
	},
	
	// --------------------------------------------------------------------
	
	/**
	 * Sell class
	 *
	 * @access public
	 */
	sell: {
		
		/*--------------------------------
		| Detail class
		| @var		mi.sell.proposal
		--------------------------------*/
		proposal: {		
			/*--------------------------------
			| Init "sell.proposal" class
			| @var		mi.sell.proposal.init
			--------------------------------*/
			init: function() {
				//Form
				mi.forms.evaluateOnline = new form;
				mi.forms.evaluateOnline.init('sell-proposal', 'index.php?c=sellajax&m=proposal', {
					submitButtonId: '#sell-proposal-submit',
					debug: false,
					
					onSend: function(selfForm, dataForm) {
						//Request
						$.ajax({
							type: 'POST',
							url: 'index.php?c=sellajax&m=proposalsend',
							data: dataForm,
							dataType: 'json',
							
							success: function(res) {																										
								if (res.success) {
									mi.alerts.contactIndexSend = new alerts;
									mi.alerts.contactIndexSend.init({
										title: 'Contact',
										content: '<div class="contact-alert-send"><img src="' + mi.config.baseUrl + mi.config.baseImages + 'valid.png" border="0" alt="' + mi.lang.contactSendSuccess + '" /><br />' + mi.lang.contactSendSuccess + '</div>'
									});
									
									//Reset form
									selfForm.reset();
									
								} else {
									alert('Send message "sell proposal" error !');	
								}
							}
						});
					}
				});
				
				//Location
				mi.forms.evaluateOnline.location = new autocomplete();
				mi.forms.evaluateOnline.location.init({
					acId: 					'autocomplete_evaluate_location',
					ajaxUrl: 				'index.php?c=searchajax&m=townList',
					parent: 				'evaluate_location',
					parentPos: 			'#evaluate_location',
					position:				{top: 21, left: 2},
					noResult: 			'<p style="text-align:center; padding:2px;">' + mi.lang.townNoResult + '</p>',
					mapValue:				'%ville%',
					mapList:				'<li villeid="%_ID%" dataId="%dataId%">{ville}<div style="float:right; font-style:italic;">%code_postal%</div></li>'
				});
			}
		} //Enf of "sell.proposal" class
		
	},  //Enf of "sell" class
	
	// --------------------------------------------------------------------
	
	/**
	 * Evaluate class
	 *
	 * @access public
	 */
	evaluate: {
		
		/*--------------------------------
		| Detail class
		| @var		mi.evaluate.online
		--------------------------------*/
		online: {		
			/*--------------------------------
			| Init "evaluate.online" class
			| @var		mi.evaluate.online.init
			--------------------------------*/
			init: function() {
				//Form
				mi.forms.evaluateOnline = new form;
				mi.forms.evaluateOnline.init('evaluate-online', 'index.php?c=evaluateajax&m=online', {
					submitButtonId: '#evaluate-online-submit',
					debug: false,
					
					onSend: function(selfForm, dataForm) {
						//Request
						$.ajax({
							type: 'POST',
							url: 'index.php?c=evaluateajax&m=onlinesend',
							data: dataForm,
							dataType: 'json',
							
							success: function(res) {
								if (res.success) {
									mi.alerts.contactIndexSend = new alerts;
									mi.alerts.contactIndexSend.init({
										title: 'Contact',
										content: '<div class="contact-alert-send"><img src="' + mi.config.baseUrl + mi.config.baseImages + 'valid.png" border="0" alt="' + mi.lang.contactSendSuccess + '" /><br />' + mi.lang.contactSendSuccess + '</div>'
									});
									
									//Reset form
									selfForm.reset();
									
								} else {
									alert('Send message "evaluate online" error !');	
								}
							}
						});
					}
				});
				
				//Location
				mi.forms.evaluateOnline.location = new autocomplete();
				mi.forms.evaluateOnline.location.init({
					acId: 					'autocomplete_evaluate_location',
					ajaxUrl: 				'index.php?c=searchajax&m=townList',
					parent: 				'evaluate_location',
					parentPos: 			'#evaluate_location',
					position:				{top: 21, left: 2},
					noResult: 			'<p style="text-align:center; padding:2px;">' + mi.lang.townNoResult + '</p>',
					mapValue:				'%ville%',
					mapList:				'<li villeid="%_ID%" dataId="%dataId%">{ville}<div style="float:right; font-style:italic;">%code_postal%</div></li>'
				});
			}
		}, //Enf of "evaluate.online" class
		
		/*--------------------------------
		| Detail class
		| @var		mi.evaluate.visit
		--------------------------------*/
		visit: {		
			/*--------------------------------
			| Init "evaluate.visit" class
			| @var		mi.evaluate.visit.init
			--------------------------------*/
			init: function() {
				//Form
				mi.forms.evaluateOnline = new form;
				mi.forms.evaluateOnline.init('evaluate-visit', 'index.php?c=evaluateajax&m=visit', {
					submitButtonId: '#evaluate-visit-submit',
					debug: false,
					
					onSend: function(selfForm, dataForm) {
						//Request
						$.ajax({
							type: 'POST',
							url: 'index.php?c=evaluateajax&m=visitsend',
							data: dataForm,
							dataType: 'json',
							
							success: function(res) {																			
								if (res.success) {
									mi.alerts.contactIndexSend = new alerts;
									mi.alerts.contactIndexSend.init({
										title: 'Contact',
										content: '<div class="contact-alert-send"><img src="' + mi.config.baseUrl + mi.config.baseImages + 'valid.png" border="0" alt="' + mi.lang.contactSendSuccess + '" /><br />' + mi.lang.contactSendSuccess + '</div>'
									});
									
									//Reset form
									selfForm.reset();
									
								} else {
									alert('Send message "evaluate online" error !');	
								}
							}
						});
					}
				});
				
				//Location
				mi.forms.evaluateOnline.location = new autocomplete();
				mi.forms.evaluateOnline.location.init({
					acId: 					'autocomplete_evaluate_location',
					ajaxUrl: 				'index.php?c=searchajax&m=townList',
					parent: 				'evaluate_location',
					parentPos: 			'#evaluate_location',
					position:				{top: 21, left: 2},
					noResult: 			'<p style="text-align:center; padding:2px;">' + mi.lang.townNoResult + '</p>',
					mapValue:				'%ville%',
					mapList:				'<li villeid="%_ID%" dataId="%dataId%">{ville}<div style="float:right; font-style:italic;">%code_postal%</div></li>'
				});
			}
		} //Enf of "evaluate.visit" class
		
	},  //Enf of "evaluate" class
	
	// --------------------------------------------------------------------
	
	/**
	 * Diags class
	 *
	 * @access public
	 */
	diags: {
		
		/*--------------------------------
		| Diags class
		| @var		mi.diags.check
		--------------------------------*/
		check: {		
			/*--------------------------------
			| Init "diags.check" class
			| @var		mi.diags.check.init
			--------------------------------*/
			init: function() {
				//Form contact
				mi.forms.diagsCheck = new form;
				mi.forms.diagsCheck.init('diags-check', 'index.php?c=diagsajax&m=diagscheck', {
					submitButtonId: '#diags-check-button'
				});
				
				//Location
				mi.search.initLocation();
				
				//Init change
				$('#diags-check .radio-checkbox-button li').mouseup(function() {
					mi.diags.check.formsDisplay();
				});
				$('#diags-check select').change(function() {
					mi.diags.check.formsDisplay();
				});
				
				//Init form
				this.formsDisplay();
			},
			
			/*--------------------------------
			| Init "diags.check" class
			| @var		mi.diags.check.formsDisplay
			--------------------------------*/
			formsDisplay: function () {
				var tmp 						= $('#diags-check').serializeArray();
				var data 						= {};
				var formCheck				= {};
				var checkUrl				= ""; //Default check (full form)
				
				//Format data
				for (x in tmp) 
					eval('data.' + tmp[x].name + ' = "' + tmp[x].value + '";');
				
				//alert(data.toSource());
				
				//Electricity age && Gas age
				if (data.diags_deal == 'rent_empty' || (data.diags_deal != 'rent_empty' && (data.diags_construction_date == "" || data.diags_construction_date == 2))) {
					$('#bloc-electricity-age, #bloc-gas-age').css('display', 'none');
					formCheck.aged = false;
				} else {
					$('#bloc-electricity-age, #bloc-gas-age').css('display', 'block');
					formCheck.aged = true;
				}
				
				//Condominium
				if (data.diags_deal == 'rent_empty' || data.diags_deal == 'rent_furnished') {
					$('#bloc-condominium').css('display', 'none');
					formCheck.condominium = false;
				} else {
					$('#bloc-condominium').css('display', 'block');
					formCheck.condominium = true;
				}
				
				//Make param
				if ( ! formCheck.condominium && ! formCheck.aged)
					checkUrl = '&type=3';
				else if ( ! formCheck.condominium && formCheck.aged)
					checkUrl = '&type=type1';
				else if (formCheck.condominium && ! formCheck.aged)
					checkUrl = '&type=type2';
				
				//Set new check type
				mi.forms.diagsCheck.opts.ajaxUrl = 'index.php?c=diagsajax&m=diagscheck' + checkUrl;
			}
			
		} //Enf of "diags.check" class
	},  //Enf of "diags" class
	
	// --------------------------------------------------------------------
	
	/**
	 * Agent class
	 *
	 * @access public
	 */
	agent: {
		
		/*--------------------------------
		| Detail class
		| @var		mi.agent.detail
		--------------------------------*/
		detail: {		
			/*--------------------------------
			| Init "contact.basic" class
			| @var		mi.agent.detail.init
			--------------------------------*/
			init: function() {
				//Init slider
				mi.property.slider.init();
				
			}
		} //Enf of "agent.detail" class
	},  //Enf of "agent" class
	
	/*--------------------------------
	| Agency class
	| @var		mi.contact.agency
	--------------------------------*/
	agency: {
		map: false,
		
		/*--------------------------------
		| Init "contact.agency" class
		| @var		mi.contact.agency.init
		--------------------------------*/
		init: function(mapAdress) {
			//Google map
			this.map = new cocciMap();
			this.map.init('contact-agency-gmap', {
				zoom: 13,
				address: mapAdress,
				mapTypeControl: false,
				navigationControl: true,
				scaleControl: false,
				markers: [
									{
										address: mapAdress
									}
								 ]
		  });
		}
	}, //Enf of "contact.agency" class
	
	// --------------------------------------------------------------------
	
	/**
	 * Contact class
	 *
	 * @access public
	 */
	contact: {
		/*--------------------------------
		| Basic class
		| @var		mi.contact.basic
		--------------------------------*/
		basic: {		
			/*--------------------------------
			| Init "contact.basic" class
			| @var		mi.contact.basic.init
			--------------------------------*/
			init: function(formId, buttonId, urlAddon, title) {
				if (typeof(urlAddon) == 'undefined') {
					alert('init "' + formId + '" error : No url addon !');
					return false;
				}
				
				//Form contact
				mi.forms.contactBasic = new form;
				mi.forms.contactBasic.init(formId, 'index.php?c=contactajax&m=contactdefault', {
					submitButtonId: buttonId,
					debug: false,
					onSend: function(selfForm, dataForm) {
						//Request
						$.ajax({
							type: 'POST',
							url: 'index.php?c=contactajax&m=contactdefaultsend&' + mi.tools.html_entity_decode(urlAddon),
							data: dataForm,
							dataType: 'json',
							
							success: function(res) {																
								if (res.success) {
									mi.alerts.contactIndexSend = new alerts;
									mi.alerts.contactIndexSend.init({
										title: 'Contact',
										content: '<div class="contact-alert-send"><img src="' + mi.config.baseUrl + mi.config.baseImages + 'valid.png" border="0" alt="' + mi.lang.contactSendSuccess + '" /><br />' + mi.lang.contactSendSuccess + '</div>'
									});
									
									//Google analytics
									if ( ! title)
										title = "unknow title";
									
									if (formId == "contact-default")
										gaq = ['_trackEvent', 'contact', 'general'];
									else if (formId == "contact-agency")
										gaq = ['_trackEvent', 'contact', 'agence', title];
									else if (formId == "contact-agent")
										gaq = ['_trackEvent', 'contact', 'mandataire', title];
									else
										gaq = ['_trackEvent', 'contact', 'unknow type', title];
									
									_gaq.push(gaq);
									
									//Reset form
									selfForm.reset();
									
								} else {
									alert('Send message error !');	
								}
							}
						});
					}
				});
			}
		} //Enf of "contact.basic" class
				
		
	}, //Enf of "contact" class
	
	// --------------------------------------------------------------------
	
	/**
	 * Seller class
	 *
	 * @access public
	 */
	seller: {
		/*--------------------------------
		| Login class
		| @var		mi.seller.login
		--------------------------------*/
		login: {		
			/*--------------------------------
			| Init "seller.login" class
			| @var		mi.seller.login.init
			--------------------------------*/
			init: function() {				
				//Form contact
				mi.forms.sellerLogin = new form;
				mi.forms.sellerLogin.init('seller-login', 'index.php?c=sellerajax&m=login', {
					submitButtonId: '#seller-submit',
					debug: false
				});
			}
		}, //Enf of "seller.login" class
		
		/*--------------------------------
		| Stats class
		| @var		mi.seller.stats
		--------------------------------*/
		stats: {
			animateBlocDuration: 1500,
			currentBlocOpen: false,
			
			/*--------------------------------
			| Init "seller.stats" class
			| @var		mi.seller.stats.init
			--------------------------------*/
			init: function() {
				//Check length
				if ($('.seller-stats-property-title').length == 1)
					return false;
				
				$('.seller-stats-property-title').click(function() {
					mi.seller.stats.blocAnim($(this).parent().attr('id'));
				});
			},
			
			/*--------------------------------
			| Init "seller.stats" class
			| @var		mi.seller.stats.blocAnim
			--------------------------------*/
			blocAnim: function(blocId) {
				//Check
				if (this.currentBlocOpen == blocId)
					return false;
				
				//init
				var open = false;
				
				$('.seller-stats-property-title').each(function() {
					//Save new opened
					mi.seller.stats.currentBlocOpen = blocId;
					
					//Find if open or close
					open = ($(this).parent().attr('id') == blocId) ? true : false;
					
					//Anim
					$(this).parent().animate({
						height: (open) ? $(this).parent().find('.seller-stats-property-container').height() + 28 : 25
						
					}, mi.seller.stats.animateBlocDuration);
					
					//Icon
					$(this).find('span.mi-icon-right')
					.removeClass((open) ? 'mi-icon-arrow-grey-s' : 'mi-icon-arrow-grey-n')
					.addClass((open) ? 'mi-icon-arrow-grey-n' : 'mi-icon-arrow-grey-s');
				});
			}
			
		} //Enf of "seller.stats" class
		
	} //Enf of "seller" class


}; //End of mi class

