function submitSearch()
{
	document.getElementById('Loader').style.display = 'inline';
	return true;
}

function submitSearch1()
{
	document.getElementById('Loader1').style.display = 'inline';
	return true;
}

function changeBerth(berthID)
{
	var berthImgID = 'berth' + berthID;
	var berthRadioID = 'berthRadio' + berthID;
	
	document.getElementById('berth2').src = '/Images/img2.png'
	document.getElementById('berth3').src = '/Images/img3.png'
	document.getElementById('berth4').src = '/Images/img4.png'
	document.getElementById('berth5').src = '/Images/img5.png'
	document.getElementById('berth6').src = '/Images/img6.png'
	
	document.getElementById(berthImgID).src = '/Images/img' + berthID + 'C.png';
	document.getElementById(berthRadioID).checked = true;

}


function totalPriceUpdate(totalPrice, totalDays, diffDropOffLocation)
{		
	
	return false;
	// ADDING PRICE FOR ACCESSORIES
	var selCount = 1;
	var selID = 'acc' + selCount;
	var accessoryPrice = 0;
	var insurancePrice = 0;
	
	while(document.getElementById(selID))
	{
		//SELECT VALUE
		var selValue = document.getElementById(selID).value;
		var accessoryArray=selValue.split('|');
		maxDays = accessoryArray[2];
		price = accessoryArray[0];
		quantity = accessoryArray[1];
		
		if(quantity > 0)
		{	
			if(maxDays == 0)
			accessoryPrice = parseFloat(accessoryPrice) + (parseInt(quantity) * parseInt(price));
			else
			{
				//Check Accessory Cap
				if(parseInt(totalDays) > parseInt(maxDays) && parseInt(maxDays) != 0)
				accessoryTotalDays = maxDays;
				else
				accessoryTotalDays = totalDays
				accessoryPrice = parseFloat(accessoryPrice) + (parseInt(accessoryTotalDays) * parseInt(price) * parseInt(quantity));
			}
		}
		
		selCount++;
		selID = 'acc' + selCount;
	}


	// ADDING PRICE FOR INSURANCE
	if(document.bookForm.insurancePrice)
	{
		for (var i=0; i < document.bookForm.insurancePrice.length; i++)
	   {
	   		if (document.bookForm.insurancePrice[i].checked)
	       {
	       		var rad_val = document.bookForm.insurancePrice[i].value;
	       }
	   }
	   
	   	var Insurance = rad_val;
	   	if(Insurance)
	   	{
			var insuranceArray=Insurance.split('_');
			var insuranceCap = parseFloat(insuranceArray[2]);
			var premier = parseFloat(insuranceArray[3]);
			var insuranceTotalDays = 0;
			
			//Check Insurance Cap
			if(parseInt(totalDays) > parseInt(insuranceCap) && parseInt(insuranceCap) != 0)
			insuranceTotalDays = insuranceCap;
			else
			insuranceTotalDays = totalDays
			
/*			var currDiffDropOff = document.getElementById('diffDropOffLocation').innerHTML;
			
			if(diffDropOffLocation == '')
			diffDropOffLocation = '0.00';
			
			if(premier == '1')
			document.getElementById('diffDropOffLocation').innerHTML = '0.00';
			else
			document.getElementById('diffDropOffLocation').innerHTML = diffDropOffLocation;
*/	
			insurancePrice = parseFloat(insuranceArray[1]) * parseInt(insuranceTotalDays);
		}
	}

	totalPrice = parseFloat(totalPrice) + parseFloat(accessoryPrice) + parseFloat(insurancePrice);
	
		/*
		if(currDiffDropOff > 0 && premier == 1)
		totalPrice = totalPrice - parseFloat(currDiffDropOff)
	   */
		// Decimal
		var num = new Number(totalPrice);
		var totalPrice = num.toFixed(2);
		
	document.getElementById('totalPrice').innerHTML = totalPrice;
	document.getElementById('finalPrice').value = totalPrice;
}





function updateClock ( )
{
	//TIME ZONE DIFFERENCE
	offset = 12;
  var currentTime = new Date ( );
  utc = currentTime.getTime() + (currentTime.getTimezoneOffset() * 60000);
  currentTime = new Date(utc + (3600000*offset));


  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );

  // Pad the minutes and seconds with leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

  // Convert an hours component of "0" to "12"
  currentHours = ( currentHours == 0 ) ? 12 : currentHours;

  // Compose the string for display
  var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;

  // Update the time display
  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}

function roundNumber(num, dec) {
	var result = Math.round( Math.round( num * Math.pow( 10, dec + 1 ) ) / Math.pow( 10, 1 ) ) / Math.pow(10,dec);
	return result;
}

function changeCity(cityID,siteBaseUrl)
{
	var link = 'attractions/' + cityID;
	window.location.href = siteBaseUrl+link;
}

function changeLocation(locationName)
{
	var link = 'activities.php?location=' + locationName;
	window.location.href = link;
}

function changeCityDeals(cityID)
{
	var link = 'deals.php?id=' + cityID;
	window.location.href = link;
}

function addToTotal(amount, cost)
{
	if(document.getElementById('adult'))
	var adult = document.getElementById('adult').value;
	else
	adult=0;

	if(document.getElementById('child1'))
	var child1 = document.getElementById('child1').value;
	else
	child1=0;

	if(document.getElementById('child2'))
	var child2 = document.getElementById('child2').value;
	else
	child2=0;

	if(document.getElementById('child3'))
	var child3 = document.getElementById('child3').value;
	else
	child3=0;

	if(document.getElementById('infant'))
	var infant = document.getElementById('infant').value;
	else
	infant=0;

	if(document.getElementById('adultPrice'))
	var adultPrice = document.getElementById('adultPrice').value;
	else
	adultPrice=0;

	if(document.getElementById('child1Price'))
	var child1Price = document.getElementById('child1Price').value;
	else
	child1Price=0;

	if(document.getElementById('child2Price'))
	var child2Price = document.getElementById('child2Price').value;
	else
	child2Price=0;

	if(document.getElementById('child3Price'))
	var child3Price = document.getElementById('child3Price').value;
	else
	child3Price=0;

	if(document.getElementById('infantPrice'))
	var infantPrice = document.getElementById('infantPrice').value;
	else
	infantPrice=0;

	if(document.getElementById('PaxPrice'))
	var PaxPrice = document.getElementById('PaxPrice').value;
	else
	PaxPrice=0;

	if(document.getElementById('TripPrice'))
	var TripPrice = document.getElementById('TripPrice').value;
	else
	TripPrice=0;
	
	if(document.getElementById('Pax'))
	var Pax = document.getElementById('Pax').value;
	else
	Pax=0;

	if(document.getElementById('Trip'))
	var Trip = document.getElementById('Trip').value;
	else
	Trip=0;

	
	var tot = parseFloat(adultPrice) * adult + parseFloat(child1Price) * child1 + parseFloat(child2Price) * child2 + parseFloat(child3Price) * child3 + parseFloat(infantPrice) * infant + parseFloat(PaxPrice) * Pax + parseFloat(TripPrice) * Trip;
	
	var num = new Number(tot);
	var tot = num.toFixed(2);

	 document.getElementById('totalAmount').value = tot;
	 document.getElementById('total').innerHTML = tot;
}

function clearAllRadio(formName,radioId) {
	var frmObj = document.forms[formName]; 
	var radioSelId = frmObj.elements[radioId];
	
	if(radioSelId.length == undefined) {
		radioSelId.checked = false;
	}
	
	for (var i=0; i< radioSelId.length; i++) {
  		radioSelId[i].checked = false;
	}
}

