/********************************************************************************************
**function BatchValidate
**input:
**output:
**Creator: Daniel Chen 13/12/2007
********************************************************************************************/
function CheckConfirm(){
	if (document.getElementById("txtFromDate").value.length==0){
		alert('Please enter from date.');
		document.getElementById("txtFromDate").focus();
		return false;
	}else if(document.getElementById("txtToDate").value.length==0){
		alert('Please enter to date.');
		document.getElementById("txtToDate").focus();
		return false;			
	}
	/*if (document.getElementById("txtFromDate").value != "") {
		if ( isDate(document.getElementById("txtFromDate"),'2000','<%=year(now) %>') == false){
			return false;
		}
	}
	if (document.getElementById("txtToDate").value != "") {
		if ( isDate(document.getElementById("txtToDate"),'2000','<%=year(now) %>') == false){
			return false;
		}
	}		*/	
	
	return true;
}

// date field validation (called by other validation functions that specify minYear/maxYear)
function isDate(gField,minYear,maxYear) { 
	var inputStr = gField.value; 
	// convert hyphen delimiters to slashes 
	while (inputStr.indexOf("-") != -1) { 
		var regexp = /-/;
		inputStr = inputStr.replace(regexp,"/"); }
	var delim1 = inputStr.indexOf("/")
	var delim2 = inputStr.lastIndexOf("/")
	if (delim1 != -1 && delim1 == delim2) { 
		// there is only one delimiter in the string
		alert("The date entry is not in an acceptable format.\n\nYou can enter dates in the following formats: mmddyyyy, mm/dd/yyyy, or mm-dd-yyyy. (If the month or date data is not available, enter \'01\' in the appropriate location.)")
		gField.focus()
		gField.select()
		return false }
	if (delim1 != -1) { 
		// there are delimiters; extract component values
		var mm = parseInt(inputStr.substring(0,delim1),10)
		var dd = parseInt(inputStr.substring(delim1 + 1,delim2),10)
		var yyyy = parseInt(inputStr.substring(delim2 + 1, inputStr.length),10)
	} else { 
		// there are no delimiters; extract component values
		var mm = parseInt(inputStr.substring(0,2),10)
		var dd = parseInt(inputStr.substring(2,4),10)
		var yyyy = parseInt(inputStr.substring(4,inputStr.length),10)
	}
	if (isNaN(mm) || isNaN(dd) || isNaN(yyyy)) { 
		// there is a non-numeric character in one of the component values
		alert("The date entry is not in an acceptable format.\n\nYou can enter dates in the following formats: mmddyyyy, mm/dd/yyyy, or mm-dd-yyyy.") 
		gField.focus()
		gField.select()
		return false
	}
	if (mm < 1 || mm > 12) { 
		// month value is not 1 thru 12 
		alert("Months must be entered between the range of 01 (January) and 12 (December).")
		gField.focus()
		gField.select()
		return false
	} 
	if (dd < 1 || dd > 31) { 
		// date value is not 1 thru 31 
		alert("Days must be entered between the range of 01 and a maximum of 31 (depending on the month and year).")
		gField.focus()
		gField.select()
		return false
	} 
	// validate year, allowing for checks between year ranges 
	// passed as parameters from other validation functions
	if (yyyy < 100) { 
		// entered value is two digits, which we allow for 1930-2029
		alert("Year must be entered in four-digit format.  Please try again!")
		gField.focus()
		gField.select()
		return false
	}
	if (yyyy < minYear || yyyy > maxYear) {
		alert("Year must be entered between the range of " + minYear + " and " + maxYear + "."); 
		gField.focus()
		gField.select()
		return false
	}	
	if (!checkMonthLength(mm,dd)) {
		gField.focus()
		gField.select()
		return false
	}
	if (mm == 2) {
		if (!checkLeapMonth(mm,dd,yyyy)) {
			gField.focus() 
			gField.select()
			return false
		}
	}
	gField.value = mm + "/" + dd + "/" + yyyy;
	return true;
}
// check the entered month for too high a value 
function checkMonthLength(mm,dd) { 
	var months = new 
	Array("","January","February","March","April","May","June","July","August","September","October","November","December") 
	if ((mm == 4 || mm == 6 || mm == 9 || mm == 11) && dd > 30) { 
		alert(months[mm] + " has only 30 days.")
		return false
	} else if (dd > 31) { 
		alert(months[mm] + " has only 31 days.")
		return false
	}
	return true
}
// check the entered February date for too high a value
function checkLeapMonth(mm,dd,yyyy) { 
	if (yyyy % 4 > 0 && dd > 28) { 
		alert("February of " + yyyy + " has only 28 days.")
		return false
	} else if (dd > 29) { 
		alert("February of " + yyyy + " has only 29 days.")
		return false
	} 
	return true
}
// get current year
function getTheYear() { 
	var thisYear = (new Date()).getFullYear();
	return thisYear
}   	


/***********************************************************
**function windows_open
**input:conf
**output:..
***********************************************************/
function windows_open(conf){

	if (conf!=""){
		eval("window.open('daytimevoucher_view.aspx?cno="+conf+"','street','width=830,height=450,scrollbars=1');");
		//eval("window.open('daytimevoucher_view.aspx?cno="+conf+"','Ride Details','width=820,height=610,scrollbars=1');");
		return false;
	}else{
		return false;
	}
	
}

function WindowOpenReceipt(){
	var conf=document.getElementById('txtconf').value;
	var lname=document.getElementById('txtlastname').value;
	var from_date=document.getElementById('txtFromDate').value;
	//if (conf!="" && lname!="" && from_date!=""){
		//alert('test');
		//eval("window.open('receipt_winopen.aspx?conf="+conf+"&lname="+lname+"&fromdate="+from_date+"','_blank','width=700,height=500,scrollbars=1');");
		//window.open("receipt_winopen.aspx?conf="+conf+"&lname="+lname+"&fromdate="+from_date,target="_blank");		
		window.open("receipt_winopen.aspx",target="_blank");
		//alert('open');
		return false;
	//}
}

function WindowOpenReceiptLink(){
	var msg=document.getElementById("hdnValue").value;
	//alert(msg);
	if (msg=="3"){						
		var conf=document.getElementById('txtconf').value;
		var lname=document.getElementById('txtlastname').value;
		var from_date=document.getElementById('txtFromDate').value;
		//if (conf!="" && lname!="" && from_date!=""){
			//alert('test');
			//eval("window.open('receipt_winopen.aspx?conf="+conf+"&lname="+lname+"&fromdate="+from_date+"','_blank','width=700,height=500,scrollbars=1');");
			//window.open("receipt_winopen.aspx?conf="+conf+"&lname="+lname+"&fromdate="+from_date,target="_blank");
			//document.getElementById('HyperLink1').onclick();
			//document.getElementById('netbee').onclick();
			//return false;
		//}
	}else if(msg=="1"){
		alert("The information entered did not match our records. Please verify your information and re-enter.");
		return false;
	}else if(msg=="2"){
		alert("This reservation has not been processed yet. Please allow 3-5 business days from the travel date to request a receipt.");
		return false;
	}else{
		//
	}
}