

//-----------Initialise Variables


userName=""
userCode=""
userPw=""
isMember=0;
cookieCount=0;
getCookieCount()
setMember()







//---------Start of Cookie code



function setMenu() {
if(isMember==0) {
document.W389443525JLF27.left = -1000;
alert(isMember);
}}


function getCookieCount() {
if(document.cookie !=""){
cookieArray=document.cookie.split("; ")
cookieCount=cookieArray.length
return cookieCount;
}}

function setMember(){
if(cookieCount==0) {
isMember = 0;
}
else{
getCookie()
myPw=getCookieItem("USER_PW")
checkPassword(myPw)
}}


function getCookie () {
if(document.cookie !=""){
cookieArray=document.cookie.split("; ")
for(i=0; i<cookieArray.length; i++){
userCode=cookieArray[i].split("=")[0]
userName=cookieArray[i].split("=")[1]
}}}


function getCookieItem(myItem){
cookieArray=document.cookie.split("; ")
for(i=0; i<cookieArray.length; i++){
if (cookieArray[i].split("=")[0] == myItem) {
return cookieArray[i].split("=")[1];
}}
return "NULL"
}


function clearCookieA() {
if(document.cookie !=""){
thisCookie=document.cookie.split("; ")
expireDate = new Date
expireDate.setYear(expireDate.getYear()-1)
for(i=0; i<thisCookie.length; i++){
cookieName=thisCookie[i].split("=")[0]
document.cookie=cookieName+ "=;expires=" +expireDate.toGMTString()
}
alert("Your user and login details have now been reset - the next time that you use the  'Members Only Area', you will be asked to Login again. Thank you")
}
}

function setCookie(name, value) {
var today = new Date()
  var expire = new Date()
  expire.setTime(today.getTime() + 1000*60*60*24*365)
  document.cookie = name + "=" + escape(value)
  + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}


function checkPassword (pWord) {
if(pWord =="q5dd62"){
isMember = 1;
return true;
}
else {
isMember = 0;
return false;
}}


function login(form) {

if (document.loginform.password.value=="") {
alert("Please enter your name -  this field is required to process this form.")
return false
}
if (document.loginform.name.value=="") {
alert("Please select your location -  this field is required to process this form.")
return false
}

else {

if (! checkPassword(document.loginform.password.value)) {
alert("The password you have entered is incorrect - please try again.");
document.loginform.name.value = ""
return false
}

setCookie("USER_ID",document.loginform.name.value);
setCookie("USER_PW",document.loginform.password.value);

if(document.getElementById){
alert("Thank you "+ document.loginform.name.value+ " - you are now logged in. The members only section is now active - please use the Members menu to navigate this section.");
window.location.href ="index.htm";
return true;
      }
else if(document.layers){
alert("Thank you "+ document.loginform.name.value+ " - you are now logged in. The members only section is now active - please use the Members menu to navigate this section.");
document.location="index.htm";
return true;
}
else if(document.all){
alert("Thank you "+ document.loginform.name.value+ " you are now logged in - The members only section is now active - please use the Members menu to navigate this section.");
window.location.href="index.htm";
return true;
      }
return true;
}
}



function newwin (url) {
window.open(url,'mywindow','width=600,height=600,scrollbars=yes,toolbar=no,menubar=no,directories=no');
return false;
}