function getStringDateRange(from, to){
    fromDate = new Date(from);
    toDate = new Date(to);
    fromMilliseconds = fromDate.getTime();
    toMilliseconds = toDate.getTime();
    ONE_DAY_MILLSECS = 60 * 60 * 1000 * 24;
    return (toMilliseconds- fromMilliseconds)/ONE_DAY_MILLSECS;
}
function getDateRange(fromDate, toDate){
    fromMilliseconds = fromDate.getTime();
    toMilliseconds = toDate.getTime();
    ONE_DAY_MILLSECS = 60 * 60 * 1000 * 24;
    return (toMilliseconds- fromMilliseconds)/ONE_DAY_MILLSECS;
}

function getBeforeDate(date, number){
    MILLSECS = 60 * 60 * 1000 * 24 * number;
    dateMilliseconds = date.getTime();
    return new Date(dateMilliseconds - MILLSECS);
}
function getAfterDate(date, number){
    MILLSECS = 60 * 60 * 1000 * 24 * number;
    dateMilliseconds = date.getTime();
    return new Date(dateMilliseconds + MILLSECS);
}

function createDate(strDate){
    arrStrDate = strDate.split("-");
    strYear=arrStrDate[0];
    strMonth=arrStrDate[1];
    strDay=arrStrDate[2];
    strDate=strYear+"/"+strMonth+"/"+strDay;
    return new Date(strDate);
}

function createDateObject(strDate,strTime){
    arrStrDate = strDate.split("-");
    strYear=arrStrDate[0];
    strMonth=arrStrDate[1];
    strDay=arrStrDate[2];
    strDate=strYear+"/"+strMonth+"/"+strDay+" "+strTime;
    return new Date(strDate);
}
function formatDateTime(dateObject){
  month = dateObject.getMonth() + 1;
  return dateObject.getFullYear() + "-"
	+ month + "-"
	+ dateObject.getDate() + " "
	+ dateObject.getHours() + ":"
	+ dateObject.getMinutes();
}

function formatDate(dateObject){
  month = dateObject.getMonth() + 1;
  return dateObject.getFullYear() + "-"
	+ month + "-"
	+ dateObject.getDate() + " ";
}

function formatTime(dateObject){
  return dateObject.getHours() + ":"
	+ dateObject.getMinutes();
}

function isEarlierThanToday(date){
   
	today = new Date();
	if (createDate(date).getTime() > today.getTime()){
	
		return false;
	}
	else{
	 	if (createDate(date).getDate() == today.getDate())
	 		return false;
		return true;
	}
}

function isEarlierThanEndday(date,number)
{   
	today = new Date();
	endday = getAfterDate(today,number);
	if (createDate(date).getTime() < endday.getTime())
	{	
		return true;
	}
	else
	{
	 	return false;
	}
}

function isValidStartEndDate(startDate, endDate){
	if (createDate(endDate).getTime() > createDate(startDate).getTime()){
		return true;
	}
	else{
		return false;
	}
}

function isAfterEndDate(startDate, endDate){
	if (createDate(endDate).getTime() >= createDate(startDate).getTime()){
		return true;
	}
	else{
		return false;
	}
}

function isInLimitDate(startDateObj, endDateObj){
  if( startDateObj==null || startDateObj.value=="" || endDateObj==null || endDateObj.value=="" ){
   
    return false;
  }
  var MinMilli = 1000 * 60;
  var HrMilli  = MinMilli * 60;
  var DyMilli  = HrMilli * 24;
  var dayLimit = 10;//13
  deffenMills   = Date.parse(convertDateFormat(endDateObj.value)) - Date.parse(convertDateFormat(startDateObj.value));
  if( deffenMills<0 ){
  
    return false;
  }
  var dayLength = Math.round(deffenMills/DyMilli);
  
  if( dayLength >dayLimit ){
 
    return false;
  }
 
  return true;
}

function convertDateFormat(strDate){
  var year  = strDate.substr(0,4);
  var month = strDate.substr(5,2);
  var day   = strDate.substr(8,2);
  var newDateFormate = month + "-" + day + "-" + year;
  return newDateFormate;
}