/**
 * CONFIRM
 */
jQuery.fn.confirm = function () {
	this.click(function(){
		if (!window.confirm(jQuery(this).attr('title'))) {
			return false;
		}
	});
};

/**
 * CREATE A ROLL OVER ON IMAGES
 */
jQuery.fn.rollOver = function (options) {
	var settings = {
		suffixe: '_over'
	};
	
	if(options){
		jQuery.extend(settings, options);
	}
	
	var images = this.filter('img');
	
	images.each(function(index){
		var image = jQuery(this);
		var fileName 					= image.attr('src');
		var fileNameWithoutExtension	= fileName.substring(0, fileName.lastIndexOf('.'));
		var fileExtension				= fileName.substring(fileName.lastIndexOf('.'), fileName.length);
		
		var imgSrc 		= fileName;
		var imgSrcOver 	= fileNameWithoutExtension + settings.suffixe + fileExtension;
		
		image.mouseover(function(){
			jQuery(this).attr('src', imgSrcOver);
		});
		image.mouseout(function(){
			jQuery(this).attr('src', imgSrc);
		});
	});
};

/**
 * DELETE DEFAULT VALUE ON FOCUS
 */
jQuery.fn.deleteDefaultValueOnFocus = function () {
	
	
	this.each(function(index){
					   
		var inputField 		= jQuery(this);		
		var defaultValue 	= inputField.val();
	
		inputField.focus(function(){
			var myInput = jQuery(this);
			if (myInput.val() == defaultValue) {
				myInput.val('');
			}
		});
		
		inputField.blur(function(){
			var myInput = jQuery(this);
			if (myInput.val() == '') {
				myInput.val(defaultValue);
			}
		});		
	});	
};

/**
 * SIMPLE ANTI SPAM : INPUT formMode true/false
 */

jQuery.fn.simpleAntiSpam = function (nameForm) {
	this.focus(function(){
		jQuery('input[name=' + nameForm + 'Mode]').val('true');
	});
};

