// JavaScript Document
var mapPopupActive=null;
var mx,my;
var noloadclick=false;

//if (document.layers) document.captureEvents(Event.MOUSEMOVE);
//document.onmousemove=mtrack;

function news_signup(locid)
{
  window.open('http://www.travstar.com/newsletter/subscribe.php?loc='+locid,'','width=400,height=500');    
}
function mtrack(e) {
   if (e) {
     mx=e.pageX;
     my=e.pageY;
   }
   else {
     mx=event.clientX;
     my=event.clientY;
   }
}

function absoluteY(e)
{
  var y=e.offsetTop;
  while (e=e.parentNode) {
    if (e.offsetTop && !isNaN(e.offsetTop))
      y+=e.offsetTop;
  }
  return y;
}

function absoluteX(e)
{
  var x=e.offsetLeft;
  while (e=e.parentNode) {
    if (e.offsetLeft && !isNaN(e.offsetLeft))
      x+=e.offsetLeft;
  }
  return x;
}

function mapOver(ev,id)
{
  var e=document.getElementById('dmp_'+id);
  var iy,ix;
   if (ev) {
     mx=ev.pageX ? ev.pageX : ev.clientX;
     my=ev.pageY ? ev.pageY : ev.clientY;
   }
   else {
     mx=event.clientX;
     my=event.clientY;
   }

  if (e) {
    if (mapPopupActive)
      mapPopupActive.style.display='none';
    mapPopupActive=e;
    iy=absoluteY(document.getElementById('centerColumn'));
    ix=absoluteX(document.getElementById('centerColumn'));
    if (false && my > iy)
      e.style.top=my-iy+'px';
    else
      e.style.top=my+15+'px';
    if (false && mx > ix)
      e.style.left=mx-ix+'px';
    else
      e.style.left=mx+15+'px';
    e.style.display='block';
  }
}

function mapOut(id)
{
  var e=document.getElementById('dmp_'+id);
  if (e) {
    if (mapPopupActive==e)
      mapPopupActive=null;
    e.style.display='none';
  }
}

function changeCategory(cat)
{
  document.location="?c="+cat;
}
function changeSort(srt)
{
  document.location="?s="+srt;
}

function currencyConverter()
{
  window.open('http://www.oanda.com/convert/classic?user=JodiNelson','CurrencyConverter','toolbar=yes,width=600,height=505');
}

function gallery(i)
{
  if (document.getElementById('galleryImage'))
    document.getElementById('galleryImage').src=galleryImages[i];
  else if (document.getElementById('webCamImage'))
    document.getElementById('webCamImage').src=galleryImages[i];
  else
    document.getElementById('rg_galleryImage').src=galleryImages[i];
  document.getElementById('index-info').innerHTML='image '+(i+1)+' of '+galleryImages.length;
  if (document.getElementById('title'))
    document.getElementById('title').innerHTML=galleryTitles[i];
  if (document.getElementById('g_description'))
    document.getElementById('g_description').innerHTML=galleryDescriptions[i];
  gImage=i;
}
function galleryMove(i)
{
  gallery(i < 0 ? (gImage==0 ? galleryImages.length-1 : gImage-1) : (gImage==galleryImages.length-1 ? 0 : gImage+1));
}

function video(i)
{
  //document.location=gVideoURL+'/'+i;
  document.getElementById('gallery-video').innerHTML=videos[i];
}
function videoMove(i)
{
  video(i < 0 ? (gVideo==0 ? gVideoCount-1 : gVideo-1) : (gVideo==gVideoCount-1 ? 0 : gVideo+1));
}

function secure_form()
{
window.open('https://www.travstar.com/secure/secure_form.php','_blank',
                        'height=500,width=428,status=no,scrollbars=yes,toolbar=no,menubar=no,location=no');
}

function mapPreview(e,i)
{
  var p=document.getElementById('mapPreview');
  if (!e)
    p.style.display='none';
  else {
    p.style.display='block';
    p.style.left=parseInt(e.parentNode.offsetLeft)+349+'px';
    p.style.top=parseInt(e.parentNode.offsetTop)+20+'px';
    document.getElementById('mpImg').src=i;
  }
}

function tablero(e,ov)
{
  if (ov) {
    e.style.backgroundColor='#10aedf';
    e.style.cursor='pointer';
  }
  else {
    e.style.backgroundColor='';
    e.style.cursor='';
  }
}

function tableo(l)
{
  if (!noloadclick)
    document.location=l;
  else
    noloadclick=false;
}
function bookNow(id,pid,gid,loc)
{
//  window.open('https://www.travstar.com/secure/on_request_booking_form_accom.php?scid='+id,'','width=650,height=600,scrollbars=1,top=0,left=0');
  noloadclick=true;
  pageTracker._link(this.href);
  window.open('https://www.travstar.com/secure/new/on_request_booking_form.php?gtid='+gid+'&scid='+id+(pid ? '&pid='+pid : '')+(loc ? '&loc='+loc : ''),'','width=650,height=600,scrollbars=1,top=0,left=0');
}
<!--

/*
   name - name of the cookie
   value - value of the cookie
   [expires] - expiration date of the cookie
     (defaults to end of current session)
   [path] - path for which the cookie is valid
     (defaults to path of calling document)
   [domain] - domain for which the cookie is valid
     (defaults to domain of calling document)
   [secure] - Boolean value indicating if the cookie transmission requires
     a secure transmission
   * an argument defaults when it is assigned null as a placeholder
   * a null placeholder is not required for trailing omitted arguments
*/

function setBoxCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}


/*
  name - name of the desired cookie
  return string containing value of specified cookie or null
  if cookie does not exist
*/

function getBoxCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


/*
   name - name of the cookie
   [path] - path of the cookie (must be same as path used to create cookie)
   [domain] - domain of the cookie (must be same as domain used to
     create cookie)
   path and domain default if assigned null or omitted if no explicit
     argument proceeds
*/

function deleteBoxCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function toggleBoxDisplay(id)
{
  var cookie=getBoxCookie('boxcollapse['+id+']');
  if (cookie==null || cookie=="" || cookie=="0")
    setBoxCookie('boxcollapse['+id+']',"1");
  else
    setBoxCookie('boxcollapse['+id+']',"0");
}
function isCollapsed(id)
{
  return getBoxCookie('boxcollapse['+id+']')=="1";
}
function expand(id)
{
  var e=document.getElementById(id);
  if (e) 
    e.style.display=e.style.display=='none' ? 'block' : 'none';
  toggleBoxDisplay(id);  
}

function giftVoucher(theForm)
{
  var qs;
  if (theForm.g_rn.value=="") {
    alert("Please enter the name of the recipient");
    theForm.g_rn.focus();
    return;
  }
  if (theForm.g_em.value=="" || !validateEmailv2(theForm.g_em.value)) {
    alert("Please enter a valid email address for the recipient");
    theForm.g_em.focus();
    return;
  }
  if (stringToNumber(theForm.g_va.value) < 20) {
    alert('The gift voucher must be at least $20 AUD value.');
    theForm.g_va.focus();
    return;
  }
  qs='?g_rn='+theForm.g_rn.value+'&g_em='+theForm.g_em.value+'&g_oc='+theForm.g_oc.value+'&g_va='+theForm.g_va.value+'&g_me='+escape(theForm.g_me.value);
  window.open('https://www.travstar.com/secure/secure_gift.php'+qs,'_blank',
                        'height=500,width=428,status=no,scrollbars=yes,toolbar=no,menubar=no,location=no');
}

function giftVoucherSent()
{
  var f=document.getElementById('giftform');
  f.g_rn.value='';
  f.g_em.value='';
  f.g_oc.value='';
  f.g_me.value='';
  f.g_va.value='';
}

function lm_rowh(e,on)
{
  for (var i=0; i < e.childNodes.length; i++)
    if (on && e.childNodes[i].className=='price') 
      e.childNodes[i].className='price ov';
    else if (!on && e.childNodes[i].className=='price ov')
      e.childNodes[i].className='price';     
}