/* Common */
	function focusControl(objInput, strDefault)
	{
		if (objInput.value == strDefault)
		{
			objInput.value = "";
		}
	}

	function blurControl(objInput, strDefault)
	{
		if (objInput.value == "")
		{
			objInput.value = strDefault;
		}
	}


/*Start Date Selector*/

function addOptGroup(strDaysId, strName)
{
	var cboDays = document.getElementById(strDaysId);
	var iSelectedDay = 0;
	var iSelectedIndex = 0;

	iSelectedIndex = cboDays.options.selectedIndex;

	if (iSelectedIndex != 0)
	{
		iSelectedDay = cboDays.options[iSelectedIndex].value;
	}

	var itmGroup = document.createElement("optgroup");
	itmGroup.label = strName;

	var iCount = cboDays.options.length;
	var iIndex = 0;
	for (iIndex = 0; iIndex < iCount; iIndex++)
	{
		var itmOption = cboDays.options[0];

		if (itmOption.value == iSelectedDay)
		{
			iSelectedIndex = iIndex;
			itmOption.selected = true;
		}
		else
		{
			itmOption.selected = false;
		}

		itmGroup.appendChild(itmOption);
	}

	cboDays.appendChild(itmGroup);

	cboDays.options.selectedIndex = iSelectedIndex;
}
	
function showHideCalendar()
{
	var divFloatingCalendar = document.getElementById("floatingCalendar");

	if (divFloatingCalendar.style.display != "block")
	{
		divFloatingCalendar.style.display = "block";
	}
	else
	{
		divFloatingCalendar.style.display = "none";
	}
}
	
function validateRentalsDays(strDaysId)
{
	var cboDays = document.getElementById(strDaysId);

	if (cboDays.options.selectedIndex == 0)
	{
		alert("Please select the number of days you require to rent the equipment.");
		return false;
	}

	return true;
}

/* Search Control */
	var strLastShownCalendar = "";

	function showHideCalendarA(strDiv)
	{
		var divFloatingCalendar = document.getElementById(strDiv);
		
		if (divFloatingCalendar.style.display != "block")
		{
			divFloatingCalendar.style.display = "block";
			strLastShownCalendar = strDiv;
		}
		else
		{
			divFloatingCalendar.style.display = "none";
			strLastShownCalendar = "";
		}
	}
	
/*	function validateAdd(strQuantity, iProductTypeId)
	{
		alert('No Online Transactions can be made until next seasons dates are available.')
		return false;
	}
*/

	function validateAdd(strQuantity, iProductTypeId)
	{
		var cboQuantity = document.getElementById(strQuantity);
		
		if (!cboQuantity)
		{
			alert("error!");
			return false
		}
		
		if (cboQuantity.selectedIndex == 0)
		{
			alert("Please select the quantity first!");
			return false;
		}
		
		if (iProductTypeId != 3 && iProductTypeId != 4 && iProductTypeId != 5)
		{
			alert("The items have been successfully added to your basket!");
			resetDotNetScrollPosition();
		}
		
		return true;
	} 
	
	function validateAddPassengers(strQuantity, iProductTypeId)
	{
		var cboQuantity = document.getElementById(strQuantity);
		
		if (!cboQuantity)
		{
			alert("error!");
			return false
		}
		
		if (cboQuantity.selectedIndex == 0)
		{
			alert("Please select the number of passengers first!");
			return false;
		}
		
		resetDotNetScrollPosition();
		
		return true;
	}
	
	function resetDotNetScrollPosition()
	{
		/*var scrollX = document.getElementById("__SCROLLPOSITIONX");
		var scrollY = document.getElementById("__SCROLLPOSITIONY");

		if(scrollX != null && scrollY != null)
		{
			scrollX.value = 0;
			scrollY.value = 0;
		}*/
		
		window.scrollTo(0,0);
	}

	function calStartDate_DateChangedJS_A(strId, strDate, blnSelected)
	{
		showHideCalendarA(strLastShownCalendar);
	}
	


/* Shopping Basket*/

function checkTandC(strCheckId)
{
	var chkReadTandC = document.getElementById(strCheckId);
	if (!chkReadTandC.checked)
	{
		alert("Please confirm that you have read the terms and conditions first!");
		return false;
	}

	return true;
}

/* Payment Page */
	function displayCharge(objSelect, strTotal, strTotalWithCharge)
	{
		var divCharge = document.getElementById("divCharge");
		var divCharge1 = document.getElementById("divCharge1");
		var spnTotalCostTop = document.getElementById("spnTotalCostTop");
		var spnTotalCostBottom = document.getElementById("spnTotalCostBottom");
		var strSelected = objSelect.options[objSelect.selectedIndex].text;
		
		if (strSelected != "Mastercard" && strSelected != "Visa" && strSelected != "Amex")
		{
			divCharge.style.display = "none";
			divCharge1.style.display = "none";
			spnTotalCostTop.innerHTML = strTotal;
			spnTotalCostBottom.innerHTML = strTotal;
		}
		else
		{
			divCharge.style.display = "block";
			divCharge1.style.display = "block";
			spnTotalCostTop.innerHTML = strTotalWithCharge;
			spnTotalCostBottom.innerHTML = strTotalWithCharge;
		}
	}
