var Path='./builder/';

window.onload = defaultPage;

function defaultPage() {
	HideExtraElements();
	document.getElementById("boatDetails").style.display = 'none';
	document.getElementById("boatDetails").style.visibility = 'hidden';
	document.getElementById("PackageName").style.display = 'none';
	document.getElementById("PackageName").style.visibility = 'hidden';
	document.getElementById("sailingPrice").innerHTML = "$0.00";
	document.getElementById("fraserPrice").innerHTML = "$0.00";
	document.getElementById("AccomPrice").innerHTML = "$0.00";
	document.getElementById("extraCostsFraser").innerHTML = "$0.00";
	document.getElementById("extraCostsWhitsundays").innerHTML = "$0.00";
	UpdatePrices();
}

function UpdatePackage(obj){
	boatIndex=obj.selectedIndex;
	if (boatIndex<1){ 
	defaultPage();
	return; }
	
	document.getElementById("boatDetails").style.display = '';
	document.getElementById("boatDetails").style.visibility = 'visible';
	document.getElementById("PackageName").style.display = '';
	document.getElementById("PackageName").style.visibility = 'visible';
	ChangeBoatPicture(obj.options[boatIndex].value);
	ChangePackagePrice(boatIndex);
	ChangeextraCostsWhitsundays(boatIndex);
	ChangeDivingOptions(boatIndex);
	ChangeSailDuration(boatIndex);
	ChangeDepartureDays(boatIndex);
	ChangeTotalPAX(boatIndex);
	ChangeBoatDescription(boatIndex);
	ChangePackageName(boatIndex);
	ChangeIncludedAccom(boatIndex);
	UpdatePrices();
}

function ChangeBoatPicture(boatName){
	document.getElementById("BoatImage").src=Path+boatName;
}

function ChangePackagePrice(Bindex){
	if (Bindex == 1){ // Hammer
		document.getElementById("sailingPrice").innerHTML = "$299.00";
	}else if (Bindex == 2){ // Siska
		document.getElementById("sailingPrice").innerHTML = "$299.00";
	}else if (Bindex == 3){ // Adventurer
		document.getElementById("sailingPrice").innerHTML = "$460.00";
	}else if (Bindex == 4){ // Boomerang
		document.getElementById("sailingPrice").innerHTML = "$359.00";
	}else if (Bindex == 5){ // British Defender
		document.getElementById("sailingPrice").innerHTML = "$359.00";
	}else if (Bindex == 6){ // Broomstick
		document.getElementById("sailingPrice").innerHTML = "$359.00";
	}else if (Bindex == 7){ // Clipper
		document.getElementById("sailingPrice").innerHTML = "$390.00";
	}else if (Bindex == 8){ // Condor
		document.getElementById("sailingPrice").innerHTML = "$359.00";
	}else if (Bindex == 9){ // New Horizon
		document.getElementById("sailingPrice").innerHTML = "$350.00";
	}else if (Bindex == 10){ // Summertime
		document.getElementById("sailingPrice").innerHTML = "$595.00";
	}else if (Bindex == 11){ // Tongarra
		document.getElementById("sailingPrice").innerHTML = "$299.00";
	}else if (Bindex == 12){ // Waltzing Matilda
		document.getElementById("sailingPrice").innerHTML = "$329.00";
	}else if (Bindex == 13){ // Wings II
		document.getElementById("sailingPrice").innerHTML = "$440.00";
	}else if (Bindex == 14){ // Solway Lass
		document.getElementById("sailingPrice").innerHTML = "$489.00";
	}else if (Bindex == 15){ // Whitsunday Magic (Islands)
		document.getElementById("sailingPrice").innerHTML = "$679.00";
	}
}

function ChangeIncludedAccom(Cindex){
	if (Cindex >= 1 && Cindex <= 16){ // 2 Nights Accommodation
		HideExtraElements();
	}else if (Cindex >= 17 && Cindex <= 30){ // 4 Nights Accommodation
		ShowExtraElements();
	}
}

function HideExtraElements(){
	document.getElementById("DropDownAccom").style.display = 'none';
	document.getElementById("DropDownAccom").selectedIndex = 0;
	document.getElementById("AccomPrice").innerHTML = "$0.00"; // No Extra Night so no fee for Accom
	document.getElementById("AccomRow").style.display = 'none';
	document.getElementById("ExtraAccomLabel").style.display = 'none';
}

function ShowExtraElements(){
	document.getElementById("DropDownAccom").style.display = '';
	document.getElementById("DropDownAccom").selectedIndex=0;
	document.getElementById("AccomPrice").innerHTML = "$0.00"; // No Extra Night so no fee for Accom
	document.getElementById("AccomRow").style.display = '';
	document.getElementById("ExtraAccomLabel").style.display = '';
}

function ChangeextraCostsWhitsundays(Jindex){
	if (Jindex >= 1 && Jindex <= 2){
		document.getElementById("extraCostsWhitsundays").innerHTML = "$40.00";
	}else if (Jindex ==  8 || (Jindex >= 4 && Jindex <= 6) ){
		document.getElementById("extraCostsWhitsundays").innerHTML = "$50.00";
	}else if (Jindex == 7 || Jindex == 9 || Jindex == 11){
		document.getElementById("extraCostsWhitsundays").innerHTML = "$65.00";
	}else if (Jindex == 3 || Jindex == 10 || Jindex == 12 || Jindex == 13){
		document.getElementById("extraCostsWhitsundays").innerHTML = "$0.00";
	}else if (Jindex == 14 || Jindex == 15){
		document.getElementById("extraCostsWhitsundays").innerHTML = "$60.00";
	}

	UpdatePrices();
}

function ChangePackageName(Dindex){
	if (Dindex >= 1 && Dindex <= 2){
		document.getElementById("PackageName").innerHTML = "Fraser + MAXI Escape";
	}else if ((Dindex >= 4 && Dindex <= 6) || Dindex == 8){
		document.getElementById("PackageName").innerHTML = "Fraser + MAXI Sail";
	}else if (Dindex == 7 || Dindex == 9){
		document.getElementById("PackageName").innerHTML = "Fraser + Fun";
	}else if (Dindex == 3 || Dindex == 13){
		document.getElementById("PackageName").innerHTML = "Fraser + IslanDive";
	}else if (Dindex == 10 || Dindex == 12){
		document.getElementById("PackageName").innerHTML = "Fraser + Relax";
	}else if (Dindex == 14 || Dindex == 15){
		document.getElementById("PackageName").innerHTML = "Fraser + Tallship";
	}else if (Dindex == 11){
		document.getElementById("PackageName").innerHTML = "Fraser + Budget";
	}
}

function ChangeTotalPAX(Eindex){
	if (Eindex == 1 || Eindex == 2 || Eindex == 11){
		document.getElementById("TotalPAX").innerHTML = "22";
	}else if (Eindex == 3){
		document.getElementById("TotalPAX").innerHTML = "12";
	}else if (Eindex == 4 || Eindex == 5){
		document.getElementById("TotalPAX").innerHTML = "28";
	}else if (Eindex == 6){
		document.getElementById("TotalPAX").innerHTML = "26";
	}else if (Eindex == 7){
		document.getElementById("TotalPAX").innerHTML = "53";
	}else if (Eindex == 8){
		document.getElementById("TotalPAX").innerHTML = "29";
	}else if (Eindex == 9 || Eindex == 14 || Eindex == 15){
		document.getElementById("TotalPAX").innerHTML = "32";
	}else if (Eindex == 10){
		document.getElementById("TotalPAX").innerHTML = "16";
	}else if (Eindex == 12){
		document.getElementById("TotalPAX").innerHTML = "14";
	}else if (Eindex == 13){
		document.getElementById("TotalPAX").innerHTML = "25";
	}
}

function ChangeSailDuration(Findex){
	if (Findex == 1 || Findex == 2 || Findex == 12){
		document.getElementById("SailDuration").innerHTML = "2 Day 1 Night";
	}else if ((Findex >= 3 && Findex <= 9) || Findex == 11 || Findex == 13){
		document.getElementById("SailDuration").innerHTML = "2 Day 2 Nights";
	}else if (Findex == 10){
		document.getElementById("SailDuration").innerHTML = "3 Day 2 Nights";
	}else if (Findex == 14 || Findex == 15){
		document.getElementById("SailDuration").innerHTML = "3 Day 3 Nights";
	}
}

function ChangeDivingOptions(Gindex){
	if (Gindex == 1 || Gindex ==2 || (Gindex >= 4 && Gindex <= 6) || Gindex == 8 || Gindex == 11 || Gindex == 14 || Gindex == 15){
		document.getElementById("DivingOptions").innerHTML = "N/A";
	}else if (Gindex == 3 || Gindex == 7 || Gindex == 9 || Gindex == 10 || Gindex == 12 || Gindex == 13){
		document.getElementById("DivingOptions").innerHTML = "On Board";
	}
}

function ChangeDepartureDays(Hindex){
	if (Hindex == 1){
		document.getElementById("DepartureDays").innerHTML = "Even Days";
	}else if (Hindex == 2){
		document.getElementById("DepartureDays").innerHTML = "Odd Days";
	}else if (Hindex == 3 || Hindex == 5 || Hindex == 7 || Hindex == 12){
		document.getElementById("DepartureDays").innerHTML = "Tuesday, Thursday, Saturday";
	}else if (Hindex == 4){
		document.getElementById("DepartureDays").innerHTML = "Wednesday, Friday, Saturday";
	}else if (Hindex == 6 || Hindex == 13){
		document.getElementById("DepartureDays").innerHTML = "Monday, Wednesday, Saturday";
	}else if (Hindex == 8){
		document.getElementById("DepartureDays").innerHTML = "Tuesday, Thursday, Sunday";
	}else if (Hindex == 9){
		document.getElementById("DepartureDays").innerHTML = "Wednesday, Friday, Sunday";
	}else if (Hindex == 10){
		document.getElementById("DepartureDays").innerHTML = "Thursday, Sunday";
	}else if (Hindex == 11){
		document.getElementById("DepartureDays").innerHTML = "Monday, Thursday, Saturday";
	}else if (Hindex == 14){
		document.getElementById("DepartureDays").innerHTML = "Tuesday, Saturday";
	}else if (Hindex == 15){
		document.getElementById("DepartureDays").innerHTML = "Monday";
	}
}

function ChangeBoatDescription(Iindex){
	if (Iindex == 1){
		document.getElementById("BoatDescription").innerHTML = "Ocean Rafting, Queensland Adventure Tourism Winner 2001.The fastest tour around the Whitsunday Islands includes exploring Whitehaven Beach, snorkelling pristine reefs and Tropical Island guided walks.";
	}else if (Iindex == 2){
		document.getElementById("BoatDescription").innerHTML = "Depending on the day of departure you will do Whitehaven Beach Picnic Adventure, covering its 5 kilometre length is soft pure white silica sand, making it unique and one of the worlds most famous beaches. The warm, tropical water is usually nothing less than crystal clear so it is a great spot to enjoy a swim. Or Blue Pearl Bay Snorkelling Adventure. A comfortable two-hour sail from the mainland, Blue Pearl Bay is the site of some of Queensland's most spectacular fringing reef. This bay is full of beautifully formed coral and teeming with thousands of colourful tropical fish.";
	}else if (Iindex == 3){
		document.getElementById("BoatDescription").innerHTML = "It\'s a full on all inclusive day on board Camira - one of the world\'s fastest sailing catamarans. That's Sailing with a capital \'S\' on a $4 million yacht! She is capable of sailing at speeds up to 30kts! There\'s plenty of room to chill with indoor and outdoor seating areas - Camira is 85ft of pure adrenalin!";
	}else if (Iindex == 4){
		document.getElementById("BoatDescription").innerHTML = "Tongarra is the FUN, multihull catamaran! If you\’re looking for a good laugh and a great crew, Tongarra is an easy way to see the Whitsunday Islands with out the airs and graces! Tongarra is famous for great snorkelling locations and extra friendly crew. It maintains large deck spaces, so of an evening pull your mattress and sleeping bag onto the deck and fall asleep under the stars.";
	}else if (Iindex == 5){
		document.getElementById("BoatDescription").innerHTML = "If you fancy a cruising sailing yacht, huge deck spaces, shaded areas, beautiful cabins, decked out with exotic timbers, a professional and friendly crew, not to mention delicious food, for a very affordable price Habibi will take you on an adventure through the Whitsunday by day and anchor in secluded coves and inlets to party under the stars at night.";
	}else if (Iindex == 6){
		document.getElementById("BoatDescription").innerHTML = "This 80ft Ocean Racing Maxi Yacht has challenged and won some of the best from Australia, New Zealand, Hawai, Hong Kong, England, & South Africa. In her claims to fame Siska\'s crew above all will introduce you to the excitement of sailing, as was also done for Prince Charles, as he joined the crew in the Queen Victoria Cup and won!";
	}else if (Iindex == 7){
		document.getElementById("BoatDescription").innerHTML = "Hammer offers an awesome sailing adventure aboard this Maxi Yacht.  See the magnificent Whitehaven Beach and snorkel the coral reefs that are teeming with marine life.";
	}else if (Iindex == 8){
		document.getElementById("BoatDescription").innerHTML = "New Horizon has beautiful features, you can see the hard work which has been put into her, and she even has a human size figurehead. She is very spacious and has a lovely wooden galley with a big half-round table for entertainment. A 97ft classic wooden schooner she offers the experience of big boat sailing at a budget price.";
	}else if (Iindex == 9){
		document.getElementById("BoatDescription").innerHTML = "The Clipper is a 111ft liveaboard sailing Yacht.  Geared toward the young adventurous traveller who want a little more for their money.  She is one of the best equiped dive boats in the. A really comfortable cruising yacht with air-conditioning throughout and a fabulous heated spa bath for 12!";
	}else if (Iindex == 10){
		document.getElementById("BoatDescription").innerHTML = "THIS BOAT IT CURRENTLY UNAVAILABLE - Pride of Airlie is a sailing catamaran that offers tropical island resort accommodation. Visit the natural beauty of the Great Barrier Reef Marine Park, South Molle Island and Whitehaven Beach with crystal clear water and white silica sand. Snorkel island fringing reef and tropical fish.";
	}else if (Iindex == 11){
		document.getElementById("BoatDescription").innerHTML = "THIS BOAT IT CURRENTLY UNAVAILABLE - The Card takes you on a Whitsunday Island Adventure you\'ll never forget. The flexible itinerary includes the jewel of the Whitsundays, magnificent Whitehaven Beach, wilderness anchorages, uninhabited beaches and the best snorkelling locations. Sail the best of the Whitsunday Islands and Coral Reefs aboard \"The Card\" a high powered around the world racing yacht";
	}else if (Iindex == 12){
		document.getElementById("BoatDescription").innerHTML = "THIS BOAT IT CURRENTLY UNAVAILABLE - Spend three unforgettable days and two magical nights cruising the Whitsunday Isalnds, with the highly expereinced crew of this race winning legend. Anaconda II has successfully completed numerous Sydney to Hobart challenges, as well as many varied blue water classic races. At 85Ft Anaconda II is the Largest Fibre Glass Maxi Yacht in the World.";
	}else if (Iindex == 13){
		document.getElementById("BoatDescription").innerHTML = "It only gets better onboard the lush, stylish and spacious British Defender! If you\’re looking to rig, navigate, sail, snorkel and sneek a few cheeky beers of an evening ......and see the Whitsunday Islands with in extreme fun then don\'t miss British Defender.";
	}else if (Iindex == 14){
		document.getElementById("BoatDescription").innerHTML = "Go for it! Want to experience the adrenalin of sailing on a fast maxi? Take a chance with Boomerang and you'll never want to come back! With this winner of the 2002 Whitsunday Fun Race, get excited, get involved, get it pumping and let the wind take you around the Whitsunday on an adventure that will blow your mind.";
	}else if (Iindex == 15){
		document.getElementById("BoatDescription").innerHTML = "Condor has won many races - Sydney to Hobart, Fastnet, Bermuda Cup, World Maxi Championship, Porto Cervo Maxi Series, Antigua Race Week and more. Built in Penryn, Cornwall, United Kingdom and now sails the Whitsunday Islands. Hoist the sails or take the wheel with plenty of opportunities to get involved while seeing the best destinations.";
	}
}


function ChangeAccomPrice(obj){
	index=obj.selectedIndex;

	// Change Total Price For Each Individual Whitsunday Trip
	if (index == 0){ // Koala Backpackers No Extra
		document.getElementById("AccomPrice").innerHTML = "$0.00";
	}else if (index == 1){ // Magnums $9.00
		document.getElementById("AccomPrice").innerHTML = "$9.00";
	}else if (index == 2){ // Airlie Waterfront 17 Bed $21.00
		document.getElementById("AccomPrice").innerHTML = "$21.00";
	}else if (index == 3){ // Airlie Waterfront 10 Bed $30.00
		document.getElementById("AccomPrice").innerHTML = "$30.00";
	}else if (index == 4){ // Airlie Waterfront 8 Bed Female $30.00
		document.getElementById("AccomPrice").innerHTML = "$30.00";
	}

	UpdatePrices();
}

function UpdatePrices(){
	// Calculate total Price
	var fraserPrice = parseFloat(document.getElementById("fraserPrice").innerHTML.substring(1,4));
	var sailingPrice = parseFloat(document.getElementById("sailingPrice").innerHTML.substring(1,4));
	var accPrice = parseFloat(document.getElementById("AccomPrice").innerHTML.substring(1,5));
	var fraserextraCostsWhitsundays = parseFloat(document.getElementById("FraserextraCostsWhitsundays").innerHTML.substring(1,4));
	var extCosts = parseFloat(document.getElementById("extraCostsWhitsundays").innerHTML.substring(1,4));
	var totalPrice = sailingPrice + accPrice + fraserextraCostsWhitsundays + extCosts;

	// Update Total Price
	if (parseInt((totalPrice.toString()).substring(4,5)) == 5){
		document.getElementById("TotalPrice").innerHTML = "$" + totalPrice + "0";
	}else {
		document.getElementById("TotalPrice").innerHTML = "$" + totalPrice + ".00";
	}
}

function orderPackage(){
	boatIndex = document.getElementById("DropDownBoat").selectedIndex;
	accomIndex = document.getElementById("DropDownAccom").selectedIndex + 1;
	packageIndex = 0;

	if (boatIndex >= 1 && boatIndex <= 3){
		packageIndex = 1;
		accomIndex = 0;
	}else if (boatIndex >= 4 && boatIndex <= 5){
		packageIndex = 2;
		accomIndex = 0;
	}else if (boatIndex >= 6 && boatIndex <= 7){
		packageIndex = 3;
		accomIndex = 0;
	}else if (boatIndex >= 8 && boatIndex <= 9){
		packageIndex = 4;
	}else if (boatIndex >= 10 && boatIndex <= 12){
		packageIndex = 5;
		accomIndex = 0;
	}else if (boatIndex >= 13 && boatIndex <= 16){
		packageIndex = 6;
		accomIndex = 0;
	}else if (boatIndex >= 17 && boatIndex <= 20){
		packageIndex = 7;
	}else if (boatIndex >= 21 && boatIndex <= 22){
		packageIndex = 8;
	}else if (boatIndex >= 23 && boatIndex <= 25){
		packageIndex = 9;
	}else if (boatIndex >= 26 && boatIndex <= 28){
		packageIndex = 10;
	}else if (boatIndex >= 29 && boatIndex <= 30){
		packageIndex = 11;
	}

	window.location.href = "https://secure15.myownserver.net/~herveybp/package-order.php?bID=" + boatIndex + "&aID=" + accomIndex + "&pID=" + packageIndex;
}

function enquirePackage(){
	boatIndex = document.getElementById("DropDownBoat").selectedIndex;
	accomIndex = document.getElementById("DropDownAccom").selectedIndex + 1;
	packageIndex = 0;

	if (boatIndex >= 1 && boatIndex <= 3){
		packageIndex = 1;
		accomIndex = 0;
	}else if (boatIndex >= 4 && boatIndex <= 5){
		packageIndex = 2;
		accomIndex = 0;
	}else if (boatIndex >= 6 && boatIndex <= 7){
		packageIndex = 3;
		accomIndex = 0;
	}else if (boatIndex >= 8 && boatIndex <= 9){
		packageIndex = 4;
	}else if (boatIndex >= 10 && boatIndex <= 12){
		packageIndex = 5;
		accomIndex = 0;
	}else if (boatIndex >= 13 && boatIndex <= 16){
		packageIndex = 6;
		accomIndex = 0;
	}else if (boatIndex >= 17 && boatIndex <= 20){
		packageIndex = 7;
	}else if (boatIndex >= 21 && boatIndex <= 22){
		packageIndex = 8;
	}else if (boatIndex >= 23 && boatIndex <= 25){
		packageIndex = 9;
	}else if (boatIndex >= 26 && boatIndex <= 28){
		packageIndex = 10;
	}else if (boatIndex >= 29 && boatIndex <= 30){
		packageIndex = 11;
	}

	window.location.href = "./package-contact.php?bID=" + boatIndex + "&aID=" + accomIndex + "&pID=" + packageIndex;
}
