//<script type="text/javascript">
//<!--
function doit() {
var colours = 0;
var i=0;
while (i<4096)
{
  var j = i;
  var count = 0;
  var k=32;
  while (k!=0)
  {
    if (j & 1) count = count + 1;
    j = j>>>1;
    k = k-1;
  }
  if (count>4) colours = colours+1;
  i = i+1;
}
document.writeln
  (colours + " colours.");
return colours;
}

var temp;

/**
 * debugFunctions.js
 *
 * This file contains a collection of debug functions for javascript.
 *
 * This source file is subject to version 2.1 of the GNU Lesser
 * General Public License (LPGL), found in the file LICENSE that is
 * included with this package, and is also available at
 * http://www.gnu.org/copyleft/lesser.html.
 * @package     Javascript
 *
 * @author      Dieter Raber <dieter@dieterraber.net>
 * @copyright   2004-12-27
 * @version     1.0
 * @license     http://www.gnu.org/copyleft/lesser.html
 *
 */

/**
 * TOC
 *
 * - getObjectProperties
 * - print_ob
 * - alert_ob
 * - window_ob
 *
 * - format_r
 * - print_r
 * - alert_r
 * - window_r
 */

/**
 * showProps
 *
 * Shows the properties of an given object
 *
 * object object
 * return array
 *
 * Use print_ob(), alert_ob() or window_ob() to display the result
 */
function getObjectProperties(item)
{
  var retVal = '';
  for (var prop in item)
  {
    if (item[prop].constructor != Function)
    {
      retVal += prop + ' => ' + item[prop] + "\n";
    }
  }
  return retVal;
}




/**
 * showProps
 *
 * Shows the properties of an given object
 *
 * object object
 * return array
 *
 * Use print_ob(), alert_ob() or window_ob() to display the result
 */
function getUserFunctions()
{
  var retVal = '';
  for (var prop in document)
  {
//    if (document[prop].constructor == Function)
//    {
//      retVal += prop + ' => ' + document[prop] + "\n";
//    }
  }
  return document;
}



/**
 * print_ob(), alert_ob(), window_ob()
 *
 * These three functions are different ways to display the result of getObjectProperties()
 * print_ob uses document.write and can hence only be called onload
 * alert_ob displays the result in an alert box
 * window_ob opens a popup window and writes the results there
 */
function alert_ob(expr)
{
  alert(getObjectProperties(expr))
}

function window_ob(expr)
{
  win = window.open('', 'format','width=400,height=300,left=50,top=50,status,menubar,scrollbars,resizable');
  win.document.open();
  win.document.write('<pre>' + getObjectProperties(expr) + '</pre>');
  win.document.close()
  win.focus();
}

function print_ob(expr)
{
  document.write('<pre>' + getObjectProperties(expr) + '</pre>');
}


/**
 * format_r
 *
 * Returns human-readable information about a variable
 *
 * format_r() returns information about a variable in a way that's readable by humans.
 * If given a string, integer or float, the value itself will be printed.
 * If given an array, values will be presented in a format that shows keys and elements.
 *
 * example:
 *   test = new Array ('foo', 'bar', 'foobar')
 *   format_r(test)
 *   returns: Array
 *            {
 *                 [0] => foo
 *                 [1] => bar
 *                 [3] => foobar
 *            }
 *
 */
function format_r(expr)
{
  var dim    = 0;
  var padVal = '\xA0\xA0\xA0\xA0\xA0';

  switch(typeof expr)
  {
    case 'string':
    case 'number':
      retVal = expr;
      break;
    case 'object':
      retVal = 'Array\n{\n' + outputFormat(expr, dim) + '\n}';
      break;
    default:
      retVal = false;
  }

  function pad(dim)
  {
    padding = '';
    for (i = 0; i < dim; i++)
    {
      padding += padVal;
    }
    return padding;
  }

  function outputFormat(expr, dim)
  {
    var retVal = '';
    for (var key in expr)
    {
        if (typeof expr[key] == 'object' && expr[key].constructor == Array)
        {
          retVal += padVal + pad(dim) + '[' + key + '] => Array\n'
                  + padVal + pad(dim) + '{\n'
                  + outputFormat(expr[key], dim + 1) + padVal + pad(dim) + '}\n';
        }
        else if (expr[key].constructor == Function)
        {
          continue;
        }
        else
        {
          retVal = retVal + padVal + pad(dim) + '[' + key + '] => ' + expr[key] + '\n';
        }
    }
    return retVal;
  }
  return retVal;
}

/**
 * print_r(), alert_r(), window_r()
 *
 * These three functions are just different ways to display the result of format_r()
 * print_r uses document.write and can hence only be called onload
 * alert_r displays the result in an alert box
 * window_r opens a popup window and writes the results there
 */
function alert_r(expr)
{
  alert(format_r(expr))
}

function window_r(expr)
{
  win = window.open('', 'format','width=400,height=300,left=50,top=50,status,menubar,scrollbars,resizable');
  win.document.open();
  win.document.write('<pre>' + format_r(expr) + '</pre>');
  win.document.close()
  win.focus();
}

function print_r(expr)
{
  document.write('<pre>' + format_r(expr) + '</pre>');
}


//////////////////////////// other fns //////////////////////////////////////

function ShowCam() { 
var t = 20 // Interval in Seconds
image = "/images/webcam/box1.jpg" //URL of the Image 
tmp = new Date(); 
tmp = "?"+tmp.getTime() 
document.images["autorefresh"].src = image+tmp 
setTimeout("ShowCam()", t*1000) 
} 

function SubstitutePicture(target,image,width,height,desc)
{
  var pastedpic = document.getElementById(target);
  pastedpic.width=width;
  pastedpic.height=height;
  pastedpic.src = image;
  pastedpic.title=desc;
}

// Image Flipper -  Cameron Gregory - http://www.bloke.com/
// http://www.bloke.com/javascript/Flipper/
// http://www.bloke.com/javascript/Flipper/link.html

function setOpacity(r, value)
{
  r.style.opacity = value/10;
  r.style.filter = 'alpha(opacity=' + value*10 + ')';
}

var fadedpic;
function changeImage(r,i,speed)
{
  r.src=i;
  fadedpic = document.getElementById('flip');
  for (var i=0;i<=10;i++)
    setTimeout('setOpacity(fadedpic,'+i+')',(speed/30)*i);
  for (i=10;i>=0;i--)
    setTimeout('setOpacity(fadedpic,'+i+')',(2*speed/3)+((speed/30)*(10-i)));
}

function goFlipURL()
{
  document.location = urlSet[currentFlip];
}

function flipFlipper(imageSet,textSet,speed)
{
  currentFlip ++;
  if (currentFlip == imageSet.length)
    currentFlip=0;
  changeImage(document.flip,imageSet[currentFlip],speed);
  if (textSet.length>0)
    document.getElementById('pictext').innerHTML=textSet[currentFlip];
  setTimeout("flipFlipper(imageSet,textSet,speed)", speed)
}



function FlipperLong(width,height,s,images,texts,hoverText,ignoredurls)
{
/* si: start index 
** i: current index
** ei: end index
** cc: current count
*/
 speed = s;
 si = 0;
 cc=0;
 imageSet = new Array();
 ei = images.length;
  for (i=1;i<ei;i++) {
    if (images.charAt(i) == ' ') {
      imageSet[cc] = images.substring(si,i);
      cc++;
      si=i+1;
    }
  }

  textSet = new Array();
  cc = 0;
  si = 0;
  ei = texts.length;
  for (i=1;i<ei;i++) {
    if (texts.charAt(i) == '|') {
      textSet[cc] = texts.substring(si,i);
      cc++;
      si=i+1;
    }
  }

  currentFlip = 0;
   
  document.write("<a title=\""+hoverText+"\"><img name='flip' id='flip'");
  if (width >0)
    document.write("width="+width);
  if (height >0)
    document.write(" height=" +height);
  document.writeln(" src=" +imageSet[0]+ "></a>");
  changeImage(document.flip,imageSet[currentFlip], speed);

  setTimeout("flipFlipper(imageSet,textSet,speed)", speed)
}

function Flipper(width,height,images,texts,hoverText)
{
  speed=5000;
  FlipperLong(width,height,speed,images,texts,hoverText);
}


function FlipperLinkLong(width,height,s,images,hoverText,urls)
{
/* si: start index 
** i: current index
** ei: end index
** cc: current count
*/
 speed = s;
 imageSet = new Array();
 urlSet = new Array();

 si = 0; 
 ci=0;
 cc=0;
 ei = images.length;
  for (i=1;i<ei;i++) {
    if (images.charAt(i) == ' ') {
      imageSet[cc]= images.substring(si,i);
      cc++;
      si=i+1;
      }
    }

 si = 0; 
 ci=0;
 ccu=0;
 ei = urls.length;
  for (i=1;i<ei;i++) {
    if (urls.charAt(i) == ' ') {
      urlSet[ccu]= urls.substring(si,i);
      ccu++;
      si=i+1;
      }
    }

  currentFlip = 0;
   
 document.write("<a title=\""+hoverText+"\" href=\"javascript:goFlipURL()\"><img name='flip'");
 if (width >0)
    document.write("width="+width);
 if (height >0)
    document.write(" height=" +height);
  document.writeln(" src=" +imageSet[0]+ "></a>");

  setTimeout("flipFlipper(imageSet,speed)", speed)
}

function FlipperLink(width,height,images,hoverText,urls)
{
  speed=1000;
  FlipperLinkLong(width,height,speed,images,hoverText,urls);
}

function changeText(r,i)
{
document.getElementById(r).innerHTML=i;
}

function flipTextFlipper(textSet,speed)
{
  currentTextFlip ++;
  if (currentTextFlip == textSet.length)
    currentTextFlip=0;
  changeText('pictext',textSet[currentTextFlip]);
  setTimeout("flipTextFlipper(textSet,speed)", speed)
}

function TextFlipperLong(s,text)
{
/* si: start index 
** i: current index
** ei: end index
** cc: current count
*/
 speed = s;
 si = 0; 
 ci=0;
 cc=0;
 textSet = new Array();
 ei = text.length;
  for (i=1;i<ei;i++) {
    if (text.charAt(i) == '|') {
      textSet[cc] = text.substring(si,i);
      cc++;
      si=i+1;
    }
  }
  currentTextFlip = 0;
   
  document.write("<a id='pictext'>");
//  document.writeln(textSet[currentTextFlip]+"</a>");
  document.writeln(textSet[currentTextFlip]+"</a>");

  setTimeout("flipTextFlipper(textSet,speed)", speed)
}

function TextFlipper(text)
{
  speed=5000;
  FlipperLong(text);
}

var sysheight;
var syswidth;
var OpenWin;
var browser = new String();
var vsn;

function BrowserVersion(browser)
{
  if (/MSIE[\/\s](\d+\.\d+)/.test(navigator.userAgent))           //test for MSIE/x.x or MSIE x.x (ignoring remaining decimal places);
    browser.value = "M";
  else if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))   //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
    browser.value = "F";
  else if (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent))    //test for Chrome/x.x or Chrome x.x (ignoring remaining digits);
    browser.value = "C";
  else if (/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent))    //test for Safari/x.x or Safari x.x (ignoring remaining digits);
    browser.value = "S";
  else if (/SeaMonkey[\/\s](\d+\.\d+)/.test(navigator.userAgent)) //test for SeaMonkey/x.x or SeaMonkey x.x (ignoring remaining decimal places);
    browser.value = "K";
  else if (/Netscape[\/\s](\d+\.\d+)/.test(navigator.userAgent))  //test for Netscape/x.x or Netscape x.x (ignoring remaining digits);
    browser.value = "N";
  else if (/Navigator[\/\s](\d+\.\d+)/.test(navigator.userAgent)) //test for Navigator/x.x or Navigator x.x (ignoring remaining digits);
    browser.value = "N";
  else if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent))     //test for Opera/x.x or Opera x.x (ignoring remaining decimal places);
    browser.value = "O";
  else
  {
    browser.value = "U";
    return 0;
  }

  vsn = new Number(RegExp.$1); // capture x.x portion and store as a number
  return vsn;
}

function OpenPicture(pic,title,css,w,h,extra,lang)
{
  // lag is en or fr ...
  caption = title;
  if (title!="")
  {
    if (extra!="")
      caption = title+' '+extra;
  }
  else
  {
    title = pic;
    caption = extra;
  }
  vcells = 2;
  if (caption=="")
    vcells = 1;

  barheight = 32;
  vscrollbar = 32;
  border = 4;
  sysborder = 6;
  cellspacing = 2;
  hspacing = (border*2)+(cellspacing*2)+vscrollbar;  // 2 borders and one cell wide (so 2 lots of cell spacing)+ scroll bar
  vspacing = (border*2)+(cellspacing*(1+vcells));  // 2 borders and two cells deep (so 3 lots of cell spacing)
  tablesurround = 16*2; // either side and top and bottom
  vtextcell = 24 * (vcells-1);

  if (!sysheight)
  {
    // open the window with a default size, just to find out how much space is used by the system
    OpenWin = window.open("", "PicWin", "height=200, width=200, toolbar=no, menubar=no, location=no, scrollbars=yes, resizable=yes, status=no, directories=no, copyhistory=no, channelmode=no");
    OpenWin.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"');
    OpenWin.document.writeln('"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
    OpenWin.document.writeln('<html xmlns="http://www.w3.org/1999/xhtml" lang="'+lang+'" xml:lang="'+lang+'">');
    OpenWin.document.writeln('<head><title>'+title+'</title>');
    OpenWin.document.writeln('</head><body>');
    OpenWin.document.writeln('<div id="resizeReference" style="position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:-1;"> &nbsp; </div>');
    OpenWin.document.writeln('</body></html>');
    OpenWin.document.close();
    vsn = BrowserVersion(browser);
    var resizeRef = OpenWin.document.getElementById('resizeReference');
    if (resizeRef)
    {
      syswidth = resizeRef.offsetWidth;
      sysheight = resizeRef.offsetHeight;
      OpenWin.resizeTo(200,200);
      syswidth -= resizeRef.offsetWidth;
      sysheight -= resizeRef.offsetHeight;
      if (browser.value=="M" && vsn==7) // I have found that the first time the window opens in MSIE7 it opens slightly shorter
        OpenWin.moveTo(0,0);
      resizeRef = null;
    }
  }
  else if (OpenWin) // not the first time through so the OpenWin may still exist but be behind the main window
  {
    // Chrome has a bug where window.focus() does not bring the window forward so we have to delete it first!
    if (browser.value=="C")
    {
      OpenWin.close();
      OpenWin = null;
    }
  }

  if (!sysheight || sysheight<=0)
  {
    if (browser.value!="M" && browser.value!="O" && browser.value!="C") // no inner and outer in MSIE and Opera and Chrome just does not work!
    {
      sysheight = OpenWin.outerHeight-OpenWin.innerHeight;
      syswidth = OpenWin.outerWidth-OpenWin.innerWidth;
    }
    if (!sysheight || sysheight<=0) // ok we have failed, finally do it based on what we think we know about the browsers
    {
      if (browser.value=="M" && vsn>=7)
        sysheight = barheight*3 + sysborder*2; // ie7 or 8 
      else if (browser.value=="C")
        sysheight = 40 + sysborder*2; // Chrome's default bar height is 40 not 32
      else
        sysheight = barheight*2 + sysborder*2;
      syswidth = sysborder*2;
    }
  }

  xmax = screen.availWidth - syswidth - tablesurround - hspacing; // 2 window borders
  ymax = screen.availHeight - sysheight - tablesurround - vspacing - vtextcell; // -HeaderBar-StatusBar (assume all browsers have them)

  if (w>xmax || h>ymax) // too big, needs shrinking
  {
    if (w/xmax > h/ymax)
    {
      // the width is the deciding factor
      h = parseInt((h*xmax) / w);
      w = xmax;
    }
    else
    {
      // the height is the deciding factor
      w = parseInt((w*ymax) / h);
      h = ymax;
    }
  }
  
  htable = w+hspacing-vscrollbar;
  vtable = h+vspacing+vtextcell;
  hwindow = htable+tablesurround+vscrollbar;
  vwindow = vtable+tablesurround;

  if (OpenWin && browser.value=="K")
  {
    OpenWin.close();
    OpenWin = null;
  }
  OpenWin = window.open("", "PicWin", "height="+vwindow+", width="+hwindow+", toolbar=no, menubar=no, location=no, scrollbars=yes, resizable=yes, status=no, directories=no, copyhistory=no, channelmode=no");
  
  OpenWin.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"');
  OpenWin.document.writeln('"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
  OpenWin.document.writeln('<html xmlns="http://www.w3.org/1999/xhtml" lang="'+lang+'" xml:lang="'+lang+'">');
  OpenWin.document.writeln('<head><title>'+title+'</title>');

  if (css.length>0)
    OpenWin.document.writeln('<link rel="stylesheet" href="'+css+'">');
  else
  {
    OpenWin.document.writeln('<style TYPE="text/css">');
    OpenWin.document.writeln('<!--');
    OpenWin.document.writeln('.homePage    { font-family: Georgia, \'Palatino Linotype\', Palatino, \'Times New Roman\', Times, serif; font-style: normal; font-weight: 500 }');
    OpenWin.document.writeln('.pagebody    { background-color: rgb(231, 225, 205); color: rgb(0, 0, 0) }');
    OpenWin.document.writeln('.photoborder { border-style: solid; border-color: rgb(125, 189, 134) rgb(0, 102, 0) rgb(0, 102, 0) rgb(125, 189, 134) }');
    OpenWin.document.writeln('a:link       { color: #993300 }');
    OpenWin.document.writeln('a:visited    { color: #993300 }');
    OpenWin.document.writeln('a:active     { color: #993300 }');
    OpenWin.document.writeln('body         { background-color: rgb(0, 102, 0); color: rgb(0, 0, 0) }');
    OpenWin.document.writeln('body         { font-family: Georgia, \'Palatino Linotype\', Palatino, \'Times New Roman\', Times, serif; font-style: normal }');
    OpenWin.document.writeln('table        { table-border-color-light: rgb(255, 255, 204); table-border-color-dark: rgb(0, 102, 0) }');
    OpenWin.document.writeln('-->');
    OpenWin.document.writeln('</style>'); 
  }
  OpenWin.document.writeln('</head><body class="pagebody">');
  OpenWin.document.writeln('<table class="photoborder" frame="border" rules="all" border="'+border+'" cellpadding="0" cellspacing="'+cellspacing+'" width="'+htable+'px" height="'+vtable+'px" align="center" valign="middle">');
  OpenWin.document.writeln('<tr><td align="center"><img  width="'+w+'px" height="'+h+'px" src="'+pic+'">');
  OpenWin.document.writeln('</td></tr>');
  if (vcells==2)
  {
    OpenWin.document.writeln('<tr><td align="center">');
    //OpenWin.document.writeln(syswidth+browser.value+sysheight+'OH='+OpenWin.outerHeight+' IH='+OpenWin.innerHeight+' OW='+OpenWin.outerWidth+' IW='+OpenWin.innerWidth+' AW='+screen.availWidth+' AH='+screen.availHeight);
    OpenWin.document.writeln(caption);
    OpenWin.document.writeln('</td></tr>');
  }
  OpenWin.document.writeln('</table>');
  OpenWin.document.writeln('</body></html>');
  OpenWin.document.close();

  // now, just in case the window was already open, the open above did not set a new size, so do it here
  // note that resize takes the outer dimensions of the window, so include borders and title/status/etc bars
  OpenWin.resizeTo(hwindow+syswidth,vwindow+sysheight); // Plus the chrome

  OpenWin.focus();
}

function GiteSelect(prompt, info, g, l, sy, sm, sd, bd, target)
{
setTimeout(function() { 
  var r = true;
  if (info.length>1)
  {
//     if (navigator.appVersion.indexOf("Safari")>0 && (navigator.platform=="Win32"))
//     {
//       if (l==1)
//         r = confirm('!!!! EN RAISON D\'UN PROBLEME AVEC LE BROWSER SAFARI, VOUS **** DEVEZ **** CLIQUER SUR UNE PARTIE VIDE DU FORMULAIRE DE RESERVATION AVANT DE CLIQUER SUR UN AUTRE BOUTON DANS CE MESSAGE!!!!\n\n'+info+'\n'+prompt);
//       else
//         r = confirm('!!!! DUE TO A FAULT IN THE SAFARI BROWSER, YOU **** MUST **** CLICK ON A BLANK PART OF THE BOOKING FORM BEFORE CLICKING ON ANY BUTTON IN THIS MESSAGE BOX !!!!\n\n'+info+'\n'+prompt);
//     }
//     else
       r = confirm(info+'\n'+prompt);
  }
  if (r==true && g>0)
  {
    // set the "hidden" form values
    document.clientdetails.g.value = g;
    document.clientdetails.l.value = l;
    document.clientdetails.sy.value = sy;
    document.clientdetails.sm.value = sm;
    document.clientdetails.sd.value = sd;
    document.clientdetails.bd.value = bd;
    document.clientdetails.submit();
  }
},1);
  return false;
}

// email

function checkemail (strng, musthavecontent, lang) {
  if (strng == "") {
    if (musthavecontent==true) {
      switch(lang) {
        case 1: // fr
          setTimeout(function() { alert("Vous n'avez pas fourni d'adresse email.\n\
Cette information nous est n\351cessaire pour traiter votre demande de r\351servation.\n"); },1);
          break;
        default: // en
          setTimeout(function() { alert("You have not supplied your email address.\n\
We need this information to process your booking.\n"); },1);
      }
      return false;
    }
    return true;
  }

  var emailFilter=/^.+@.+\..{2,3}$/;
  if (!(emailFilter.test(strng))) { 
    switch(lang) {
      case 1: // fr
        setTimeout(function() { alert("Votre adresse email est incorrecte,\n\
Elle devrait comporter les \351l\351ments suivants: moi@place.fr\n\
Merci de recommencer.\n"); },1);
        break;
      default: // en
        setTimeout(function() { alert("You have not supplied a valid email address,\n\
it should be something like me@place.com\n\
please re-enter.\n"); },1);
    }
    return false;
  }
  else {
    //test email for illegal characters
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]\|]/
    if (strng.match(illegalChars)) {
      switch(lang) {
        case 1: // fr
          setTimeout(function() { alert("Votre adresse email comporte des caract\350res invalides,\n\
Merci de recommencer.\n"); },1);
          break;
        default: // en
          setTimeout(function() { alert("Your email address contains unacceptable characters,\n\
please re-enter.\n"); },1);
      }
      return false;
    }
  }
  return true;   
}

// phone number - strip out delimiters

function checkphone (strng, musthavecontent, lang) {
  if (strng=='') {
    if (musthavecontent==true) {
      switch(lang) {
        case 1: // fr
          setTimeout(function() { alert("Vous n'avez pas fourni votre num\351ro de t\351l\351phone.\n\
Cette information nous est n\351cessaire pour traiter votre demande de r\351servation.\n"); },1);
          break;
        default: // en
          setTimeout(function() { alert("You have not supplied a telephone number.\n\
We need this information to process your booking.\n"); },1);
      }
      return false;
    }
    return true;
  }

  var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
  if (isNaN(parseInt(stripped))) {
    switch(lang) {
      case 1: // fr
        setTimeout(function() { alert("Votre num\351ro de t\351l\351phone comporte des caract\350res invalides.\n\
Merci de recommencer.\n"); },1);
        break;
      default: // en
        setTimeout(function() { alert("Your telephone number contains unacceptable characters,\n\
please re-enter.\n"); },1);
    }
    return false;
  } 
  return true;
}

// a persons first or last name
function checkname (strng, whatname, musthavecontent, lang) {
  if (strng=='') {
    if (musthavecontent==true) {
      switch(lang) {
        case 1: // fr
          setTimeout(function() { alert("Vous n'avez pas fourni votre "+whatname+".\n\
Cette information nous est n\351cessaire pour traiter votre demande de r\351servation.\n"); },1);
          break;
        default: // en
          setTimeout(function() { alert("You have not supplied a "+whatname+".\n\
We need this information to process your booking.\n"); },1);
      }
      return false;
    }
    return true;
  }

  var illegalChars = /[0-9\(\)\,\`\¬\!\"\£\$\%\^\*\_\+\=\{\}\[\]\:\;\@\~\#\<\>\?\/\|\\]/i; // allow a-z,',- and spaces
  if (illegalChars.test(strng)) {
    switch(lang) {
      case 1: // fr
        setTimeout(function() { alert("Votre "+whatname+" doit uniquement comporter des lettres de A \340 Z,apostrophe,-,et des espaces.\n\
Merci de recommencer.\n"); },1);
        break;
      default: // en
        setTimeout(function() { alert("Your "+whatname+" can only contain the characters A-Z,single quote,-,and spaces,\n\
please re-enter.\n"); },1);
    }
    return false;
  }
  return true;
}       

function checkaddress (strng, thewhatname, ofwhatname, musthavecontent, lang) {
  if (strng=='') {
    if (musthavecontent==true) {
      switch(lang) {
        case 1: // fr
          setTimeout(function() { alert("Vous n'avez pas fourni "+thewhatname+" de votre adresse.\n\
Cette information nous est n\351cessaire pour traiter votre demande de r\351servation.\n"); },1);
          break;
        default: // en
          setTimeout(function() { alert("You have not supplied "+thewhatname+" of your address.\n\
We need this information to process your booking.\n"); },1);
      }
      return false;
    }
    return true;
  }

  var illegalChars = /[\`\¬\!\£\$\%\^\&\*\_\+\=\{\}\[\]\:\;\@\~\#\<\>\?\/\|\\]/i; // allow a-z0-9(),-'" and spaces
  if (illegalChars.test(strng)) {
    switch(lang) {
      case 1: // fr
        setTimeout(function() { alert("Les caract\350res "+ofwhatname+" de votre adresse doivent uniquement comporter des lettres de\n\
A \340 Z ,des chiffres de 0 \340 9, (), virgule, -, espace et interlignes, merci de recommencer.\n"); },1);
        break;
      default: // en
        setTimeout(function() { alert(""+thewhatname+" of your address can only contain the characters\n\
A-Z,0-9,(),comma,-,space or single or double quote, please re-enter.\n"); },1);
    }
    return false;
  }
  return true;
}


function CheckDetailsAndSubmit(code, lang)
{
  if (document.clientdetails.bd.value<1)
  {
    switch(lang) {
      case 1: // fr
        setTimeout(function() { alert("Vous n'avez pas encore s\351lectionn\351 de nuits!!!\n"); },1);
        break;
      default: // en
        setTimeout(function() { alert("You have not selected any nights yet!!!\n"); },1);
    }
    return false;
  }

  var totalPeople = document.clientdetails.ps.options[document.clientdetails.ps.options.selectedIndex].text * 1;
  totalPeople = totalPeople + (document.clientdetails.children.options[document.clientdetails.children.options.selectedIndex].text * 1);
  //var totalPeoples = 'total people '+totalPeople+'\n';
  //alert(totalPeoples);

  if (totalPeople>(document.clientdetails.mps.value))
  {
    switch(lang) {
      case 1: // fr
        if (document.clientdetails.g.value!=3)
          setTimeout(function() { alert("Le nombre de personnes d\351passe la capacit\351 du g\356te sélectionn\351.\n"); },1);
        else
          setTimeout(function() { alert("Le nombre de personnes d\351passe la capacit\351 des g\356tes sélectionn\351.\n"); },1);
        break;
      default: // en
        if (document.clientdetails.g.value!=3)
          setTimeout(function() { alert("There are too many people in your group for the g\356te you have requested\n"); },1);
        else
          setTimeout(function() { alert("There are too many people in your group for the g\356tes you have requested\n"); },1);
    }
    return false;
  }

  //if gite includes griffon and start date is before April 1 2011 then reduce maxpeople by 5
  if (document.clientdetails.g.value!=1) // griffon included
  {
    if ((totalPeople>(document.clientdetails.mps.value-2)) && !document.clientdetails.bureau.checked)
    {
      switch(lang) {
        case 1: // fr
          setTimeout(function() { alert("Vous devez r\351server la chambre d'h\364tes annexe afin d'accommoder le nombre de personnes indiqu\351\n"); },1);
          break;
        default: // en
          setTimeout(function() { alert("For the number of people you have requested,\nyou need to also book the use of the adjoining spare double room\n"); },1);
      }
      return false;
    }
  }

  if (!checkemail(document.clientdetails.Ecom_BillTo_Online_Email.value, true, lang)) return false;
  if (!checkphone(document.clientdetails.Ecom_BillTo_Telecom_Phone_Number.value, true, lang)) return false;
  if (lang==1)
  {
    if (!checkname(document.clientdetails.Ecom_BillTo_Postal_Name_Prefix.value, "titre", false, lang)) return false;
    if (!checkname(document.clientdetails.Ecom_BillTo_Postal_Name_First.value, "pr\351nom", false, lang)) return false;
    if (!checkname(document.clientdetails.Ecom_BillTo_Postal_Name_Last.value, "nom", true, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_Street_Line1.value, "la premi\350re ligne", "de la premi\350re ligne", true, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_Street_Line2.value, "la deuxi\350me ligne", "de la deuxi\350me ligne", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_Street_Line3.value, "la troisi\350me ligne", "de la troisi\350me ligne", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_City.value, "la ville", "de la ville", true, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_StateProv.value, "le d\351partment", "du d\351partment", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_PostalCode.value, "le code postal", "du code postal", true, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_CountryCode.value, "le pays", "du pays", true, lang)) return false;
  }
  else
  {
    if (!checkname(document.clientdetails.Ecom_BillTo_Postal_Name_Prefix.value, "title", false, lang)) return false;
    if (!checkname(document.clientdetails.Ecom_BillTo_Postal_Name_First.value, "first name", false, lang)) return false;
    if (!checkname(document.clientdetails.Ecom_BillTo_Postal_Name_Last.value, "last name", true, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_Street_Line1.value, "the first line", "the first line", true, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_Street_Line2.value, "the second line", "the second line", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_Street_Line3.value, "the third line", "the third line", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_City.value, "the town or city", "the town or city", true, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_StateProv.value, "the county", "the county", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_PostalCode.value, "the post code", "the post code", true, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_CountryCode.value, "the country", "the country", true, lang)) return false;
  }
  if (code!=document.clientdetails.xx.value)
  {
    switch(lang) {
      case 1: // fr
        setTimeout(function() { alert("Le code de r\351servation que vous avez inscrit ne correspond pas!\n"); },1);
        break;
      default: // en
        setTimeout(function() { alert("The booking code you typed in does not match what you were asked to type in!\n"); },1);
    }
    return false;
  }
  if (!document.clientdetails.agreement.checked)
  {
    switch(lang) {
      case 1: // fr
        setTimeout(function() { alert("Vous n'avez pas coch\351 la case \340 cocher \"Acceptez nos Conditions G\351n\351rales\".\n"); },1);
        break;
      default: // en
        setTimeout(function() { alert("You have not ticked the \"Agree to our Terms & Conditions\" check box.\n"); },1);
    }
    return false;
  }
/*
  if (document.clientdetails.recommended.value!='')
  {
    if (!document.clientdetails.referral.checked)
    {
      switch(lang) {
        case 1: // fr
          setTimeout(function() { alert("Vous avez donn\351 le nom de quelqu'un qui nous a recommand\351, mais vous n'avez pas coch\351 la case \340 cocher \"Confirmation\".\nSoit cocher la case \340 cocher ou effacer le nom \"Recommand\351 par\".\n"); },1);
          break;
        default: // en
          setTimeout(function() { alert("You have given the name of somebody who recommended us but you have not ticked the \"Confirmation\" check box.\nEither tick the checkbox or clear the \"Recommended By\" name.\n"); },1);
      }
      return false;
    }
  }
  else if (document.clientdetails.referral.checked)
  {
    switch(lang) {
      case 1: // fr
        setTimeout(function() { alert("Vous avez coch\351 la case \340 cocher Confirmation, mais n'ont pas donn\351 le nom de la personne qui nous a recommand\351.\nSoit d\351cochez la case \340 cocher ou tapez le nom de la personne qui nous a recommand\351.\n"); },1);
        break;
      default: // en
        setTimeout(function() { alert("You have ticked the \"Confirmation\" check box but have not given the name of the person who recommended us.\nEither untick the checkbox or type the name of the person into the \"Recommended By\" box.\n"); },1);
    }
    return false;
  }
*/
  document.getElementById("clientdetails").submit();
  return true;
}


//-->
//</script>

