//<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 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)
{
  var r = true;
  if (info.length>1)
  {
     if (navigator.appVersion.indexOf("Safari")>0 && (navigator.platform=="Win32"))
     {
       if (l==1)
         r = confirm('!!!! D\333 \300 UN D\311FAUT DANS LE NAVIGATEUR SAFARI, VOUS **** DEVEZ **** CLIQUER SUR UNE PARTIE VIDE DU FORMULAIRE DE R\311SERVATION AVANT DE CLIQUER SUR UN BOUTON DANS CETTE BO\316TE DE 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();

//    window.location = "/include/booking.php"
/*
                    + "?ps="   + escape(String(document.clientdetails.ps.options[document.clientdetails.ps.options.selectedIndex].text))
                    + "&pet=" + escape(String(document.clientdetails.pet.options[document.clientdetails.pet.options.selectedIndex].text))
                    + "&cot=" + escape(String(document.clientdetails.cot.options[document.clientdetails.cot.options.selectedIndex].text))
                    + "&c=" + String(document.clientdetails.c.value)
                    + "&t=" + escape(String(document.clientdetails.t.value))
                    + "&fn=" + escape(String(document.clientdetails.fn.value))
                    + "&ln=" + escape(String(document.clientdetails.ln.value))
                    + "&e=" + escape(String(document.clientdetails.e.value))
                    + "&tel=" + escape(String(document.clientdetails.tel.value))
                    + "&a1=" + escape(String(document.clientdetails.a1.value))
                    + "&a2=" + escape(String(document.clientdetails.a2.value))
                    + "&a3=" + escape(String(document.clientdetails.a3.value))
                    + "&at=" + escape(String(document.clientdetails.at.value))
                    + "&ad=" + escape(String(document.clientdetails.ad.value))
                    + "&ac=" + escape(String(document.clientdetails.ac.value))
                    + "&ap=" + escape(String(document.clientdetails.ap.value))
                    + "&g=" + String(g)
                    + "&l=" + String(l)
                    + "&sy=" + String(sy)
                    + "&sm=" + String(sm)
                    + "&sd=" + String(sd)
                    + "&bd=" + String(bd)
*/
//                    + "#x" + String(target);
  }
  return false;
}

// email

function checkemail (strng, lang) {
  if (strng == "") {
    switch(lang) {
      case 1: // fr
        alert("Vous n'avez pas donn\351 votre adresse e-mail.\n\
Nous avons besoin de ces renseignements pour traiter votre r\351servation.\n");
        break;
      default: // en
        alert("You have not supplied your email address.\n\
We need this information to process your booking.\n");
    }
    return false;
  }

  var emailFilter=/^.+@.+\..{2,3}$/;
  if (!(emailFilter.test(strng))) { 
    switch(lang) {
      case 1: // fr
        alert("Vous n'avez pas fourni une adresse email valide,\n\
il doit \352tre quelque chose comme moi@place.fr\n\
s'il vous pla\356t entrer de nouveau.\n");
        break;
      default: // en
        alert("You have not supplied a valid email address,\n\
it should be something like me@place.com\n\
please re-enter.\n");
    }
    return false;
  }
  else {
    //test email for illegal characters
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]\|]/
    if (strng.match(illegalChars)) {
      switch(lang) {
        case 1: // fr
          alert("Votre adresse e-mail contient des caract\350res non,\n\
s'il vous pla\356t entrer de nouveau.\n");
          break;
        default: // en
          alert("Your email address contains unacceptable characters,\n\
please re-enter.\n");
      }
      return false;
    }
  }
  return true;   
}

// phone number - strip out delimiters

function checkphone (strng, lang) {
  if (strng != "") {
    var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
      switch(lang) {
        case 1: // fr
          alert("Votre num\351ro de t\351l\351phone contient des caract\350res non,\n\
s'il vous pla\356t entrer de nouveau.\n");
          break;
        default: // en
          alert("Your telephone number contains unacceptable characters,\n\
please re-enter.\n");
      }
      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
          alert("Vous n'avez pas fourni un "+whatname+".\n\
Nous avons besoin de ces renseignements pour traiter votre r\351servation.\n");
          break;
        default: // en
          alert("You have not supplied a "+whatname+".\n\
We need this information to process your booking.\n");
      }
      return false;
    }
    return true;
  }

  var illegalChars = /[0-9\(\)\,\-\'\`\¬\!\"\£\$\%\^\&\*\_\+\=\{\}\[\]\:\;\@\~\#\<\>\?\/\|\\]/i; // allow a-z and spaces
  if (illegalChars.test(strng)) {
    switch(lang) {
      case 1: // fr
        alert("Votre "+whatname+" ne peut contenir que des lettres de A \340 Z et les espaces,\n\
s'il vous pla\356t entrer de nouveau.\n");
        break;
      default: // en
        alert("Your "+whatname+" can only contain the letters A-Z and spaces,\n\
please re-enter.\n");
    }
    return false;
  }
  return true;
}       

function checkaddress (strng, whatname, musthavecontent, lang) {
  if (strng=='') {
    if (musthavecontent==true) {
      switch(lang) {
        case 1: // fr
          alert("Vous n'avez pas fourni un "+whatname+".\n\
Nous avons besoin de ces renseignements pour traiter votre r\351servation.\n");
          break;
        default: // en
          alert("You have not supplied a "+whatname+".\n\
We need this information to process your booking.\n");
      }
      return false;
    }
    return true;
  }

  var illegalChars = /[\`\¬\!\£\$\%\^\&\*\_\+\=\{\}\[\]\:\;\@\~\#\<\>\?\/\|\\]/i; // allow a-z0-9(),-'" and spaces
  if (illegalChars.test(strng)) {
    switch(lang) {
      case 1: // fr
        alert("Le "+whatname+" de votre adresse ne peut contenir que les caract\350res\n\
A \340 Z ,0 \340 9, (), virgule, -, l'espace ou guillemet simple ou double, s'il vous pla\356t entrer de nouveau.\n");
        break;
      default: // en
        alert("The "+whatname+" of your address can only contain the characters\n\
A-Z,0-9,(),comma,-,space or single or double quote, please re-enter.\n");
    }
    return false;
  }
  return true;
}


function CheckDetailsAndSubmit(code, lang)
{
  if (document.clientdetails.bd.value<1)
  {
    switch(lang) {
      case 1: // fr
        alert("Vous n'avez s\351lectionn\351 aucun nuits encore!!!\n");
        break;
      default: // en
        alert("You have not selected any nights yet!!!\n");
    }
    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)
          alert("Il ya trop de gens dans votre groupe pour le g\356te que vous avez demand\351.\n");
        else
          alert("Il ya trop de gens dans votre groupe pour les g\356tes que vous avez demand\351.\n");
        break;
      default: // en
        if (document.clientdetails.g.value!=3)
          alert("There are too many people in your group for the g\356te you have requested\n");
        else
          alert("There are too many people in your group for the g\356tes you have requested\n");
    }
    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 (document.clientdetails.am.value>0)
    {
      // before April, so need to remove capacity
      if (totalPeople>(document.clientdetails.mps.value-document.clientdetails.am.value))
      {
        switch(lang) {
          case 1: // fr
            alert("Avant avril, la capacit\351 de Le Griffon est de 4 personnes,\nil n'a pas la capacit\351 que vous avez demand\351\n");
            break;
          default: // en
            alert("Before April the capacity of The Griffon is 4 people,\nit does not have the capacity you have requested\n");
        }
        return false;
      }
    }
    else
*/
    {
      if ((totalPeople>(document.clientdetails.mps.value-2)) && !document.clientdetails.bureau.checked)
      {
        switch(lang) {
          case 1: // fr
            alert("Pour le nombre de personnes que vous avez demand\351,\nvous devez \351galement r\351server l'utilisation de notre chambre d'h\364te d'h\351bergement\n");
            break;
          default: // en
            alert("For the number of people you have requested,\nyou need to also book the use of our bed and breakfast accommodation\n");
        }
        return false;
      }
    }
  }

  if (!checkemail(document.clientdetails.Ecom_BillTo_Online_Email.value, lang)) return false;
  if (!checkphone(document.clientdetails.Ecom_BillTo_Telecom_Phone_Number.value, lang)) return false;
  if (lang==1)
  {
    if (!checkname(document.clientdetails.Ecom_BillTo_Postal_Name_First.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, "premi\350re ligne", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_Street_Line2.value, "deuxi\350me ligne", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_Street_Line3.value, "troisi\350me ligne", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_City.value, "ville", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_StateProv.value, "d\351partment", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_PostalCode.value, "code postal", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_CountryCode.value, "pays", true, lang)) return false;
  }
  else
  {
    if (!checkname(document.clientdetails.Ecom_BillTo_Postal_Name_First.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, "first line", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_Street_Line2.value, "second line", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_Street_Line3.value, "third line", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_City.value, "town or city", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_StateProv.value, "county", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_PostalCode.value, "post code", false, lang)) return false;
    if (!checkaddress(document.clientdetails.Ecom_BillTo_Postal_CountryCode.value, "country", false, lang)) return false;
  }
  if (code!=document.clientdetails.xx.value)
  {
    switch(lang) {
      case 1: // fr
        alert("Le code de r\351servation que vous avez tap\351 ne correspond pas dans le code qui vous a \351t\351 demand\351 de taper!\n");
        break;
      default: // en
        alert("The booking code you typed in does not match what you were asked to type in!\n");
    }
    return false;
  }
/*
  if (document.clientdetails.recommended.value!='')
  {
    if (!document.clientdetails.referral.checked)
    {
      switch(lang) {
        case 1: // fr
          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");
          break;
        default: // en
          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");
      }
      return false;
    }
  }
  else if (document.clientdetails.referral.checked)
  {
    switch(lang) {
      case 1: // fr
        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");
        break;
      default: // en
        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");
    }
    return false;
  }
*/
  document.clientdetails.submit();
  return true;
}


//-->
//</script>

