// Start: Once Charter type selected, sets the Text for maximum pax.
function paxmaxtext()
{
var CharterTypeList = document.form1.CharterType;
var selectedType = CharterTypeList.options[CharterTypeList.selectedIndex].text;

	if (selectedType == "Pittwater Romantics"){
		return "Maximum 4 People (2 Couples).";}
	else if (selectedType == "Weddings"){
		return "Maximum 15 People.";}
	else if (selectedType == "Sydney Harbour New Years Eve"){
		return "Maximum 21 People.";}
	else if (selectedType == "Sydney Harbour Evening"){
		return "Maximum 21 People.";}
	else if (selectedType == "Sydney Harbour 2 Day/1 Night"){
		return "Maximum 4 People (2 Couples).";}
	else if (selectedType == "Sydney Harbour Day"){
		return "Maximum 21 People.";}
	else if (selectedType == "Whitsundays 5 Day"){
		return "Maximum 4 People (2 Couples).";}
	else if (selectedType == "Whitsundays 4 Day"){
		return "Maximum 4 People (2 Couples).";}
	else {
		return "Maximum 21 People.";}
}
// End: Once Charter type selected, sets the Text for maximum pax.

// Start: Once Catering type selected, sets the Text for cost per person.
function cateringCostText()
{
var cateringList = document.form1.catering;
var selectedCateringCost = cateringList.options[cateringList.selectedIndex].text;

	if (selectedCateringCost == "Seafood Extravaganza"){
		return "($55.00 per person)";}
	else if (selectedCateringCost == "Seafood Combination"){
		return "($44.50 per person)";}
	else if (selectedCateringCost == "Barbeque"){
		return "($37.50 per person)";}
	else if (selectedCateringCost == "Set Menu"){
		return "($44.50 per person)";}
	else {
		return "";}
}
// End: Once Catering type selected, sets the Text for cost per person.

// Start: Once Charter type selected, sets the Text for NYE catering per person.
/*function NYEcostpptext()
{
var CharterTypeList = document.form1.CharterType;
var selectedType = CharterTypeList.options[CharterTypeList.selectedIndex].text;

	if (selectedType == "Sydney Harbour New Years Eve"){
		return "($44.50 per person)";}
	else {
		return "";}
}*/
// End: Once Charter type selected, sets the Text for NYE catering per person.

// Start: Once Charter type selected, sets the Text for Weddings.
function Weddingtext()
{
var CharterTypeList = document.form1.CharterType;
var selectedType = CharterTypeList.options[CharterTypeList.selectedIndex].text;

	if (selectedType == "Weddings"){
		return "(Does not include optional extras)";}
	else {
		return "";}
}
// End: Once Charter type selected, sets the Text for Weddings.

// START: Get the current year to pass into smartCal function.
function year() {
	now = new Date();
	theYear = now.getFullYear();
	
	return theYear;
}
// END: Get the current year to pass into smartCal function.

// START: smart calendar
function smartCal() {

var CharterTypeList = document.form1.CharterType;
var selectedType = CharterTypeList.options[CharterTypeList.selectedIndex].text;
var nextYear = year() + 1;
var thisYear = year();

// Use this one below if no booking yet for NYE
	if (selectedType == "Sydney Harbour New Years Eve"){
		document.form1.date.value = "31 Dec " + thisYear +"";}
	else {
		showCal('Calendar1');}
	
// Use this one below if NYE is already booked for this current year
/*	if (selectedType == "Sydney Harbour New Years Eve"){
		document.form1.date.value = "31 Dec " + nextYear +"";}
	else {
		showCal('Calendar1');}
*/
}
// END: smart calendar


function getCatering(){

var getCateringList = document.form1.catering;
var selectedCatering = getCateringList.options[getCateringList.selectedIndex].text;

	if (selectedCatering == "Seafood Extravaganza"){
		return "55.00";}
	else if (selectedCatering == "Seafood Combination"){
		return "44.50";}
	else if (selectedCatering == "Barbeque"){
		return "37.50";}
	else if (selectedCatering == "Set Menu"){
		return "44.50";}
	else {
		return "0";}}
		
// START: calculate the wharf cost.

function wharfCost(){
var wharf = document.form1.Pickup.options[document.form1.Pickup.selectedIndex].text;
var wharfCharge = parseFloat("28.00");
var wharfNoCharge = parseFloat("0.00");
var wharf_1 = "Darling Harbour";
var wharf_2 = "The Quay";
var wharf_3 = "Newport Arms/Mirage";
 var wharf_4 = "Other";

if ((wharf == wharf_1)||(wharf == wharf_2)){
	return wharfCharge }
	else {
	return wharfNoCharge }
}
// END: calculate the wharf cost.

// START: checks if charter is a particular date, then assigns the appropriate quote calculation file.
function quote() {

var eDate = document.form1.orderdate.value;
var calYear = eDate.substring(0,4);
var calMth = eDate.substring(4,6);
var calDay = eDate.substring(6,8);
var a = new Date(calYear, calMth, calDay);
var startDate1 = new Date(2008,12,26);
var endDate1 = new Date(2008,12,26);
var boxingDay = new Date(2008,12,26);


if ((a >= startDate1) && (a <= endDate1)) {
		return quote_boxingday()}
	else {
		return quote_normal()}

}
// START: checks if charter is a particular date, then assigns the appropriate quote calculation file.

// Start: Displaying average cost per passenger.
function DisplayCost(){
var peopleNum = document.form1.pax.options[document.form1.pax.selectedIndex].text;
var average = quote()/peopleNum;
var AvCostPP = average.toFixed(0);
var TotalCost = quote();

document.getElementById("costpp").childNodes[0].nodeValue = AvCostPP
document.getElementById("quote").childNodes[0].nodeValue = TotalCost
}
// End: Displaying average cost per passenger.

// Start: Display Dynamic Text to the user.
function DynamicText(id, text){
	document.getElementById(id).innerHTML = text;
	}
// End: Display Dynamic Text to the user.

// Start: Refresh the browser window for re-input by user.
function hardReload() { 
location.reload(true); 
}
// End: Refresh the browser window for re-input by user.

// Start: Passing the estimate to the hidden field for emailing purposes.
function dollarize(){
var dollar = " AUD $";
var cost = quote();
	return dollar +""+ cost;
}
function HiddenTotal(form){
document.form1.EmailEstimate.value = dollarize();
}
// End: Passing the estimate to the hidden field for emailing purposes.

// Start: Passing the estimate to the hidden field for database purposes.
function HiddenTotalDB(form){
document.getElementById("DataBaseEstimate").value = quote();
}
// End: Passing the estimate to the hidden field for database purposes.

// Start: Convert 1st letter of name to uppercase.
function changeCase(frmObj) {
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
tmpStr = frmObj.value.toLowerCase();
strLen = tmpStr.length;
if (strLen > 0)  {
for (index = 0; index < strLen; index++)  {
if (index == 0)  {
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
}
else {
tmpChar = tmpStr.substring(index, index+1);
if (tmpChar == " " && index < (strLen-1))  {
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+2,strLen);
tmpStr = preString + tmpChar + postString;
         }
      }
   }
}
frmObj.value = tmpStr;
}
// End: Convert 1st letter of name to uppercase.

// START: Auto select next form element.
function one_two(){
document.form1.CharterType.focus()}
function two_three(){
document.form1.textfield4.focus()}
function three_four(){
document.form1.Pickup.focus()}
function four_five(){
document.form1.pax.focus()}
function five_six(){
document.form1.catering.focus()}
// END: Auto select next form element.


// START: popup alert for NYE being already booked.
/*
function nyeBooked(){
var booked = document.form1.CharterType.options[document.form1.CharterType.selectedIndex].text;

if (booked == "Sydney Harbour New Years Eve"){
	alert ("We apologise but the New Years Eve Charter is already booked for this year.")}
else {
	return false }
}
*/
//START: Parsing readable date for emailing purposes.
function emaildate() {

var eDate = document.form1.orderdate.value;
var calYear = eDate.substring(0,4);
var calMth = eDate.substring(4,6);
var calDay = eDate.substring(6,8);
var x = calDay + "-" + calMth + "-" + calYear;

document.form1.emailDate.value = x;
}
//END: Parsing readable date for emailing purposes.

