
var deptdateformat = 'mm/dd/yy'; //Set the dateformat

// returns array with days in the months

function deptdatearrayOfDaysInMonths(adm_isLeapYear) 
{
	this[0] = 31;
	this[1] = 28;
	// if Leap Year there is 29 days in Feb
	if (adm_isLeapYear)
		this[1] = 29;
	this[2] = 31;
	this[3] = 30;
	this[4] = 31;
	this[5] = 30;
	this[6] = 31;
	this[7] = 31;
	this[8] = 30;
	this[9] = 31;
	this[10] = 30;
	this[11] = 31;

}


// _________________________________________________________
// The next two functions handle the formatting of the date.
// To add a new mask you only need to added the conversion
// to the next two functions respectively
// _________________________________________________________

// Split the date based on format
function deptdateSplitDate(stDate)
{
	arryDate = stDate.split('/');
	arryNewDate = new Array(3);
	if (deptdateformat == 'mm/dd/yy')
		arryNewDate = new Array(arryDate[0]-0,arryDate[1]-0,arryDate[2]);
	else
	if(deptdateformat == 'dd/mm/yy')
		arryNewDate = new Array(arryDate[1]-0,arryDate[0]-0,arryDate[2]);
		return arryNewDate;
	//Return date array: [0] = month, [1] = day, [2] = year
}


// Join the date based on format
function deptdateJoinDate(arryDate)
{
	//arryDate: [0] = month, [1] = day, [2] = year
	if (deptdateformat == 'mm/dd/yy')
		var stDate = (arryDate[0]<10?'0'+arryDate[0]:arryDate[0]) + '/' + (arryDate[1]<10?'0'+arryDate[1]:arryDate[1]) + '/' +   arryDate[2];
	else 
		if(deptdateformat == 'dd/mm/yy')
			var stDate = (arryDate[1]<10?'0'+arryDate[1]:arryDate[1]) + '/' + (arryDate[0]<10?'0'+arryDate[0]:arryDate[0]) + '/' +   arryDate[2];
	return stDate
}


// Returns the days in the given month and year
function deptdatedaysInMonth(dim_month,dim_year) 
{
	// Check for leap year
	var dim_isLeapYear = (((dim_year % 4 == 0) && ( dim_year % 100 != 0)) || (dim_year % 400 == 0));
	// Create array of days in each month
	var dim_monthDays = new deptdatearrayOfDaysInMonths(dim_isLeapYear);
	// Return the days in month
	return dim_monthDays[dim_month];
}


// Validates date on onBlur of date field
function deptdateValidateDate(strDate) 
{
	arryDate = deptdateSplitDate(strDate);
	// Split the date up into a month day year array
	if ((isNaN(parseInt(arryDate[2])) || isNaN(parseInt(arryDate[0])) || arryDate[0] > 12 || isNaN(parseInt(arryDate[1])) || arryDate[1] > deptdatedaysInMonth(arryDate[0] - 1,arryDate[2]))) 
	{
		Start();
		//arryDate[0] = new Date().getMonth() + 1 ;
		//arryDate[1] = new Date().getDate();
		//arryDate[2] = new Date().getFullYear() - 2000;
		//arryDate[2] = (arryDate[2]<10? '0' + arryDate[2] :arryDate[2]);
		//document.req.deptdate.value = deptdateJoinDate(arryDate);
	}
}


function deptdatenextDay(n) 
{
	currDate = document.forms['req'].elements['deptdate'].value;
	arryDate = deptdateSplitDate(currDate);
	// Split the date up into a month day year array
	arryDate = deptdateisValidDate(arryDate);
	if (arryDate[0] == 12 && arryDate[1] == 31 && arryDate[2] == 99)
	{}
	else 
	{
		daysinCurrMonth = deptdatedaysInMonth(parseInt(arryDate[0])-1,parseInt(arryDate[2]));
		// Get the number of days in the current month
		arryDate[1] = parseInt(arryDate[1]) + n;
		// Add one to the day
		// Check for day value to be more than days in the month
		if (arryDate[1] > daysinCurrMonth) 
		{
			nextMonth = parseInt(arryDate[0]) + 1;
			if (nextMonth > 12) 
			{
				arryDate[0] = 1;
				arryDate[2] = parseInt(arryDate[2]) + 1;
				if (arryDate[2] < 10) 
				{
					arryDate[2] = '0' + arryDate[2]; 
				}
			}
			else
				arryDate[0] = nextMonth;
			arryDate[1] = 1;
		}
	}
	document.forms['req'].deptdate.value = deptdateJoinDate(arryDate);
	validii();
}

function deptdatepreviousDay(n) 
{
	currDate = document.forms['req'].deptdate.value;
	arryDate = deptdateSplitDate(currDate);
	arryDate = deptdateisValidDate(arryDate);
	if (arryDate[0] == 1 && arryDate[1] == 1 && arryDate[2] == 0) 
	{}
	else 
	{
		daysinPrevMonth = deptdatedaysInMonth(parseInt(arryDate[0])-2,parseInt(arryDate[2]));
		arryDate[1] = parseInt(arryDate[1]) - n;
		// Check for day of zero
		if (arryDate[1] < 1) 
		{
			prevMonth = parseInt(arryDate[0]) - 1;
			if(prevMonth == 0) 
			{
				arryDate[0] = 12;
				arryDate[2] = parseInt(arryDate[2]) - 1;
				if (arryDate[2] < 10) {arryDate[2] = '0' + arryDate[2]; }
				arryDate[1] = 31;
			}
			else 
			{
				arryDate[0] = prevMonth;
				arryDate[1] = daysinPrevMonth;
			}
		}
	}
	document.forms['req'].deptdate.value = deptdateJoinDate(arryDate);
	validii();
}


// Make sure date being processed is valid if not, set date to today
function deptdateisValidDate(dateObj) 
{
	if (isNaN(parseInt(dateObj[0])) || isNaN(parseInt(dateObj[1])) || isNaN(parseInt(dateObj[2]))) 
	{
		dateObj[0] = new Date().getMonth() + 1 ;
		dateObj[1] = new Date().getDate();
		dateObj[2] = new Date().getFullYear() - 2000;
		dateObj[2] = (dateObj[2]<10? '0' + dateObj[2] :dateObj[2]);
	}
	return (dateObj);
}

function y2k(number) 
{
	return (number < 1000) ? number + 1900 : number;
}

var today = new Date();
var day   = today.getDate();
var month = today.getMonth();
var year  = y2k(today.getYear());
var activeDateField;


function restart() 
{
	arryDate = new Array((parseInt(month)+1),day,year)
	//alert(activeDateField.value);
	activeResetFunction = eval(activeDateField.name+'JoinDate');
	activeDateField.value = activeResetFunction(arryDate);
	mywindow.close();
}


function deptdatenewWindow(DateField) 
{
	if (DateField.value != '')
	{
		arryDate = deptdateSplitDate(DateField.value);
		month = arryDate[0]-1;
		year = arryDate[2];
		day = arryDate[1];
		validii();
	}
	activeDateField = DateField;
	mywindow=open('http://' + document.domain + '/ticketsto/comunes/cal.htm','myname','resizable=no,width=350,height=270');
	// mywindow.location.href = 'http://' + document.domain + '/ticketsto/comunes/cal.htm';
	// mywindow=open('http://' + document.domain + '/ticketsto/comunes/cal.htm','myname','resizable=no,width=350,height=270');
	mywindow.location.href = 'http://' + document.domain + '/ticketsto/comunes/cal.htm';
	if (mywindow.opener == null) mywindow.opener = self;

}


function deptdatenewWinPop(DateField) 
{
	if (DateField.value != '')
	{
		arryDate = deptdateSplitDate(DateField.value);
		month = arryDate[0]-1;
		year = arryDate[2];
		day = arryDate[1];
		validii();
	}
	activeDateField = DateField;
	mywindow=open('http://' + document.domain + '/ticketsto/comunes/cal.htm','myname','resizable=no,width=350,height=270');
	mywindow.location.href = 'http://' + document.domain + '/ticketsto/comunes/cal.htm';
	//mywindow=open('http://' + document.domain + '/ticketsto/comunes/cal.htm','myname','resizable=no,width=350,height=270');
	mywindow.location.href = 'http://' + document.domain + '/ticketsto/comunes/cal.htm';
	if (mywindow.opener == null) mywindow.opener = self;
}

var retndateformat = 'mm/dd/yy'; //Set the dateformat

// returns array with days in the months
function retndatearrayOfDaysInMonths(adm_isLeapYear) 
{
	this[0] = 31;
	this[1] = 28;
	// if Leap Year there is 29 days in Feb
	if (adm_isLeapYear)
		this[1] = 29;
	this[2] = 31;
	this[3] = 30;
	this[4] = 31;
	this[5] = 30;
	this[6] = 31;
	this[7] = 31;
	this[8] = 30;
	this[9] = 31;
	this[10] = 30;
	this[11] = 31;
}

// _________________________________________________________
// The next two functions handle the formatting of the date.
// To add a new mask you only need to added the conversion
// to the next two functions respectively
// _________________________________________________________

// Split the date based on format
function retndateSplitDate(stDate)
{
	arryDate = stDate.split('/');
	arryNewDate = new Array(3);
	if (retndateformat == 'mm/dd/yy')
		arryNewDate = new Array(arryDate[0]-0,arryDate[1]-0,arryDate[2]);
	else 
		if(retndateformat == 'dd/mm/yy')
			arryNewDate = new Array(arryDate[1]-0,arryDate[0]-0,arryDate[2]);
	return arryNewDate;
	//Return date array: [0] = month, [1] = day, [2] = year
}


// Join the date based on format
function retndateJoinDate(arryDate)
{
	//arryDate: [0] = month, [1] = day, [2] = year
	if (retndateformat == 'mm/dd/yy')
		var stDate = (arryDate[0]<10?'0'+arryDate[0]:arryDate[0]) + '/' + (arryDate[1]<10?'0'+arryDate[1]:arryDate[1]) + '/' +  arryDate[2];
	else 
		if(retndateformat == 'dd/mm/yy')
			var stDate = (arryDate[1]<10?'0'+arryDate[1]:arryDate[1]) + '/' + (arryDate[0]<10?'0'+arryDate[0]:arryDate[0]) + '/' +  arryDate[2];
	return stDate
}


// Returns the days in the given month and year
function retndatedaysInMonth(dim_month,dim_year) 
{
	 // Check for leap year
	var dim_isLeapYear = (((dim_year % 4 == 0) && ( dim_year % 100 != 0)) || (dim_year % 400 == 0));
	// Create array of days in each month
	var dim_monthDays = new retndatearrayOfDaysInMonths(dim_isLeapYear);
	// Return the days in month
	return dim_monthDays[dim_month];
}

// Validates date on onBlur of date field
function retndateValidateDate(strDate) 
{
	arryDate = retndateSplitDate(strDate);
	// Split the date up into a month day year array
	if ((isNaN(parseInt(arryDate[2])) || isNaN(parseInt(arryDate[0])) || arryDate[0] > 12 || isNaN(parseInt(arryDate[1])) || arryDate[1] > retndatedaysInMonth(arryDate[0] - 1,arryDate[2])))
	{
		//arryDate[0] = new Date().getMonth()+1;
		//arryDate[1] = new Date().getDate();
		//arryDate[2] = new Date().getFullYear() - 2000;
		//arryDate[2] = (arryDate[2]<10? '0' + arryDate[2] :arryDate[2]);
		//document.req.retndate.value = retndateJoinDate(arryDate);
	}
}


function retndatenextDay(n) 
{
	currDate = document.req.retndate.value;
	arryDate = retndateSplitDate(currDate);
	// Split the date up into a month day year array
	arryDate = retndateisValidDate(arryDate);
	if (arryDate[0] == 12 && arryDate[1] == 31 && arryDate[2] == 99)
	{}
	else 
	{
		daysinCurrMonth =retndatedaysInMonth(parseInt(arryDate[0])-1,parseInt(arryDate[2]));
		// Get the number of days in the current month
		arryDate[1] = parseInt(arryDate[1]) + n;
		// Add one to the day
		// Check for day value to be more than days in the month
		if (arryDate[1] > daysinCurrMonth) 
		{
			nextMonth = parseInt(arryDate[0]) + 1;
			if (nextMonth > 12) 
			{
				arryDate[0] = 1;
				arryDate[2] = parseInt(arryDate[2]) + 1;
				if (arryDate[2] < 10) 
				{
					arryDate[2] = '0' + arryDate[2]; 
				}
			}
			else
				arryDate[0] = nextMonth;
			arryDate[1] = 1;
		}
	}
	document.req.retndate.value = retndateJoinDate(arryDate);
}


function retndatepreviousDay(n) 
{
	currDate = document.req.retndate.value;
	arryDate = retndateSplitDate(currDate);
	arryDate = retndateisValidDate(arryDate);
	if (arryDate[0] == 1 && arryDate[1] == 1 && arryDate[2] == 0) 
	{}
	else 
	{
		daysinPrevMonth = retndatedaysInMonth(parseInt(arryDate[0])-2,parseInt(arryDate[2]));
		arryDate[1] = parseInt(arryDate[1]) - n;
		// Check for day of zero
		if (arryDate[1] < 1) 
		{
			prevMonth = parseInt(arryDate[0]) - 1;
			if(prevMonth == 0) 
			{
				arryDate[0] = 12;
				arryDate[2] = parseInt(arryDate[2]) - 1;
				if (arryDate[2] < 10) 
				{
					arryDate[2] = '0' + arryDate[2]; 
				}
				arryDate[1] = 31;
			}
			else 
			{
				arryDate[0] = prevMonth;
				arryDate[1] = daysinPrevMonth;
			}
		}
	}
	document.req.retndate.value = retndateJoinDate(arryDate);
}


// Make sure date being processed is valid if not,
// set date to today
function retndateisValidDate(dateObj) 
{
	if (isNaN(parseInt(dateObj[0])) || isNaN(parseInt(dateObj[1])) || isNaN(parseInt(dateObj[2]))) 
	{
		dateObj[0] = new Date().getMonth()+1;
		dateObj[1] = new Date().getDate();
		dateObj[2] = new Date().getFullYear() - 2000;
		dateObj[2] = (dateObj[2]<10? '0' + dateObj[2] :dateObj[2]);
	}
	return (dateObj);
}


function y2k(number) 
{
	return (number < 1000) ? number + 1900 : number;
}

var today = new Date();
var day   = today.getDate();
var month = today.getMonth();
var year  = y2k(today.getYear());
var activeDateField;


function restart() 
{
	arryDate = new Array((parseInt(month)+1),day,year)
	//alert(activeDateField.value);
	activeResetFunction = eval(activeDateField.name+'JoinDate');
	activeDateField.value = activeResetFunction(arryDate);
	mywindow.close();
}


function retndatenewWindow(DateField) 
{
	if (DateField.value != '')
	{
		arryDate = retndateSplitDate(DateField.value);
		month = arryDate[0]-1;
		year = arryDate[2];
		day = arryDate[1];
	}
	activeDateField = DateField;
	mywindow=open('http://' + document.domain + '/ticketsto/comunes/cal.htm','myname','resizable=no,width=350,height=270');
	mywindow.location.href = 'http://' + document.domain + '/ticketsto/comunes/cal.htm';
	if (mywindow.opener == null) mywindow.opener = self;
}


function retndatenewWinPop(DateField) 
{
	if (DateField.value != '')
	{
		arryDate = retndateSplitDate(DateField.value);
		month = arryDate[0]-1;
		year = arryDate[2];
		day = arryDate[1];
	}
	activeDateField = DateField;
	mywindow=open('http://' + document.domain + '/ticketsto/comunes/cal.htm','myname','resizable=no,width=350,height=270');
	mywindow.location.href = 'http://' + document.domain + '/ticketsto/comunes/cal.htm';
	if (mywindow.opener == null) mywindow.opener = self;
}


var ckindateformat = 'mm/dd/yy'; //Set the dateformat

// returns array with days in the months
function ckindatearrayOfDaysInMonths(adm_isLeapYear) 
{
	this[0] = 31;
	this[1] = 28;
	// if Leap Year there is 29 days in Feb
	if (adm_isLeapYear)
		this[1] = 29;
	this[2] = 31;
	this[3] = 30;
	this[4] = 31;
	this[5] = 30;
	this[6] = 31;
	this[7] = 31;
	this[8] = 30;
	this[9] = 31;
	this[10] = 30;
	this[11] = 31;
}


// _________________________________________________________
// The next two functions handle the formatting of the date.
// To add a new mask you only need to added the conversion
// to the next two functions respectively
// _________________________________________________________

// Split the date based on format

function ckindateSplitDate(stDate)
{
	arryDate = stDate.split('/');
	arryNewDate = new Array(3);
	if (ckindateformat == 'mm/dd/yy')
		arryNewDate = new Array(arryDate[0]-0,arryDate[1]-0,arryDate[2]);
	else 
		if(ckindateformat == 'dd/mm/yy')
			arryNewDate = new Array(arryDate[1]-0,arryDate[0]-0,arryDate[2]);
		return arryNewDate;
	//Return date array: [0] = month, [1] = day, [2] = year
}


// Join the date based on format
function ckindateJoinDate(arryDate)
{
	//arryDate: [0] = month, [1] = day, [2] = year
	if (ckindateformat == 'mm/dd/yy')
		var stDate = (arryDate[0]<10?'0'+arryDate[0]:arryDate[0]) + '/' + (arryDate[1]<10?'0'+arryDate[1]:arryDate[1]) + '/' +   arryDate[2];
	else 
		if(ckindateformat == 'dd/mm/yy')
			var stDate = (arryDate[1]<10?'0'+arryDate[1]:arryDate[1]) + '/' + (arryDate[0]<10?'0'+arryDate[0]:arryDate[0]) + '/' +   arryDate[2];
	return stDate
}


// Returns the days in the given month and year
function ckindatedaysInMonth(dim_month,dim_year) 
{
	// Check for leap year
	var dim_isLeapYear = (((dim_year % 4 == 0) && ( dim_year % 100 != 0)) || (dim_year % 400 == 0));
	// Create array of days in each month
	var dim_monthDays = new ckindatearrayOfDaysInMonths(dim_isLeapYear);
	// Return the days in month
	return dim_monthDays[dim_month];
}


// Validates date on onBlur of date field
function ckindateValidateDate(strDate) 
{
	arryDate = ckindateSplitDate(strDate);
	// Split the date up into a month day year array
	if ((isNaN(parseInt(arryDate[2])) || isNaN(parseInt(arryDate[0])) || arryDate[0] > 12 || isNaN(parseInt(arryDate[1])) || arryDate[1] > ckindatedaysInMonth(arryDate[0] - 1,arryDate[2]))) 
	{
		arryDate[0] = 7;
		arryDate[1] = 6;
		arryDate[2] = 2000;
		arryDate[2] = (arryDate[2]<10? '0' + arryDate[2] :arryDate[2]);
		document.req.ckindate.value = ckindateJoinDate(arryDate);
	}
}


function ckindatenextDay(n) 
{
	currDate = document.req.ckindate.value;
	arryDate = ckindateSplitDate(currDate);
	// Split the date up into a month day year array
	arryDate = ckindateisValidDate(arryDate);
	if (arryDate[0] == 12 && arryDate[1] == 31 && arryDate[2] == 99)
	{}
	else 
	{
		daysinCurrMonth = ckindatedaysInMonth(parseInt(arryDate[0])-1,parseInt(arryDate[2]));
		// Get the number of days in the current month
		arryDate[1] = parseInt(arryDate[1]) + n;
		// Add one to the day
		// Check for day value to be more than days in the month
		if (arryDate[1] > daysinCurrMonth) 
		{
			nextMonth = parseInt(arryDate[0]) + 1;
			if (nextMonth > 12) 
			{
				arryDate[0] = 1;
				arryDate[2] = parseInt(arryDate[2]) + 1;
				if (arryDate[2] < 10) 
				{
					arryDate[2] = '0' + arryDate[2]; 
				}
			}
			else
				arryDate[0] = nextMonth;
				arryDate[1] = 1;
		}
	}
	document.req.ckindate.value = ckindateJoinDate(arryDate);
}


function ckindatepreviousDay(n) 
{
	currDate = document.req.ckindate.value;
	arryDate = ckindateSplitDate(currDate);
	arryDate = ckindateisValidDate(arryDate);
	if (arryDate[0] == 1 && arryDate[1] == 1 && arryDate[2] == 0) 
	{}
	else 
	{
		daysinPrevMonth = ckindatedaysInMonth(parseInt(arryDate[0])-2,parseInt(arryDate[2]));
		arryDate[1] = parseInt(arryDate[1]) - n;
		// Check for day of zero
		if (arryDate[1] < 1) 
		{
			prevMonth = parseInt(arryDate[0]) - 1;
			if(prevMonth == 0) 
			{
				arryDate[0] = 12;
				arryDate[2] = parseInt(arryDate[2]) - 1;
				if (arryDate[2] < 10) 
				{
					arryDate[2] = '0' + arryDate[2]; 
				}
				arryDate[1] = 31;
			}
			else 
			{
				arryDate[0] = prevMonth;
				arryDate[1] = daysinPrevMonth;
			}
		}
	}
	document.req.ckindate.value = ckindateJoinDate(arryDate);
}




// Make sure date being processed is valid if not, set date to today
function ckindateisValidDate(dateObj) 
{
	if (isNaN(parseInt(dateObj[0])) || isNaN(parseInt(dateObj[1])) || isNaN(parseInt(dateObj[2]))) 
	{
		dateObj[0] = 7;
		dateObj[1] = 6;
		dateObj[2] = 2000;
		dateObj[2] = (dateObj[2]<10? '0' + dateObj[2] :dateObj[2]);
	}
	return (dateObj);
}


function ckindatenewWindow(DateField) 
{
	if (DateField.value != '')
	{
		arryDate = ckindateSplitDate(DateField.value);
		month = arryDate[0]-1;
		year = arryDate[2];
		day = arryDate[1];
	}
	activeDateField = DateField;
	mywindow=open('http://' + document.domain + '/ticketsto/comunes/cal.htm','myname','resizable=no,width=350,height=270');
	mywindow.location.href = 'http://' + document.domain + '/ticketsto/comunes/cal.htm';
	if (mywindow.opener == null) mywindow.opener = self;
}

<!--

var ckotdateformat = 'mm/dd/yy'; //Set the dateformat


// returns array with days in the months
function ckotdatearrayOfDaysInMonths(adm_isLeapYear) 
{
	this[0] = 31;
	this[1] = 28;
	// if Leap Year there is 29 days in Feb
	if (adm_isLeapYear)
		this[1] = 29;
	this[2] = 31;
	this[3] = 30;
	this[4] = 31;
	this[5] = 30;
	this[6] = 31;
	this[7] = 31;
	this[8] = 30;
	this[9] = 31;
	this[10] = 30;
	this[11] = 31;
}

// _________________________________________________________
// The next two functions handle the formatting of the date.
// To add a new mask you only need to added the conversion
// to the next two functions respectively
// _________________________________________________________

// Split the date based on format
function ckotdateSplitDate(stDate){
arryDate = stDate.split('/');
arryNewDate = new Array(3);
if (ckotdateformat == 'mm/dd/yy')
arryNewDate = new Array(arryDate[0]-0,arryDate[1]-0,arryDate[2]);
else if(ckotdateformat == 'dd/mm/yy')
arryNewDate = new Array(arryDate[1]-0,arryDate[0]-0,arryDate[2]);
return arryNewDate;
//Return date array: [0] = month, [1] = day, [2] = year
}


// Join the date based on format
function ckotdateJoinDate(arryDate){
//arryDate: [0] = month, [1] = day, [2] = year
 if (ckotdateformat == 'mm/dd/yy')
 var stDate = (arryDate[0]<10?'0'+arryDate[0]:arryDate[0]) + '/' +
(arryDate[1]<10?'0'+arryDate[1]:arryDate[1]) + '/' +  arryDate[2];
 else if(ckotdateformat == 'dd/mm/yy')
 var stDate = (arryDate[1]<10?'0'+arryDate[1]:arryDate[1]) + '/' +
(arryDate[0]<10?'0'+arryDate[0]:arryDate[0]) + '/' +  arryDate[2];
 return stDate
}


// Returns the days in the given month and year
function ckotdatedaysInMonth(dim_month,dim_year) {
 // Check for leap year
 var dim_isLeapYear = (((dim_year % 4 == 0) &&
( dim_year % 100 != 0)) ||
(dim_year % 400 == 0));
 // Create array of days in each month
 var dim_monthDays =
new ckotdatearrayOfDaysInMonths(dim_isLeapYear);
 // Return the days in month
 return dim_monthDays[dim_month];
}


// Validates date on onBlur of date field
function ckotdateValidateDate(strDate) {
 arryDate = ckotdateSplitDate(strDate);
// Split the date up into a month day year array
 if ((isNaN(parseInt(arryDate[2])) ||
isNaN(parseInt(arryDate[0])) ||
arryDate[0] > 12 || isNaN(parseInt(arryDate[1])) ||
arryDate[1] > ckotdatedaysInMonth(arryDate[0] - 1,arryDate[2])))
{
arryDate[0] = 7;
arryDate[1] = 6;
arryDate[2] = 2000;
arryDate[2] = (arryDate[2]<10? '0' + arryDate[2] :arryDate[2]);
document.req.ckotdate.value = ckotdateJoinDate(arryDate);
 }
}


function ckotdatenextDay(n) {
currDate = document.req.ckotdate.value;
arryDate = ckotdateSplitDate(currDate);
// Split the date up into a month day year array
arryDate = ckotdateisValidDate(arryDate);
if (arryDate[0] == 12 && arryDate[1] == 31 && arryDate[2] == 99){}
else {
daysinCurrMonth =
ckotdatedaysInMonth(parseInt(arryDate[0])-1,parseInt(arryDate[2]));
// Get the number of days in the current month
arryDate[1] = parseInt(arryDate[1]) + n;
// Add one to the day
// Check for day value to be more than days in the month
if (arryDate[1] > daysinCurrMonth) {
nextMonth = parseInt(arryDate[0]) + 1;
if (nextMonth > 12) {
arryDate[0] = 1;
arryDate[2] = parseInt(arryDate[2]) + 1;
if (arryDate[2] < 10) {arryDate[2] = '0' + arryDate[2]; }
}
else
arryDate[0] = nextMonth;
arryDate[1] = 1;
}
}
document.req.ckotdate.value = ckotdateJoinDate(arryDate);
}


function ckotdatepreviousDay(n) {
currDate = document.req.ckotdate.value;
arryDate = ckotdateSplitDate(currDate);
arryDate = ckotdateisValidDate(arryDate);
if (arryDate[0] == 1 && arryDate[1] == 1 && arryDate[2] == 0) {}
else {
daysinPrevMonth =
ckotdatedaysInMonth(parseInt(arryDate[0])-2,parseInt(arryDate[2]));
arryDate[1] = parseInt(arryDate[1]) - n;
// Check for day of zero
if (arryDate[1] < 1) {
prevMonth = parseInt(arryDate[0]) - 1;
if(prevMonth == 0) {
arryDate[0] = 12;
arryDate[2] = parseInt(arryDate[2]) - 1;
if (arryDate[2] < 10) {arryDate[2] = '0' + arryDate[2]; }
arryDate[1] = 31;
}
else {
arryDate[0] = prevMonth;
arryDate[1] = daysinPrevMonth;
}
}
}
document.req.ckotdate.value = ckotdateJoinDate(arryDate);
}


// Make sure date being processed is valid if not,
// set date to today
function ckotdateisValidDate(dateObj) {
 if (isNaN(parseInt(dateObj[0])) ||
isNaN(parseInt(dateObj[1])) ||
 isNaN(parseInt(dateObj[2]))) {
 dateObj[0] = 7;
 dateObj[1] = 6;
 dateObj[2] = 2000;
 dateObj[2] = (dateObj[2]<10? '0' + dateObj[2] :dateObj[2]);
 }
 return (dateObj);
}


function ckotdatenewWindow(DateField) {
 if (DateField.value != ''){
  arryDate = ckotdateSplitDate(DateField.value);
  month = arryDate[0]-1;
  year = arryDate[2];
  day = arryDate[1];
 }
   activeDateField = DateField;
   mywindow=open('http://' + document.domain + '/ticketsto/comunes/cal.htm','myname','resizable=no,width=350,height=270');
   mywindow.location.href = 'http://' + document.domain + '/ticketsto/comunes/cal.htm';
   if (mywindow.opener == null) mywindow.opener = self;
}


var pickdateformat = 'mm/dd/yy'; //Set the dateformat

// returns array with days in the months
function pickdatearrayOfDaysInMonths(adm_isLeapYear) {
 this[0] = 31;
 this[1] = 28;
 // if Leap Year there is 29 days in Feb
 if (adm_isLeapYear)
 this[1] = 29;
 this[2] = 31;
 this[3] = 30;
 this[4] = 31;
 this[5] = 30;
 this[6] = 31;
 this[7] = 31;
 this[8] = 30;
 this[9] = 31;
 this[10] = 30;
 this[11] = 31;
}


// _________________________________________________________
// The next two functions handle the formatting of the date.
// To add a new mask you only need to added the conversion
// to the next two functions respectively
// _________________________________________________________

// Split the date based on format
function pickdateSplitDate(stDate){
 arryDate = stDate.split('/');
 arryNewDate = new Array(3);
 if (pickdateformat == 'mm/dd/yy')
 arryNewDate = new Array(arryDate[0]-0,arryDate[1]-0,arryDate[2]);
 else if(pickdateformat == 'dd/mm/yy')
 arryNewDate = new Array(arryDate[1]-0,arryDate[0]-0,arryDate[2]);
 return arryNewDate;
 //Return date array: [0] = month, [1] = day, [2] = year
}


// Join the date based on format
function pickdateJoinDate(arryDate){
//arryDate: [0] = month, [1] = day, [2] = year
 if (pickdateformat == 'mm/dd/yy')
 var stDate = (arryDate[0]<10?'0'+arryDate[0]:arryDate[0]) + '/' +
(arryDate[1]<10?'0'+arryDate[1]:arryDate[1]) + '/' +   arryDate[2];
 else if(pickdateformat == 'dd/mm/yy')
 var stDate = (arryDate[1]<10?'0'+arryDate[1]:arryDate[1]) + '/' +
(arryDate[0]<10?'0'+arryDate[0]:arryDate[0]) + '/' +   arryDate[2];
 return stDate
}


// Returns the days in the given month and year
function pickdatedaysInMonth(dim_month,dim_year) {
 // Check for leap year
 var dim_isLeapYear = (((dim_year % 4 == 0) &&
( dim_year % 100 != 0)) || (dim_year % 400 == 0));
 // Create array of days in each month
 var dim_monthDays = new pickdatearrayOfDaysInMonths(dim_isLeapYear);
 // Return the days in month
 return dim_monthDays[dim_month];
}


// Validates date on onBlur of date field
function pickdateValidateDate(strDate) {
 arryDate = pickdateSplitDate(strDate);
// Split the date up into a month day year array
 if ((isNaN(parseInt(arryDate[2])) || isNaN(parseInt(arryDate[0])) ||
arryDate[0] > 12 || isNaN(parseInt(arryDate[1])) ||
arryDate[1] > pickdatedaysInMonth(arryDate[0] - 1,arryDate[2]))) {
 arryDate[0] = 7;
 arryDate[1] = 6;
 arryDate[2] = 2000;
 arryDate[2] = (arryDate[2]<10? '0' + arryDate[2] :arryDate[2]);
 document.req.pickdate.value = pickdateJoinDate(arryDate);
 }
}


function pickdatenextDay(n) {
currDate = document.req.pickdate.value;
arryDate = pickdateSplitDate(currDate);
// Split the date up into a month day year array
arryDate = pickdateisValidDate(arryDate);
if (arryDate[0] == 12 && arryDate[1] == 31 && arryDate[2] == 99){}
else {
daysinCurrMonth =
pickdatedaysInMonth(parseInt(arryDate[0])-1,parseInt(arryDate[2]));
// Get the number of days in the current month
arryDate[1] = parseInt(arryDate[1]) + n;
// Add one to the day
// Check for day value to be more than days in the month
if (arryDate[1] > daysinCurrMonth) {
nextMonth = parseInt(arryDate[0]) + 1;
if (nextMonth > 12) {
arryDate[0] = 1;
arryDate[2] = parseInt(arryDate[2]) + 1;
if (arryDate[2] < 10) {arryDate[2] = '0' + arryDate[2]; }
}
else
arryDate[0] = nextMonth;
arryDate[1] = 1;
}
}
document.req.pickdate.value = pickdateJoinDate(arryDate);
}


function pickdatepreviousDay(n) {
currDate = document.req.pickdate.value;
arryDate = pickdateSplitDate(currDate);
arryDate = pickdateisValidDate(arryDate);
if (arryDate[0] == 1 && arryDate[1] == 1 && arryDate[2] == 0) {}
else {
daysinPrevMonth =
pickdatedaysInMonth(parseInt(arryDate[0])-2,parseInt(arryDate[2]));
arryDate[1] = parseInt(arryDate[1]) - n;
// Check for day of zero
if (arryDate[1] < 1) {
prevMonth = parseInt(arryDate[0]) - 1;
if(prevMonth == 0) {
arryDate[0] = 12;
arryDate[2] = parseInt(arryDate[2]) - 1;
if (arryDate[2] < 10) {arryDate[2] = '0' + arryDate[2]; }
arryDate[1] = 31;
}
else {
arryDate[0] = prevMonth;
arryDate[1] = daysinPrevMonth;
}
}
}
document.req.pickdate.value = pickdateJoinDate(arryDate);
}




// Make sure date being processed is valid if not, set date to today
function pickdateisValidDate(dateObj) {
 if (isNaN(parseInt(dateObj[0])) || isNaN(parseInt(dateObj[1])) ||
isNaN(parseInt(dateObj[2]))) {
 dateObj[0] = 7;
 dateObj[1] = 6;
 dateObj[2] = 2000;
 dateObj[2] = (dateObj[2]<10? '0' + dateObj[2] :dateObj[2]);
 }
 return (dateObj);
}



function pickdatenewWindow(DateField) {
 if (DateField.value != ''){
 arryDate = pickdateSplitDate(DateField.value);
 month = arryDate[0]-1;
 year = arryDate[2];
 day = arryDate[1];
 }
 activeDateField = DateField;
 mywindow=open('http://' + document.domain + '/ticketsto/comunes/cal.htm','myname','resizable=no,width=350,height=270');
 mywindow.location.href = 'http://' + document.domain + '/ticketsto/comunes/cal.htm';
 if (mywindow.opener == null) mywindow.opener = self;
}


var dropdateformat = 'mm/dd/yy'; //Set the dateformat


// returns array with days in the months
function dropdatearrayOfDaysInMonths(adm_isLeapYear) {
 this[0] = 31;
 this[1] = 28;
 // if Leap Year there is 29 days in Feb
 if (adm_isLeapYear)
 this[1] = 29;
 this[2] = 31;
 this[3] = 30;
 this[4] = 31;
 this[5] = 30;
 this[6] = 31;
 this[7] = 31;
 this[8] = 30;
 this[9] = 31;
 this[10] = 30;
 this[11] = 31;
}

// _________________________________________________________
// The next two functions handle the formatting of the date.
// To add a new mask you only need to added the conversion
// to the next two functions respectively
// _________________________________________________________

// Split the date based on format
function dropdateSplitDate(stDate){
arryDate = stDate.split('/');
arryNewDate = new Array(3);
if (dropdateformat == 'mm/dd/yy')
arryNewDate = new Array(arryDate[0]-0,arryDate[1]-0,arryDate[2]);
else if(dropdateformat == 'dd/mm/yy')
arryNewDate = new Array(arryDate[1]-0,arryDate[0]-0,arryDate[2]);
return arryNewDate;
//Return date array: [0] = month, [1] = day, [2] = year
}


// Join the date based on format
function dropdateJoinDate(arryDate){
//arryDate: [0] = month, [1] = day, [2] = year
 if (dropdateformat == 'mm/dd/yy')
 var stDate = (arryDate[0]<10?'0'+arryDate[0]:arryDate[0]) + '/' +
(arryDate[1]<10?'0'+arryDate[1]:arryDate[1]) + '/' +  arryDate[2];
 else if(dropdateformat == 'dd/mm/yy')
 var stDate = (arryDate[1]<10?'0'+arryDate[1]:arryDate[1]) + '/' +
(arryDate[0]<10?'0'+arryDate[0]:arryDate[0]) + '/' +  arryDate[2];
 return stDate
}


// Returns the days in the given month and year
function dropdatedaysInMonth(dim_month,dim_year) {
 // Check for leap year
 var dim_isLeapYear = (((dim_year % 4 == 0) &&
( dim_year % 100 != 0)) ||
(dim_year % 400 == 0));
 // Create array of days in each month
 var dim_monthDays =
new dropdatearrayOfDaysInMonths(dim_isLeapYear);
 // Return the days in month
 return dim_monthDays[dim_month];
}


// Validates date on onBlur of date field
function dropdateValidateDate(strDate) {
 arryDate = dropdateSplitDate(strDate);
// Split the date up into a month day year array
 if ((isNaN(parseInt(arryDate[2])) ||
isNaN(parseInt(arryDate[0])) ||
arryDate[0] > 12 || isNaN(parseInt(arryDate[1])) ||
arryDate[1] > dropdatedaysInMonth(arryDate[0] - 1,arryDate[2])))
{
arryDate[0] = 7;
arryDate[1] = 6;
arryDate[2] = 2000;
arryDate[2] = (arryDate[2]<10? '0' + arryDate[2] :arryDate[2]);
document.req.dropdate.value = dropdateJoinDate(arryDate);
 }
}


function dropdatenextDay(n) {
currDate = document.req.dropdate.value;
arryDate = dropdateSplitDate(currDate);
// Split the date up into a month day year array
arryDate = dropdateisValidDate(arryDate);
if (arryDate[0] == 12 && arryDate[1] == 31 && arryDate[2] == 99){}
else {
daysinCurrMonth =
dropdatedaysInMonth(parseInt(arryDate[0])-1,parseInt(arryDate[2]));
// Get the number of days in the current month
arryDate[1] = parseInt(arryDate[1]) + n;
// Add one to the day
// Check for day value to be more than days in the month
if (arryDate[1] > daysinCurrMonth) {
nextMonth = parseInt(arryDate[0]) + 1;
if (nextMonth > 12) {
arryDate[0] = 1;
arryDate[2] = parseInt(arryDate[2]) + 1;
if (arryDate[2] < 10) {arryDate[2] = '0' + arryDate[2]; }
}
else
arryDate[0] = nextMonth;
arryDate[1] = 1;
}
}
document.req.dropdate.value = dropdateJoinDate(arryDate);
}


function dropdatepreviousDay(n) {
currDate = document.req.dropdate.value;
arryDate = dropdateSplitDate(currDate);
arryDate = dropdateisValidDate(arryDate);
if (arryDate[0] == 1 && arryDate[1] == 1 && arryDate[2] == 0) {}
else {
daysinPrevMonth =
dropdatedaysInMonth(parseInt(arryDate[0])-2,parseInt(arryDate[2]));
arryDate[1] = parseInt(arryDate[1]) - n;
// Check for day of zero
if (arryDate[1] < 1) {
prevMonth = parseInt(arryDate[0]) - 1;
if(prevMonth == 0) {
arryDate[0] = 12;
arryDate[2] = parseInt(arryDate[2]) - 1;
if (arryDate[2] < 10) {arryDate[2] = '0' + arryDate[2]; }
arryDate[1] = 31;
}
else {
arryDate[0] = prevMonth;
arryDate[1] = daysinPrevMonth;
}
}
}
document.req.dropdate.value = dropdateJoinDate(arryDate);
}


// Make sure date being processed is valid if not,
// set date to today
function dropdateisValidDate(dateObj) {
 if (isNaN(parseInt(dateObj[0])) ||
isNaN(parseInt(dateObj[1])) ||
 isNaN(parseInt(dateObj[2]))) {
 dateObj[0] = 7;
 dateObj[1] = 6;
 dateObj[2] = 2000;
 dateObj[2] = (dateObj[2]<10? '0' + dateObj[2] :dateObj[2]);
 }
 return (dateObj);
}



function dropdatenewWindow(DateField) {
 if (DateField.value != ''){
  arryDate = dropdateSplitDate(DateField.value);
  month = arryDate[0]-1;
  year = arryDate[2];
  day = arryDate[1];
 }
   activeDateField = DateField;
   mywindow=open('http://' + document.domain + '/ticketsto/comunes/cal.htm','myname','resizable=no,width=350,height=270');
   mywindow.location.href = 'http://' + document.domain + '/ticketsto/comunes/cal.htm';
   if (mywindow.opener == null) mywindow.opener = self;

}
 function Start() {
 var month,depDay1,retDay1,addays,maxdays;
 var MFlag=0;
   addays =4;
 if (document.forms['req'].deptdate.value == "")
 {
   depMonth = new Date().getMonth();
   if(depMonth == 0 || depMonth == 2 || depMonth == 4 ||
   depMonth == 6 || depMonth == 7 || depMonth == 9 ||
   depMonth == 11)


  {
  maxdays = 31;
  if (depDay+addays>maxdays)
     {
     depDay1=depDay+addays-maxdays;
     month=depMonth+1;
     }
  else
  {
    depDay1=depDay+addays;
    month=depMonth;
  }




  if(depDay+addays+1>maxdays)
     {
     retDay1=depDay+addays+1-maxdays;
     var retmonth=depMonth+1;
      }
  else
  {
    retDay1=depDay1+1;
    retmonth=depMonth;
   }
 }

 if(depMonth == 1)
 {


   if(depYear%4 == 0)
   {
      maxdays=29;
      if(depYear%100 != 0 || depYear%400 == 0)
       {
        if(depDay+addays>maxdays)
          {
            depDay1=depDay+addays-maxdays;

            month=depMonth+1;
           }
        else
          {
           depDay1=depDay+addays;


             depDay1=depDay+addays;
             month=depMonth;
            }

          if(depDay+addays+1>maxdays)
           {
             retDay1=depDay+addays+1-maxdays;
             var retmonth=depMonth+1;
            }
          else
           {
             retDay1=depDay1+1;
             retmonth=depMonth;
            }


      }
    } //for leap year( % 100)
  else
   {
       maxdays=28;
       if(depDay+addays>maxdays)
        {
           depDay1=depDay+addays-maxdays;
           month=depMonth+1;
        }
       else
        {
           depDay1=depDay+addays;
           month=depMonth;


        }
       if(depDay+addays+1>maxdays)
        {
           retDay1=depDay+addays+1-maxdays;
           var retmonth=depMonth+1;
        }
       else
        {
           retDay1=depDay1+1;
           var retmonth=depMonth;
         }

     }



  } //first if

  if(depMonth == 3 || depMonth == 5 || depMonth == 8 || depMonth == 10)
  {
     maxdays=30;
         if (depDay+addays>maxdays)
           {
              depDay1=depDay+addays-maxdays;
              month=depMonth+1;
           }
         else
           {
              depDay1=depDay+addays;
              month=depMonth;



          }


        if(depDay+addays+1>maxdays)
          {
             retDay1=depDay+addays+1-maxdays;
             var retmonth=depMonth+1;

           }
        else
          {

             retDay1=depDay1+1;


              var retmonth=depMonth;
            }
   }

 //document.req.Dept_Month.options[month].selected = true;

 //document.req.Dept_Year.value = depYear;
 //document.req.Dept_Day.options[depDay1-1].selected = true;
 //document.req.Ret_Month.options[retmonth].selected = true;
 //document.req.Ret_Year.value = retYear;
 //document.req.Ret_Day.options[retDay1-1].selected = true;
 document.forms['req'].deptdate.value =
     (month+1) + "/" + depDay1 + "/" + "0"+depYear;
 document.req.retndate.value =
       (retmonth+1) + "/" + retDay1 + "/" + "0"+retYear;
  }
  }







   function validii() {
   var sysdate=new Date();
   var d1=sysdate.getDate()+2;
   var m1=sysdate.getMonth()+1;
   var y1=sysdate.getYear();
   if(!document.all)
   y1=y1+1900;
   var SysDateStr=m1+'/'+d1+'/'+y1;
   var date1 = new Date(SysDateStr);
   var temp = document.forms['req'].deptdate.value;
   var mm1 = temp.substring(0,temp.indexOf("/"));
   temp = temp.substring(temp.indexOf("/")+1,temp.length);
   var dd1 = temp.substring(0,temp.indexOf("/"));
   var yy1 = temp.substring(temp.indexOf("/")+1,temp.length);

   var dat=eval(mm1) + "/" +eval(dd1)+ "/" + "200"+eval(yy1);
   var date2=new Date(dat);
   //alert(date1);
   //alert(date2);
   var date1parse=Date.parse(date1);
   var date2parse=Date.parse(date2);
   var diff=(date2parse-date1parse);
   if (diff<0) {
  alert("Earliest travel date we can accommodate is 2 days from today.");
  document.req.deptdate.focus();
       return false;
     } else {
        return true;
        }
      }


   function validnodays() {
   var sysdate=new Date();
   var d1=sysdate.getDate();
   var m1=sysdate.getMonth()+1;
   var y1=sysdate.getYear();
   if(!document.all)
   y1=y1+1900;
   var SysDateStr=m1+'/'+d1+'/'+y1;
   var date1 = new Date(SysDateStr);
   var temp = document.forms['req'].deptdate.value;
   var mm1 = temp.substring(0,temp.indexOf("/"));
   temp = temp.substring(temp.indexOf("/")+1,temp.length);
   var dd1 = temp.substring(0,temp.indexOf("/"));
   var yy1 = temp.substring(temp.indexOf("/")+1,temp.length);

   var dat=eval(mm1) + "/" +eval(dd1)+ "/" + "200"+eval(yy1);
   var date2=new Date(dat);
   //alert(date1);
   //alert(date2);
   var date1parse=Date.parse(date1);
   var date2parse=Date.parse(date2);
   var diff=(date2parse-date1parse)/86400000;
   if (diff>331) {
  alert("Cannot book more than 331 days in advance.");
  document.req.deptdate.focus();
       return false;
     } else {
        return true;
        }
      }

function CF_checkcheck (form) {

if (!CheckFieldExtra(form, "DEPART", "Departure City", true, "C", " ") ||
!CheckFieldExtra(form, "DEST", "Destination City", true, "C"," "))
return false;
else
return true;
}

function CheckFieldExtra(form, attributeName, attributeLabel, mand, type,addChars) {
var     attribute;

eval("attribute = form." + attributeName + ";");
if (!attribute) {
alert("Attribute " + attributeName + " not found.");
return false;
}

  if (mand)
  {
      if(attribute.type.indexOf("SELECT") >=0 ||
      attribute.type.indexOf("select") >=0) {
       if (attribute.selectedIndex < 0) {

       alert(attributeLabel + " is a required field.");
       return false;
       }
      } else
       if (attribute.value.length == 0) {
       alert(attributeLabel + " is a required field.");
       return false;
       }
  }

  if (attribute.type.indexOf("SELECT") >=0 ||
      attribute.type.indexOf("select") >=0) {
      return true;
      }


if (attribute.value.length > 0 && type) {
// alphabets
if (type.toUpperCase() == "C") {
for ( i = 0; i < attribute.value.length; i++ ) {
var c = attribute.value.charAt(i);
if (!isLetter(c) && !isCharInString(c, addChars)) {
alert(attributeLabel + " can only contain characters (a-z,A-Z).");
return false;
}
}
}
// numeric
if (type.toUpperCase() == "N") {



for ( i = 0; i < attribute.value.length; i++ ) {
var c = attribute.value.charAt(i);
if (!isDigit(c) && !isCharInString(c, addChars)) {
alert(attributeLabel + " can only contain numbers (0-9).");
return false;
}
}
}
// alphanumeric
else {
for (i = 0; i < attribute.value.length; i++) {
var c = attribute.value.charAt(i);
if (!isDigit(c) && !isLetter(c) && !isCharInString(c, addChars)) {
alert(attributeLabel + " can only contain alphanumeric character.");


return false;
}
}
}
}

return true;
}
function fun1()
   {
     if (document.req.COMPANY.value  == "INTERVAL")
    {
     if(validii() && validnodays() && checkdays() && vald()){
     window.location="https://travel.intervalworld.com/CGIDEVPGM/BUILD.PGM/?COMPANY=INTERVAL&COMPCODE=&RQSTTYPE=AIR1&MBRTYPE=&MBRID=1977009";
    return false;   }
   }
   else
     if (document.req.COMPANY.value  == "COSTAMAR")
   {
     if(validii() && validnodays() && checkdays() && vald()){
     window.location = "http://explorer.prologicsystems.com" +
                    "/CGIDEVPGM/BUILD.PGM/?COMPANY=COSTAMAR&COMPCODE=&RQSTTYPE=AIR1&PLSID="+document.forms['req'].elements['plsid'].value+"&PLSEMAIL="+document.forms['req'].elements['plsemail'].value;
    return false;   }
   }
   else
     if (document.req.COMPANY.value  == "COSTAMARGN")
   {
     if(validii() && validnodays() && checkdays() && vald()){
     window.location = "http://explorer.prologicsystems.com" +
                    "/CGIDEVPGM/BUILD.PGM/?COMPANY=COSTAMARGN&COMPCODE=&RQSTTYPE=AIR1&PLSID="+document.forms['req'].elements['plsid'].value+"&PLSEMAIL="+document.forms['req'].elements['plsemail'].value;
    return false;   }
   }
   }


function carfun()
   {
     if(validii() && validnodays() && checkdays() && vald()){
     window.location = "http://explorer.prologicsystems.com" +
                    "/CGIDEVPGM/BUILD.PGM/?COMPANY=INTERVAL&COMPCODE=&RQSTTYPE=CAR1&MBRTYPE=/%MBRTYPE%/&MBRID=1977009";
     return false;
   }
   }


function hotfun()
   {
     if(validii() && validnodays() && checkdays() && vald()){
     window.location = "http://explorer.prologicsystems.com" +
                    "/CGIDEVPGM/BUILD.PGM/?COMPANY=INTERVAL&COMPCODE=&RQSTTYPE=HOTEL1&MBRTYPE=/%MBRTYPE%/&MBRID=1977009";
     return false;
   }
   }


function airfun()
   {
     if(validii() && validnodays() && checkdays() && vald()){
     window.location = "http://explorer.prologicsystems.com" +
                    "/CGIDEVPGM/BUILD.PGM/?COMPANY=INTERVAL&COMPCODE=&RQSTTYPE=AIR1&MBRTYPE=/%MBRTYPE%/&MBRID=1977009";
     return false;
   }
   }

   function checkdays() {
   //var date1 = new Date(SysDateStr);
   var temp = document.forms['req'].deptdate.value;
   var mm1 = temp.substring(0,temp.indexOf("/"));
   temp = temp.substring(temp.indexOf("/")+1,temp.length);
   var dd1 = temp.substring(0,temp.indexOf("/"));
   var yy1 = temp.substring(temp.indexOf("/")+1,temp.length);
   var temp1 = document.req.retndate.value;
   var mm2 = temp1.substring(0,temp1.indexOf("/"));
   temp1 = temp1.substring(temp1.indexOf("/")+1,temp1.length);
   var dd2 = temp1.substring(0,temp1.indexOf("/"));
   var yy2 = temp1.substring(temp1.indexOf("/")+1,temp1.length);

   var dat=eval(mm1) + "/" +eval(dd1)+ "/" + "200"+eval(yy1);
   var dat1=eval(mm2) + "/" +eval(dd2)+ "/" + "200"+eval(yy2);

   var date1=new Date(dat);
   var date2=new Date(dat1);
   var date1parse=Date.parse(date1);
   var date2parse=Date.parse(date2);
   if(date2parse<date1parse)   {
  alert("Return date can not be earlier than origin date.")
  document.req.retndate.focus();
       return false;
     } else {
        return true;
        }
      }
   function vald() {
   var sysdate=new Date();
   var d1=sysdate.getDate();
   var m1=sysdate.getMonth()+1;
   var y1=sysdate.getYear();
   if(!document.all)
   y1=y1+1900;
   var SysDateStr=m1+'/'+d1+'/'+y1;
   var date1 = new Date(SysDateStr);
   var temp = document.req.retndate.value;
   var mm1 = temp.substring(0,temp.indexOf("/"));
   temp = temp.substring(temp.indexOf("/")+1,temp.length);
   var dd1 = temp.substring(0,temp.indexOf("/"));
   var yy1 = temp.substring(temp.indexOf("/")+1,temp.length);

   var dat=eval(mm1) + "/" +eval(dd1)+ "/" + "200"+eval(yy1);
   var date2=new Date(dat);
   //alert(date1);
   //alert(date2);
   var date1parse=Date.parse(date1);
   var date2parse=Date.parse(date2);
   var diff=(date2parse-date1parse)/86400000;
   if (diff>331) {
  alert("Cannot book more than 331 days in advance.");
  document.req.deptdate.focus();
       return false;
     } else {
        return true;
        }
      }
function chkNochilds() {
  var childcount = document.forms['req'].elements['childsf'].options[document.forms['req'].elements['childsf'].options.selectedIndex].value;
 var cnt; cnt = 0;
 for (var i = 1; i <=9; i++) {
       var textname = "chdage" + i;
       if (document.forms['req'].elements[textname].value.length > 0) {
           cnt++;
       }
       if (cnt > childcount) {
          alert("Child age cannot exceed no. of children.");
          document.forms['req'].elements[textname].value = "";
          return false;
      }
  }

 }

