function jLaunchWindow( sURL, sWidth, sHeight ){
	sParams = "'directories=no,height=300,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,width=" + sWidth + ",height=" + sHeight + ",toolbar=no'"
	 newWin = window.open( sURL,'Help', sParams);
}

function jfIsValid( sValue, strValidChars  ) {
	var isValid = new Boolean()
	isValid=true
	var myChar=""
	var myInt=0

	if (sValue!="" && typeof(sValue)=="string") {
		for (i=0;i<sValue.length;i++) {
			myChar=sValue.charAt(i)
			myInt=strValidChars.indexOf(myChar)

			if (myInt == -1) {
				isValid=false
				break;
			}
		}
	}
	else {
		isValid=false
	}

	return isValid
}

function jfIsDate(data,datename)
{

// function created : 31.12.03
// created by 		: Farrakh Aslam
// input paramaters : data     - the formname
//datename - the fieldname specified when calling the vbscript date box function
// description      : Can be used to validate any of the vbscript date box functions
data = "document." + data + "."

var day   = eval( data + datename + "_d.value")
var month = eval( data + datename + "_m.value")
var year  = eval( data + datename + "_y.value")

var calcYear = (year % 4 == 0)
if (!calcYear)
	{
	leapDays = 28
	}
else
	{
	leapDays = 29
	}

if (month == 02)
	{
	if (day > leapDays)
	   {
	   return false;
	   }


	}
else if (month == 04 || month == 06 || month == 09 || month == 11)
	{
	if (day > 30)
	   {
	   return false;
	   }

	}
return true;
}

function jfIsEmail(incoming) {
	var emailstring = incoming;
	var ampIndex = emailstring.indexOf("@");
	var afterAmp = emailstring.substring((ampIndex + 1), emailstring.length);
		// find a dot in the portion of the string after the ampersand only
	var dotIndex = afterAmp.indexOf(".");
		// determine dot position in entire string (not just after amp portion)
	dotIndex = dotIndex + ampIndex + 1;
		// afterAmp will be portion of string from ampersand to dot
	afterAmp = emailstring.substring((ampIndex + 1), dotIndex);
		// afterDot will be portion of string from dot to end of string
	var afterDot = emailstring.substring((dotIndex + 1), emailstring.length);
	var beforeAmp = emailstring.substring(0,(ampIndex));

	var email_regex = /^\w(?:\w|-|\.(?!\.|@))*@\w(?:\w|-|\.(?!\.))*\.\w{2,3}/
		// index of -1 means "not found"
	if ((emailstring.indexOf("@") != "-1") &&
		(emailstring.length > 5) &&
		(afterAmp.length > 0) &&
		(beforeAmp.length > 1) &&
		(afterDot.length > 1) &&
		(email_regex.test(emailstring)) ) {
		  return true;
	} else {
			return false;
	}
}

function jfIsPhoneNum( sValue ) {
	var isPhoneNum = new Boolean()
	isPhoneNum=true
	var myChar=""
	var myInt=0
	var strValidChars = "0123456789";

	if (sValue!="" && typeof(sValue)=="string") {
		for (i=0;i<sValue.length;i++) {
			myChar=sValue.charAt(i)
			myInt=strValidChars.indexOf(myChar)

			if (myInt == -1) {
				isPhoneNum=false
			}
		}

	} else {
		isPhoneNum=false
	}

	return isPhoneNum
}

function jfIsInt( sValue ) {
	var isInteger = new Boolean()
	isInteger=true
	var myChar=""
	var myInt=0

	if (sValue!="" && typeof(sValue)=="string") {
		for (i=0;i<sValue.length;i++) {
			myChar=sValue.charAt(i)
			myInt=parseInt(myChar)

			if (isNaN(myInt)) {
				isInteger=false
			}
		}

	} else {
		isInteger=false
	}

	return isInteger
}



//search.asp
	function jMovePage( iPage ){
		frm = document.frmSearch
		iMaxPage = frm.txtMaxPage.value
		if ( iPage == 0 ){
			iPage = 1
		}
		else if ( iPage >= iMaxPage ){
			iPage = iMaxPage
		}
		frm.txtPage.value = iPage
		frm.submit();
	}


//product.asp

function open_win(url)
{
window.open(url,"my_new_window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=400, height=450")
}



	function check_box( boxNo){

	var numofticked = 0;
	var ticksrequired = 0;
	var numofboxes = eval("document.frmProduct.txtBoxNum" + ".value" );

			for (x=0;x <= numofboxes;x++)
			{
				boxname = "chkColor" + x;

				if (document.frmProduct.elements[boxname].checked == true)
				{

					numofticked++;
				}
			}
			if (numofticked > ticksrequired)
			{
				for (x=0;x <= numofboxes;x++)
				{
					boxname = "chkColor" + x;

					if (document.frmProduct.elements[boxname].checked == true)
					{
					document.frmProduct.elements[boxname].checked = false;
					}
				}
				boxname = "chkColor" + boxNo;
				document.frmProduct.elements[boxname].checked = true;
				document.frmProduct.elements["imgFrame"].src = document.frmProduct.elements["txtImage" + boxNo].value;
				document.frmProduct.txtFrameColor.value = document.frmProduct.elements["txtFrameColor" + boxNo].value;
			}
	}

	function jfMoreInfo( iMsgType, iDisplay ){
		t=document.getElementById('tbl_info_' + iMsgType);
		if ( iDisplay == 1 ){
			t.style.display= 'block';
		}
		else{
			t.style.display= 'none';
		}
	}

	function jRedraw(){
		frm = document.frmProduct
		frm.action = "product.asp"
		frm.submit();
	}

	function jToggleCoating( iType, iValue ){
		frm = document.frmProduct

		if (iType == 1){
			if (iValue == 0){
				frm.optLensTransitionColor.disabled = false;
				frm.optLensPolarised.disabled = false;
			}
			else{
				frm.optLensTransitionColor.disabled = true;
				frm.optLensPolarised.disabled = true;
				frm.optLensTransitionColor.value = 0;
				frm.optLensPolarised.value = 0;
			}
		}

		else if (iType == 2){
			if (iValue == 0){
				frm.optLensColor.disabled = false;
				frm.optLensTransitionColor.disabled = false;
				frm.chkCoating2.disabled = false;
			}
			else{
				frm.optLensColor.disabled = true;
				frm.optLensTransitionColor.disabled = true;
				frm.optLensColor.value = 0;
				frm.optLensTransitionColor.value = 0;
				frm.chkCoating2.disabled = true;
			}
		}

		else if (iType == 3){
			if (iValue == 0){
				frm.optLensColor.disabled = false;
				frm.optLensPolarised.disabled = false;
				frm.chkCoating2.disabled = false;
				frm.chkCoating3.disabled = false;
			}
			else{
				frm.optLensColor.disabled = true;
				frm.optLensPolarised.disabled = true;
				frm.optLensColor.value = 0;
				frm.optLensPolarised.value = 0;
				frm.chkCoating2.disabled = true;
				frm.chkCoating3.disabled = true;
			}
		}
	}


	function jsubmit1(){
		frm = document.frmProduct
		if (frm.chkFrameOnly.checked == true ){
			frm.action = "product.asp"
		}
		frm.submit();
	}

	function jsubmit2(){
		frm = document.frmProduct
		var iError = -1
		cssNormal = "text-9pt"
		cssRequired =  'text-red-8pt'
		cssInvalid =  'text-blue-8pt'

		sAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- '()"

// ==== Personal Details ==== //
		// Title //
		if (frm.optLensType.value ==0){
			if ( iError == -1 ){frm.optLensType.focus()}
			iError = 0
			alert("Please select a lens type")
		}

		if ( iError == -1 ){
			frm.submit();
		}
	}

	function jsubmit3(){
		frm = document.frmProduct
		frm.action = "basket.asp"
		frm.submit();
	}
	
	
//basket.asp

	function jdelivery(){
		frm = document.frmOrder
		frm.action = "basket.asp"
		frm.submit();
	}

	function jbasketsubmit(){
		frm = document.frmOrder

		if (frm.chkterms.checked == false ){
			frm.chkterms.focus()
			alert("You must accept the Select Eye Glasses terms & conditions.")
			return;
		}
		else if (frm.optDelivery.value == 0 ){
			frm.optDelivery.focus()
			alert("You must select a country for delivery.")
			return;
		}
		frm.submit();
	}
	
	
//tracking.asp

	function jNext( iMode ){
		frm = document.frmAccount
		frm.txtMode.value = iMode
		frm.submit();
	}

	function jBack( iMode ){
		frm = document.frmAccount
		frm.txtMode.value = iMode
		frm.txtStep.value = 1

		frm.submit();
	}

	function jfHelp( iHelp ){

	}
	
//include_date.asp

function jfIsDate(data,datename)
{

// function created : 31.12.03
// created by 		: Farrakh Aslam
// input paramaters : data     - the formname
//					  datename - the fieldname specified when calling the vbscript date box function
// description      : Can be used to validate any of the vbscript date box functions

var day   = eval("data." + datename + "_d.value")
var month = eval("data." + datename + "_m.value")
var year  = eval("data." + datename + "_y.value")


var calcYear = (year % 4 == 0)
if (!calcYear)
	{
	leapDays = 28
	}
else
	{
	leapDays = 29
	}

if (month == 02)
	{
	if (day > leapDays)
	   {
	   return false;
	   }
	}
else if (month == 04 || month == 06 || month == 09 || month == 11)
	{
	if (day > 30)
	   {
	   return false;
	   }

	}
return true;
}



//prescripton.asp


	function jfMoreInfo( iMsgType, iDisplay ){
		t=document.getElementById('tbl_info_' + iMsgType);
		if ( iDisplay == 1 ){
			t.style.display= 'block';
		}
		else{
			t.style.display= 'none';
		}
	}

	function jRedraw(){
		frm = document.frmOrder
		frm.action = "Specific.asp"
		frm.submit();
	}

	function submitForm(){
		frm = document.frmOrder
		frm.action = "basket.asp"

		var iLensThin
		var bAction = true

		var iShpereR=0
		var iShpereL=0
		var iCylinderR=0
		var iCylinderL=0

		var sText1
		var sText2

		if (frm.chkADD.checked == false && frm.optAddition_R.value == 0 && frm.optAddition_L.value == 0 ){
			alert("You must confirm there is no addition (ADD/near) on your prescription")
			return;
		}

		if (frm.optSphere_R.value != 0 && frm.optSphere_R.value <= 9 ){
			sText1="You have selected a sphere value less than -6.00 and"
			iShpereR=1
		}
		else if (frm.optSphere_R.value != 0 && frm.optSphere_R.value >= 59){
			sText1="You have selected a sphere value higher than +6.00 and"
			iShpereR=1
		}

		if (frm.optCylinder_R.value != 0 && frm.optCylinder_R.value <= 9 ){
			sText1=sText1+" a cylinder value less than -2.00 for your right eye. "
			iCylinderR=1
		}
		else if (frm.optCylinder_R.value != 0 && frm.optCylinder_R.value >= 27){
			sText1=sText1+" a cylinder value higher than +2.00 for your right eye. "
			iCylinderR=1
		}


		if (frm.optSphere_L.value != 0 && frm.optSphere_L.value <= 9 ){
			sText2="You have selected a sphere value less than -6.00 and"
			iShpereL=1
		}
		else if (frm.optSphere_L.value != 0 && frm.optSphere_L.value >= 59){
			sText2="You have selected a sphere value higher than +6.00 and"
			iShpereL=1
		}

		if (frm.optCylinder_L.value != 0 && frm.optCylinder_L.value <= 9 ){
			sText2=sText2+" a cylinder value less than -2.00 for your left eye. "
			iCylinderL=1
		}
		else if (frm.optCylinder_L.value != 0 && frm.optCylinder_L.value >= 27){
			sText2=sText2+" a cylinder value higher than +2.00 for your left eye. "
			iCylinderL=1
		}

		//alert(iShpereR)
		//alert(iShpereL)
		//alert(iCylinderR)
		//alert(iCylinderL)

		if ( iShpereR == 1 && iCylinderR == 1 ){
			iLensThin = 28
			bAction= confirm(sText1 + "  It is suggested that due to your prescription, the higher refractive index lenses of 1.6 be used to minimise lens thickness and be more cosmetically acceptable. The cost will be an additional 30.00 GBP.")
		}
		else if ( iShpereL == 1 && iCylinderL == 1 ){
			iLensThin = 28
			bAction= confirm(sText2 + "  It is suggested that due to your prescription, the higher refractive index lenses of 1.6 be used to minimise lens thickness and be more cosmetically acceptable. The cost will be an additional 30.00 GBP.")
		}
		else{
			iLensThin = frm.chkLensThin.value
			bAction = true
		}

		if ( bAction == true ){
			frm.chkLensThin.value = iLensThin
			frm.submit();
		}
		else if ( bAction == false ){
			frm.chkLensThin.value = 0
			return;
		}


	}


	function jToggleCoating( iValue ){
		frm = document.frmOrder
		if (iValue == 0){
			frm.chkCoating1.disabled = false;
			frm.chkCoating2.disabled = false;
			frm.chkCoating3.disabled = false;
		}
		else{
		 	frm.chkCoating1.disabled = true;
			frm.chkCoating2.disabled = true;
			frm.chkCoating3.disabled = true;
		}
	}