//NAV POINTER FUNCTION

function pointer(which)
{
document.getElementById(which).style.visibility="visible";
}

function nopointer(which)
{
document.getElementById(which).style.visibility='hidden';
}


// SELECT DROP DOWN URL FUNCTION

 function doSel(obj)
 {
     for (i = 1; i < obj.length; i++)
        if (obj[i].selected == true)
           eval(obj[i].value);
}


//GALLERY SWAP FUNCTION

function gallerySwap(img, txt)
{
document.getElementById('galleryTextLoad').style.visibility = "visible";
document.getElementById('galleryImage').setAttribute('src', img);
document.getElementById('caption').firstChild.nodeValue=txt;
}


function hideLoad()
 {
document.getElementById('galleryTextLoad').style.visibility = "hidden";
 }
 

// FORM VALIATION


function isEmpty(field)
{
str = field;
if(str == "")
  {
  return true;
  }
else
  {
  for(j=0; j<str.length; j++)
    {
    if(str.charAt(j) != " ")
      {
      return false;
      }
    }
  }
return true;
}

function containsNumbers(str)
{
for(j=0; j<str.length; j++)
  {
  c=str.charAt(j);
  if(c >= "0" && c <= "9")
    {
    return true;
    }
  }
return false;
}

function validNumber(str)
{
var notNumber = 0;
for(j=0; j<str.length; j++)
  {
  c=str.charAt(j);
  if((!(c >= 0) && !(c <= 9)) && c != '-' && c !='(' && c!=')' && c!= ' ' && c!='+')
    {
    notNumber++; 
    }
  }
if (notNumber > 0)
  {
  return true;
  }
else
  {
  return false;
  }
}



function isEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}


function ltrim(argvalue) {

  while (1) {
    if (argvalue.substring(0, 1) != " ")
      break;
    argvalue = argvalue.substring(1, argvalue.length);
  }

  return argvalue;
}


function rtrim(argvalue) {

  while (1) {
    if (argvalue.substring(argvalue.length - 1, argvalue.length) != " ")
      break;
    argvalue = argvalue.substring(0, argvalue.length - 1);
  }

  return argvalue;
}


function trim(argvalue) {
  var tmpstr = ltrim(argvalue);

  return rtrim(tmpstr);

}


//FORM VALIDATION FUNCTION

function validateForm(form)
    {
        
var msg = "";

    if (isEmpty(form.Name.value)){
         msg += "\n\n* Please enter in your Name.";
        }
        
    if (isEmpty(form.Email.value) && isEmpty(form.Telephone.value)  && isEmpty(form.Fax.value) && isEmpty(form.Address.value))
        {msg += "\n\n* Please provide at least one method of contact."}
        
    if (isEmpty(form.Adults.value) && isEmpty(form.Childunderten.value)  && isEmpty(form.Childten.value) && isEmpty(form.Childfourteen.value))
        {msg += "\n\n* Please let us know how many people you wish to book for."}
        
    if (isEmpty(form.Arrive.value)){
         msg += "\n\n* Please provide an arrival date.";
        }
    
    if (isEmpty(form.Depart.value)){
         msg += "\n\n* Please provide a departure date.";
        }
    
    if (isEmpty(form.validation.value)){
 msg += "\n\n* Please enter the characters you see in the image at the end of the form.";
    }
        
    
    if (!(isEmpty(form.Email.value)))
    {
 var tEmail = form.Email.value;
 var eEmail = trim(tEmail);
        if (!(isEmail(eEmail)))
        {
 msg += "\n\n* You have entered an invalid email address.  Please re-enter.";
        }
    }


    if(msg == "")
        {
return true;
        }
else
        {
  alert('There are some errors on your form:\n\n -----------------------------------' + msg);
  return false;
        }
  
    }