var the_screen = new Object;
var focus_test = 1;

if ((navigator.appName == 'Netscape' || navigator.appName.indexOf('Microsoft') >= 0) && parseInt(navigator.appVersion) < 4)
{
  the_screen.width = 640;
  the_screen.height = 480;
}
else
{
  the_screen.width = screen.width;
  the_screen.height = screen.height;
}


if ((navigator.appName.indexOf('Microsoft') >= 0) && (parseInt(navigator.appVersion) < 5))
{
    if (navigator.appVersion.indexOf("MSIE 5") == -1) focus_test = 0;
}

function show_self()
{
  if (document.images)
    self.focus();
}

// Quicksearch popup.
function popup_sr()
{ 
  var url = '/cgi-bin/search1.pl?webab=qs&';
  with (window.document) {
    url = url + 'filter=' + escape(search.filter.value);
    if (search.type)        url = url + '&type='        + escape(search.type.value);
    if (search.background)  url = url + '&background='  + escape(search.background.value);
    if (search.darkColour)  url = url + '&darkColour='  + escape(search.darkColour.value);
    if (search.lightColour) url = url + '&lightColour=' + escape(search.lightColour.value);
    if (search.schID)       url = url + '&schID='       + escape(search.schID.value);
    if (search.callback)    url = url + '&callback='    + escape(search.callback.value);
    if (search.splurgeUrl)  url = url + '&splurgeUrl='  + escape(search.splurgeUrl.value);
  } 
  var sr_window = window.open(url, 'sr', 'width=550,height=280,resizable,scrollbars');
  if (focus_test == 1)
  {
    if (sr_window.opener == null) sr_window.opener = self;
    sr_window.focus();
  }
}

// Location search popup.
function popup_sr2()
{ 
  var url = '/cgi-bin/search1.pl?webab=ls&';
  with (window.document) {
    url = url + 'filter=' + escape(search2.filter.value);
    if (search2.type)        url = url + '&type='        + escape(search2.type.value);
    if (search2.background)  url = url + '&background='  + escape(search2.background.value);
    if (search2.darkColour)  url = url + '&darkColour='  + escape(search2.darkColour.value);
    if (search2.lightColour) url = url + '&lightColour=' + escape(search2.lightColour.value);
    if (search2.schID)       url = url + '&schID='       + escape(search2.schID.value);
    if (search2.callback)    url = url + '&callback='    + escape(search2.callback.value);
    if (search2.splurgeUrl)  url = url + '&splurgeUrl='  + escape(search2.splurgeUrl.value);
  }
  var sr_window = window.open(url, 'sr', 'width=550,height=280,resizable,scrollbars');
  if (focus_test == 1)
  {
    if (sr_window.opener == null) sr_window.opener = self;
    sr_window.focus();
  }
}

// Subscriptions.
function popup_sub()
{
  var sub_window = window.open(
    '/manage_subs_login.htm', 'sub',
    'width=680,height=440,resizable,scrollbars,toolbar'
  );
  if (focus_test == 1)
  {
    if (sub_window.opener == null) sub_window.opener = self;
   sub_window.focus();
  }
}

// B&B.
function popup_bb()
{
  var bb_window = window.open(
    '/cgi-bin/click1.pl?ref='+escape(window.location.href)+'&url=http%3A//allhotelsbb.worldres.com/index.html', 'bb',
    'width=540,height=440,resizable,scrollbars,toolbar'
  );
  if (focus_test == 1)
  {
    if (bb_window.opener == null) bb_window.opener = self;
    bb_window.focus();
  }
}

// Currency converter.
function popup_cc(site)
{
  if (!site) site = '';
  var cc_window = window.open(
    site+'/services/currency/ucc.htm', 'cc',
    'width=640,height=560,resizable,scrollbars'
  );
  if (focus_test == 1)
  {
    if (cc_window.opener == null) cc_window.opener = self;
    cc_window.focus();
  }
}

// Guest book.
function popup_gb(site)
{
  if (!site) site = '';
  var gb_window = window.open(
    site+'/cgi-bin/click1.pl?ref='+escape(window.location.href)+'&url=http%3A//www.all-hotels.org/guestbook/guestbookdefault.asp', 'gb',
    'width=600,height=500,resizable,scrollbars,toolbar'
  );
  if (focus_test == 1)
  {
    if (gb_window.opener == null) gb_window.opener = self;
    gb_window.focus();
  }
}

// Car rental.
function popup_rc()
{
  var rc_window = window.open(
    'http://www.travelnow.com/cars/home.html?cid=625', 'rc',
    'width=510,height=500,resizable,scrollbars,toolbar'
  );
  if (focus_test == 1)
  {
    if (rc_window.opener == null) rc_window.opener = self;
    rc_window.focus();
  }
}

// General purpose popup.
function popup_gen(url, target)
{
  var gen_window = window.open(url, target);
  if (focus_test == 1)
  {
    if (gen_window.opener == null) gen_window.opener = self;
    gen_window.focus();
  }
}

// ABook.
function popup_ab(file,height)
{
  var window_height;
  if (height=='max')
  {
  	window_height = the_screen.height * .75;
  }
  else
  {
    window_height = height;
  }
  var window_width = 680;
  if (the_screen.width == 640)
  {
  	window_width = 620;
  }
  var window_top = (the_screen.height/2) - (window_height/2);
  var window_left = (the_screen.width/2) - (window_width/2);

  var ab_window = window.open(
    '/servlets/' + file, 'ab',
    'width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left +
    ',resizable,scrollbars,status,toolbar');

  if (focus_test == 1)
  {
    if (ab_window.opener == null) ab_window.opener = self;
    ab_window.focus();
  }  
}

// ABook for new QuickSearch
function popup_abqs(windowName,height)
{
  var window_height;
  if (height=='max')
  {
  	window_height = the_screen.height * .75;
  }
  else
  {
    window_height = height;
  }
  var window_width = 680;
  if (the_screen.width == 640)
  {
  	window_width = 620;
  }
  var window_top = (the_screen.height/2) - (window_height/2);
  var window_left = (the_screen.width/2) - (window_width/2);

  var ab_window = window.open(
    'about:blank', windowName,
    'width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left +
    ',resizable,scrollbars,status,toolbar');

  if (focus_test == 1)
  {
    if (ab_window.opener == null) ab_window.opener = self;
    ab_window.focus();
  }  
}

// Ares.
function popup_ar(hid, trk)
{
  var window_width  = 640;
  var window_height = the_screen.height * 0.75;
  var window_top    = 25;
  var window_left   = (the_screen.width - window_width) / 2;
  var url;
  if (trk) {
    url = '/cgi-bin/click1.pl?lnk=book&hid=' + hid + '&url=http%3A//ares.all-hotels.com/servlets/Requirements&HID=';
  } else {
    url = 'http://ares.all-hotels.com/servlets/Requirements?HID=';
  }
  var ar_window = window.open(
    url + hid, 'book',
    'width=' + window_width + ',height=' + window_height +
    ',top=' + window_top + ',left=' + window_left +
    ',resizable,scrollbars,status,toolbar,menubar');
  if (focus_test == 1)
  {
    if (ar_window.opener == null) ar_window.opener = self;
    ar_window.focus();
  }  
}

// Email a friend.
function popup_ef(hotel, url, hid)
{
  var ef_window = window.open(
    '/cgi-bin/mail1.pl?hotel=' + escape(hotel) + '&place=' + escape(location_name) + '&url=' + escape(url) + '&hid=' + hid,
    'ef', 'width=460,height=580,resizable'
  );
  if (focus_test == 1)
  {
    if (ef_window.opener == null) ef_window.opener = self;
    ef_window.focus();
  }
}

//Email a friend link under qsearch
function getUrl(the_page)
{
  var str = the_page;
  var newstr = str.replace(":", "%3a");
  var url="/servlets/EmailAFriend?page="+newstr;
  window.open('/servlets/EmailAFriend?Page='+url, 'email', 'width=550,height=550');
}

//Email a friend October Promotion
function emailPromo() 
{
	window.open('/servlets/EmailAFriend?page=promotion', 'email', 'width=550,height=550');
}

// Save a hotel.
function popup_sh(hid)
{
  var sh_window = window.open(
    '/servlets/MSDecision?' + 'hotl_id=' + hid,
    'myhotels', 'width=680,height=550,resizable,scrollbars'
  );
  if (focus_test == 1)
  {
    if (sh_window.opener == null) sh_window.opener = self;
    sh_window.focus();
  }
}

//Promotion page url.
function promotion()
{
  window.open('/promotions/index.htm', '_parent');
//  window.open('/hotdeals/index.htm', '_parent');  
}

function act(imgName, image) {
  if (document.images)
    document[imgName].src = eval(image + 'on.src');
}

function inact(imgName, image) {
  if (document.images)
    document[imgName].src = eval(image + 'off.src');
}

//preload splurge mouseover images
    searchon = new Image();
    searchon.src = "/images/search-btn_lt.gif";
    searchoff = new Image();
    searchoff.src = "/images/search-btn_dk.gif";
