jQuery.noConflict();
class_avis = function() {
	this.projet;
	this.name;
	this.mail;
	this.txt;
	this.wait;
	this.successMsg='';
	this.errorMsg='';
	return this.init();
	}
jQuery.extend(class_avis.prototype, {
	init:function() {
		this.projet=jQuery('#avis_form #projet').val();
		this.wait = jQuery('#avis_form #avis_loading');
		},
	setSuccessMsg:function(msg) {
		this.successMsg=msg;
		},
	setErrorMsg:function(msg) {
		this.errorMsg=msg;
		},
	insert:function() {		
		this.name=jQuery('#avis_form #Nom').val();
		this.mail=jQuery('#avis_form #Mail').val();
		this.txt=jQuery('#avis_form #Comment').val();
		if (this.txt!='') {
			this.putAvis();
			}
			else {
				this.error();
				}
		},
	putAvis:function() {
		var obj=this;
		jQuery.ajax({
			type: "POST",			
			url: "./fr/a_vendre_avis.asp",
			dataType: "text",
			async: true,
			data: {
				projet: this.projet,
				mail: this.mail,
				name: this.name,
				txt: this.txt
				},
			beforeSend: function() {
				obj.waiting();
				},
			success: function() {
				obj.success();
				},
			error: function() {
				obj.error();
				}
			});
		},
	waiting:function() {
		this.background(1);
		this.wait.html('');
		},
	success:function() {
		this.background(0);
		this.wait.css({
			'background-image':'url(./images/ico_correct.gif)'
			});
		var txt = '';
		txt+='<span style="color:green;">';
		txt+=this.successMsg;
		txt+='</span>';
		this.wait.html(txt);		
		},
	error:function() {
		this.background(0);
		this.wait.css({
			'background-image':'url(./images/ico_error.gif)'
			});
		var txt = '';
		txt+='<span style="color:red;">';
		txt+=this.errorMsg;
		txt+='</span>';
		this.wait.html(txt);	
		},
	background:function(flag) {
		switch(flag) {
			case 1:
				this.wait.css({
					'background-image':'url(./images/waiting.gif)'
					});
				break;
			case 0:
				this.wait.css({
					'background-image':'none'
					});
				break;
			}		
		}
	});
