
function confirmation(title, message, action)
{
	var confBox = '';
	confBox += '<div id="confirmationBox" title="'+title+'">'
			+ '<p>'+message+'</p>'
			+ '</div>';

	var body = $("body")[0];
	$(body).append(confBox);
	$("#confirmationBox").dialog(	
			{
        modal: true,
				close: function(event, ui) 
				{
					$('#confirmationBox').remove();
				},
				buttons:
				{
				 Annuler : function(event, ui) 
		 					{
								$(this).dialog('close');
								try {
									action.cancel();
								} catch (e) {
								}
							},
				 Confirmer : function(event, ui) 
							{	
								$(this).dialog('close');
								action.action();
							}
				}				
			}
				
	);
}

function warning(title, message)
{
  var confBox = '';
  confBox += '<div id="warningBox" title="'+title+'">'
      + '<p>'+message+'</p>'
      + '</div>';

  var body = $("body")[0];
  $(body).append(confBox);
  $("#warningBox").dialog( 
      {
        modal: true,
        close: function(event, ui) 
        {
          $('#warningBox').remove();
        },
        buttons:
        {
         Ok: function(event, ui) 
              { 
                $(this).dialog('close');
              }
        }       
      }
        
  );
}


function trim(myString)
{
  return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
} 

function delPlug(plugId)
{
  
  //alert(applicationPath+'/dashboard/index/delplug/plug_id/'+plugId);
  
  var confBox = '<div id="delplugBox" title="Suppression de Widget">'
      + '<p id="p_delplugBox">Patientez...</p>'
      + '</div>';

  var body = $("body")[0];
  $(body).append(confBox);
  $("#delplugBox").dialog( 
      {
        modal: true,
        close: function(event, ui) 
        {
          $('#delplugBox').remove();
        },
        buttons:
        {
         Ok: function(event, ui) 
              { 
                $(this).dialog('close');
                reloadTab("#dashboard");
              }
        }       
      }
        
  );
  $("#p_delplugBox").load(applicationPath+'/dashboard/index/delplug/plug_id/'+plugId);

}


function addPlug(plugUrl)
{
  
  //alert(applicationPath+'/dashboard/index/addplug/plug_id/'+plugId);
  
  var confBox = '<div id="addplugBox" title="Ajout de Widget">'
      + '<p id="p_addplugBox">Patientez...</p>'
      + '</div>';

  var body = $("body")[0];
  $(body).append(confBox);
  $("#addplugBox").dialog( 
      {
        modal: true,
        close: function(event, ui) 
        {
          $('#addplugBox').remove();
        },
        buttons:
        {
         Ok: function(event, ui) 
              { 
                $(this).dialog('close');
                reloadTab("#dashboard");
              }
        }       
      }
        
  );
  $("#p_addplugBox").load(applicationPath+'/dashboard/index/addplug/plug_url/'+plugUrl);
  return false;
}

//code anythingslider demo
function formatText(index, panel) {
	return index + "";
	}
	    
$(function () {
	        
	$('.anythingSlider').anythingSlider({
	   easing: "easeInOutExpo", // Anything other than "linear" or "swing" requires the easing plugin
	   autoPlay: true, // This turns off the entire FUNCTIONALY, not just if it starts running or not.
	   delay: 3000, // How long between slide transitions in AutoPlay mode
	   startStopped: false, // If autoPlay is on, this can force it to start stopped
	   animationTime: 600, // How long the slide transition takes
	   hashTags: true, // Should links change the hashtag in the URL?
	   buildNavigation: true, // If true, builds and list of anchor links to link to each slide
	   pauseOnHover: true, // If true, and autoPlay is enabled, the show will pause on hover
	   startText: "Go", // Start text
	   stopText: "Stop", // Stop text
	   navigationFormatter: formatText // Details at the top of the file on this use (advanced use)
	 });
	            
	$("#slide-jump").click(function(){
	   $('.anythingSlider').anythingSlider(6);
	});
	            
});
