function changeClass(e,objState) { var e=e || window.event; if (objState == 'on') { e.className = 'shop_button_highlighted'; } else { e.className = 'shop_button'; } } function checkEmail() { var err_msg = ''; if (document.forms['frmContactUs'].name.value == '') { err_msg = "Please enter your name!"; } if (err_msg.length == 0) { if (document.forms['frmContactUs'].custemail.value == '') { err_msg = "Please enter your email address!"; } } if (err_msg.length == 0) { if (document.forms['frmContactUs'].comment.value == '') { err_msg = "Please enter your enquiry!"; } } if (err_msg.length != 0) { alert(err_msg); return false; } return true; } function submitEmail() { if (checkEmail()) { document.forms['frmContactUs'].action = "mailer.php"; document.forms['frmContactUs'].submit(); } } function changeOn(td,col,sel,cur){ if (sel != 1) { if (cur == 1) { td.style.cursor = 'pointer'; } td.style.backgroundColor=col; } } function changeOut(td,col,sel){ if (sel != 1) { td.style.cursor = 'default'; td.style.backgroundColor=col; } } function submitClearBasket(urlStub) { result = confirm("Are you sure you want to remove all the items from your shopping basket?\n\nClick OK to remove all the items or CANCEL to return to your order."); //check for confirmation if (result) { window.location = "clearBasket.php?pid=" + urlStub; } } function submitClick (urlStub) { window.location = urlStub; } function submitUpdateBasket(refURL) { err_msg = ""; document.forms['frmBasket'].flagChange.value = 1; frmObjLength = document.forms['frmBasket'].length; inputList = ""; inputFlag = -1; for (i=0; i < frmObjLength; i++) { inputArray = document.forms['frmBasket'][i].name.split("_"); if (inputArray[0] == "valQty") { if (inputFlag != -1) { inputList = inputList + ","; } if ((document.forms['frmBasket'][i].value == "") || (document.forms['frmBasket'][i].value <= 0)) { document.forms['frmBasket'][i].value = 1; err_msg = "Please check quantities for items in your shopping basket!\n\nYou must enter a value greater than 0!"; } inputList = inputList + inputArray[1] + "|" + document.forms['frmBasket'][i].value inputFlag = 1; } } if (err_msg.length == 0) { document.forms['frmBasket'].lstInputValues.value = inputList; document.forms['frmBasket'].action = "updateBasket.php?pid=" + refURL; document.forms['frmBasket'].submit(); } else { alert(err_msg); } } function submitCheckout (userActive) { var booExists = typeof document.forms['frmBasket'] != 'undefined'; var strURL = "login_register&checkout"; if (booExists) { if (checkForChanges()) { document.forms['frmBasket'].action = "citroxx.php?pid=" + strURL; document.forms['frmBasket'].submit(); } } else { submitClick('citroxx.php?pid=' + strURL); } } function flagChanges(frmName) { frm = document.getElementById(frmName); frm.flagChange.value = 1; } function checkForChanges() { var booExists = typeof document.forms['frmBasket'] != 'undefined'; if (booExists) { if (document.forms['frmBasket'].flagChange.value == 1) { result = confirm("You have made changes to your order and not updated it!\n\nClick OK to lose those changes or CANCEL to return to your order."); if (result) { document.forms['frmBasket'].flagChange.value = -1; } else { return false; } } } return true; } function checkEmailAddr(strCheck) { var i = 0; var at_counter = 0; var alpha_counter = 0; var dot_counter = 0; for (i=0; i < strCheck.length; i++) { //find ascii value of character a = strCheck.charCodeAt(i); //Check ascii value within permitted characters A..Z, a..z, 0..9 if ((a >= 65 && a <= 90) || (a >= 97 && a <= 122) || (a >= 48) && (a <= 57)) { //Increment alpha counter alpha_counter++; } if (a == 46) { //Increment dot counter dot_counter++; } if (a == 64) { //Increment @ counter at_counter++; } } if ((alpha_counter >= 3) && (at_counter == 1) && (dot_counter >= 1)) { //Returns true to submit return true; } return false; } function isDataOKCheck(strToCheck,okType) { var okArray = ""; var flagNotOK = false; switch (okType) { case 0: var okArray = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "; break; case 1: var okArray = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; break; case 2: var okArray = "0123456789"; break; case 3: var okArray = "0123456789+() "; break; case 4: var okArray = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; break; } if (strToCheck.length > 0) { for (i=0; i < strToCheck.length; i++) { strChar = strToCheck.charAt(i); for (j=0; j < okArray.length; j++) { if (strChar == okArray.charAt(j)) { break; } if (j == (okArray.length - 1)) { flagNotOK = true; break; } } if (flagNotOK == true) { break; } } } if (flagNotOK == false) { return true; } return false; } function submitDetails(refURL) { var err_msg = ""; if (err_msg.length == 0) { if (document.forms['frmBasket'].strFirstName.value == "") { err_msg = "Please enter your first name!"; } } if (err_msg.length == 0) { if (document.forms['frmBasket'].strLastName.value == "") { err_msg = "Please enter your last name!"; } } if (err_msg.length == 0) { if (document.forms['frmBasket'].strEmailAddress.value == "") { err_msg = "Please enter your email address!"; } else { if (!checkEmailAddr(document.forms['frmBasket'].strEmailAddress.value)) { err_msg = "Please check your email address!"; } } } if (err_msg.length == 0) { if (document.forms['frmBasket'].strEmailAddressConfirm.value == "") { err_msg = "Please confirm your email address!"; } } if (err_msg.length == 0) { if (document.forms['frmBasket'].strEmailAddress.value != document.forms['frmBasket'].strEmailAddressConfirm.value) { document.forms['frmBasket'].strEmailAddress.value = ""; document.forms['frmBasket'].strEmailAddressConfirm.value = ""; document.forms['frmBasket'].strEmailAddress.focus(); err_msg = "Your email address does not match! Please re-enter your email address"; } } if (err_msg.length == 0) { if (document.forms['frmBasket'].strAddress1.value == "") { err_msg = "Please complete address line 1!"; } } if (err_msg.length == 0) { if (document.forms['frmBasket'].strTownCity.value == "") { err_msg = "Please enter your town/city!"; } } if (err_msg.length == 0) { if (document.forms['frmBasket'].strPostcode.value == "") { err_msg = "Please enter your postcode!"; } } if (err_msg.length == 0) { if (document.forms['frmBasket'].strTelephone.value == "") { err_msg = "Please enter your telephone number!"; } else { if (!isDataOKCheck(document.forms['frmBasket'].strTelephone.value,3)) { err_msg = "Please check your telephone number!"; } } } if (err_msg.length == 0) { if (document.forms['frmBasket'].strMobile.value != "") { if (!isDataOKCheck(document.forms['frmBasket'].strMobile.value,3)) { err_msg = "Please check your mobile telephone number!"; } } } if (err_msg.length == 0) { if (document.forms['frmBasket'].strUserName) { if (document.forms['frmBasket'].strUserName.value == "") { err_msg = "Please enter a username!"; } } } if (err_msg.length == 0) { if (document.forms['frmBasket'].strPassword) { if (document.forms['frmBasket'].strPassword.value == "") { err_msg = "Please enter a password!"; } else { if (!isDataOKCheck(document.forms['frmBasket'].strPassword.value,4)) { err_msg = "Please check your password!"; } else { if ((document.forms['frmBasket'].strPassword.value.length < 6) || (document.forms['frmBasket'].strPassword.value.length > 10)) { err_msg = "Passwords should be between 6 and 10 characters long!"; } } if (err_msg.length != 0) { document.forms['frmBasket'].strPassword.value = ""; document.forms['frmBasket'].strPasswordConfirm.value = ""; document.forms['frmBasket'].strPassword.focus(); } } } } if (err_msg.length == 0) { if (document.forms['frmBasket'].strPasswordConfirm) { if (document.forms['frmBasket'].strPasswordConfirm.value == "") { err_msg = "Please confirm your password!"; } } } if (err_msg.length == 0) { if (document.forms['frmBasket'].strPasswordConfirm) { if (document.forms['frmBasket'].strPassword.value != document.forms['frmBasket'].strPasswordConfirm.value) { document.forms['frmBasket'].strPassword.value = ""; document.forms['frmBasket'].strPasswordConfirm.value = ""; document.forms['frmBasket'].strPassword.focus(); err_msg = "Your passwords do not match! Please re-enter your passwords"; } } } if (err_msg.length != 0) { alert(err_msg); } else { document.forms['frmBasket'].action = refURL; document.forms['frmBasket'].submit(); } } // submit order to worldpay function submitOrder(urlLink) { document.forms['frmOrder'].action = urlLink; document.forms['frmOrder'].submit(); } function removeItemFromBasket(refURL, prodID) { result = confirm("Are you sure you want to remove this item from your basket?\n\nClick OK to remove the item or CANCEL to continue without removing the item."); if (result) { document.forms['frmBasket'].action = "removeFromBasket.php?pid=" + refURL + "&rec=" + prodID; document.forms['frmBasket'].submit(); } } function hideItemAddedInfo() { frmObj = document.getElementById('basket_here_notice'); frmObj.style.display = "none"; } function urlWinOpen(link) { if ( (link != "") && (link != null) ) { window.open(link,'newWin',''); } else { alert("\nYou must make a selection."); } } function urlJump(urlStub) { window.location = urlStub; } function submitLogin(refURL,loginType) { var err_msg = ""; if (loginType == 0) { var strUname = document.getElementById('ulogin'); var strPwd = document.getElementById('upwd'); var url = 'userLogin.php'; } else { var strUname = document.getElementById('strUsername'); var strPwd = document.getElementById('strPassword'); var strPwdConfirm = document.getElementById('strPasswordConfirm'); var strEmailAddress = document.getElementById('strEmailAddress'); var url = 'citroxx.php'; } if (err_msg.length == 0) { if (strUname) { if (strUname.value == "") { err_msg = "Please enter a username!"; } } } if (err_msg.length == 0) { if (strEmailAddress) { if (strEmailAddress.value == "") { err_msg = "Please enter your email address!"; } else { if (!checkEmailAddr(strEmailAddress.value)) { err_msg = "Please check your email address!"; } } } } if (err_msg.length == 0) { if (strPwd) { if (strPwd.value == "") { err_msg = "Please enter a password!"; } else { if (!isDataOKCheck(strPwd.value,4)) { err_msg = "Please check your password!"; } else { if ((strPwd.value.length < 6) || (strPwd.value.length > 10)) { err_msg = "Passwords should be between 6 and 10 characters long!"; } } if (err_msg.length != 0) { strPwd.value = ""; strPwdConfirm.value = ""; strPwd.focus(); } } } } if (err_msg.length == 0) { if (strPwdConfirm) { if (strPwdConfirm.value == "") { err_msg = "Please enter the confirm password!"; } else { if (!isDataOKCheck(strPwdConfirm.value,4)) { err_msg = "Please check your confirm password!"; } else { if ((strPwdConfirm.value.length < 6) || (strPwdConfirm.value.length > 10)) { err_msg = "Passwords should be between 6 and 10 characters long!"; } } if (err_msg.length != 0) { strPwd.value = ""; strPwdConfirm.value = ""; strPwd.focus(); } } } } if (err_msg.length == 0) { if ((strPwd) && (strPwdConfirm)) { if (strPwd.value != strPwdConfirm.value) { err_msg = "The passwords you entered do not match!"; } } } if (err_msg.length != 0) { alert(err_msg); } else { document.forms['frmLogin'].action = url + "?pid=" + refURL; document.forms['frmLogin'].submit(); } } function submitReminder() { var err_msg = ""; if (err_msg.length == 0) { if (document.forms['frmReminder'].strEmailAddress.value == "") { err_msg = "Please enter your email address!"; } else { if (!checkEmailAddr(document.forms['frmReminder'].strEmailAddress.value)) { err_msg = "Please check your email address!"; } } } if (err_msg.length != 0) { alert(err_msg); } else { document.forms['frmReminder'].action = "userReminder.php?pid=reminder_confirm"; document.forms['frmReminder'].submit(); } } function submitPassword() { var err_msg = ""; if (err_msg.length == 0) { if (document.forms['frmPassword'].strUserName) { if (document.forms['frmPassword'].strUserName.value == "") { err_msg = "Please enter a username!"; } } } if (err_msg.length == 0) { if (document.forms['frmPassword'].strUserName) { if ((document.forms['frmPassword'].strUserName.value.length < 6) || (document.forms['frmPassword'].strUserName.value.length > 10)) { err_msg = "Please enter a username that is between 6 and 10 characters in length!"; } } } if (err_msg.length == 0) { if (document.forms['frmPassword'].strPassword) { if (document.forms['frmPassword'].strPassword.value == "") { err_msg = "Please enter a password!"; } else { if (!isDataOKCheck(document.forms['frmPassword'].strPassword.value,4)) { err_msg = "Please check your password!"; } else { if ((document.forms['frmPassword'].strPassword.value.length < 6) || (document.forms['frmPassword'].strPassword.value.length > 10)) { err_msg = "Passwords should be between 6 and 10 characters long!"; } } if (err_msg.length != 0) { document.forms['frmPassword'].strPassword.value = ""; document.forms['frmPassword'].strPasswordConfirm.value = ""; document.forms['frmPassword'].strPassword.focus(); } } } } if (err_msg.length == 0) { if (document.forms['frmPassword'].strPasswordConfirm) { if (document.forms['frmPassword'].strPasswordConfirm.value == "") { err_msg = "Please confirm your password!"; } } } if (err_msg.length == 0) { if (document.forms['frmPassword'].strPasswordConfirm) { if (document.forms['frmPassword'].strPassword.value != document.forms['frmPassword'].strPasswordConfirm.value) { document.forms['frmPassword'].strPassword.value = ""; document.forms['frmPassword'].strPasswordConfirm.value = ""; document.forms['frmPassword'].strPassword.focus(); err_msg = "Your passwords do not match! Please re-enter your passwords"; } } } if (err_msg.length != 0) { alert(err_msg); } else { document.forms['frmPassword'].action = "updatePassword.php"; document.forms['frmPassword'].submit(); } }