function right(str,nbCar)
{
  if (nbCar>=str.length){return str;}
  if (nbCar<=0){return "";}
  var newStr=str.substring(str.length,str.length-nbCar);
  return newStr;
}

function cutRight(string,n)
{
	if (n>=string.length){return "";}
	if (n<=0){return string;}
	var newStr=string.substring(0,string.length-n);
	return newStr;
}

// Fonction basique pour supprimer les 2 derniers caractères d'une string. Ici les caractères 'px' des propriétés css
// Retourne un integer
function enlevePx(str)
{
  var str=str.substring(0,str.length-2);
  return parseInt(str);
}

// Fonction simple pour suivre un log dans une div du type <div id="log"></div>
// Une fois la div ci-dessus créée dans le document, s'utilise comme suit: log(valeur);
function log(str)
{
  $('#log').html(str);
}


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



// Fonction qui retourne vrai si le navigateur est un iPad ou un iPhone
function iOS()
{
  return null != navigator.userAgent.match(/(iPad|iPhone)/i);
  /*
  if( 
    (navigator.userAgent.match(/iPhone/i)) ||  
    (navigator.userAgent.match(/iPad/i)) || 
    (navigator.userAgent.match(/iPod/i)) ||  
    (navigator.userAgent.match(/symbian/i)) ||  
    (navigator.userAgent.match(/android/i)) ||  
    (navigator.userAgent.match(/series60/i)) ||  
    (navigator.userAgent.match(/windows ce/i)) ||  
    (navigator.userAgent.match(/blackberry/i)) ||  
    (navigator.userAgent.match(/palm/i))  
  )
  { 
    alert("Vous utilisez un navigateur mobile"); 
  } 
  */
}
    
    
// fonctions pour rendre le tri de tableau insensible à la casse.
function charOrdA(a, b)
{
	a = a.toLowerCase(); b = b.toLowerCase();
	if (a>b) return 1;
	if (a <b) return -1;
	return 0;
}

function charOrdD(a, b)
{
	a = a.toLowerCase(); b = b.toLowerCase();
	if (a<b) return 1;
	if (a >b) return -1;
	return 0;
}


/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
*    The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
*/
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];
 
  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
} 

function isset(variable){
if ( typeof( window[variable] ) != "undefined" ) {
     return true;
   }
else {
     return false;
   }
}


