// ***************************************************************************************************************************************
// For non-home pages and IE browser, add one more CSS
// ***************************************************************************************************************************************
// Function :: Used to add CSS for display of transparent .PNG Logo
function DispLogo(blnIsThisHome)
{
	if (blnIsThisHome == "True")
	{
		document.getElementById('LogoEyeExperts').innerHTML = "<a href='/index.htm' title='EyeExperts - Home'><img src='/images/eye-experts.gif' width='207' height='47' border='0' alt='EyeExperts - Home'></a>";
	}
	else
	{
		if (navigator.appName == "Microsoft Internet Explorer")
		{
			document.getElementById('LogoEyeExperts').innerHTML = "<div class='LogoImgIE' onclick=\"javascript:location.href='/index.htm'\"></div>";
		}
		else
		{
			document.getElementById('LogoEyeExperts').innerHTML = "<a href='/index.htm' title='EyeExperts - Home'><img src='/images/eye-experts.png' width='207' height='47' border='0' alt='EyeExperts - Home'></a>";
		}
	}
}
// ***************************************************************************************************************************************
// Includes header page - Validate search text, create URL and submit page
// ***************************************************************************************************************************************
// Used to display search results if is through the criteria
function ProductSearch()
{
	if (Trim(document.frmHSearch.txtHSearchBox.value) == "")
	{
		return false;
	}
	else
	{
		var strSearchString = "";
		strSearchString = (Trim(document.frmHSearch.txtHSearchBox.value)).replace(/ /g, "-").toLowerCase();
		document.frmHSearch.action = document.frmHSearch.action + strSearchString;
		return true;
	}
}

function txtHSearchBoxLostFocus()
{
	if (Trim(document.frmHSearch.txtHSearchBox.value) == "")
	{
		document.frmHSearch.txtHSearchBox.value = "Product search";
	}
}
function txtHSearchBoxSetFocus()
{
	if (Trim(document.frmHSearch.txtHSearchBox.value) == "Product search")
	{
		document.frmHSearch.txtHSearchBox.value = "";
	}
}
// ***************************************************************************************************************************************
// Home page - function used to rotates offer images
// ***************************************************************************************************************************************
// Used to rotate images displaying offers wherever flash is not present/installed
function RotateOffers()
{
	if (intDispOffer == 1)
	{
		intDispOffer = 2;
		document.getElementById('EEOfferLnk').innerHTML = "<img src='/images/flash/pound-15-glasses.jpg' width='487' height='253' border='0' alt='£15 glasses'>";
		document.getElementById('EEOfferLnk').href = "/15-pound-glasses.htm";
		document.getElementById('EEOfferLnk').title = "£15 glasses";
	}
	else if (intDispOffer == 2)
	{
		intDispOffer = 3;
		document.getElementById('EEOfferLnk').innerHTML = "<img src='/images/flash/prescription-sunglasses.jpg' width='487' height='253' border='0' alt='Prescription sunglasses'>";
		document.getElementById('EEOfferLnk').href = "/prescription-sunglasses.htm";
		document.getElementById('EEOfferLnk').title = "Prescription sunglasses";
	}
	else if (intDispOffer == 3)
	{
		intDispOffer = 1;
		document.getElementById('EEOfferLnk').innerHTML = "<img src='/images/flash/designer-glasses.jpg' width='487' height='253' border='0' alt='Designer frames'>";
		document.getElementById('EEOfferLnk').href = "/designer-frames.htm";
		document.getElementById('EEOfferLnk').title = "Designer frames";
	}
	
	var delay = setTimeout("RotateOffers()", 4000);
}
// ***************************************************************************************************************************************
// Product details page - on click function
// ***************************************************************************************************************************************
// Display image on which mouse scrolls over
function ShowImage(strShowImage)
{
	document.ViewBigImg.src = strShowImage;
}
// ***************************************************************************************************************************************
// Display popup help
/*
function ShowPopupHelp(strLayerName)
{
	document.getElementById(strLayerName).style.display = "block";
}
*/
// ***************************************************************************************************************************************
// Function - Used to display selected information about the Product
function DispInfo(strProdInfo)
{
	if (strProdInfo == "FrameMeasurements")
	{
		document.getElementById("ProdDtlsTab1").innerHTML = "Frame size<Br>....................";
		document.getElementById("ProdDtlsTab2").innerHTML = "<a href='javascript:void(0);' onClick='javascript:DispInfo(\"AvailableVisions\");' id='ProdDtlsLink2' class='ProdDtlsTab' title='Ideal for'>Ideal for</a><Br><Br>";
		
		document.getElementById("ContainerProdInfo").innerHTML = strFrameMeasurement;
	}
	else
	{
		document.getElementById("ProdDtlsTab1").innerHTML = "<a href='javascript:void(0);' onClick='javascript:DispInfo(\"FrameMeasurements\");' id='ProdDtlsLink1' class='ProdDtlsTab' title='Frame size'>Frame size</a><Br><Br>";
		document.getElementById("ProdDtlsTab2").innerHTML = "Ideal for<Br>....................";
		
		document.getElementById("ContainerProdInfo").innerHTML = strAvailableVisions;
	}
}
// ***************************************************************************************************************************************
// Product enlraged images display page - on mouse over functions
// ***************************************************************************************************************************************
// Function - Used to disable all data of the page and display enlarged images view
function DispEnlargedView()
{
	var intSetTop = 0;
	
	document.getElementById("DisablePageData").style.top = "0px";
	document.getElementById("DisablePageData").style.left = "0px";
	document.getElementById("DisablePageData").style.height = ((document.height || document.body.offsetHeight) + 36) + "px";
	document.getElementById("DisablePageData").style.width = (document.width || document.body.offsetWidth) + "px";
	document.getElementById("DisablePageData").style.display = "block";
	
	document.getElementById("EnlargeImgbox").style.top = ((document.body.parentElement) ? (document.body.parentElement.scrollTop - 12) : (window.pageYOffset - 12)) + "px";
	document.getElementById("EnlargeImgbox").style.left = (((document.width || document.body.offsetWidth) - 954) / 2) + "px";
	document.getElementById("EnlargeImgbox").style.height = "598px";
	document.getElementById("EnlargeImgbox").style.width = "954px";
	document.getElementById("EnlargeImgbox").style.display = "block";
}
// ***************************************************************************************************************************************
// Function - Used to enable all data of the page and hide enlarged images view
function HideEnlargedView()
{
	document.getElementById("EnlargeImgbox").style.display = "none";
	document.getElementById("DisablePageData").style.display = "none";
}
// ***************************************************************************************************************************************
// Lens selection details page - function used to reflect Lens selection values
// ***************************************************************************************************************************************
// Function - Used to reflect Lens usage options according to the Lens type selected
function DispUsageOpts(strSelLensType)
{
	// Display usage options as per the selection
	if (strSelLensType == "Standard lenses")
	{
		document.getElementById('LensTypeStd').innerHTML = strStdLensUsages;
		document.getElementById('LensTypeCZ').innerHTML = "<img src='/images/spacer.gif' width='1' height='6' alt=''>";
	}
	else if (strSelLensType == "Carl Zeiss lenses")
	{
		document.getElementById('LensTypeStd').innerHTML = "<img src='/images/spacer.gif' width='1' height='6' alt=''>";
		document.getElementById('LensTypeCZ').innerHTML = strCZLensUsages;
	}
	
	// On selection, mark all Lens related fields as blank
	document.frmLensDtls.hdnLensType.value = "";
	document.frmLensDtls.hdnLensUsage.value = "";
	document.frmLensDtls.hdnLensUsageCost.value = "";
}
// ***************************************************************************************************************************************
// Function - Used to remember selected Lens type, its usage and its cost
function MarkLensDtls(strSelLensDtls)
{
	strSelLensDtls = strSelLensDtls.split('##');
	document.frmLensDtls.hdnLensType.value = (strSelLensDtls[0].replace("-", " ")).replace("-", " ");
	document.frmLensDtls.hdnLensUsage.value = (strSelLensDtls[1].replace("-", " ")).replace("-", " ");
	document.frmLensDtls.hdnLensUsageCost.value = strSelLensDtls[2];
	strSelLensDtls = strSelLensDtls.join('##');
}
// ***************************************************************************************************************************************
// Function - Used to check Lens type and usage selection and update URL of the form to submit
function LensSelection()
{
	if ((document.frmLensDtls.hdnLensType.value == "") || (document.frmLensDtls.hdnLensUsage.value == "") || (document.frmLensDtls.hdnLensUsageCost.value == ""))
	{
		alert("Please select brand of lenses you would like to use.");
		return false;
	}
	
	document.frmLensDtls.action = document.frmLensDtls.action + ((document.frmLensDtls.hdnLensType.value.replace(" lenses", "")).replace(" ", "-")).toLowerCase() + ".htm";
	return true;
}
// ***************************************************************************************************************************************
// Display popup help
function ShowPopupHelp(LayerName, intPosTop, intPosLeft)
{
	document.getElementById(LayerName).style.top = intPosTop;
	document.getElementById(LayerName).style.left = intPosLeft;
	document.getElementById(LayerName).style.display = "block";
}
// ***************************************************************************************************************************************
// Hide popup help
function HidePopupHelp(LayerName)
{
	document.getElementById(LayerName).style.display = "none";
}
// ***************************************************************************************************************************************
// Optional extras page - optional extras functions
// ***************************************************************************************************************************************
// Function - Used to reflect selected Thickness and its Cost
function ThicknessCost(strSelThickness, strThicknessCost)
{
	document.getElementById('ThicknessOpt').innerHTML = strSelThickness;
	document.getElementById('ThicknessOptCost').innerHTML = strThicknessCost;
	
	document.frmOptionalExtras.hdnThickness.value = strSelThickness;
	document.frmOptionalExtras.hdnThicknessCost.value = strThicknessCost;
	
	// Recalculate total cost
	CalTotalCost();
}
// ***************************************************************************************************************************************
// Function - Used to reflect selected Tint colour and it costs
function LensTintOpt(strSelLensTintOpt)
{
	strSelLensTintOpt = strSelLensTintOpt.split('##');
	if (strSelLensTintOpt[2] == "")
	{
		document.frmOptionalExtras.hdnLensTintOpt.value = "";
		document.frmOptionalExtras.hdnLensTintColour.value = "";
		
		document.getElementById('TintOpt').innerHTML = "---";
		document.getElementById('TintOptCost').innerHTML = "---";
	}
	else
	{
		document.frmOptionalExtras.hdnLensTintOpt.value = strSelLensTintOpt[0] + " lenses";
		document.frmOptionalExtras.hdnLensTintColour.value = strSelLensTintOpt[1];
		
		document.getElementById('TintOpt').innerHTML = strSelLensTintOpt[1] + " " + strSelLensTintOpt[0] + " lenses";
		
		if (strSelLensTintOpt[2] == "FREE")
		{
			document.frmOptionalExtras.hdnLensTintCost.value = strSelLensTintOpt[2];
			document.getElementById('TintOptCost').innerHTML = strSelLensTintOpt[2];
		}
		else
		{
			document.frmOptionalExtras.hdnLensTintCost.value = "£" + parseFloat(strSelLensTintOpt[2].replace("£","")).toFixed(2);
			document.getElementById('TintOptCost').innerHTML = "£" + parseFloat(strSelLensTintOpt[2].replace("£","")).toFixed(2);
		}
	}
	strSelLensTintOpt = strSelLensTintOpt.join('##');
	
	// Recalculate total cost
	CalTotalCost();
}
// ***************************************************************************************************************************************
// Function - Used to reflect Coating costs
function OtherCosts()
{
	var intSelOptsCnt, strCoatingOpts, strCoatingOptsCost;
	intSelOptsCnt = 0;
	strCoatingOpts = "";
	strCoatingOptsCost = 0;
	
	document.frmOptionalExtras.hdnARCoatingCost.value = "";
	document.frmOptionalExtras.hdnPCoatingCost.value = "";
	document.frmOptionalExtras.hdnSRCoatingCost.value = "";
	document.frmOptionalExtras.hdnWRCoatingCost.value = "";
	
	if (document.frmOptionalExtras.chkARCoating.checked == true)
	{
		intSelOptsCnt = intSelOptsCnt + 1;
		strCoatingOpts = strCoatingOpts + "Anti-reflective";
		document.frmOptionalExtras.hdnARCoatingCost.value = document.frmOptionalExtras.chkARCoating.value;
		
		if (document.frmOptionalExtras.chkARCoating.value != "FREE")
		{
			strCoatingOptsCost = strCoatingOptsCost + parseFloat(document.frmOptionalExtras.chkARCoating.value.replace("£",""));
		}
	}
	if (document.frmOptionalExtras.chkPCoating.checked == true)
	{
		if (strCoatingOpts != "")
		{
			strCoatingOpts = strCoatingOpts + ", ";
		}
		
		intSelOptsCnt = intSelOptsCnt + 1;
		strCoatingOpts = strCoatingOpts + "Scratch resistant";
		document.frmOptionalExtras.hdnPCoatingCost.value = document.frmOptionalExtras.chkPCoating.value;
		
		if (document.frmOptionalExtras.chkPCoating.value != "FREE")
		{
			strCoatingOptsCost = strCoatingOptsCost + parseFloat(document.frmOptionalExtras.chkPCoating.value.replace("£",""));
		}
	}
	if (document.frmOptionalExtras.chkSRCoating.checked == true)
	{
		if (strCoatingOpts != "")
		{
			strCoatingOpts = strCoatingOpts + ", ";
		}
		
		intSelOptsCnt = intSelOptsCnt + 1;
		strCoatingOpts = strCoatingOpts + "UV400 protective";
		document.frmOptionalExtras.hdnSRCoatingCost.value = document.frmOptionalExtras.chkSRCoating.value;
		
		if (document.frmOptionalExtras.chkSRCoating.value != "FREE")
		{
			strCoatingOptsCost = strCoatingOptsCost + parseFloat(document.frmOptionalExtras.chkSRCoating.value.replace("£",""));
		}
	}
	if (document.frmOptionalExtras.chkWRCoating.checked == true)
	{
		if (strCoatingOpts != "")
		{
			strCoatingOpts = strCoatingOpts + ", ";
		}
		
		intSelOptsCnt = intSelOptsCnt + 1;
		strCoatingOpts = strCoatingOpts + "Water repellent";
		document.frmOptionalExtras.hdnWRCoatingCost.value = document.frmOptionalExtras.chkWRCoating.value;
		
		if (document.frmOptionalExtras.chkWRCoating.value != "FREE")
		{
			strCoatingOptsCost = strCoatingOptsCost + parseFloat(document.frmOptionalExtras.chkWRCoating.value.replace("£",""));
		}
	}
	
	if (intSelOptsCnt == 0)
	{
		document.getElementById('CoatingOpts').innerHTML = "---";
		document.getElementById('CoatingOptsCost').innerHTML = "---";
	}
	else
	{
		if (strCoatingOpts.match(", Water repellent") != null)
		{
			strCoatingOpts = strCoatingOpts.replace(", Water repellent", " and Water repellent");
		}
		else if (strCoatingOpts.match(", UV400 protective") != null)
		{
			strCoatingOpts = strCoatingOpts.replace(", UV400 protective", " and UV400 protective");
		}
		else if (strCoatingOpts.match(", Scratch resistant") != null)
		{
			strCoatingOpts = strCoatingOpts.replace(", Scratch resistant", " and Scratch resistant");
		}
		strCoatingOpts = strCoatingOpts + " coating";
		if (intSelOptsCnt > 1)
		{
			strCoatingOpts = strCoatingOpts + "s";
		}
		document.getElementById('CoatingOpts').innerHTML = strCoatingOpts;
		
		if (strCoatingOptsCost == 0)
		{
			document.getElementById('CoatingOptsCost').innerHTML = "FREE";
		}
		else
		{
			document.getElementById('CoatingOptsCost').innerHTML = "£" + strCoatingOptsCost.toFixed(2);
		}
	}
	
	// Recalculate total cost
	CalTotalCost();
}
// ***************************************************************************************************************************************
// Function - Used to Calculate Total cost
function CalTotalCost()
{
	var strTotalPrice = 0;
	
	// Fetch here Frame cost
	strTotalPrice = parseFloat((document.getElementById('ProdPrice').innerHTML).replace("£",""));
	
	// Now add Lens selection and Usage cost as per the selection
	if ((document.getElementById('LensNUsageCost').innerHTML != "") && (document.getElementById('LensNUsageCost').innerHTML != "FREE"))
	{
		strTotalPrice = parseFloat(strTotalPrice) + parseFloat((document.getElementById('LensNUsageCost').innerHTML).replace("£",""));
	}
	
	// Add to the total cost of the Lens Thickness
	if ((document.getElementById('ThicknessOptCost').innerHTML != "") && (document.getElementById('ThicknessOptCost').innerHTML != "FREE"))
	{
		strTotalPrice = parseFloat(strTotalPrice) + parseFloat((document.getElementById('ThicknessOptCost').innerHTML).replace("£",""));
	}
	
	// Now add cost for the Lens Colour and Tint selection
	if ((document.getElementById('TintOptCost').innerHTML != "") && (document.getElementById('TintOptCost').innerHTML != "---") && (document.getElementById('TintOptCost').innerHTML != "FREE"))
	{
		strTotalPrice = parseFloat(strTotalPrice) + parseFloat((document.getElementById('TintOptCost').innerHTML).replace("£",""));
	}
	
	// And finally add to the total cost, cost of the Coating options selected
	if ((document.getElementById('CoatingOptsCost').innerHTML != "") && (document.getElementById('CoatingOptsCost').innerHTML != "---") && (document.getElementById('CoatingOptsCost').innerHTML != "FREE"))
	{
		strTotalPrice = parseFloat(strTotalPrice) + parseFloat((document.getElementById('CoatingOptsCost').innerHTML).replace("£",""));
	}
	
	// Store and display final/Total cost for the frame and its selected options
	document.getElementById('TotalCost').innerHTML = "£" + strTotalPrice.toFixed(2);
	document.frmOptionalExtras.hdnTotalCost.value = "£" + strTotalPrice.toFixed(2);
}
// ***************************************************************************************************************************************
// Prescription page - For client side validation and Dynamic HTML display
// ***************************************************************************************************************************************
// Default variable declaration and initialization to be used on the Page
var blnSphere, blnCylinder, intCylinderAxis, strEmptyTable;
var strRXValues1, strRXValues2, strRXMessage0, strRXMessage1, strRXMessage2, strRXMessage3;

strEmptyTable = "<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr>";
strEmptyTable = strEmptyTable + "<td><img src='/images/spacer.gif' width='1' height='1' alt=''></td></tr></table>";

strRXValues1 = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
strRXValues1 = strRXValues1 + "<tr><td class='PreTblHeading'>Confirm prescription</td>";
strRXValues1 = strRXValues1 + "<td align='right'><input type='checkbox' name='chkRxCheck' tabindex='16'></td></tr>";
strRXValues1 = strRXValues1 + "<tr><td colspan='2'><img src='/images/spacer.gif' width='1' height='2' alt=''></td></tr>";
strRXValues1 = strRXValues1 + "<tr><td colspan='2' class='PreText1'>";

strRXValues2 = "</td></tr>";
strRXValues2 = strRXValues2 + "<tr><td colspan='2'><img src='/images/spacer.gif' width='1' height='6' alt=''></td></tr>";
strRXValues2 = strRXValues2 + "<tr><td colspan='2' class='Border5'><img src='/images/spacer.gif' width='1' height='1' alt=''></td></tr>";
strRXValues2 = strRXValues2 + "<tr><td colspan='2'><img src='/images/spacer.gif' width='1' height='4' alt=''></td></tr></table>";

strRXMessage1 = "I confirm that as per my prescription, I have a negative sphere reading in one eye and positive in the other.";
strRXMessage2 = "I confirm that as per my prescription, I have a negative cylinder reading in one eye and positive in the other.";
strRXMessage3 = "I confirm that as per my prescription, I have negative sphere and cylinder reading in one eye and positive in the other.";

strRXMessage0 = strEmptyTable;
strRXMessage1 = strRXValues1 + strRXMessage1 + strRXValues2;
strRXMessage2 = strRXValues1 + strRXMessage2 + strRXValues2;
strRXMessage3 = strRXValues1 + strRXMessage3 + strRXValues2;
// ***************************************************************************************************************************************
// Function - Used to display prescription fields as per the users complexity selection
function MarkSelectedTab(strTabName)
{
	if (strTabName == "Simple")
	{
		document.getElementById("LPTab1").className = "BGLPTabSel";
		document.getElementById("LPTab2").className = "BGLPTab";
		document.getElementById("LPLink1").className = "LPTabSel";
		document.getElementById("LPLink2").className = "LPTab";
		
		document.getElementById("LPSimple").style.display = "block";
		document.getElementById("LPComplex").style.display = "none";
	}
	else
	{
		document.getElementById("LPTab1").className = "BGLPTab";
		document.getElementById("LPTab2").className = "BGLPTabSel";
		document.getElementById("LPLink1").className = "LPTab";
		document.getElementById("LPLink2").className = "LPTabSel";
		
		document.getElementById("LPSimple").style.display = "none";
		document.getElementById("LPComplex").style.display = "block";
	}
	document.frmPrescription.PrescriptionIs.value = strTabName;
}
// ***************************************************************************************************************************************
// Function - Used to set/reset value on GotFocus and LostFocus events
function txtRLostFocus(intIndex)
{
	if (document.getElementById("txtRAxis" + intIndex).value == "")
	{
		document.getElementById("txtRAxis" + intIndex).value = "None";
	}
}
function txtLLostFocus(intIndex)
{
	if (document.getElementById("txtLAxis" + intIndex).value == "")
	{
		document.getElementById("txtLAxis" + intIndex).value = "None";
	}
}

function txtRSetFocus(intIndex)
{
	if (document.getElementById("txtRAxis" + intIndex).value == "None")
	{
		document.getElementById("txtRAxis" + intIndex).value = "";
	}
}
function txtLSetFocus(intIndex)
{
	if (document.getElementById("txtLAxis" + intIndex).value == "None")
	{
		document.getElementById("txtLAxis" + intIndex).value = "";
	}
}
// ***************************************************************************************************************************************
// Function - Used to validate Pupillary distance
function ValidatePD()
{
	var ValidChars = "0123456789.";
	var strSelCharIs = "";
	var intOccurances = 0;
	var strInputValue = Trim(document.frmPrescription.txtPupillaryDistance.value);
	
	// Check whether the string is empty
	if (strInputValue == "")
	{
		alert("Please enter Pupillary distance value.");
		return false;
	}
	
	// Check if number sign or decimal point entered at start
	strSelCharIs = strInputValue.charAt(0);
	if (strSelCharIs == ".")
	{
		strInputValue = "0" + strInputValue;
	}
	else if (strSelCharIs == "+")
	{
		strInputValue = strInputValue.replace("+", "");
	}
	else if (strSelCharIs == "-")
	{
		alert("Please enter valid Pupillary distance.");
		return false;
	}
	
	for (i = 0; i < strInputValue.length; i++) 

	{ 
		strSelCharIs = strInputValue.charAt(i);
		
		if (strSelCharIs == ".")
		{
			intOccurances = parseInt(intOccurances) + parseInt(1);
		}
		
		if ((ValidChars.indexOf(strSelCharIs) == -1) || (intOccurances > 1))
		{
			alert("Please enter valid numeric Pupillary distance.");
			return false;
		}
	}
	
	document.frmPrescription.txtPupillaryDistance.value = strInputValue;
	return true;
}
// ***************************************************************************************************************************************
// Function - Used to validate Prescription values
function ValidatePrescription(intIndex)
{
	blnSphere = false;
	blnCylinder = false;
	
	if ((document.getElementById("cmbRSphere" + intIndex).value != "") && (document.getElementById("cmbLSphere" + intIndex).value != ""))
	{
		if ((document.getElementById("cmbRSphere" + intIndex).value == "Infinity") || (document.getElementById("cmbLSphere" + intIndex).value == "Infinity"))
		{
			blnSphere = false;
		}
		else if ((isNaN(document.getElementById("cmbRSphere" + intIndex).value) == false) && (isNaN(document.getElementById("cmbLSphere" + intIndex).value) == false))
		{
			if ((document.getElementById("cmbRSphere" + intIndex).value < 0) && (document.getElementById("cmbLSphere" + intIndex).value > 0))
			{
				blnSphere = true;
			}
			else if ((document.getElementById("cmbRSphere" + intIndex).value > 0) && (document.getElementById("cmbLSphere" + intIndex).value < 0))
			{
				blnSphere = true;
			}
		}
	}
	
	if ((document.getElementById("cmbRCylinder" + intIndex).value != "") && (document.getElementById("cmbLCylinder" + intIndex).value != ""))
	{
		if ((document.getElementById("cmbRCylinder" + intIndex).value == "Infinity") || (document.getElementById("cmbLCylinder" + intIndex).value == "Infinity"))
		{
			blnCylinder = false;
		}
		else if ((isNaN(document.getElementById("cmbRCylinder" + intIndex).value) == false) && (isNaN(document.getElementById("cmbLCylinder" + intIndex).value) == false))
		{
			if ((document.getElementById("cmbRCylinder" + intIndex).value < 0) && (document.getElementById("cmbLCylinder" + intIndex).value > 0))
			{
				blnCylinder = true;
			}
			else if ((document.getElementById("cmbRCylinder" + intIndex).value > 0) && (document.getElementById("cmbLCylinder" + intIndex).value < 0))
			{
				blnCylinder = true;
			}
		}
	}
	
	if ((blnSphere == true) && (blnCylinder == true))
	{
		document.getElementById('RXValues').innerHTML = strRXMessage3;
	}
	else if (blnSphere == true)
	{
		document.getElementById('RXValues').innerHTML = strRXMessage1;
	}
	else if (blnCylinder == true)
	{
		document.getElementById('RXValues').innerHTML = strRXMessage2;
	}
	else
	{
		document.getElementById('RXValues').innerHTML = strRXMessage0;
	}
}
// ***************************************************************************************************************************************
// Function - Used to validate form data before submitting
function CheckPrescription()
{
	var intIndex, intSIndex, intEIndex;
	
	// Set looping elements
	if (document.frmPrescription.PrescriptionIs.value == "Simple")
	{
		intSIndex = 1;
		intEIndex = 2;
	}
	else
	{
		intSIndex = 2;
		intEIndex = 5;
	}
	
	// For each pair of right and left eye prescription, loop as per the prescription complexity selection
	for (intIndex = intSIndex; intIndex < intEIndex; intIndex++)
	{
		// Validate right eye Axis(AXI) readings
		if (document.getElementById("cmbRCylinder" + intIndex).value != "")
		{
			if (isNaN(document.getElementById("txtRAxis" + intIndex).value) == false)
			{
				if ((parseFloat(document.getElementById("txtRAxis" + intIndex).value) > parseFloat(999)) || (parseFloat(document.getElementById("txtRAxis" + intIndex).value) < parseFloat(-999)))
				{
					alert("Please enter valid Axis(AXI) reading for right eye.");
					document.getElementById("txtRAxis" + intIndex).value = "";
					document.getElementById("txtRAxis" + intIndex).focus();
					return false;
				}
			}
			else
			{
				alert("Please enter valid Axis(AXI) reading for right eye.");
				document.getElementById("txtRAxis" + intIndex).value = "";
				document.getElementById("txtRAxis" + intIndex).focus();
				return false;
			}
		}
		
		// Validate left eye Axis(AXI) readings
		if (document.getElementById("cmbLCylinder" + intIndex).value != "")
		{
			if (isNaN(document.getElementById("txtLAxis" + intIndex).value) == false)
			{
				if ((parseFloat(document.getElementById("txtLAxis" + intIndex).value) > parseFloat(999)) || (parseFloat(document.getElementById("txtLAxis" + intIndex).value) < parseFloat(-999)))
				{
					alert("Please enter valid Axis(AXI) reading for left eye.");
					document.getElementById("txtLAxis" + intIndex).value = "";
					document.getElementById("txtLAxis" + intIndex).focus();
					return false;
				}
			}
			else
			{
				alert("Please enter valid Axis(AXI) reading for left eye.");
				document.getElementById("txtLAxis" + intIndex).value = "";
				document.getElementById("txtLAxis" + intIndex).focus();
				return false;
			}
		}
		
		// Now check whether corresponding Cylinder(CYL) and Axis(AXI) readings are entered by user
		if ((document.getElementById("cmbRCylinder" + intIndex).value != "") && (document.getElementById("txtRAxis" + intIndex).value == "None"))
		{
			alert("Please enter the corresponding Axis(AXI) reading for the specified Cylinder(CYL) value.");
			document.getElementById("txtRAxis" + intIndex).value = "";
			document.getElementById("txtRAxis" + intIndex).focus();
			return false;
		}
		else if ((document.getElementById("cmbRCylinder" + intIndex).value == "") && (document.getElementById("txtRAxis" + intIndex).value != "None"))
		{
			alert("Please select the corresponding Cylinder(CYL) value for the specified Axis(AXI) reading.");
			document.getElementById("cmbRCylinder" + intIndex).focus();
			return false;
		}
		else if ((document.getElementById("cmbLCylinder" + intIndex).value != "") && (document.getElementById("txtLAxis" + intIndex).value == "None"))
		{
			alert("Please enter the corresponding Axis(AXI) reading for the specified Cylinder(CYL) value.");
			document.getElementById("txtLAxis" + intIndex).value = "";
			document.getElementById("txtLAxis" + intIndex).focus();
			return false;
		}
		else if ((document.getElementById("cmbLCylinder" + intIndex).value == "") && (document.getElementById("txtLAxis" + intIndex).value != "None"))
		{
			alert("Please select the corresponding Cylinder(CYL) value for the specified Axis(AXI) reading.");
			document.getElementById("cmbRCylinder" + intIndex).focus();
			return false;
		}
	}
	
	// Check for Pupillary Distance(PD) value
	if (ValidatePD() == false)
	{
		document.frmPrescription.txtPupillaryDistance.focus();
		return false;
	}
	
	// User must be agree with the terms nad conditions
	if (document.frmPrescription.chkTerms.checked == false)
	{
		alert("Please agree to the Prescription disclaimer terms and conditions to proceed.");
		document.frmPrescription.chkTerms.focus();
		return false;
	}
	
	// User must be of 16 years old
	if (document.frmPrescription.chkCertification.checked == false)
	{
		alert("Please agree to the age check to proceed.");
		document.frmPrescription.chkCertification.focus();
		return false;
	}
	
	// Confirm that sphere and cylinder values entered are proper
	if (document.getElementById("chkRxCheck") != null)
	{
		if (document.getElementById("chkRxCheck").checked == false)
		{
			alert("Please confirm that according to your prescription you have a negative sphere/cylinder reading in one eye and positive in the other.");
			document.getElementById("chkRxCheck").focus();
			return false;
		}
	}
	
	// Otherwise submit the form
	return true;
}
// ***************************************************************************************************************************************
// Function - Used to open a popup page, which will help to upload file for the prescription
function UploadPrescription()
{
	window.open('/cart/upload-prescription.asp','UploadPrescription','width=400,height=167,top=200,left=200,status=no,scrollbars=no,resizable=no');
}
// ***************************************************************************************************************************************
// Function - Used to open informatic popup for Pupillary distance
function Pupillary_Distance()
{
	window.open("/cart/pupillary-distance.asp", "PupillaryDistance", "width=650,height=384,status=yes,scrollbars=yes,resizable=No,top=0,left=0");
}
// ***************************************************************************************************************************************
// Function - Used to open popup of Terms and Conditions
function PricePromise()
{
	window.open("/cart/price-promise.asp", "PricePromise", "width=670,height=596,status=yes,scrollbars=yes,resizable=No,top=0,left=0");
}
// ***************************************************************************************************************************************
// Function - Used to open popup of Terms and Conditions
function Terms_Conditions()
{
	window.open("/cart/terms-n-conditions.asp", "TermsConditions", "width=670,height=600,status=yes,scrollbars=yes,resizable=No,top=0,left=0");
}
// ***************************************************************************************************************************************
// View Cart page - For client side Postage cost updation
// ***************************************************************************************************************************************
// Function - Used to reflect total order cost according to the Postage and Packaging selection
function PnP_Cost()
{
	var intCalOrderCost;
	
	if (document.frmCart.cmbDelOption.value == "Postage within UK")
	{
		intCalOrderCost = 3.95;
		intCalOrderCost = parseFloat(intCalOrderCost) + parseFloat(document.frmCart.hidTotalCost.value.replace("£",""));
		intCalOrderCost = parseFloat(intCalOrderCost) - parseFloat(document.getElementById('PromoDiscount').innerHTML.replace("£",""));
		
		document.getElementById('PnPCost').innerHTML = "£3.95&nbsp;";
		document.getElementById('TotalOrderCost').innerHTML = "£" + intCalOrderCost.toFixed(2) + '&nbsp;';
	}
	else
	{
		intCalOrderCost = 5;
		intCalOrderCost = parseFloat(intCalOrderCost) + parseFloat(document.frmCart.hidTotalCost.value.replace("£",""));
		intCalOrderCost = parseFloat(intCalOrderCost) - parseFloat(document.getElementById('PromoDiscount').innerHTML.replace("£",""));
		
		document.getElementById('PnPCost').innerHTML = "£5.00&nbsp;";
		document.getElementById('TotalOrderCost').innerHTML = "£" + intCalOrderCost.toFixed(2) + '&nbsp;';
	}
}
// ***************************************************************************************************************************************
// Function - Used to mark clicked button and redirect to the corresponding page
function MarkButtonClick(strActionName)
{
	document.frmCart.hidGotoPage.value = strActionName;
}
// ***************************************************************************************************************************************
// Checkout page - For client side Postage cost updation
// ***************************************************************************************************************************************
// Function - Used to reflect Shipping data same as that of Billing data if marked
function fnSameShipAddress()
{
	if (document.frmCheckout.chkSameShipAddr.checked)
	{
		document.frmCheckout.cmbShipTitle.selectedIndex 	= 	document.frmCheckout.cmbTitle.selectedIndex;
		document.frmCheckout.txtShipFirstName.value 		= 	document.frmCheckout.txtFirstName.value;
		document.frmCheckout.txtShipLastName.value 			= 	document.frmCheckout.txtLastName.value;
		document.frmCheckout.txtShipAddress1.value 			= 	document.frmCheckout.txtAddress1.value;
		document.frmCheckout.txtShipAddress2.value 			= 	document.frmCheckout.txtAddress2.value;
		document.frmCheckout.txtShipCity.value				=	document.frmCheckout.txtCity.value;
		document.frmCheckout.txtShipCounty.value			=	document.frmCheckout.txtCounty.value;
		document.frmCheckout.txtShipPostCode.value			=	document.frmCheckout.txtPostCode.value;
		document.frmCheckout.cmbShipCountry.selectedIndex	=   document.frmCheckout.cmbCountry.selectedIndex;
		document.frmCheckout.txtShipEmail.value				=   document.frmCheckout.txtEmail.value;
		document.frmCheckout.txtShipDayPhone.value     		=   document.frmCheckout.txtDayPhone.value;
		document.frmCheckout.txtShipEvePhone.value     		=   document.frmCheckout.txtEvePhone.value;
	}
}
// ***************************************************************************************************************************************
// Function - Used to display popup for Terms and Conditions
function TermsAndConditions()
{
	window.open("/cart/terms-n-conditions.asp", "TermsConditions", "width=670,height=600,status=yes,scrollbars=yes,resizable=No,top=0,left=0");
}
// ***************************************************************************************************************************************
// For non-home pages and IE browser, add one more CSS
// ***************************************************************************************************************************************
// Verify summation to submit the form
function VerifySum(intSumValue)
{
	if (Trim(document.frmSubscription.txtSumVal.value) == intSumValue)
	{
		return true;
	}
	else
	{
		alert("Please enter the correct value of the addition.");
		document.frmSubscription.txtSumVal.focus();
		return false;
	}
}
// ***************************************************************************************************************************************