
	function submitenter(myfield,e)
	{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else {
		if (myfield == 'mylogin') {
	   		document.forms.mylogin.submit();
		}
		if (myfield == 'myresid')
	   		document.forms.myresid.submit();
		else if (myfield == 'enquiry')
	   		document.forms.myenquiry.submit();
		else 
			return true;
	}
	
	if (keycode == 13)
	   {
	   myfield.form.submit();
	   return false;
	   }
	else {
	   return true;
		}
	}
function submit_enquiry(){
	var errorMsg = '' 
	if (document.getElementById('first_id').value == '')
		errorMsg = 'First Name is required\n'	
	if (document.getElementById('last_id').value == '')
		errorMsg += 'Last Name is required\n'	
	if (document.getElementById('email_id').value == '')
		errorMsg += 'Email address is required\n'	
	if (errorMsg != '')
		alert(errorMsg);
	else
		 document.getElementById('myEnquiry').submit()
}

function selectReturn(myfield) {
	var value = myfield.value
	if (value == 'yes') {
		document.QForm.returnday.selectedIndex = document.QForm.departday.selectedIndex 	
		document.QForm.returnmonth.selectedIndex = document.QForm.departmonth.selectedIndex 	
	}
	if (value == 'no') {
		document.QForm.returnday.selectedIndex = 0
		document.QForm.returnmonth.selectedIndex = 0
	}
}

function privateMessage(){
	alert('Ticking this box will\nmake this charter\nunavailable for other passengers\n')
}

function privateCharter(type,baseprice,basepriceChild){
	var price = parseInt(baseprice,10)
	var priceChild = parseInt(basepriceChild,10)
	if (type == 'depart') {
		if (document.mycharter_depart.nwa_private[1]) { // must be a return booking 
			if (document.mycharter_depart.nwa_private[0].checked)
				price = price * 1.5 
		}
		else { 
			if (document.mycharter_depart.nwa_private.checked)
				price = price * 1.5 
		}
		document.mycharter_depart.nwa_cost_depart.value = price
		if (document.mycharter_depart.nwa_cost_child_depart.type != 'hidden') {
			if (document.mycharter_depart.nwa_private[0].checked) {
				if (document.mycharter_depart.nwa_private[1]) { // must be a return booking 
					if (document.mycharter_depart.nwa_private[0].checked)
						priceChild = priceChild * 1.5 
				}
				else  {
					if (document.mycharter_depart.nwa_private.checked)
						priceChild = priceChild * 1.5 
				}
			}
			document.mycharter_depart.nwa_cost_child_depart.value = priceChild
		}
	}
	if (type == 'return') {
		if (document.mycharter_depart.nwa_private[1].checked)
			price = price * 1.5 
		document.mycharter_depart.nwa_cost_return.value = price
		if (document.mycharter_depart.nwa_cost_child_return.type != 'hidden') {
			if (document.mycharter_depart.nwa_private[1].checked)
				priceChild = priceChild * 1.5 
			document.mycharter_depart.nwa_cost_child_return.value = priceChild
		}
	}
}

function RedirectIt(url){
	var browser_type=navigator.appName
	var browser_version=parseInt(navigator.appVersion)
	
	//if NS 4+
	if (browser_type=="Netscape"&&browser_version>=4)
	window.location.replace(url)
	//if IE 4+
	else if (browser_type=="Microsoft Internet Explorer"&&browser_version>=4)
		window.location.replace(url)
	//Default goto page (NOT NS 4+ and NOT IE 4+)
	else {
			window.location=url ;
	}
}

function charterTime(myfield,diff_hr, diff_min) {
	if (!diff_hr && !diff_min)
		return
	if (myfield.options[myfield.selectedIndex].value == '') {
		return
	}
	if ((myfield.name == 'nwa_depart_time_hr_depart') || (myfield.name == 'nwa_depart_time_min_depart')){
		el = document.getElementById('flightTime_depart')
		var hr = document.mycharter_depart.nwa_depart_time_hr_depart.options[document.mycharter_depart.nwa_depart_time_hr_depart.selectedIndex].value
		var idx = myfield.options[myfield.selectedIndex].value
		var addone = 0
		if (document.mycharter_depart.nwa_depart_time_min_depart.type == 'hidden')  {
			var min = hr.substring(3,5)
			var lth = hr.length
			var flight = hr.substring(5,lth)
			document.mycharter_depart.nwa_flight_pk_depart.value = flight
			hr = hr.substring(0,2)
		}
		else  {
			var min = document.mycharter_depart.nwa_depart_time_min_depart.options[document.mycharter_depart.nwa_depart_time_min_depart.selectedIndex].value
			if ((document.mycharter_depart.nwa_depart_time_hr_depart.options[0].value == 'hr') || (document.mycharter_depart.nwa_depart_time_hr_depart.options[0].value == '')){
				addone = 1
			}
		}
		var hrInt = parseInt(hr,10)
		var hrInt2 = parseInt(diff_hr,10)
		var minInt = parseInt(min,10)
		if(isNaN(minInt)) {
			document.mycharter_depart.nwa_depart_time_min_depart.selectedIndex = addone
			minInt = 0
		}
		var minInt2 = parseInt(diff_min,10)
		var total_min = minInt + minInt2
		var extra_hr = 0 
		if (total_min > 60 || total_min == 60) {
			total_min = total_min - 60
			extra_hr = 1 
		}
		if (total_min < 0) {
			total_min = total_min + 60
			extra_hr = -1 
		}
			
		var total_hr = hrInt + hrInt2 + extra_hr + addone 
		if (total_min > 0)
			total_min = total_min/5 + addone
		else
			total_min = addone
		if (total_hr > 24) {
			document.mycharter_depart.nwa_error_depart.value = 1 ;
			document.mycharter_depart.nwa_depart_time_hr_depart.focus() 
		}
		else {
			document.mycharter_depart.nwa_error_depart.value = 0 ;
			if (document.mycharter_depart.nwa_arrive_time_min_depart.type == 'hidden')  {
				document.mycharter_depart.nwa_arrive_time_hr_depart.value = total_hr
				document.mycharter_depart.nwa_depart_time_min_depart.value == min 
			}
			else {
				document.mycharter_depart.nwa_arrive_time_hr_depart.selectedIndex = total_hr
				document.mycharter_depart.nwa_arrive_time_min_depart.selectedIndex = total_min
			}	
		}
	}
	if ((myfield.name == 'nwa_arrive_time_hr_depart') || (myfield.name == 'nwa_arrive_time_min_depart')){
		el = document.getElementById('flightTime_depart')
		var hr = document.mycharter_depart.nwa_arrive_time_hr_depart.options[document.mycharter_depart.nwa_arrive_time_hr_depart.selectedIndex].value
		var addone = 0
		if (document.mycharter_depart.nwa_arrive_time_min_depart.type == 'hidden')  {
			var min = hr.substring(3,5)
			var lth = hr.length
			var checkin = hr.substring(5,10)
			var flight = hr.substring(10,lth)
			hr = hr.substring(0,2)
			document.mycharter_depart.nwa_flight_pk_depart.value = flight
		}
		else {
			var min = document.mycharter_depart.nwa_arrive_time_min_depart.options[document.mycharter_depart.nwa_arrive_time_min_depart.selectedIndex].value
			if ((document.mycharter_depart.nwa_arrive_time_hr_depart.options[0].value == 'hr') || (document.mycharter_depart.nwa_arrive_time_hr_depart.options[0].value == '')) {
			addone = 1
			}
		}
		var hrInt = parseInt(hr,10)
		var hrInt2 = parseInt(diff_hr,10)
		var minInt = parseInt(min,10)
		if(isNaN(minInt)) {
			document.mycharter_depart.nwa_arrive_time_min_depart.selectedIndex = addone
			minInt = 0
		}
		var minInt2 = parseInt(diff_min,10)
		var total_min = minInt - minInt2
		var extra_hr = 0 
		if (total_min < 0) {
			total_min = total_min + 60
			extra_hr = -1 
		}
		var total_hr = hrInt - hrInt2 + extra_hr  + addone
		if (total_min > 0)
			total_min = total_min/5 + addone
		else
			total_min = addone
		if (total_hr <= 0) {
			alert('Invalid Time\n Pickup Before Midnight')
			document.mycharter_depart.nwa_error_depart.value = 1 ;
			document.mycharter_depart.nwa_depart_time_hr_depart.focus() 
		}
		else {
			document.mycharter_depart.nwa_error_depart.value = 0 ;
			if (document.mycharter_depart.nwa_depart_time_min_depart.type == 'hidden')  {
				document.mycharter_depart.nwa_depart_time_hr_depart.value = total_hr
				document.mycharter_depart.nwa_depart_time_min_depart.value = total_min*5
				document.mycharter_depart.nwa_arrive_time_min_depart.value == min 
			}
			else {
				document.mycharter_depart.nwa_depart_time_hr_depart.selectedIndex = total_hr
				document.mycharter_depart.nwa_depart_time_min_depart.selectedIndex = total_min
			}	
		}
	}
// Check the return times also .. .
	if ((myfield.name == 'nwa_depart_time_hr_return') || (myfield.name == 'nwa_depart_time_min_return')){
		var hr = document.mycharter_depart.nwa_depart_time_hr_return.options[document.mycharter_depart.nwa_depart_time_hr_return.selectedIndex].value
		var idx = myfield.options[myfield.selectedIndex].value
		var addone = 0
		if (document.mycharter_depart.nwa_depart_time_min_return.type == 'hidden')  {
			el = document.getElementById('flightTime_return')
			var min = hr.substring(3,5)
			var lth = hr.length
			var flight = hr.substring(5,lth)
			document.mycharter_depart.nwa_flight_pk_return.value = flight
			hr = hr.substring(0,2)
		}
		else {
			var min = document.mycharter_depart.nwa_depart_time_min_return.options[document.mycharter_depart.nwa_depart_time_min_return.selectedIndex].value
			var addone = 0
			if ((document.mycharter_depart.nwa_depart_time_hr_return.options[0].value == 'hr') || (document.mycharter_depart.nwa_depart_time_hr_return.options[0].value == '')){
				addone = 1
			}
		}
		var hrInt = parseInt(hr,10)
		var hrInt2 = parseInt(diff_hr,10)
		var minInt = parseInt(min,10)
		if(isNaN(minInt)) {
			document.mycharter_depart.nwa_depart_time_min_return.selectedIndex = addone
			minInt = 0
		}
		var minInt2 = parseInt(diff_min,10)
		var total_min = minInt + minInt2
		var extra_hr = 0 
		if (total_min > 60 || total_min == 60) {
			total_min = total_min - 60
			extra_hr = 1 
		}
		if (total_min < 0) {
			total_min = total_min + 60
			extra_hr = -1 
		}
			
		var total_hr = hrInt + hrInt2 + extra_hr + addone 
		if (total_min > 0)
			total_min = total_min/5 + addone
		else
			total_min = addone
		if (total_hr > 24) {
			alert('Invalid Time - Dropoff Past Midnight '+total_hr)
			document.mycharter_depart.nwa_error_return.value = 1 ;
			document.mycharter_depart.nwa_depart_time_hr_return.focus() 
		}
		else {
			document.mycharter_depart.nwa_error_return.value = 0 ;
			if (document.mycharter_depart.nwa_arrive_time_min_return.type == 'hidden')  {
				document.mycharter_depart.nwa_arrive_time_hr_return.value = total_hr
				document.mycharter_depart.nwa_arrive_time_min_return.value = total_min*5
				document.mycharter_depart.nwa_depart_time_min_return.value == min 
			}
			else {
				document.mycharter_depart.nwa_arrive_time_hr_return.selectedIndex = total_hr
				document.mycharter_depart.nwa_arrive_time_min_return.selectedIndex = total_min
			}	
		}
	}
	if ((myfield.name == 'nwa_arrive_time_hr_return') || (myfield.name == 'nwa_arrive_time_min_return')){
		var hr = document.mycharter_depart.nwa_arrive_time_hr_return.options[document.mycharter_depart.nwa_arrive_time_hr_return.selectedIndex].value
		var addone = 0
		if (document.mycharter_depart.nwa_arrive_time_min_return.type == 'hidden')  {
			el = document.getElementById('flightTime_return')
			var min = hr.substring(3,5)
			var lth = hr.length
			var checkin = hr.substring(5,10)
			var flight = hr.substring(10,lth)
			hr = hr.substring(0,2)
			document.mycharter_depart.nwa_flight_pk_return.value = flight
		}
		else {
			var min = document.mycharter_depart.nwa_arrive_time_min_return.options[document.mycharter_depart.nwa_arrive_time_min_return.selectedIndex].value
			if ((document.mycharter_depart.nwa_arrive_time_hr_return.options[0].value == 'hr') || (document.mycharter_depart.nwa_arrive_time_hr_return.options[0].value == '')) {
				addone = 1
			}
		}
		var hrInt = parseInt(hr,10)
		var hrInt2 = parseInt(diff_hr,10)
		var minInt = parseInt(min,10)
		if(isNaN(minInt)) {
			document.mycharter_depart.nwa_arrive_time_min_return.selectedIndex = addone
			minInt = 0
		}
		var minInt2 = parseInt(diff_min,10)
		var total_min = minInt - minInt2
		var extra_hr = 0 
		if (total_min < 0) {
			total_min = total_min + 60
			extra_hr = -1 
		}
		var total_hr = hrInt - hrInt2 + extra_hr  + addone
		if (total_min > 0)
			total_min = total_min/5 + addone
		else
			total_min = addone
		if (total_hr <= 0) {
			alert('Invalid Time\n Pickup Before Midnight')
			document.mycharter_depart.nwa_error_return.value = 1 ;
			document.mycharter_depart.nwa_depart_time_hr_return.focus() 
		}
		else {
			document.mycharter_depart.nwa_error_return.value = 0 ;
			if (document.mycharter_depart.nwa_depart_time_min_return.type == 'hidden')  {
				document.mycharter_depart.nwa_depart_time_hr_return.value = total_hr
				document.mycharter_depart.nwa_depart_time_min_return.value = total_min*5
				document.mycharter_depart.nwa_arrive_time_min_return.value == min 
			}
			else {
				document.mycharter_depart.nwa_depart_time_hr_return.selectedIndex = total_hr
				document.mycharter_depart.nwa_depart_time_min_return.selectedIndex = total_min
			}	
		}
	}
	if (flight) {
		if (checkin) {
			fl = document.getElementById('checkinTime')
			fl.innerHTML = '+ (' + checkin + ' hr check-in time)' ;
		}
		var ldZero = '' ;
		if (total_min <= 1)
			ldZero = '0' ;
		el.innerHTML = total_hr + ':' + ldZero + total_min*5 ;
	}
}

function checkCharter() {
	var mess = ""
	var mess_r = ""
		
	if (document.mycharter_depart.nwa_depart_time_hr_depart.type != 'hidden') {
		if (document.mycharter_depart.nwa_error_depart.value == 1){
			mess += " Invalid  Charter times\n" ;
		}
	}
	if (document.mycharter_depart.nwa_depart_time_hr_depart.type != 'hidden') {
		if (document.mycharter_depart.nwa_depart_time_hr_depart.options[document.mycharter_depart.nwa_depart_time_hr_depart.selectedIndex].value == ''){
			mess += "  Departing hour\n" ;
		}
	}
	if (document.mycharter_depart.nwa_depart_time_min_depart.type != 'hidden') {
		if (document.mycharter_depart.nwa_depart_time_min_depart.options[document.mycharter_depart.nwa_depart_time_min_depart.selectedIndex].value == ''){
			mess += "  Departing minute\n" ;
		}
	}
	if (document.mycharter_depart.nwa_arrive_time_hr_depart.type != 'hidden') {
		if (document.mycharter_depart.nwa_arrive_time_hr_depart.options[document.mycharter_depart.nwa_arrive_time_hr_depart.selectedIndex].value == ''){
			mess += "  Arriving hour\n" ;
		}
	}
	if (document.mycharter_depart.nwa_arrive_time_min_depart.type != 'hidden') {
		if (document.mycharter_depart.nwa_arrive_time_min_depart.options[document.mycharter_depart.nwa_arrive_time_min_depart.selectedIndex].value == ''){
			mess += "  Arriving min\n" ;
		}
	}
	if (document.mycharter_depart.nwa_depart_time_hr_return) {
		if (document.mycharter_depart.nwa_error_return.value == 1){
			mess_r += " Invalid  Charter times\n" ;
		}
		if (document.mycharter_depart.nwa_depart_time_hr_return.type != 'hidden') {
			if (document.mycharter_depart.nwa_depart_time_hr_return.options[document.mycharter_depart.nwa_depart_time_hr_return.selectedIndex].value == ''){
				mess_r += "  Departing hour\n" ;
			}
		}
		if (document.mycharter_depart.nwa_depart_time_min_return.type != 'hidden') {
			if (document.mycharter_depart.nwa_depart_time_min_return.options[document.mycharter_depart.nwa_depart_time_min_return.selectedIndex].value == ''){
				mess_r += "  Departing minute\n" ;
			}
		}
		if (document.mycharter_depart.nwa_arrive_time_hr_return.type != 'hidden') {
			if (document.mycharter_depart.nwa_arrive_time_hr_return.options[document.mycharter_depart.nwa_arrive_time_hr_return.selectedIndex].value == ''){
				mess_r += "  Arriving hour\n" ;
			}
		}
		if (document.mycharter_depart.nwa_arrive_time_min_return.type != 'hidden') {
			if (document.mycharter_depart.nwa_arrive_time_min_return.options[document.mycharter_depart.nwa_arrive_time_min_return.selectedIndex].value == ''){
				mess_r += "  Arriving min\n" ;
			}
		}
		if ((document.mycharter_depart.nwa_cost_return.value == '') && (document.mycharter_depart.nwa_cost_child_return.value == '')){
			mess_r += " Charter Cost\n" ;
		}
	}
	if ((document.mycharter_depart.nwa_cost_depart.value == '') && (document.mycharter_depart.nwa_cost_child_depart.value == '')){
		mess += "  Charter Cost\n" ;
	}
	if (mess != "")
		alert('Departing Information missing :\n' + mess);
	if (mess_r != "")
		alert('Returning Information missing :\n' + mess_r);
	if (mess == "" && mess_r == "")	
		document.mycharter_depart.submit()
}

function agePolicy() {
	alert('All Ages are at the time of travel \nInfants 0-3 yrs - Free (includes 1 baby seat - PLEASE CONTACT THE OFFICE IF REQUIRED)\nChildren 4-14yrs - Applicable Child fare\n15 yrs and above - Adult fare\nUnaccompanied children under 14 years cannot travel without prior approval from the office')
}

function checkSubmit() {
	if (document.QForm.lstMake.selectedIndex == 0) {
		alert('Please enter\n your pick up location') ;
		return false ;
	}
	else if (document.QForm.lstModel.selectedIndex == 0) {
		alert('Please enter\n your drop off location') ;
		return false ;
	}
	else if (document.QForm.nwa_qty.selectedIndex == 0 && document.QForm.nwa_child.selectedIndex == 0) {
		alert('Please enter\n the number of passengers')
		return false ;
	}
	else if (document.QForm.returnday.selectedIndex < document.QForm.departday.selectedIndex && 
			document.QForm.returnmonth.options[document.QForm.returnmonth.selectedIndex].value <= document.QForm.departmonth.options[document.QForm.departmonth.selectedIndex].value && 
			document.QForm.returnday.selectedIndex  > 0 &&
			document.QForm.returnmonth.selectedIndex > 0 &&
			document.QForm.nwa_return[1].checked)  {
		alert('Return date prior\n to departing date')
		return false ;
	}
	else if (document.QForm.nwa_return[1].checked && document.QForm.returnday.selectedIndex == 0 && document.QForm.returnmonth.selectedIndex == 0) {
		alert('Return Service Selected,\n Please enter the return date')
		return false ;
	}
	else  {
		if (document.QForm.returnday.selectedIndex > 0 && document.QForm.returnmonth.selectedIndex > 0 &&
			document.QForm.nwa_return[1].checked == false) {
			document.QForm.nwa_return[1].checked = true
			document.QForm.nwa_return[0].checked = false
		}
		document.QForm.submit()
	}
}

function MM_origin(targ,selObj,restore) { 
eval(targ+".location='"+"index.php?nwa_origin="+selObj.options['selObj.selectedIndex'].value+"'"); 
if (restore) selObj.selectedIndex=0; 
} 
var childWindow = null;
var childclose = null;
var type = null;

function GotoDates (type) {
childclose = null ;
targetitem = document.QForm.maparea;
if (childWindow){
	if (childWindow.closed) 
		childWindow = window.open('showdates.php?type='+type,'childWindow','toobar=no,scrollbars=no,resizable=no,copyhistory=no,height=260,width=200,screenX=250,screenY=150,top=150,left=250');
	else {
		childWindow.focus()  ;
	}
}
else {
		childWindow = window.open('showdates.php?type='+type,'childWindow','toobar=no,scrollbars=no,resizable=no,copyhistory=no,height=260,width=200,screenX=250,screenY=150,top=150,left=250');
}
childWindow.targetitem = targetitem ;

if (childclose == null) {
		if (type == 'depart')
			document.intervalId = window.setInterval("checkIfClosed(childWindow,'depart')", 100);
		if (type == 'return')
			document.intervalId = window.setInterval("checkIfClosed(childWindow,'return')", 100);
	}
};

var childWindow = null;
function pop_window (URL,height,width,scroll) {
	childclose = null ;
	if (childWindow)
		childWindow.close()  ;
	childWindow = window.open(URL,'childWindow','toobar=0,scrollbars=yes'+scroll+',statusbar=yes,menubar=0,resizable=yes,copyhistory=no,height='+height+',width='+width+',screenX=450,screenY=150,top=150,left=450');
}

function checkIfClosed(childWindow,type){
	if (childWindow.closed && childclose != 1){
		window.clearInterval(document.intervalId);
//		alert("Popup closed. Event caught."+type+document.QForm.maparea.value);
		if (type == 'depart'){
			document.QForm.departday.selectedIndex = document.QForm.maparea.value.substr(0,2) - 1 ;
			document.QForm.departmonth.selectedIndex = document.QForm.maparea.value.substr(2,2)  ;
		}
		if (type == 'return'){
			document.QForm.returnday.selectedIndex = document.QForm.maparea.value.substr(0,2) - 1 ;
			document.QForm.returnmonth.selectedIndex = document.QForm.maparea.value.substr(2,2)  ;
		}
		childclose = 1 ;
	}
}
function MM_destination(targ,selObj,restore) { 
eval(targ+".location='"+"index.php?nwa_destination="+selObj.options['selObj.selectedIndex'].value+"'"); 
if (restore) selObj.selectedIndex=0; 
} 
function MM_select(targ,selObj,restore) { 
eval(targ+".location='"+"index.php?"+selObj.options['selObj.selectedIndex'].value+"'"); 
if (restore) selObj.selectedIndex=0; 
} 
function MM_qty(targ,selObj,restore) { 
eval(targ+".location='"+"index.php?"+selObj.options['selObj.selectedIndex'].value+"'"); 
if (restore) selObj.selectedIndex=0; 
} 
function myService(typeVal,service_pk,nwa_serloc_pk, alt_serloc_pk){
var expire = new Date();
var today = new Date();
expire.setTime(today.getTime() + 3600000*24);
document.cookie = (typeVal)+"="+escape(service_pk)
                 + ";expires="+expire.toGMTString() ;

window.status="Booking service :"+(service_pk)+ "To " + (typeVal);
eval("parent.location='"+"index.php?selected=1&"+(typeVal)+"_service="+(service_pk)+"&"+(typeVal)+"_nwa_serloc_pk="+nwa_serloc_pk+"&"+(typeVal)+"_alt_serloc_pk="+alt_serloc_pk+"'"); 
}

function myStatus(cookieVal,dispVal,changeVal){
var expire = new Date();
var today = new Date();
expire.setTime(today.getTime() + 3600000*24);
//document.cookie = "nwa_return="+escape(cookieVal)
//                 + ";expires="+expire.toGMTString() ;

window.status="Ticket Type:"+(changeVal)
eval("parent.location='"+"index.php?"+(changeVal)+"'"); 
}
function doUncheck(message)
{
var i, j;
alert (message);
//for(i = 0, j = ra.length; i < j; i++) ra['i'].checked = false;
}
