// Validates a date Three arguments month(MON), Date(DD), year(yyyy)
// Returns a Boolean value true or false

function validateDate(myMonthStr, myDayStr, myYearStr){
	var myDateStr = myMonthStr + '/' + myDayStr + '/' + (myYearStr-1);
	var myDate = new Date(myDateStr);
	if ((myDate.getDate() != myDayStr)||(myDate.getMonth()+1 != myMonthStr)){
		return false ;
	}
	return true ;
}
// Validates if start date is prior to end date six arguments month(MON), Date(DD), year(yyyy),month(MON), Date(DD), year(yyyy)
// Returns a int value else Returns 0 if true

function future_DateValidation(startMonthStr, startDayStr, startYearStr,endMonthStr, endDayStr, endYearStr ){
if(!validateDate(startMonthStr,startDayStr,startYearStr)){
  return 6 ;
}	

if(!validateDate(endMonthStr,endDayStr,endYearStr)){
  return 5 ;
}
	
var endDateStr = endMonthStr + '/' + endDayStr + '/' + endYearStr;
var startDateStr = startMonthStr + '/' +startDayStr + '/' + startYearStr;

var endDate = new Date(endDateStr);
var startDate = new Date(startDateStr);

var endDate_string = endDate.toGMTString();
var startDate_string = startDate.toGMTString();
var endDate_array = endDate_string.split(' ');
var startDate_array = startDate_string.split( ' ' );

if (endDate_array[2] == "Jan"){
	endDate_array[2] = 1;
}

if (endDate_array[2] == "Feb"){
	endDate_array[2] = 2;
}

if (endDate_array[2] == "Mar"){
	endDate_array[2] = 3;
}
if (endDate_array[2] == "Apr"){
	endDate_array[2] = 4;
}
if (endDate_array[2] == "May"){
	endDate_array[2] = 5;
}
if (endDate_array[2] == "Jun"){
	endDate_array[2] = 6;
}
if (endDate_array[2] == "Jul"){
	endDate_array[2] = 7;
}
if (endDate_array[2] == "Aug"){
	endDate_array[2] = 8;
}
if (endDate_array[2] == "Sep"){
	endDate_array[2] = 9;
}
if (endDate_array[2] == "Oct"){
	endDate_array[2] = 10;
}
if (endDate_array[2] == "Nov"){
	endDate_array[2] = 11;
}
if (endDate_array[2] == "Dec"){
	endDate_array[2] = 12;
}



if (startDate_array[2] == "Jan"){
	startDate_array[2] = 1;
}
if (startDate_array[2] == "Feb"){
	startDate_array[2] = 2;
}
if (startDate_array[2] == "Mar"){
	startDate_array[2] = 3;
}
if (startDate_array[2] == "Apr"){
	startDate_array[2] = 4;
}
if (startDate_array[2] == "May"){
	startDate_array[2] = 5;
}
if (startDate_array[2] == "Jun"){
	startDate_array[2] = 6;
}
if (startDate_array[2] == "Jul"){
	startDate_array[2] = 7;
}
if (startDate_array[2] == "Aug"){
	startDate_array[2] = 8;
}
if (startDate_array[2] == "Sep"){
	startDate_array[2] = 9;
}
if (startDate_array[2] == "Oct"){
	startDate_array[2] = 10;
}
if (startDate_array[2] == "Nov"){
	startDate_array[2] = 11;
}
if (startDate_array[2] == "Dec"){
	startDate_array[2] = 12;
}




var tmpVar3 = parseInt(endDate_array[3],10);  //Selected Year Array
var tmpVar4 = parseInt(startDate_array[3],10); //start Year Array
var tmpVar = parseInt(endDate_array[2],10);  //Selected Month Array
var tmpVar0 = parseInt(startDate_array[2],10); //start Month Array
var tmpVar1 = parseInt(endDate_array[1],10); //Selected Date Array
var tmpVar2 = parseInt(startDate_array[1],10); //start Date Array


if (tmpVar3 < tmpVar4){
	return 2;
}

if (tmpVar3 == tmpVar4){
	if (tmpVar < tmpVar0){
		return 3;
	}

}

if (tmpVar3 == tmpVar4){
	if (tmpVar == tmpVar0){
			if (tmpVar1 < tmpVar2){
				 return 4;
			}
		}
}
return 0;

}
// Validates if start date is prior to end date 2 arguments start date (day-mon-year) and end date (day-mon-year)
// Returns a int value else Returns 0 if true

function future_DateValidation1(startDate,endDate){
	var param1_array = startDate.split('/');
	var param2_array = endDate.split('/');
	return future_DateValidation(param1_array[0],param1_array[1],param1_array[2],param2_array[0],param2_array[1],param2_array[2]) ;	
}

// Validates if end date is prior to start date 2 arguments start date (mon/day/year) and end date (mon/day/year)
// Returns a int value else Returns 0 if true

function past_DateValidation1(startDate,endDate){
	var param1_array = startDate.split('/');
	var param2_array = endDate.split('/');
	return past_DateValidation(param1_array[0],param1_array[1],param1_array[2],param2_array[0],param2_array[1],param2_array[2]) ;	
}

// Validates if end date is prior to start date six arguments month(MON), Date(DD), year(yyyy),month(MON), Date(DD), year(yyyy)
// Returns a int value else Returns 0 if true

function past_DateValidation(startMonthStr, startDayStr, startYearStr,endMonthStr, endDayStr, endYearStr ){
if(!validateDate(startMonthStr,startDayStr,startYearStr)){
		return 6 ;
	}	

if(!validateDate(endMonthStr,endDayStr,endYearStr)){
		return 5 ;
	}
	

var endDateStr = endMonthStr + '/' + endDayStr + '/' + endYearStr;
var startDateStr =  startMonthStr + '/' + startDayStr + '/' + startYearStr;

var endDate = new Date(endDateStr);
var startDate = new Date(startDateStr);

var endDate_string = endDate.toGMTString();
var startDate_string = startDate.toGMTString();
var endDate_array = endDate_string.split(' ');
var startDate_array = startDate_string.split( ' ' );


if (endDate_array[2] == "Jan")
{
endDate_array[2] = 1;
}
if (endDate_array[2] == "Feb")
{
endDate_array[2] = 2;
}
if (endDate_array[2] == "Mar")
{
endDate_array[2] = 3;
}
if (endDate_array[2] == "Apr")
{
endDate_array[2] = 4;
}
if (endDate_array[2] == "May")
{
endDate_array[2] = 5;
}
if (endDate_array[2] == "Jun")
{
endDate_array[2] = 6;
}
if (endDate_array[2] == "Jul")
{
endDate_array[2] = 7;
}
if (endDate_array[2] == "Aug")
{
endDate_array[2] = 8;
}
if (endDate_array[2] == "Sep")
{
endDate_array[2] = 9;
}
if (endDate_array[2] == "Oct")
{
endDate_array[2] = 10;
}
if (endDate_array[2] == "Nov")
{
endDate_array[2] = 11;
}
if (endDate_array[2] == "Dec")
{
endDate_array[2] = 12;
}



if (startDate_array[2] == "Jan")
{
startDate_array[2] = 1;
}
if (startDate_array[2] == "Feb")
{
startDate_array[2] = 2;
}
if (startDate_array[2] == "Mar")
{
startDate_array[2] = 3;
}
if (startDate_array[2] == "Apr")
{
startDate_array[2] = 4;
}
if (startDate_array[2] == "May")
{
startDate_array[2] = 5;
}
if (startDate_array[2] == "Jun")
{
startDate_array[2] = 6;
}
if (startDate_array[2] == "Jul")
{
startDate_array[2] = 7;
}
if (startDate_array[2] == "Aug")
{
startDate_array[2] = 8;
}
if (startDate_array[2] == "Sep")
{
startDate_array[2] = 9;
}
if (startDate_array[2] == "Oct")
{
startDate_array[2] = 10;
}
if (startDate_array[2] == "Nov")
{
startDate_array[2] = 11;
}
if (startDate_array[2] == "Dec")
{
startDate_array[2] = 12;
}




var tmpVar3 = parseInt(endDate_array[3],10);  //Selected Year Array
var tmpVar4 = parseInt(startDate_array[3],10); //start Year Array

var tmpVar = parseInt(endDate_array[2],10);  //Selected Month Array
var tmpVar0 = parseInt(startDate_array[2],10); //start Month Array

var tmpVar1 = parseInt(endDate_array[1],10); //Selected Date Array
var tmpVar2 = parseInt(startDate_array[1],10); //start Date Array

if (tmpVar3 > tmpVar4)
{
return 2;
}

if (tmpVar3 == tmpVar4)
{
	if (tmpVar > tmpVar0)
		{
	
		return 3;
		}

}

if (tmpVar3 == tmpVar4)
{
	if (tmpVar == tmpVar0)
		{
			if (tmpVar1 > tmpVar2)
				{

				 return 4;
				}
		}
}
return 0;

}
