
var win=null;

var browser = "ie";
  if (window.opera) browser="opera";
var ua = navigator.userAgent.toLowerCase();
   if (ua.indexOf('safari/') != -1) browser = "safari";
   if (ua.indexOf('chrome/') != -1) browser="chrome";
   if(navigator.userAgent.indexOf("Firefox")!=-1) {
        var versionindex=navigator.userAgent.indexOf("Firefox")+8
        if (parseInt(navigator.userAgent.charAt(versionindex))>=1) browser="firefox";
   }

function NewWindow(mypage,myname,w,h,scroll,pos){
        if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
        if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
        if(pos=="right"){LeftPosition=(screen.width)?(screen.width-w-30):100;TopPosition=20}
        else if((pos!="center" && pos!="random") || pos==null){LeftPosition=20;TopPosition=20}
        settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no';
        win=window.open(mypage,myname,settings);
}

function tpWindow() {
        var tph = 650;
        if (browser == "opera") tph = 611 ;
        if (browser == "safari") tph = 611 ;
        if (browser == "chrome") tph = 611 ;
        if (browser == "firefox") tph = 626 ;
        {NewWindow('tourprice1.php?<?php echo SID; ?>','tourprice','710',tph,'yes','right');return false; }
}

function makeCookie(name,value,days) {
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return null;
}

function eraseCookie(name) {
        createCookie(name,"",-1);
}


function picFeature(name,value,days) {
        var depth=540;
        var width=540;
        if (browser == "opera") {
          var depth=540;
          var width=540;
        }
        if (browser == "safari") {
          var depth=543;
          var width=550;
        }
        if (browser == "chrome") {
          var depth=542;
          var width=550;
        }
        if (browser == "firefox") {
          var depth=540;
          var width=550;
        }
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.cookie = name+"="+value+expires+"; path=/";
        LeftPosition=(screen.width)?(screen.width-610):100;TopPosition=20;
        settings='width='+width+',height='+depth+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no';
        win=window.open('picturefeature.php','hotels',settings);
}

function findObj(n, d) { //v4.01
        var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
        if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
        for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
        if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function showHide() { //v6.0
        var i,p,v,obj,args=showHide.arguments;
        for (i=0; i<(args.length-1); i+=2) if ((obj=findObj(args[i]))!=null) { v=args[i+1];
        if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
        obj.visibility=v; }
}

function show() {
        var i,p,v,obj,args=show.arguments;
        for (i=0; i<(args.length); i+=1) if ((obj=findObj(args[i]))!=null) {
        if (obj.style) { obj=obj.style; v='visible' }
        obj.visibility=v; }
}

function hide() {
        var i,p,v,obj,args=hide.arguments;
        for (i=0; i<(args.length); i+=1) if ((obj=findObj(args[i]))!=null) {
        if (obj.style) { obj=obj.style; v='hidden' }
        obj.visibility=v; }
}

function vizlayers() {

  var npax = document.getElementById('nopx').selectedIndex;

  if (npax == 0) {hide('sub1','sub2','sub3','sub4','sub5','sub6','sub7','sub8','sub9');
                  hide('pax2','pax3','pax4','pax5','pax6','pax7','pax8','pax9','paxmore'); }

  if (npax == 1) {show('sub1'); hide('sub2','sub3','sub4','sub5','sub6','sub7','sub8','sub9');
                                hide('pax2','pax3','pax4','pax5','pax6','pax7','pax8','pax9','paxmore'); }

  if (npax == 2) {show('sub2'); hide('sub1','sub3','sub4','sub5','sub6','sub7','sub8','sub9');
                  show('pax2'); hide('pax3','pax4','pax5','pax6','pax7','pax8','pax9','paxmore'); }

  if (npax == 3) {show('sub3'); hide('sub1','sub2','sub4','sub5','sub6','sub7','sub8','sub9');
                  show('pax2','pax3'); hide('pax4','pax5','pax6','pax7','pax8','pax9','paxmore'); }

  if (npax == 4) {show('sub4'); hide('sub1','sub2','sub3','sub5','sub6','sub7','sub8','sub9');
                  show('pax2','pax3','pax4'); hide('pax5','pax6','pax7','pax8','pax9','paxmore'); }

  if (npax == 5) {show('sub5'); hide('sub1','sub2','sub3','sub4','sub6','sub7','sub8','sub9');
                  show('pax2','pax3','pax4','pax5'); hide('pax6','pax7','pax8','pax9','paxmore'); }

  if (npax == 6) {show('sub6'); hide('sub1','sub2','sub3','sub4','sub5','sub7','sub8','sub9');
                  show('pax2','pax3','pax4','pax5','pax6'); hide('pax7','pax8','pax9','paxmore'); }

  if (npax == 7) {show('sub7'); hide('sub1','sub2','sub3','sub4','sub5','sub6','sub8','sub9');
                  show('pax2','pax3','pax4','pax5','pax6','pax7'); hide('pax8','pax9','paxmore'); }

  if (npax == 8) {show('sub8'); hide('sub1','sub2','sub3','sub4','sub5','sub6','sub7','sub9');
                  show('pax2','pax3','pax4','pax5','pax6','pax7','pax8'); hide('pax9','paxmore'); }

  if (npax == 9) {show('sub9'); hide('sub1','sub2','sub3','sub4','sub5','sub6','sub7','sub8');
                  show('pax2','pax3','pax4','pax5','pax6','pax7','pax8','pax9'); hide('paxmore'); }

  if (npax == 10)  {hide('sub1','sub2','sub3','sub4','sub5','sub6','sub7','sub8','sub9');
                  show('paxmore'); hide('pax2','pax3','pax4','pax5','pax6','pax7','pax8','pax9'); }

}

function clearpx() {
        document.getElementById('nopx').selectedIndex = "select";
        vizlayers();
}

function clearsel() {
        document.enq.enqtype[0].checked = false;
}

function emailcode () {
        var emailarray7438= new Array(115,97,108,101,115,64,100,114,97,103,111,110,116,114,97,118,101,108,46,99,111,46,117,107)
        var postemail7438=''
        for (i=0;i<emailarray7438.length;i++)
        postemail7438+=String.fromCharCode(emailarray7438[i])
        document.write('<table width="100%"><tr><td width="270" class="r"><a class="but_email" href="mailto:'+postemail7438+'"></a></td><td><p>&lt; Click here to email us</p></td></tr></table>')
}

function checkFields() {
  checkinfo = "";
  if (document.quoterequest.forename1.value == "") {
  checkinfo += "\n     -  First name";
  }
  else {
  if ((document.quoterequest.forename1.value.length < 2) || (document.quoterequest.forename1.value.charAt(1) == ".")) {
    checkinfo += "\n     -  Full first name please (not initials)";
    }
  }
  if (document.quoterequest.surname1.value == "") {
  checkinfo += "\n     -  Surname";
  }
  if (document.quoterequest.telephone.value == "") {
  checkinfo += "\n     -  Telephone number";
  }
  if ((document.quoterequest.email.value == "") ||
  (document.quoterequest.email.value.indexOf('@') == -1) ||
  (document.quoterequest.email.value.indexOf('.') == -1)) {
  checkinfo += "\n     -  Email address";
  }
  if (document.quoterequest.tour.value == "select tour") {
  checkinfo += "\n     -  Select your tour";
  }
  if (document.quoterequest.travmonth.value == 0) {
  checkinfo += "\n     -  Travel date";
  }
  else {

    tnow = new Date();
    x = tnow.getTime();
    ts = new Date(document.quoterequest.travyear.value, document.quoterequest.travmonth.value-1, document.quoterequest.travdate.value);
    y = ts.getTime();
    if (y < x) checkinfo += "\n     -  Your selected tour date has passed: please select a future date";

  }

  for (n = 2; n<10; n++) {
    ns = n; ns = ns+"";
      if (document.quoterequest.nopx.value >= n) {
        if (document.quoterequest.elements[5*n+8].value == "") {
        checkinfo +="\n     -  First name for traveller" + ns;
        }
      else {
        if ((document.quoterequest.elements[5*n+8].value.length < 2) || (document.quoterequest.elements[5*n+8].value.charAt(1) == ".")) {
          checkinfo += "\n     -  Full first name for traveller " + ns +" please (not initials)";
          }
      }
      if (document.quoterequest.elements[5*n+9].value == "") {
      checkinfo += "\n     -  Surname for traveller" + ns;
      }
    }
  }

  if (checkinfo != "") {
  checkinfo ="Please check the following information:\n" + checkinfo;
  alert(checkinfo);
  return false;
  }
  else return true;
}

