// fonctions ajax
var isLoadingPage = false;

$(document).ajaxStart( function() {
					     if (!isLoadingPage) { resetMsg(); }
					     $('body').css('cursor','wait');
                         //$('body').css('cursor','url(./css/images/ajax-loader_bkg_w.gif),url(./css/images/ajax-loader_bkg_w.ico),url(./css/images/ajax-loader_bkg_w.cur), wait');
	                   } );
$(document).ajaxStop( function(){
				        isLoadingPage = false;
	                    $('body').css('cursor','auto');
                      } );
function obtenirAsync(url, datas, callback, method, typeReturn) {
	try {
		$.ajax( {
                 type        : method,
                 url         : url,
                 data        : datas,
                 dataType    : typeReturn,
                 success     : function( returnData ) {
                                 callback ( returnData ); 
                               },
                 error       : function( o, s, e ) {
                                 alert( "ERREUR XMLHttpRequest !\n" + url + "\n" + s );
                               }
                } );
	} catch (e) {
		alert(e.message);
	}
}
// FIN fonctions ajax

// bulles
function tipMessage( target, contentTip, classeTip, posTarget, posTip, widthTip, hideOn) {
	if( typeof target == "string" ) {
		$target = $(target);
	} else {
		$target = target;
	}

	var theClasses = (classeTip || 'ui-tooltip') + ' ui-tooltip-shadow ui-tooltip-rounded';
	var thePosAt   = posTarget || 'bottom center';
	var thePosMy   = posTip || 'top left';
	var theWidth   = widthTip || 70;
	var hideEvent  = hideOn || 0;
	if( !hideEvent ) {
		var hideTip = {
		               event    : false,
					   inactive : 3000
					  };
	} else {
		var hideTip = {
		               event : hideEvent
		              };
	}
	
	$target.qtip( {
	               overwrite : true,
				   content   : contentTip,
				   position  : {
				                at : thePosAt,
								my : thePosMy
							   },
				   show      : {
				                event : false,
								ready : true
							   },
				   hide      : hideTip,
				   style     : {
				                classes : theClasses,
								tip     : {
								           width : theWidth
										  }
				               }
	              } );
}
// FIN bulles

function youtubeFeedCallback( data ) {
	var id = data.entry.id.$t.split(':');
	$('#titre-' + id[ id.length - 1 ] + ' span').html( data.entry.title.$t );
}

function resetMsg() {
	$('#messages').html( '' );
}

function StrFormat(temp, dataarry) {
    return temp.replace(/\{([\d]+)\}/g, function(s1, s2) { var s = dataarry[s2]; if (typeof (s) != "undefined") { if (s instanceof (Date)) { return s.getTimezoneOffset() } else { return encodeURIComponent(s) } } else { return "" } });
}

$(document).ready( function() { 
                     isLoadingPage = true; 
		
		             $('#popMsg').dialog( {
				                           autoOpen      : false,
							               closeOnEscape : true,
							               draggable     : true,
							               modal         : true,
							               title         : 'Confirmation mot cl&eacute;',
							               width         : 450,
							               show          : "scale",
							               hide          : "scale"
							              } );
				   } );
