//Version 1.0.0.0

today=new Date();
today.setTime(today.getTime() + (3600000));
today=today.toGMTString();
currentdate=new Date();
currentdate=currentdate.toLocaleString();
numFields=0;


index = document.cookie.indexOf('jlaReference');
if (index > -1) {
   countbegin=(document.cookie.indexOf('=',index)+1);
   countend=document.cookie.indexOf(';',index);
   if(countend==-1) {
      fulllist='';
   } else {
      fulllist=document.cookie.substring(countbegin,countend);
   }
} else {
   fulllist='';
}
if(fulllist.length < 1) {
   document.cookie='jlaReference=.; expires='+today;
   document.cookie='jlaName=.; expires='+today;
   document.cookie='jlaAddress=.; expires='+today;
   document.cookie='jlaDayphone=.; expires='+today;
   document.cookie='jlaEvephone=.; expires='+today;
   document.cookie='jlaEmail=.; expires='+today;
   document.cookie='jlaSolname=.; expires='+today;
   document.cookie='jlaSoladdress=.; expires='+today;
   document.cookie='jlaSolphone=.; expires='+today;
}

function addToCookie(thecookie,thevalue) {
  if (thevalue=='')  {
    thevalue='.';}
  while (thevalue.indexOf ('\n')!=-1) {
    thevalue = thevalue.substring(0,thevalue.indexOf ('\n')-1)+'|'+thevalue.substring(thevalue.indexOf ('\n')+1,thevalue.length);
  }
//rc=alert(thevalue);
  document.cookie=thecookie+'='+thevalue+'; expires='+today;
}

function clearCookie() {
  index=document.cookie.indexOf('jla');
  document.cookie='jlaReference=.; expires='+today;
}

function retrieveCookie(thecookie) {
  var sTemp='';

  index = document.cookie.indexOf(thecookie);
  countbegin=(document.cookie.indexOf('=',index)+1);
  countend=document.cookie.indexOf(';',index);
  if(countend==-1) { countend=document.cookie.length; }
  sTemp = document.cookie.substring(countbegin,countend);
  if (sTemp=='.') {
    sTemp='';
  }
//rc=alert(sTemp);
  while (sTemp.indexOf ('|')!=-1) {
    sTemp = sTemp.substring(0,sTemp.indexOf ('|'))+' \n'+sTemp.substring(sTemp.indexOf ('|')+1,sTemp.length);
  }
  return sTemp;
}

function loadInterestLink (Reference) {
tReference="'"+Reference+"'";
document.writeln ('<font size="1" face="Verdana, Arial, Helvetica, sans-serif">');
document.writeln ('<A HREF="noteofinterest.htm" ONCLICK="writeCookie ('+tReference+')">To Note Interest in property '+Reference+' online, please click here</A></font>');
}

function writeCookie (Reference) {
clearCookie();
addToCookie('jlaReference',Reference);
}

function saveAddress() {
if (document.NoteOfInterestForm.propertyNumber.value=='') {
  rc=alert('We need to know the property reference number');
  return false
}
if (document.NoteOfInterestForm.enquirerName.value=='') {
  rc=alert('We need to know your name');
  return false
}
if (document.NoteOfInterestForm.enquirerAddress.value=='') {
  rc=alert('We need to know your address');
  return false
}
if (document.NoteOfInterestForm.daytimePhone.value=='') {
  rc=alert('We need to know your daytime telephone number');
  return false
}
if (document.NoteOfInterestForm.eveningPhone.value=='') {
  rc=alert('We need to know your evening telephone number');
  return false
}
if (document.NoteOfInterestForm.emailAddress.value=='') {
  rc=alert('We need to know your e-mail address');
  return false
}
if (document.NoteOfInterestForm.emailAddress.value.indexOf ('@')==-1) {
  rc=alert('The e-mail address appears to be invalid');
  return false
}
if (document.NoteOfInterestForm.solicitorsName.value=='') {
  rc=alert('We need to know your solicitors name');
  return false
}
if (document.NoteOfInterestForm.solicitorsAddress.value=='') {
  rc=alert('We need to know your solicitors address');
  return false
}
if (document.NoteOfInterestForm.solicitorsPhone.value=='') {
  rc=alert('We need to know your solicitors telephone number');
  return false
}
addToCookie('jlaName',document.NoteOfInterestForm.enquirerName.value);
addToCookie('jlaAddress',document.NoteOfInterestForm.enquirerAddress.value);
addToCookie('jlaDayphone',document.NoteOfInterestForm.daytimePhone.value);
addToCookie('jlaEvephone',document.NoteOfInterestForm.eveningPhone.value);
addToCookie('jlaEmail',document.NoteOfInterestForm.emailAddress.value);
addToCookie('jlaSolname',document.NoteOfInterestForm.solicitorsName.value);
addToCookie('jlaSoladdress',document.NoteOfInterestForm.solicitorsAddress.value);
addToCookie('jlaSolphone',document.NoteOfInterestForm.solicitorsPhone.value);
return true;
}

function retrieveReference() {
document.writeln ('<INPUT TYPE="TEXT" NAME="propertyNumber" VALUE="'+retrieveCookie("jlaReference")+'" SIZE="50">');
}

function retrieveName() {
document.writeln ('<INPUT TYPE="TEXT" NAME="enquirerName" VALUE="'+retrieveCookie("jlaName")+'" SIZE="50">');
}

function retrieveAddress() {
document.writeln ('<TEXTAREA NAME="enquirerAddress" ROWS="3" COLS="38">'+retrieveCookie("jlaAddress")+'</TEXTAREA>');
}

function retrieveDayphone() {
document.writeln ('<INPUT TYPE="TEXT" NAME="daytimePhone" VALUE="'+retrieveCookie("jlaDayphone")+'" SIZE="50">');
}

function retrieveEvephone() {
document.writeln ('<INPUT TYPE="TEXT" NAME="eveningPhone" VALUE="'+retrieveCookie("jlaEvephone")+'" SIZE="50">');
}

function retrieveEmail() {
document.writeln ('<INPUT TYPE="TEXT" NAME="emailAddress" VALUE="'+retrieveCookie("jlaEmail")+'" SIZE="50">');
}

function retrieveSolname() {
document.writeln ('<INPUT TYPE="TEXT" NAME="solicitorsName" VALUE="'+retrieveCookie("jlaSolname")+'" SIZE="50">');
}

function retrieveSoladdress() {
document.writeln ('<TEXTAREA NAME="solicitorsAddress" ROWS="3" COLS="38">'+retrieveCookie("jlaSoladdress")+'</TEXTAREA>');
}

function retrieveSolphone() {
document.writeln ('<INPUT TYPE="TEXT" NAME="solicitorsPhone" VALUE="'+retrieveCookie("jlaSolphone")+'" SIZE="50">');
}