///////////////////////////////////////////////////////////////////////////////////
// returns the rounded value of `value` - with precision digits after .point //////
///////////////////////////////////////////////////////////////////////////////////
function roundWithPrecision(value, precision) {
	var precisionDecimalValue=Math.pow(10,precision);
	return Math.round(value*precisionDecimalValue)/precisionDecimalValue;
}

///////////////////////////////////////////////////////////////////////////////////
// CHECKS IF A VALUE THAT IS NOT NUMERIC - AND SETS 0 IF SO ///////////////////////
///////////////////////////////////////////////////////////////////////////////////
function clearsNumber(value) {
	if (!(value>=0) || value=='')
		return 0;
	else
		return value;
}

///////////////////////////////////////////////////////////////////////////////////
// Check if string is numeric
///////////////////////////////////////////////////////////////////////////////////
function isInteger(strString) {
   //  check for valid numeric strings

   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}
//--------------------------------
// EXPLODE a STRING to an ARRAY (depending on the separators)
//--------------------------------

function explodeString(theString, separators){
	var result=Array();
	lastSeparatorPos=-1;

	for(var i=0; i<theString.length; i++){
		for(var j=0;j<separators.length;j++){
			if(theString.charAt(i)==separators[j]){

				if(theString.substring(lastSeparatorPos+1,i)!='')
					result.push(theString.substring(lastSeparatorPos+1,i));

				lastSeparatorPos=i;
				break;
			}
		}
	}
	if(lastSeparatorPos<theString.length){
		result.push(theString.substring(lastSeparatorPos+1,theString.length));
	}

	return result;
}

//------------------------------------------------
// cancel reservation
//------------------------------------------------
function cancelReservation(reservationId) {
	var answer = confirm("Esti sigur(a) ca vrei sa anulezi aceasta rezervare?")
	if (answer){
		window.location = "?section=user&subsection=reservationList&xxReservation="+reservationId;
	}
}
