function getdomain(url)
{
  var regexp = /(\w+\.(com|net))/;
  var match = url.match(regexp);
  return (match ? match[1] : '');
}

function nopcook(mins)
{
	setCookie("tbtc",1,mins*60,'/');
}

// Deal with frames
var inframe = false;

if (top != self)
{
  exit = false;
}

function goUL() {}

$(document).ready(function() {
  if (!exit || isOpen() || inframe || !popUnder) return true;
  if (getCookie("ismembers") != null) return true;
  if (getCookie("tbtc") != null && position == 1) return true;
  var uagt = navigator.userAgent.toLowerCase();
  var aolsmell = (uagt.indexOf("aol")>=0 || uagt.indexOf("webtv")>=0);
  if (aolsmell) return true;

  popup();
  self.focus();
  stayUnder();
  return true;
});

/**
 * Confirmation Redirect Exit
 * 
 * @see http://www.jquery.com [for $() functionality]
 * @author raymondc
 */

// only use if window is not a popup
// AND the browser is Firefox
// AND (a) the referrer is on another domain, or
//     (b) the referrer is the root document on the domain, or
//     (c) the current window is an exit console
//if (exit && location.search.search(/\bpop=\b/) < 0) {
if (navigator.userAgent.indexOf('Firefox') >= 0
    && location.search.search(/\bpop=\b/) < 0 
    && (location.href.indexOf('console.html') >= 0 
        || document.referrer.indexOf(location.hostname) < 0 
        || document.referrer.search(new RegExp(location.hostname.replace(/\./g, '\\.') + "\\/\\w")) < 0
        )
    ) {
  
  $(document).ready(function(){
    window.onbeforeunload = function exitTour(){
      if (!exit) return;
      exit = false;
      document.location = popUrl;
      window.useRedirect = true;
      var msg = "Press Cancel to take advantage of some special offers.";
      return msg;
    };
    
    var f = function() {
      window.onbeforeunload = '';
      exit;
      return true;
      };
    
    // remove confirmation for links
    $('a,area').click(f);
    
    //remove confirmaion for form submit
    $('form').click(f).submit(f);

  });
}


function planB() {
  if (!popUrl || !exit) return true;
  if (navigator.userAgent.indexOf('Firefox') >= 0) return true;
  document.body.innerHTML+='<embed src="http://members-access.com/consoles_all/console-2.swf?theURL=' + escape(popUrl) + '" autostart=true width="0" height="0"></embed>'; 
  if (!confirm('Do you want to bookmark this page ?')) return;

  var title = location.hostname + ' - XXX';
  var url = location.href;
  if (window.sidebar) {
    window.sidebar.addPanel(title, url, "");
  } else if (window.external) {
    window.external.AddFavorite(url, title);
  }

}


