// Copyright (C) www.iPopBox.com
// Author: Dave Guindon

function gopop(dp,dw,dh,dt) {
  window.setTimeout('dopop("'+dp+'","'+dw+'","'+dh+'")', dt);  
}

function dopop(dp,dw,dh) {
  MOOdalBox.open(dp,'','moodalbox '+dw+' '+dh);
}

function getMouseXY(e) {
  if (IE) { 
    yy = event.clientY + document.body.scrollTop;
  } else {  
    yy = e.pageY;
  } 
  if (ox == 2){
    if (yy >= xh){
      st = 1; 
    }
  }else{   
    if ((yy >= xh) & (st != 2)){
      st = 1; 
    }
  }  
  if ((st == 1) & (yy <= xh)){
    gopop(popgx,wtx,htx,'100');
    st = 2;
  }  
}

if ((ox == 1) | (ox == 2)){
  var yy = 0;
  var st = 0;
  var xh = 50;
  var IE = document.all?true:false;
  if (!IE) {
    document.captureEvents(Event.MOUSEMOVE); 
  }
  document.onmousemove = getMouseXY;
}

if (oe == 1){
  window.onload=function() {gopop(popg,wt,ht,ttm)};  
}else if (oe == 2){
  var key_value = "iPopBoxCookie=true";
  var foundCookie = 0;
  var cookieArray = document.cookie.split(';');
  for(var i=0;i < cookieArray.length;i++){
    var checkCookie = cookieArray[i];
    while (checkCookie.charAt(0)==' '){
      checkCookie = checkCookie.substring(1,checkCookie.length);
    }
    if (checkCookie.indexOf(key_value) == 0){
      foundCookie = 1;
    }
  }
  if ( foundCookie == 0){
    document.cookie = key_value;
    window.onload=function() {gopop(popg,wt,ht,ttm)};
  }
}
