String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

/**********************************************************************************
 * To remove all accent characters, replace space by hiphen and return small letter  
 **********************************************************************************/
function removeAccents(str) {
	
	str = str.toLowerCase();
	
	str = str.replace(/\t\n/,'');

	str = str.replace(/[\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5]/g,'a');
	str = str.replace(/[\u00E7]/g,'c');
	str = str.replace(/[\u00E8\u00E9\u00EA\u00EB]/g,'e');
	str = str.replace(/[\u00EC\u00ED\u00EE\u00EF]/g,'i');
	str = str.replace(/[\u00F2\u00F3\u00F4\u00F5\u00F6\u00F8]/g,'o');
	str = str.replace(/[\u00F9\u00FA\u00FB\u00FC]/g,'u');
	str = str.replace(/[\u00FD\u00FF]/g,'y');
	str = str.replace(/[\u00F1]/g,'n');
	str = str.replace(/[\u0153]/g,'oe');
	str = str.replace(/[\u00E6]/g,'ae');
	str = str.replace(/[\u00DF]/g,'ss');

	str = str.replace(/[^a-z0-9_\s\'\:\/\[\]-]/g,'');
	str = str.replace(/[\s\'\:\/\[\]-]+/g,' ');
	str = str.replace(/[ ]/g,'-');

	return str;
	
}

$(document).ready(function() {

});

if(document.all) {
	function blink_show() {
		$('blink').each(function() { $(this).css('visibility', 'visible'); });
		window.setTimeout( 'blink_hide()', 700 );
	}

	function blink_hide() {
		$('blink').each(function() { $(this).css('visibility', 'hidden'); });
		window.setTimeout( 'blink_show()', 250 );
	}

	window.onload = blink_show;
}

/*set variable for facebook from facebook_app.php
******/
var fb_data_name="";
var fb_data_email="";
var fb_data_id="";
function fb_data_set(fb_data){
	eval(fb_data);
}
$(document).ready(function() {
    $(this)
        .find('form')
            .submit(function() { // validation des champs obligatoires
                var nb_error = 0;
                $(this)
                    .find('.oblig')
                        .each(function() {
                            if($(this).val().trim() == '') { // champ vide
                                $(this)
                                    .addClass('error')
                                    .focus(function() { $(this).removeClass('error'); });   
                                nb_error++;
                            }
                        })
                    .end();
                if(nb_error != 0) {
                    alert('Veuillez remplir le(les) champ(s) indiqué(s)');
                    scrollTo(0,0);
                    return false;
                }
                return true;
            })
        .end();
});
