// how long to wait before activating pops
var time = 0;

// switch to control execution
var doexit = 0;

//specify window features
if (!winfeatures) {
    var winfeatures="width=800,height=610,scrollbars=1,resizable=1,toolbar=0,location=0,menubar=0,status=0,directories=0";
}

//specify window features
if (!popupurl) {
    var popupurl="http://mkmortgage.com/optimum";
}

//Pop-under only once per browser session? (0=no, 1=yes)
var once_per_session=0;

function do_popups(popupurl, popupurl2, popupurl3) {
  popit(popupurl, 1);
  if (popupurl2) {
    popit(popupurl2, 1);
  }
  if (popupurl3) {
    popit(popupurl3, 1);
  }
}

function do_exitpops() {
  if (doexit) {
    popit(popupurl, 1);
  }
}

function get_cookie(Name) {
  var search = Name + "=";
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search);
    if (offset != -1) { // if cookie exists
      offset += search.length;
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end));
      }
   }
  return returnvalue;
}

function loadornot(url, doblur) {
  if (get_cookie('popunder')=='') {
    loadpopunder(url, doblur);
    document.cookie="popunder=yes";
  }
}

function loadpopunder(url, doblur) {
  win2 = window.open(url, "", winfeatures);
  if (win2 && doblur) {
    win2.blur();
    //window.focus();
  }
}

function popit(url, doblur) {
  once_per_session ? loadornot(url, doblur) : loadpopunder(url, doblur);
}


