function NewWindow(pPage, pName, w, h, scroll) {
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=yes';
  win = window.open(pPage, pName, winprops);
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function validEmail(pInput) {
  var at="@";
  var dot=".";
  var lat=pInput.indexOf(at);
  var lstr=pInput.length;
  var ldot=pInput.indexOf(dot);
  if (pInput.indexOf(at)==-1){ return false; }
  if (pInput.indexOf(at)==-1 || pInput.indexOf(at)==0 || pInput.indexOf(at)==lstr){ return false; }
  if (pInput.indexOf(dot)==-1 || pInput.indexOf(dot)==0 || pInput.indexOf(dot)==lstr){ return false; }
  if (pInput.indexOf(at,(lat+1))!=-1){ return false; }
  if (pInput.indexOf(",")!=-1){ return false; }
  if (pInput.indexOf(";")!=-1){ return false; }
  if (pInput.indexOf(":")!=-1){ return false; }
  if (pInput.substring(lat-1,lat)==dot || pInput.substring(lat+1,lat+2)==dot){ return false; }
  if (pInput.indexOf(dot,(lat+2))==-1){ return false; }
  if (pInput.indexOf(" ")!=-1){ return false; }
  return true	;				
}

function checkEmailTypos(pInput) {
  for (var i=0; i<emailTypos.length; i++) {
    var itm=emailTypos[i].split(';');
    if (pInput.toLowerCase().indexOf(itm[0].toLowerCase())>0){
      if(window.confirm("Your email address contains a common typo; '"+itm[0]+"'\n\nPress 'ok' to continue or 'cancel' to rectify")) { return true; }
      else { return false; }
    }
  }
  return true	;				
}

function validateRegistration() {
  if (document.TravellerRegistration.TravellerEMail.value < '!') {
    alert('Enter your email address');
    document.TravellerRegistration.TravellerEMail.focus();
    document.TravellerRegistration.TravellerEMail.value='';
    return false;
   }
  if (document.TravellerRegistration.TravellerName.value < '!') {
    alert('Enter your name');
    document.TravellerRegistration.TravellerName.focus();
    document.TravellerRegistration.TravellerName.value='';
    return false;
   }
   return true;
}

function getElement(pID) { 
  if(document.all) {return document.all[pID];}
  else{return document.getElementById(pID);}
} 

var indImage = 0;
function gallery(pDirection) {
  if((indImage==0 && pDirection==-1)||(indImage==arrGallery.length-1 && pDirection==1)) {
    //window.alert("No can do!");
  }
  else {
		getElement("product_image").src="/imagesclient/" + arrGallery[indImage+pDirection];
		indImage = indImage + pDirection;
		getElement("current_image").innerHTML=indImage+1;
		if(indImage==0) {
		  getElement("prev_image").src="/images/site/gallery_prev_dis.gif";
		  getElement("prev_image").className="gallery_prev_dis";
		}
		else {
		  getElement("prev_image").src="/images/site/gallery_prev.gif";
		  getElement("prev_image").className="gallery_prev";
		}
		if(indImage==arrGallery.length-1) {
		  getElement("next_image").src="/images/site/gallery_next_dis.gif";
		  getElement("next_image").className="gallery_next_dis";
		}
		else {
		  getElement("next_image").src="/images/site/gallery_next.gif";
		  getElement("next_image").className="gallery_next";
		}
  }
}
function trim(pStr) {
  return pStr.replace(/^\s+|\s+$/g, '');
}