//debugWin = window.open("","debugWin","height=500,width=400,resizable=yes,scrollbars=yes");

function println(str) {
  debugWin.document.writeln(str+"<br>");
}

function launchPopUp() {
  showLandingPagePopUp('/popup.html',400,230);
}

function showLandingPagePopUp(url, width, height, scrolling) {
  showAd = true;
  now = new Date;
  exDate = new Date;
  exDate.setMonth( exDate.getMonth() + 6 );
  lastViewed = new Date;
  lastViewed.setMonth( lastViewed.getMonth() - 1 );
  
  if (document.cookie != "") {
    cooks = document.cookie.split(";");
    for (i=0; i<cooks.length; i++) {
      if ( cooks[i].split("=")[0].indexOf("lastViewed") != -1 ) {
        lastViewed = new Date( cooks[i].split("=")[1] );
        break;
      }
    }
    if ( lastViewed.getDate() == now.getDate() &&
         lastViewed.getMonth() == now.getMonth() ) {
      showAd = false;
    }
  }

  //if (IE)
    //document.cookie = "lastViewed="+now+";expires="+exDate.toGMTString()+";domain=iomega.com;path=/;";
  //else
    document.cookie = "lastViewed=" + now + ";expires=" + exDate.toGMTString();

  if (showAd) {
    openPopupWindow(url, width, height, scrolling);
    window.focus();
  }
}

function openPopupWindow(url, width, height, scrolling) { //v2.0
    if (!width) width = 350;
    if (!height) height = 350;
    if (!scrolling) scrolling = "no"; 
    features = "width="+width+","
             + "height="+height+","
             + "toolbar=no,"
             + "location=no,"
             + "status=no,"
             + "menubar=no,"
             + "scrollbars="+scrolling+","
             + "top="+(window.screen.height-height)/2+","
             + "left="+(window.screen.width-width)/2;
    window.open(url,"win"+Math.round(Math.random()*1000),features);
}
